elkers
2025-01-16 0b62eca817d6c40c188dc72c3034835a61a30a35
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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
<template>
    <div class="alarm-container">
        <div class="left-content">
            <div class="handle-box">
                <div class="handle-title">报警处理</div>
                <div class="handle-content">
                    <div class="handle-echarts">
                        <div id="handel"></div>
                    </div>
                    <div class="handel-box">
                        <ul>
                            <li v-for="(item,index) in toBeHandData" :style="{color:item.color}">{{item.description}}</li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="analysis-box">
                <div class="analysis-title">报警分析</div>
                <div class="analysis-content">
                    <div id="analysis"></div>
                    <div class="analysis-mini">
                        <div v-for="(item,index) in statisticList" class="mini-item" :key="index">
                            <div :style="{background:item.color}"></div>
                            <div>{{ item.description}}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="right-content">
            <div class="table-box">
                <div class="table-title">报警记录</div>
                <div class="table-content">
                    <el-table v-loading="loading" :data="tableData" width="100%" max-height="690px">
                        <el-table-column
                            label="序号"
                            align="center"
                            prop="num"
                            fixed="left"
                        >
                        </el-table-column>
                        <el-table-column
                            v-for="(item, key, index) of tableHeader"
                            :prop="key.toString()"
                            :label="item"
                            :key="index"
                            align="center"
                        >
                        </el-table-column>
                    </el-table>
                </div>
                <div class="pagination">
                    <el-pagination
                        v-model:current-page="pageParam.page"
                        background
                        :page-size="pageParam.limit"
                        layout="total,prev, pager, next, jumper"
                        :total="pageParam.total"
                        @current-change="currentPage"
                    />
                </div>
            </div>
        </div>
    </div>
</template>
 
<script setup>
import alarmHistoryApi from '@/api/alarmApi/alarmHistory'
import alarm from '@/api/screen/alarm/index'
import  * as echarts from 'echarts'
import {romColor,screenAlarmColor} from '@/utils/color'
import {onBeforeUnmount} from "vue";
 
 
//初始化echarts
let loadingEcharts = {
    text: 'loading',
    textColor: 'rgba(105,133,219, 1)',
    maskColor: 'rgba(202, 224, 252, 0.2)',
    fontSize: '20px',
}
let analysisEcharts = undefined
let handelEcharts = undefined
const initEcharts = () =>{
    analysisEcharts = echarts.init(document.getElementById('analysis'));
    handelEcharts = echarts.init(document.getElementById('handel'));
}
/**
 * 报警处理
 * */
 
//echarts配置项
const setHandelOptions = () =>{
   let option = {
       tooltip: {
           trigger: 'item',
       },
        series: [
            {
                name: '报警处理',
                type: 'pie',
                radius: ['30%', '70%'], // 设置饼图的内半径和外半径,形成圆环
                center: ['50%', '50%'], // 饼图的中心(圆心)坐标
                roseType: 'radius', // 设置为南丁格尔图,'radius'模式
                itemStyle: {
                    borderRadius: 5
                },
                data: handleData.value,
                label:{
                    formatter: '{b}:{c}单 \n\n 占比:{d}%',
                    textStyle: {
                        fontSize: 18,
                        color:'#77C9A3',
                        fontWeight:500
                    }
                }
            }
        ]
    };
    handelEcharts.setOption(option,true);
}
//请求报警处理数据
const handleData = ref([])
const getHandelData = async () => {
    handelEcharts.showLoading(loadingEcharts)
    await alarm().getHandel().then((res) => {
        let list = []
        list.push({value:res.data.YesSolve,name:'已处理'}) //{YesSolve noSolve }
        list.push({value:res.data.noSolve,name:'未处理'}) //{YesSolve noSolve }
        handleData.value = list
        handleData.value.forEach((item,index) => {
            if(item.name === '未处理'){
                item.label={ show:true,color:'#C97F7F'}
            }else{
                item.label={ show:true,color:'#77C9A3'}
            }
        })
    })
    handelEcharts.hideLoading()
    setHandelOptions()
}
//待处理数据
const toBeHandData = ref([])
const handelColor = screenAlarmColor()
const gettoBeHandelData = async () => {
    let val = {limit:10000,page:1,isSolve:0}
    await alarmHistoryApi().search(val).then((res) =>{
        toBeHandData.value = res.data.list
        toBeHandData.value.forEach((item,index) => {
            item.color = handelColor[index]
        })
    })
    setHandelOptions()
}
/**
 * 报警分析
 * */
