zhaojiale
2022-09-16 357231819223f9241077700ed692f9b5fc58f02c
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
<template>
    <div>
        <div class="echart">
            <h2 class="title">距上次应急演练结束{{day}}天</h2>
            <el-form :model="form" label-width="20px">
                <el-row>
                    <el-col :span="4" :offset="15">
                        <el-form-item size="default">
                            <el-tree-select v-model="form.deptId" :data="data" @change="eaclick" placeholder="选择部门" :props="propse"  style="width: 100%" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item size="default">
                            <el-select v-model="form.type" placeholder="年/月" @change="eaclick" style="width:100%">
                                <el-option label="年" :value="1" />
                                <el-option label="月" :value="2" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div ref="main" style="width: 100%; height: 300px"></div>
            <div style="width: 100%; padding-left: 20px">
                <el-select v-model="params.searchParams.classification" style="width: 200px"
                           placeholder="请选择物资分类" @change="emergencySuppliesCount">
                    <el-option label="事故气体吸收装置" :value="1"></el-option>
                    <el-option label="通讯设施" :value="2"></el-option>
                    <el-option label="交通运输工具" :value="3"></el-option>
                    <el-option label="照明装置" :value="4"></el-option>
                    <el-option label="防护器材" :value="5"></el-option>
                    <el-option label="其它" :value="6"></el-option>
                </el-select>
                <div class="pie-body">
                    <div class="pie-item" ref="echarts0">
                    </div>
                    <div class="pie-item" ref="echarts1">
                    </div>
                    <div class="pie-item" ref="echarts2">
                    </div>
                    <div class="pie-item" ref="echarts3">
                    </div>
                    <div class="pie-item" ref="echarts4">
                    </div>
                    <ArrowLeftBold class="pie-left" :class="disabledLeft" @click="leftClick" />
                    <ArrowRightBold class="pie-right" :class="disabledRight" @click="rightClick" />
                </div>
            </div>
        </div>
    </div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from 'vue';
