陈战涛
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<!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-content {
                width: 96%;
                margin: auto;
            }
            .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;
            }
 
            /* 粮情总览 */
            .grain_all {
                display: block;
                height: 212px;
            }
 
            .grain_all .grain_title {
                display: block;
                font-size: 16px;
                padding: 0 15px;
                box-sizing: border-box;
                color: #245ca7;
                height: 40px;
                line-height: 40px;
                background: #FFFFFF;
            }
 
            .grain_all .t1 {
                font-size: 16px;
                font-weight: 400;
            }
 
            .grain_all .t2 {
                font-size: 18px;
            }
 
            .down {
                float: left;
                width: 25%;
                background: #FFFFFF;
                padding: 10px 0;
                text-align: center;
                border-top: 1px #efefef solid;
            }
 
            .first {
                float: left;
                width: 100%;
                background: #FFFFFF;
                padding: 5px 0;
                border-top: 1px #efefef solid;
            }
 
            .first strong {
                font-weight: 400;
                float: left;
            }
 
            .up {
                float: left;
                width: 33.333%;
                background: #FFFFFF;
                padding: 10px 0;
                text-align: center;
                border-top: 1px #efefef solid;
            }
 
            .f1 {
                border-right: 1px #efefef solid;
            }
 
            .grain_title2 {
                display: block;
                font-size: 16px;
                background: #fff;
                padding: 0 15px;
                box-sizing: border-box;
                color: #245ca7;
                height: 40px;
                line-height: 40px;
                margin-top: 5px;
            }
 
            .grain_table1 {
                width: 100%;
            }
 
            .grain_table1 table {
                width: 100%;
                background-color: #fff !important
            }
 
            .grain_table1 th {
                font-size: 15px;
                text-align: center;
            }
 
            .grain_table1 tr {
                font-size: 14px;
                text-align: center;
                line-height: 35px;
                border-top: 1px #efefef solid !important;
            }
 
            .grain_table1 .yello {
                color: #ffa800;
            }
 
            .grain_table1 .red {
                color: #f00;
            }
 
            .grain_table1 .blue {
                color: #0020c1;
            }
 
            .grain_table2 {
                width: 100%;
                overflow: scroll;
            }
 
            .grain_table2 table {
                width: 100%;
                background-color: #fff !important
            }
 
            .grain_table2 tr {
                font-size: 13px;
                text-align: center;
                line-height: 30px;
                border-top: 1px #efefef solid !important;
            }
            .grain_table2 th {
                font-weight: 400;
                min-width: 42px;
                text-align: center;
                padding: 0 5px;
            }
 
            .grain_table2 td {
                min-width: 42px;
                text-align: center;
                padding: 0 5px;
            }
        </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="grain_all mb-2">
                <div class="grain_title">
                    <strong>粮情总览</strong>
                </div>
                <div class="up">
                    <h3 class="t1">粮均温</h3>
                    <h3 class="t2"><span id="tempAve"></span>℃</h3>
                </div>
                <div class="up">
                    <h3 class="t1">粮高温</h3>
                    <h3 class="t2"><span id="tempMax"></span>℃</h3>
                </div>
                <div class="up">
                    <h3 class="t1">粮低温</h3>
                    <h3 class="t2"><span id="tempMin"></span>℃</h3>
                </div>
                <div class="down">
                    <h3 class="t1">仓内温</h3>
                    <h3 class="t2"><span id="tempIn"></span>℃</h3>
                </div>
                <div class="down f1">
                    <h3 class="t1">仓内湿</h3>
                    <h3 class="t2"><span id="humidityIn"></span>%</h3>
                </div>
                <div class="down">
                    <h3 class="t1">仓外温</h3>
                    <h3 class="t2"><span id="tempOut"></span>℃</h3>
                </div>
                <div class="down">
                    <h3 class="t1">仓外湿</h3>
                    <h3 class="t2"><span id="humidityOut"></span>%</h3>
                </div>
                <div class="first">
                    <strong style="padding-left: 15px;">采集时间:</strong>
                    <strong id="receiveDate"></strong>
                </div>
            </div>
            <div class="grain_title2"><strong>各层粮情信息</strong></div>
            <div class="grain_table1">
                <table>
                    <thead>
                        <tr>
                            <th width="25%">显示控制</th>
                            <th width="25%" class="yello">平均温</th>
                            <th width="25%" class="red">最高温</th>
                            <th width="25%" class="blue">最低温</th>
                        </tr>
                    </thead>
                    <tbody id="table1">
                        <!-- <tr>
                            <td>
                                <input type="checkbox">
                                <span>1层</span>
                            </td>
                            <td class="yello">###℃</td>
                            <td class="red">###℃</td>
                            <td class="blue">###℃</td>
                        </tr>-->
                    </tbody>
                </table>
            </div>
            <div class="grain_title2"><strong><span id="ceng"></span>层详细粮情</strong></div>
            <div class="grain_table2" style="margin-top:2px;">
                <table>
                    <thead id="table2_1">
                        <!-- <tr>
                            <th>圈\列</th>
                            <th>1列</th>
                            <th>2列</th>
                            <th>3列</th>
                            <th>4列</th>
                            <th>5列</th>
                            <th>6列</th>
                            <th>7列</th>
                            <th>8列</th>
                        </tr> -->
                    </thead>
                    <tbody id="table2_2">
                        <!-- <tr>
                            <td>1圈</td>
                            <td>0.0</td>
                            <td>0.0</td>
                            <td>0.0</td>
                            <td>—</td>
                            <td>—</td>
                            <td>—</td>
                            <td>—</td>
                            <td>—</td>
                        </tr>-->
                    </tbody>
                </table>
            </div>
 
            <div style="margin-bottom: 10px;"></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 grainData; //粮情信息
            var depotName; //仓库名称
            var tagCeng; //粮情层数
            var tagHang; //粮情层数
            var tagLie; //粮情层数
 
            mui.init()
            mui.plusReady(function() {
                //获取粮情信息、仓库名称等参数
                var curr = plus.webview.currentWebview();
                grainData = curr.data;
                depotName = curr.depotName;
                $("#depotName").html(depotName);
                //粮情渲染
                renderGrain();
            })
 
            //渲染粮情数据
            function renderGrain() {
                if (grainData != null) {
                    //解析出层,取最大层
                    var array1 = grainData.cableCir.split("-");
                    tagCeng = parseInt(array1[0], 10);
                    for(var i = 1;i<array1.length;i++){
                        if(parseInt(array1[i], 10)>tagLie){
                            tagCeng = parseInt(array1[i], 10);
                        }
                    }
                    //解析出圈
                    tagHang = array1.length;
                    //解析出列,取最大列
                    var array2 = grainData.cable.split("-");
                    tagLie = parseInt(array2[0], 10);
                    for(var i = 1;i<array2.length;i++){
                        if(parseInt(array2[i], 10)>tagLie){
                            tagLie = parseInt(array2[i], 10);
                        }
                    }
                    
                    //渲染总览信息
                    $("#tempAve").html(grainData.tempAve);
                    $("#tempMax").html(grainData.tempMax);
                    $("#tempMin").html(grainData.tempMin);
                    $("#tempIn").html(grainData.tempIn);
                    $("#humidityIn").html(grainData.humidityIn);
                    $("#tempOut").html(grainData.tempOut);
                    $("#humidityOut").html(grainData.humidityOut);
                    $("#receiveDate").html(grainData.receiveDate);
                    //渲染各层粮情
                    var tableOne = grainData.details;
                    var html1 = '';
                    tagCeng = tableOne.length;
                    if (tableOne != null && tableOne.length > 0) {
                        $.each(tableOne, function(index, item) {
                            html1 += '<tr><td><input id="check' + item.fz + '" type="checkbox" onclick="showCen(\'' + item.fz + '\')">';
                            html1 += '<span>' + item.fzName + '</span></td>';
                            html1 += '<td class="yello">' + item.tempAve + '℃</td>';
                            html1 += '<td class="red">' + item.tempMax + '℃</td>';
                            html1 += '<td class="blue">' + item.tempMin + '℃</td>';
                        })
                    } else {
                        html1 += '<tr><td colspan="4">暂无数据</td></tr>';
                    }
                    $("#table1").html(html1);
                    //默认选中1层并渲染
                    $("#check1").attr("checked", true);
                    renderTierGrain(1);
                }
            }
 
            //选择层渲染
            function showCen(fz) {
                for (var i = 1; i <= tagCeng; i++) {
                    if (fz != i) {
                        $("#check" + i).attr("checked", false);
                    }
                }
                renderTierGrain(fz)
            }
 
            //渲染某层粮情
            function renderTierGrain(tag) {
                
                var tableTwo = grainData.points;
                //每圈列数
                var array = grainData.cable.split("-");
                var html1 = '';
                var html2 = '';
                if (tableTwo != null && tableTwo.length > 0) {
                    var arrData = new Array;
                    arrData.push(0);
                    $.each(tableTwo, function(index, item) {
                        if (item.fz == tag) {
                            arrData.push(item.temp);
                        }
                    })
                    if (arrData.length > 1) {
                        var count = 1;
                        html1 += '<tr><th>圈\\列</th>';
                        for (var i = 1; i <= tagHang; i++) {
                            if(count < arrData.length){
                                html2 += '<tr><td>' + i + '圈</td>';
                                var temp = 0;
                                if(i>1){
                                    temp = parseInt(array[i-2], 10);
                                }
                                for (var j = 1; j <= tagLie; j ++) {
                                    if(i==1){
                                        html1 += '<td>' + j + '列</td>';
                                    }
                                    if(j <= array[i-1]){
                                        html2 += '<td>' + arrData[j+temp] + '</td>';
                                        count += 1;
                                    }else{
                                        html2 += '<td>—</td>';
                                    }
                                }
                                html1 += '</tr>';
                                html2 += '</tr>';
                            }
                        }
                    }
                } else {
                    html1 += '<tr><td>暂无数据</td></tr>';
                }
                $("#ceng").html(tag);
                $("#table2_1").html(html1);
                $("#table2_2").html(html2);
            }
        </script>
    </body>
</html>