//echarts配置项
const colors = romColor()
const setAnalysisOptions = () =>{
    //自定义颜色组
    const itemStyles = statisticData.value.map(() => colors.shift());
    statisticList.value.forEach((item,index) => {
        item.color = itemStyles[index]
    })
    let option = {
        legend:{},
        xAxis: {
            type: 'category',
            data:statisticDataName.value,
            axisTick:{
                show: false,
            },
            axisLabel:{
                color:'#BAEBEC',
                fontSize: 14
            },
        },
        yAxis: {
            type: 'value',
            splitLine:{
                show:true,
                lineStyle:{
                    width:1,
                    color:'rgba(231,236,240,0.1)',
                }
            },
            axisLabel:{
                color:'#BAEBEC',
                fontSize: 16
            },
            axisLine:{
                show: true,
                lineStyle:{
                    color:'rgba(231,236,240,0.4)',
                    width:1
                }
            },
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            },
        },
        series: {
            data:statisticData.value.map((value,index) =>({
                value,
                itemStyle: {
                    color: itemStyles[index]
                }
            })),
            type: 'bar'
            },
        grid:{
            width:'95%',
            height:'80%',
            top:'10%',
            left:'8%',
        }
    };
    analysisEcharts.setOption(option,true);
}
//请求分析数据
const statisticList = ref()
const statisticData = ref()
const statisticDataName = ref()
const getStatictis = async () =>{
    analysisEcharts.showLoading(loadingEcharts)
    await alarm().get().then((res) =>{
        statisticList.value = res.data
        let list = []
        let listName = []
        res.data.forEach((item) =>{
            list.push(item.count)
            listName.push(item.description)
        })
        statisticData.value = list
        statisticDataName.value = listName
    })
    analysisEcharts.hideLoading()
    setAnalysisOptions()
    }
/**
 *  Table表格数据列表相关
 */
const pageParam = ref({
    total:200,
    limit:10,
    page:1,
})
const tableData = ref([]);
let  tableHeader = ref({
    description: "报警内容",
    code: "代码",
    createTimeView: "报警时间",
})
 
/** 获取列表 */
const loading = ref(false);
async function getTableData(val) {
    loading.value = true;
    if(val){
        if(!val.limit){
            val.limit = 8
        }
        if(!val.page){
            val.page = 8
        }
    }else{
        val = { limit:8,page:1 }
    }
    await alarmHistoryApi().search(val).then((res) =>{
        tableData.value = res.data.list
        //添加序号
        tableData.value.forEach((item,index) =>{
            item.num = index + 1
        })
        //分页参数
        pageParam.value.total = res.data.total
        pageParam.value.limit = res.data.limit
        pageParam.value.page = res.data.page
    })
    loading.value = false;
}
//分页
const currentPage = (val) =>{
    getTableData({page:val})
}
window.addEventListener('resize', function() {
    analysisEcharts.resize();
    handelEcharts.resize();
});
onMounted(async () => {
    initEcharts()
    await getStatictis()
    getHandelData()
    gettoBeHandelData()
    await getTableData()
})
//卸载前销毁图表
const disposeEcharts = (echarts) => {
    if (echarts) {
        echarts.dispose();
        echarts = null;
    }
}
onBeforeUnmount(async ()=> {
    disposeEcharts(analysisEcharts)
    disposeEcharts(handelEcharts)
})
</script>
 