import * as echarts from 'echarts';
import { ElMessage } from 'element-plus';
import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue';
import { goalManagementApi } from '/@/api/goalManagement';
import { toNamespacedPath } from 'path/posix';
import { deepClone } from '/@/utils/other';
export default defineComponent({
    components: {
        ArrowLeftBold,
        ArrowRightBold,
    },
    setup() {
        const params = ref({
            pageIndex:1,
            pageSize:5,
            searchParams:{
                classification:''
            }
        })
        const list = ref([])
 
        const leftClick = () => {
            params.value.pageIndex--
            emergencySuppliesCount()
            initPies()
        }
        const rightClick = () => {
            params.value.pageIndex++
            emergencySuppliesCount()
            initPies()
        }
        const disabledLeft = ref()
        const disabledRight = ref()
        //加载数据
        const emergencySuppliesCount = () => {
            goalManagementApi()
                    .emergencySuppliesCount(params.value)
                    .then((res) => {
                        if (res.data.code == 200) {
                            list.value = res.data.data;
                            initPies()
                            //禁用左右按钮
                            if(res.data.pageIndex==1){
                                disabledLeft.value = 'disabled-pie'
                            }else{
                                disabledLeft.value = ''
                            }
                            if(res.data.pageIndex==res.data.pages){
                                disabledRight.value = 'disabled-pie'
                            }else{
                                disabledRight.value = ''
                            }
                        } else {
                            ElMessage.error(res.data.msg);
                        }
                    });
        };
        const echarts0 = ref()
        const echarts1 = ref()
        const echarts2 = ref()
        const echarts3 = ref()
        const echarts4 = ref()
        const initPies = () => {
            var myChart0 = echarts.init(echarts0.value);
            var myChart1 = echarts.init(echarts1.value);
            var myChart2 = echarts.init(echarts2.value);
            var myChart3 = echarts.init(echarts3.value);
            var myChart4 = echarts.init(echarts4.value);
            myChart0.clear()
            myChart1.clear()
            myChart2.clear()
            myChart3.clear()
            myChart4.clear()
            for(var a = 0;a<list.value.length;a++){
                var option = {
                    tooltip: {
                        trigger: 'item',
                        show:false
                    },
                    color:['#24c548'],
                    title: {
                        text: list.value[a].name+'\n\n'+list.value[a].totalNum,
                        x: '49%',
                        y: '35%',
                        textAlign:'center',
                        textStyle: {
                            color: '#24c548',
                            fontSize: 19,
                            fontWeight: "bold",
                            fontFamily:'D-DIN',
                            textShadowColor:'red'
                        },
                    },
                    series: [
                        {
                            name: null,
                            type: 'pie',
                            radius: ['80%', '90%'],
                            avoidLabelOverlap: false,
                            itemStyle: {
                                borderRadius: 10,
                                borderColor: '#fff',
                                borderWidth: 0
                            },
                            label: {
                                show: false,
                                position: 'center'
                            },
                            labelLine: {
                                show: false
                            },
                            data: [
                                { value: list.value[a].totalNum, name: list.value[a].name },
                            ]
                        }
                    ]
                };
 
 
                if(a==0){
                    var option0 = deepClone(option)
                    option0.color = ['#24c548']
                    option0.title.textStyle.color = '#24c548'
                    myChart0.setOption(option0, true);
                }
                if(a==1){
                    var option1 = deepClone(option)
                    option1.color = ['#e7bd27']
                    option1.title.textStyle.color = '#e7bd27'
                    myChart1.setOption(option1, true);
                }
                if(a==2){
                    var option2 = deepClone(option)
                    option2.color = ['#e65c3e']
                    option2.title.textStyle.color = '#e65c3e'
                    myChart2.setOption(option2, true);
                }
                if(a==3){
                    var option3 = deepClone(option)
                    option3.color = ['#8e66e7']
                    option3.title.textStyle.color = '#8e66e7'
                    myChart3.setOption(option3, true);
                }
                if(a==4){
                    var option4 = deepClone(option)
                    option4.color = ['#28b8d6']
                    option4.title.textStyle.color = '#28b8d6'
                    myChart4.setOption(option4, true);
                }
            }
 
        };
 
        const form = ref({
            type:1,
            deptId:1
        });
        //部门
        const department = () => {
            goalManagementApi()
                .getTreedepartment()
                .then((res) => {
                    if (res.data.code == 200) {
                        data.value = res.data.data;
                    } else {
                        ElMessage.error(res.data.msg);
                    }
                });
        };
        const propse = {
            label: 'depName',
            children: 'children',
            value: 'depId',
        };
        const eaclick=()=>{
            listApi()
        }
        onMounted(() => {
            listApi()
            department();
            emergencySuppliesCount()
        });
        const day=ref(0)
        const listApi=()=>{
            goalManagementApi().emergencyStat(form.value).then(res=>{
               if(res.data.code==200){
                day.value=res.data.data.days
                let date=[]
                let names=[]
                res.data.data.dataList.forEach(item => {
                    date.push(item.num)
                    names.push(item.name)
                });
                init(date,names)
               }
            })
        }
        const main = ref();
        const init = (data: any,names:any) => {
            var myChart = echarts.init(main.value);
            var option = {
                tooltip: {},
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '5%',
                    containLabel: true,
                },
                xAxis: {
                    type: 'category',
                    data: names,
                },
                yAxis: {
                    type: 'value',
                    name: '次数',
                    nameTextStyle: {
                        color: '#aaa',
                        nameLocation: 'start',
                    },
                },
                color: ['#6394f9'],
                series: [
                    {
                        data: data,
                         barWidth : 40,
                        type: 'bar',
                    },
                ],
            };
 
            myChart.setOption(option);
        };
        const data = ref([])
        return {
            form,
            main,
            init,
            data,
            department,
            propse,
            listApi,
            eaclick,
            day,
            list,
            emergencySuppliesCount,
            params,
            initPies,
            leftClick,
            rightClick,
            echarts0,
            echarts1,
            echarts2,
            echarts3,
            echarts4,
            disabledRight,
            disabledLeft
        };
    },
});
</script>
<style scoped>
.title{
    text-align: center;
    padding: 20px 0;
}
.echart {
    background-color: #fff;
    border-radius: 5px;
}
.el-form {
    padding: 20px 0;
}
    .pie-body{
        width: 50%;
        height: 370px;
        display: flex;
        justify-content: space-around;
        flex-wrap: wrap;
        position: relative;
    }
    .pie-item{
        width: 32%;
        height: 48%;
        margin-right: 1%;
        margin-bottom: 1%;
    }
    .pie-left{
        position: absolute;
        width: 30px;
        height: 30px;
        left: 0;
        top: 48%;
        cursor: pointer;
    }
    .pie-right{
        position: absolute;
        width: 30px;
        height: 30px;
        right: 0;
        top: 48%;
        cursor: pointer;
    }
    .disabled-pie{
        pointer-events:none;
        color: #9b9da1;
    }
</style>