Your Name
2022-08-26 b1bdac435d4aa9fe34bde1a859490842166b47f7
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
<template>
    <div class="app-container">
        <div>
            <el-button
                class="filter-item"
                style="margin-left: 10px;"
                type="primary"
                icon="el-icon-refresh"
                @click="refreshHandle"
            >刷新</el-button>
            <el-date-picker
                v-model="dateRange"
                :picker-options="pickerOptions"
                type="datetimerange"
                align="right"
                unlink-panels
                :clearable="pickClear"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                value-format="yyyy-MM-dd HH:mm:ss"
                style="width:25%;"/>
            <el-select v-model="queryForm.enterprisetype" clearable placeholder="请选择企业类型">
                <el-option
                    class="filter-item"
                    @keyup.enter.native="queryHandle"
                    v-for="item in enterpriseTypeList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
            </el-select>
            <el-select v-model="queryForm.warnlevel" clearable placeholder="请选择警告级别" style="width: 10%">
                <el-option
                    class="filter-item"
                    @keyup.enter.native="queryHandle"
                    v-for="item in warnLevelList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
            </el-select>
            <el-input v-model="queryForm.enterprisename" class="filter-item" placeholder="企业名称" style="width: 20%;"/>
            <el-button
                class="filter-item"
                type="primary"
                icon="el-icon-search"
                @click="queryHandle"
            />
            <br>
            <div style="display: block;padding-top: 10px">
                <div class="basic_search">
                    <span>区域:</span>
                    <el-select v-model="queryForm.province" clearable filterable @change="changeArea('province')">
                        <el-option
                            v-for="item in provinceList"
                            :key="item.id"
                            :label="item.name"
                            :value="item.name"
                        >
                        </el-option>
                    </el-select>
                </div>
                <div class="basic_search">
                    <el-select v-model="queryForm.city" prop="city" clearable filterable @change="changeArea('city')">
                        <el-option
                            v-for="item in cityList"
                            :key="item.id"
                            :label="item.name"
                            :value="item.name"
                        >
                        </el-option>
                    </el-select>
                </div>
                <div class="basic_search">
                    <el-select v-model="queryForm.area" clearable filterable @change="changeArea('area')">
                        <el-option
                            v-for="item in districtList"
                            :key="item.id"
                            :label="item.name"
                            :value="item.name"
                        >
                        </el-option>
                    </el-select>
                </div>
                <div class="basic_search">
                    <el-select v-model="queryForm.town" clearable filterable @change="changeArea('town')" >
                        <el-option
                            v-for="item in streetList"
                            :key="item.id"
                            :label="item.name"
                            :value="item.name"
                        >
                        </el-option>
                    </el-select>
                </div>
                <div class="basic_search">
                    <el-select v-model="queryForm.community" clearable filterable>
                        <el-option
                            v-for="item in committeeList"
                            :key="item.id"
                            :label="item.name"
                            :value="item.name"
                        >
                        </el-option>
                    </el-select>
                </div>
            </div>
        </div>
        <div class="table_content">
            <el-table
                v-loading="listLoading"
                ref="warningTable"
                :key="tableKey"
                :data="stockWarningData"
                border
                fit
                highlight-current-row
                style="width: 100%;"
                @sort-change="sortWarningChange"
            >
                <el-table-column
                    type="selection"
                    align="center"
                    width="80"
                />
                <el-table-column
                    label="企业类型"
                    prop="enterprisetype"
                    align="center"
                    sortable="custom"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.enterprisetype }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="企业编号"
                    prop="enterprisenumber"
                    align="center"
                    sortable="custom"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.enterprisenumber }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="企业名称"
                    prop="enterprisename"
                    align="center"
                    sortable="custom"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.enterprisename }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="办公地址"
                    prop="enterprisename"
                    align="center"
                    sortable="custom"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.officeaddress }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="警告级别"
                    prop="warnlevel"
                    align="center"
                    sortable="custom"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.warnlevel }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="报警内容"
                    prop="period"
                    align="center"
                    sortable="custom"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.warncontent }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="是否处理"
                    prop="maximum"
                    align="center"
                    sortable="custom"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.ismend | parseSms(scope.row.ismend) }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="是否需要发短信"
                    prop="maximum"
                    align="center"
                    sortable="custom"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.isneed | parseSms(scope.row.isneed) }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="是否已发短信"
                    prop="maximum"
                    align="center"
                    sortable="custom"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.issend | parseSms(scope.row.issend) }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="更新人"
                    prop="modifiedby"
                    align="center"
                    sortable="custom"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.modifiedby }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="更新时间"
                    prop="modifieddate"
                    align="center"
                    sortable="custom"
                >
                    <template slot-scope="scope">
                        <span>{{ scope.row.modifieddate | parseTime('{y}-{m}-{d}') }}</span>
                    </template>
                </el-table-column>
            </el-table>
            <br>
            <el-pagination
                v-show="recordTotal>0"
                :current-page="currentPage"
                :page-sizes="[10, 20, 30, 50]"
                :page-size="pageSize"
                :total="recordTotal"
                layout="total, sizes, prev, pager, next, jumper"
                background
                style="float:right;"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
            />
        </div>
        <div style="clear: both;" />
    </div>