<style lang="scss" scoped>
.alarm-container{
    width: 100%;
    height: 100%;
    padding:1%;
    display:flex;
    justify-content:center;
    .left-content{
        width: 50.5%;
        height: 100%;
        //background: #a2b9e8;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        .handle-box{
            width: 100%;
            height:46.5%;
            background-image: url("../../../assets/images/screen/alarm/analysis.png");
            background-repeat: no-repeat;
            background-size: 100% 100%;
            padding:1.5%;
            .handle-title{
                width: 100%;
                height:13%;
                background-image: url("../../../assets/images/screen/alarm/title-icon.png");
                background-repeat: no-repeat;
                background-position:5% 100%;
                font-weight: 400;
                font-size: 20px;
                color: #FFFFFF;
                display: flex;
                align-items:flex-end;
                padding-left:12%;
            }
            .handle-content{
                width: 100%;
                height:87%;
                display: flex;
                padding-left: 10%;
                position: relative;
                .handle-echarts{
                    width: 63%;
                    height: 100%;
                    background-image: url("../../../assets/images/screen/alarm/center.png");
                    background-repeat: no-repeat;
                    background-position: center;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    #handel{
                        width: 100%;
                        height: 100%;
                    }
                }
                .handel-box{
                    right: 5%;
                    position: absolute;
                    width: 30%;
                    height: 100%;
                    padding:2%  0 4%;
                    ul{
                        background:transparent;
                        border: 1px solid #1FB0BE;
                        border-radius: 10px;
                        height: 100%;
                        padding-top:3%;
                        opacity: 0.8;
                        overflow-y: auto;
                        li{
                            list-style-type:circle;
                            margin-top: 2%;
                            font-size: 16px;
                            font-weight: lighter;
                        }
                    }
                }
            }
        }
        .analysis-box{
            width: 100%;
            height:53.5%;
            background-image: url("../../../assets/images/screen/alarm/handle.png");
            background-repeat: no-repeat;
            background-size: 100% 100%;
            display: flex;
            flex-direction: column;
            justify-content: space-around;
            padding:1.5%;
            .analysis-title{
                width: 100%;
                height: 12%;
                background-image: url("../../../assets/images/screen/alarm/title-icon.png");
                background-repeat: no-repeat;
                background-position:5% 100%;
                padding:2% 0 0 12%;
                font-weight: 400;
                font-size: 20px;
                color: #FFFFFF;
            }
            .analysis-content{
                width: 100%;
                height: 88%;
                display: flex;
                align-items: center;
                justify-content:center;
                #analysis{
                    width: 70%;
                    height: 100%;
                }
                .analysis-mini{
                    width: 29%;
                    height: 80%;
                    display: flex;
                    flex-wrap: wrap;
                    align-items: center;
                    padding: 0 2%;
                    .mini-item{
                        width:50%;
                        height:10%;
                        display: flex;
                        justify-content: space-evenly;
                        align-items: center;
                        div:last-child{
                            font-weight: 400;
                            font-size: 14px;
                            color: #BAEBEC;
                            width: 50%;
                            height: 100%;
                            display: flex;
                            justify-content: center;
                            align-items: center;
                        }
                        div:first-child{
                            width: 20px;
                            height: 20px;
                            background: #ecd4e6;
                            border-radius: 2px;
                        }
                    }
                }
            }
        }
    }
    .right-content{
        width: 49.5%;
        height: 100%;
        .table-box{
            width: 100%;
            height: 100%;
            background-image: url("../../../assets/images/screen/alarm/table-border.png");
            background-repeat: no-repeat;
            background-size: 98% 96%;
            background-position: 50% 50%;
            position: relative;
            .table-title{
                position: absolute;
                top: 2.5%;
                left: 1.5%;
                height:8%;
                width:97%;
                display: flex;
                justify-content:center;
                align-items: center;
                font-weight: 500;
                font-size: 22px;
                color: #8DFEFF;
                background: linear-gradient(to right,rgba(21,173,248,0.5),rgba(66,93,114,0.3));
            }
            .table-content{
                position: absolute;
                top: 10%;
                left: 1.5%;
                height:77%;
                width:100%;
                padding: 1% 4%;
                overflow-y: hidden;
                //修改边框和字体
                :deep(.el-table){
                    --el-table-border-color:rgba(0,0,0,0);
                    font-weight: 400;
                    font-size: 20px;
                    color: #D1D1D1;
                }
                //修改头部字体
                :deep(.el-table__header th){
                    font-weight: 400;
                    font-size: 20px;
                    color: #D1D1D1;
                }
                /*最外层透明*/
                :deep(.el-table),
                :deep(.el-table__expanded-cell){
                    background-color: transparent !important;
                }
                /* 表格内背景颜色 */
                :deep(.el-table th),
                :deep(.el-table tr),
                :deep(.el-table td){
                    background-color: transparent !important;
                    border-bottom:1px solid #1D627D !important;
                }
                //:deep(.el-table tr){
                //    border:1px solid #000 !important;
                //}
                /*去除底边框*/
                :deep(.el-table td.el-table__cell){
                    border:0;
                }
                :deep(.el-table th.el-table__cell.is-leaf) {
                    border: 0;
                }
                /*去除底部灰条.el-table::before*/
                :deep(.el-table::before) {
                    display: none;
                }
            }
            .pagination{
                position: absolute;
                top: 90%;
                left: 1.5%;
                width:100%;
                height:10%;
                display:flex;
                justify-content:center;
                :deep(.el-pagination__total),
                :deep(.el-pagination__goto),
                :deep(.el-pagination__classifier){
                    color: #bcd4f3
                }
                :deep(.el-pager li) {
                    font-size: 15px;
                    color: #BAEBEC;
                    background: transparent;
                    padding: 0 4px;
                    border: 1px solid #BAEBEC;
                    border-radius: 0;
                    margin: 0 4px;
                    min-width: 25px;
                    height: 25px;
                }
                :deep(.el-pagination button) {
                    color: #BAEBEC;
                    background: transparent;
                    padding: 0 4px;
                    border-radius: 0;
                    margin: 0 4px;
                }
                :deep(.el-pagination .btn-next .el-icon),
                :deep(.el-pagination .btn-prev .el-icon) {
                    font-size: 18px !important;
                }
                :deep(.el-input__wrapper) {
                    background: transparent;
                    box-shadow: 0 0 0 1px #BAEBEC inset;
                    border-radius: 0;
                    height: 25px;
                    min-width: 30px;
                }
                :deep(.el-input__inner) {
                    font-size: 16px;
                    color: #BAEBEC;
                    height: 25px;
                    line-height: 30px !important;
                }
                :deep(.el-pager li.is-active) {
                    background-color: #1FB0BE;
                    color: #ffffff;
                    border: 1px solid #1FB0BE;
                }
            }
        }
    }
}
</style>