陈战涛
2023-03-14 c29ed2aa867b00eccfdc7c3a68f431008b13ea7d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>气体展示</title>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <link href="./css/mui.min.css" rel="stylesheet" />
 
        <style>
            .mui-bar-nav {
                background: #245ca7;
                -webkit-box-shadow: none;
                box-shadow: none;
            }
 
            .mui-title {
                color: #FFFFFF;
            }
 
            .mui-icon-back:before,
            .mui-icon-left-nav:before {
                color: #FFFFFF;
            }
 
            .gas_title {
                background: #fff;
                border-bottom: 1px #efefef solid;
                padding: 20px;
                box-sizing: border-box;
                width: 96%;
                margin: auto;
            }
 
            .gas_title strong {
                display: block;
                text-align: center;
                color: #245ca7;
                font-size: 16px;
            }
 
            .gas_title span {
                display: block;
                text-align: center;
                padding: 5px 0;
                font-size: 14px;
            }
 
            .gas_table {
                width: 96%;
                margin: auto;
                margin-top: 6px;
            }
 
            .gas_table table {
                width: 100%;
                background-color: #fff !important
            }
 
            .gas_table th {
                border-top: 1px #efefef solid !important;
                font-size: 15px;
                text-align: center;
            }
 
            .gas_table tr {
                font-size: 14px;
                text-align: center;
                line-height: 35px;
            }
 
            .gas_table td {
                border-top: 1px #efefef solid !important;
            }
 
            .gas_table .yello {
                color: #ffa800;
            }
 
            .gas_table .red {
                color: #f00;
            }
 
            .gas_table .blue {
                color: #0020c1;
            }
 
            .gas_table .green {
                color: #1c7430;
            }
 
 
            .gas_btn {
                display: block;
                text-align: center;
            }
 
            .gas_btn button {
                background: #668dc1;
                color: #fff;
                border: 0px;
                border-radius: 3px;
                height: 44px;
                line-height: 44px;
                padding: 0 20px;
                margin: 10px 0;
            }
        </style>
    </head>
    <body>
        <header class="mui-bar mui-bar-nav">
            <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
            <h1 class="mui-title"><span id="depotName"></span>气体信息</h1>
        </header>
        <div class="mui-content">
            <div class="gas_title">
                <strong>气体检测记录</strong>
                <span id="checkUser">检测人:</span>
                <span id="receiveDate">检测时间:</span>
            </div>
            <div class="gas_table">
                <table>
                    <tr>
                        <th width="40%">气体类型</th>
                        <th width="20%" class="red">最高</th>
                        <th width="20%" class="blue">平均</th>
                        <th width="20%" class="green">最低</th>
                    </tr>
                    <tr>
                        <td>CO2浓度(PPM)</td>
                        <td class="red" id="perCo2Max"></td>
                        <td class="blue" id="perCo2"></td>
                        <td class="green" id="perCo2Min"></td>
                    </tr>
                    <tr>
                        <td>PH3浓度(PPM)</td>
                        <td class="red" id="perPh3Max"></td>
                        <td class="blue" id="perPh3"></td>
                        <td class="green" id="perPh3Min"></td>
                    </tr>
                    <tr>
                        <td>O2浓度(%)</td>
                        <td class="red" id="perO2Max"></td>
                        <td class="blue" id="perO2"></td>
                        <td class="green" id="perO2Min"></td>
                    </tr>
                    <tr>
                        <td>N2浓度(%)</td>
                        <td class="red" id="perN2Max"></td>
                        <td class="blue" id="perN2"></td>
                        <td class="green" id="perN2Min"></td>
                    </tr>
                </table>
            </div>
 
            <div class="gas_btn">
                <button onclick="gatherGas()">气体采集</button>
            </div>
 
        </div>
        <script src="./js/mui.js"></script>
        <script src="./js/jquery.min.js"></script>
        <script src="./js/echarts.min.js"></script>
 
        <script type="text/javascript" charset="utf-8">
            var url; //接口路径
            var gasData; //集合
            //气体展示接口数据
            var data1 = {
                "interfaceId": "5306",
                "sign": "10306",
                "outId": "10306",
                "reqDateTime": new Date(),
                "tokenAuth": "",
                "data": {
                    "depotId": "",
                    "type": ""
                }
            };
            //气体采集的参数
            var data2 = {
                "interfaceId": "5307",
                "sign": "10307",
                "outId": "10307",
                "reqDateTime": new Date(),
                "tokenAuth": "",
                "data": {
                    "depotId": ""
                }
            };
            mui.init()
            mui.plusReady(function() {
                //获取仓库参数,如仓库Id,仓库类型和仓库名称
                var curr = plus.webview.currentWebview();
                $("#depotName").html(curr.depotName);
                //获取接口路径及tokenAuth
                var user = JSON.parse(localStorage.getItem('user'))
                //请求参数赋值
                data1.tokenAuth = user.tokenAuth;
                data1.data.depotId = curr.depotId;
                data1.data.type = curr.depotType;
                data2.tokenAuth = user.tokenAuth;
                data2.data.depotId = curr.depotId;
                url = user.url + "/api-phone/gateway";
                //查询仓库气体信息
                getGasData();
            })
 
            //获取仓库信息
            function getGasData() {
                //发送请求获取仓库信息
                mui.ajax(url, {
                    type: "POST",
                    dataType: "json",
                    crossDomain: true,
                    contentType: "application/json;charset=utf-8",
                    data: JSON.stringify(data1),
                    success: function(result) {
                        if (result.code == "0000") {
                            gasData = result.data;
                            if (gasData != null) {
                                renderGasList();
                            } else {
                                mui.alert("暂无检测记录!", '提示',["确定"],function(){},"div");
                            }
                        } else {
                            mui.alert("无气体检测记录!", '提示',["确定"],function(){},"div");
                        }
                    },
                    error: function() {
                        mui.alert('系统繁忙,请重试!', '提示',["确定"],function(){},"div");
                    }
                })
            }
 
            //渲染
            function renderGasList() {
                $("#checkUser").html("检测人:" + gasData.checkUser);
                $("#receiveDate").html("检测时间:" + gasData.receiveDate);
                $("#perCo2Max").html(gasData.perCo2Max);
                $("#perCo2").html(gasData.perCo2);
                $("#perCo2Min").html(gasData.perCo2Min);
                $("#perPh3Max").html(gasData.perPh3Max);
                $("#perPh3").html(gasData.perPh3);
                $("#perPh3Min").html(gasData.perPh3Min);
                $("#perO2Max").html(gasData.perO2Max);
                $("#perO2").html(gasData.perO2);
                $("#perO2Min").html(gasData.perO2Min);
                $("#perN2Max").html(gasData.perN2Max);
                $("#perN2").html(gasData.perN2);
                $("#perN2Min").html(gasData.perN2Min);
            }
            
            //气体采集
            function gatherGas() {
                //发送请求采集气体
                mui.ajax(url, {
                    type: "POST",
                    dataType: "json",
                    crossDomain: true,
                    contentType: "application/json;charset=utf-8",
                    data: JSON.stringify(data2),
                    success: function(data) {
                        if (data.code == "0000") {
                            mui.alert('采集命令发送成功,请等待30秒重新打开此页面查看采集数据!', '提示',["确定"],function(){},"div");
                        } else {
                            mui.alert(data.msg, '提示',["确定"],function(){},"div");
                        }
                    },
                    error: function() {
                        mui.alert('系统繁忙,请重试!', '提示',["确定"],function(){},"div");
                    }
                })
            }
        </script>
    </body>
</html>