</template>
 
<script>
    import { mapGetters } from 'vuex'
    import { getStockWarningList } from '@/api/warning'
    import { parseTime, computePageCount } from '@/utils'
    import { parseError } from '@/utils/messageDialog'
    import Cookies from 'js-cookie'
    import { Message, MessageBox } from 'element-ui'
    import { dictionaryAllItems } from '@/api/dictionary';
    import { checkBtnPermission } from '@/utils/permission'
    import {getCityListData, getProvinceListData} from "@/api/area";
    import {getCertWarningList} from "../../api/warning";
 
    export default {
        name: 'cert',
        filters: {
            parseSms(value) {
                if (value == 1) {
                    return '是'
                } else {
                    return '否'
                }
            },
        },
        computed: {
            ...mapGetters([
                'userType'
            ])
        },
        data() {
            return {
                sort:'id',
                order:'asc',
                pageSize: 10,
                recordTotal: 0,
                currentPage: 1,
                pageTotal: 0,
                tableKey: 0,
                stockWarningData: null,
                listLoading: true,
                queryForm: {
                    warnlevel: '',
                    enterprisetype:'',
                    enterprisename:'',
                    starttime:'',
                    endtime:'',
                    province:'',
                    city:'',
                    area:'',
                    town:'',
                    community:'',
                },
                enterpriseTypeList:[],
                warnLevelList:[
                    {
                        label:"报警",
                        value:"报警",
                    },
                    {
                        label:"预警",
                        value:"预警",
                    }
                ],
                dateRange: [],
                pickClear:false,
                pickerOptions: {
                    shortcuts: [{
                        text: '最近一周',
                        onClick(picker) {
                            const end = new Date()
                            const start = new Date()
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 6)
                            end.setTime(end.getTime() + 3600 * 1000 * 24)
                            picker.$emit('pick', [start, end])
                        }
                    }, {
                        text: '最近一个月',
                        onClick(picker) {
                            const end = new Date()
                            const start = new Date()
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 29)
                            end.setTime(end.getTime() + 3600 * 1000 * 24)
                            picker.$emit('pick', [start, end])
                        }
                    }, {
                        text: '最近三个月',
                        onClick(picker) {
                            const end = new Date()
                            const start = new Date()
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 89)
                            end.setTime(end.getTime() + 3600 * 1000 * 24)
                            picker.$emit('pick', [start, end])
                        }
                    }, {
                        text: '最近一年',
                        onClick(picker) {
                            const end = new Date()
                            const start = new Date()
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 364)
                            end.setTime(end.getTime() + 3600 * 1000 * 24)
                            picker.$emit('pick', [start, end])
                        }
                    }]
                },
                provinceList:[],
                cityList:[],
                districtList:[],
                streetList:[],
                committeeList:[],
            }
        },
        created() {
            this.setDateRange();
            this.getProvince();
            this.getDictionaryEnterpriseType();
            this.getCertWarningList();
        },
        methods: {
            setDateRange(){
                const start = new Date()
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 6);
                let startyear = start.getFullYear();
                let startmonth = start.getMonth()+1;
                let startday = start.getDate();
                let starthour = start.getHours();
                let startmins = start.getMinutes();
                let startsecs = start.getSeconds();
                if (startmonth < 10){
                    startmonth = '0'+startmonth
                }
                if (startday < 10){
                    startday = '0' + startday
                }
                if (starthour < 10){
                    starthour = '0' + starthour
                }
                if (startmins < 10){
                    startmins = '0' + startmins
                }
                if (startsecs < 10){
                    startsecs = '0' + startsecs
                }
 
                this.dateRange[0] = startyear+'-'+startmonth+'-'+startday+' '+starthour+":"+startmins+":"+startsecs;
                let enddate = new Date();
                enddate.setTime(enddate.getTime() + 3600 * 1000 * 24)
                let endyear = enddate.getFullYear();
                let endmonth = enddate.getMonth()+1;
                let endday = enddate.getDate();
                let endhour = enddate.getHours();
                let endmins = enddate.getMinutes();
                let endsecs = enddate.getSeconds();
                if (endmonth < 10){
                    endmonth = '0'+endmonth
                }
                if (endday < 10){
                    endday = '0' + endday
                }
                if (endhour < 10){
                    endhour = '0' + endhour
                }
                if (endmins < 10){
                    endmins = '0' + endmins
                }
                if (endsecs < 10){
                    endsecs = '0' + endsecs
                }
                this.dateRange[1] = endyear+'-'+endmonth+'-'+endday+' '+endhour+":"+endmins+":"+endsecs;
            },
            getDictionaryEnterpriseType() {
                const _this = this
                if (_this.enterpriseTypeList && _this.enterpriseTypeList.length > 0) {
                    return
                }
                const params = {}
                params['dictionaryType'] = '安全监管分类'
                dictionaryAllItems(params).then(response => {
                    const res = response.data
                    if (res.code == 200) {
                        _this.enterpriseTypeList = res.result
                    } else {
                        parseError({ error: res.message, vm: _this })
                    }
                }).catch(error => {
                    parseError({ error: error, vm: _this })
                })
            },
            getCertWarningList() {
                const _this = this
                const params = {}
                params['sort'] = _this.sort
                params['order'] = _this.order
                params['pageIndex'] = _this.currentPage
                params['pageSize'] = _this.pageSize
                for (const i in _this.queryForm) {
                    if (_this.queryForm[i] != undefined && _this.queryForm[i].toString() != '') {
                        params[i] = _this.queryForm[i]
                    }
                }
                _this.listLoading = true
                getCertWarningList(params).then(response => {
                    const res = response.data
                    if (res.code === "200") {
                        const result = res.result;
                        _this.recordTotal = result.totalCount
                        _this.pageSize = result.pageSize
                        _this.pageTotal = computePageCount(result.totalCount, result.pageSize)
                        _this.currentPage = result.pageIndex
                        _this.stockWarningData = result.result
                    } else {
                        parseError({ error: res.message, vm: _this })
                    }
                    _this.listLoading = false
                }).catch(error => {
                    _this.listLoading = false
                    parseError({ error: error, vm: _this })
                })
            },
            refreshHandle: function() {
                this.getCertWarningList()
            },
            queryHandle: function() {
                this.currentPage = 1
                this.getCertWarningList()
            },
            sortWarningChange: function(param){
                this.sort = param.prop;
                this.order = param.order;
                this.getCertWarningList()
            },
            handleSizeChange: function(val) {
                this.pageSize = val
                this.currentPage = 1
                this.getCertWarningList()
            },
            handleCurrentChange: function(val) {
                this.currentPage = val
                this.getCertWarningList()
            },
            getBtnPermission(btnType) {
                return checkBtnPermission(this.userType, btnType)
            },
            async getProvince(){
                let res = await getProvinceListData()
                if(res.data.code === "200"){
                    this.provinceList = res.data.result.provinceList
                }
            },//获取省
            async changeArea(value){
                if(value === 'province'){
                    this.queryForm.city = ''
                    this.queryForm.area = ''
                    this.queryForm.town = ''
                    this.queryForm.community = ''
                    this.areaListQuery = {
                        type: 2,
                        parenttype: 1,
                        parentname: this.queryForm.province,
                    }
                    let res = await getCityListData(this.areaListQuery)
                    if(res.data.code === "200"){
                        this.cityList = res.data.result
                    }
                }else if(value === 'city'){
                    this.queryForm.area = ''
                    this.queryForm.town = ''
                    this.queryForm.community = ''
                    this.areaListQuery = {
                        type: 3,
                        parenttype: 2,
                        parentname: this.queryForm.city,
                    }
                    let res = await getCityListData(this.areaListQuery)
                    if(res.data.code === "200"){
                        this.districtList = res.data.result
                    }
                }else if(value === 'area'){
                    this.queryForm.town = ''
                    this.queryForm.community = ''
                    this.areaListQuery = {
                        type: 4,
                        parenttype: 3,
                        parentname: this.queryForm.area,
                    }
                    let res = await getCityListData(this.areaListQuery)
                    if(res.data.code === "200"){
                        this.streetList = res.data.result
                    }
                }else if(value === 'town'){
                    this.queryForm.community = ''
                    this.areaListQuery = {
                        type: 5,
                        parenttype: 4,
                        parentname: this.queryForm.town,
                    }
                    let res = await getCityListData(this.areaListQuery)
                    if(res.data.code === "200"){
                        this.committeeList = res.data.result
                    }
                }
            },//市、镇、街道、委员会
        }
    }
</script>
 
<style scoped>
    .basic_search{
        display:inline-block;
    }
</style>