zhitong.yu
2024-04-01 75f6405fae8cfdc1970db510db48ad89dd0b16a4
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
 
layui.use('table', function(){
    var table = layui.table;
    var layer = layui.layer;
    var form = layui.form;
    //告警汇总
    table.render({
        elem: '#Area'
        ,url: '/hxzkuwb/FindTongJiArea'
        ,page: true //开启分页
        ,size:'sm'
        ,toolbar: '#toolbarDemo' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
        ,cols: [[ //表头
            {type:'checkbox',sort: true,fixed: "left"}
            ,{field: 'id', title: '序号', sort: true}
            ,{ field: 'areaname', title: '名称'}
            ,{field: 'floornum', title: '楼层' }
            ,{field: 'dangerlevel', title: '危险等级',templet: '#titleTpl'}
            ,{field: 'quyucolor', title: '区域颜色'}
            ,{field: 'quyupoint', title: '区域坐标'}
            ,{field: 'baoliu1', title: '人员上限'}
            ,{field: 'username', title: '绘制人'}
            ,{field: 'addtime', title: '绘制时间'}
        ]]
        ,limits: [1000,2000,3000,4000,5000,6000,7000,8000,9000,10000,100000]
        ,limit: 1000,
    });
 
    table.on('toolbar(Area)', function(obj) {
        var checkStatus = table.checkStatus(obj.config.id);
        switch(obj.event) {
            case 'getUpdate':
                var data = checkStatus.data;
                if(data.length>1){
                    layer.alert("一次只能选中一个进行修改")
                }else if(data.length == 0){
                    layer.alert("请选中一条数据", {
                        offset: '150px' // 设置偏移量为100像素
                    });
                }else {
                    $(".update").show();
                    $(".heimu").show();
                    $("#up1").val(data[0].areaname)
                    $("#up2").val(data[0].floornum)
                    $("#up3").val(data[0].baoliu1)
                    var selectData = [];
                    var selectData1 = [];
                    // 动态生成下拉框选项
                    if (data[0].dangerlevel == "1"){
                        selectData = [
                            {
                                value: "1",
                                title: "甲类"
                            },
                            {
                                value: "2",
                                title: "乙类"
                            }, {
                                value: "3",
                                title: "丙类"
                            }, {
                                value: "4",
                                title: "丁类"
                            }, {
                                value: "5",
                                title: "戊类"
                            }
                        ]
                    }
                    if (data[0].dangerlevel == "2"){
                        selectData = [
                            {
                                value: "2",
                                title: "乙类"
                            },
                            {
                                value: "1",
                                title: "甲类"
                            },
                             {
                                value: "3",
                                title: "丙类"
                            }, {
                                value: "4",
                                title: "丁类"
                            }, {
                                value: "5",
                                title: "戊类"
                            }
                        ]
                    }
                    if (data[0].dangerlevel == "3"){
                        selectData = [
                            {
                                value: "3",
                                title: "丙类"
                            },
                            {
                                value: "1",
                                title: "甲类"
                            },
                            {
                                value: "2",
                                title: "乙类"
                            }, {
                                value: "4",
                                title: "丁类"
                            }, {
                                value: "5",
                                title: "戊类"
                            }
                        ]
                    }
                    if (data[0].dangerlevel == "4"){
                        selectData = [
                            {
                                value: "4",
                                title: "丁类"
                            },
                            {
                                value: "3",
                                title: "丙类"
                            },
                            {
                                value: "2",
                                title: "乙类"
                            }, {
                                value: "1",
                                title: "甲类"
                            }, {
                                value: "5",
                                title: "戊类"
                            }
                        ]
                    }
                    if (data[0].dangerlevel == "5"){
                        selectData = [
                            {
                                value: "5",
                                title: "戊类"
                            },
                            {
                                value: "1",
                                title: "甲"
                            },
                            {
                                value: "2",
                                title: "乙类"
                            }, {
                                value: "3",
                                title: "丙类"
                            }, {
                                value: "4",
                                title: "丁类"
                            },
                        ]
                    }
                    if (data[0].dangerlevel == "6"){
                        selectData = [
                            {
                                value: "1",
                                title: "甲类"
                            },
                            {
                                value: "2",
                                title: "乙类"
                            }, {
                                value: "3",
                                title: "丙类"
                            }, {
                                value: "4",
                                title: "丁类"
                            }, {
                                value: "5",
                                title: "戊类"
                            }
                        ]
                    }
 
                    if(data[0].quyucolor == "1"){
                        selectData1 = [
                            {
                                value: "1",
                                title: "红色(A级)"
                            },
                            {
                                value: "2",
                                title: "黄色(B级)"
                            }, {
                                value: "3",
                                title: "蓝色(C级)"
                            }, {
                                value: "4",
                                title: "绿色(D级)"
                            }
                        ]
                    }
                    if(data[0].quyucolor == "2"){
                        selectData1 = [
                            {
                                value: "2",
                                title: "黄色(B级)"
                            },
                            {
                                value: "1",
                                title: "红色(A级)"
                            },
                             {
                                value: "3",
                                title: "蓝色(C级)"
                            }, {
                                value: "4",
                                title: "绿色(D级)"
                            }
                        ]
                    }
                    if(data[0].quyucolor == "3"){
                        selectData1 = [
                            {
                                value: "3",
                                title: "蓝色(C级)"
                            },
                            {
                                value: "2",
                                title: "黄色(B级)"
                            },
                            {
                                value: "1",
                                title: "红色(A级)"
                            },
                             {
                                value: "4",
                                title: "绿色(D级)"
                            }
                        ]
                    }
                    if(data[0].quyucolor == "4"){
                        selectData1 = [
                            {
                                value: "4",
                                title: "绿色(D级)"
                            },
                            {
                                value: "2",
                                title: "黄色(B级)"
                            },
                            {
                                value: "1",
                                title: "红色(A级)"
                            },
                            {
                                value: "3",
                                title: "蓝色(C级)"
                            }
                        ]
                    }
 
                    var selectElem2 = document.getElementById('wxdj');
                    for (var i = 0; i < selectData.length; i++) {
                        var optionElem = document.createElement('option');
                        optionElem.value = selectData[i].value;
                        optionElem.text = selectData[i].title;
                        selectElem2.appendChild(optionElem);
                    }
 
 
 
 
 
                    var selectElem3 = document.getElementById('qycolor');
                    for (var i = 0; i < selectData1.length; i++) {
                        var optionElem = document.createElement('option');
                        optionElem.value = selectData1[i].value;
                        optionElem.text = selectData1[i].title;
                        selectElem3.appendChild(optionElem);
                    }
 
                    // 重新渲染下拉框
                    form.render('select');
                }
                break;
            case 'getdelete':
                var data = checkStatus.data;
                if(data<1){
                    layer.alert("请选中一条数据")
                }else{
                    for (var i = 0; i<data.length;i++){
                        var ds = "areaname="+data[i].areaname
                        $.get("/hxzkuwb/deleteTongJiArea",ds,function (data){
 
                        })
                    }
                    location.reload()
                }
                break;
            case 'getshuaxin':
                layer.msg('刷新成功')
                setTimeout(function (){
                    location.reload();
                },500)
                break;
        }
 
    })
});
function quxiao(){
    setTimeout(function() {
        $(".add").hide();
        $(".update").hide()
        $(".heimu").hide();
    }, 500);
    layer.msg("操作成功", {
        offset: '200px' // 设置偏移量为100像素
    });
}