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
| <template>
| <div class="main_app">
| <QueryForm v-model="filters" :query-form-config="queryFormConfig" @handleQuery="getData(1)" @clear="clear"
| @changeForm='changeForm'>
| <template #fastdate>
| <el-radio-group v-model="filters.fastdate" size="small" @input="changeRadio">
| <el-radio-button label="0">当天</el-radio-button>
| <el-radio-button label="6">近7天</el-radio-button>
| <el-radio-button label="29">近30天</el-radio-button>
| </el-radio-group>
| </template>
| </QueryForm>
| <div class="main_content">
| <div class="type_wrap">
| <div class="title">隐患类型统计</div>
| <div v-show="typeList && typeList.length > 0" class="echart1" ref="typeRef"></div>
| <div v-show="typeList.length == 0" style="width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;">
| <img style="width: 240px;" src="@/assets/images/default_homeimg.png" alt="">
| </div>
|
| </div>
| <div class="dept_wrap">
| <div class="title">隐患归属部门统计</div>
| <div v-show="deptList && deptList.length > 0" class="echart2" ref="deptRef"></div>
| <div v-show="deptList.length == 0" style="width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;">
| <img style="width: 240px;" src="@/assets/images/default_homeimg.png" alt="">
| </div>
| </div>
| </div>
| </div>
| </template>
|
| <script>
| import QueryForm from '@/components/common/QueryForm'
| import * as echarts from 'echarts'
| import { hiddenDangerDataPost } from '@/api/business/hiddenDanger'
| import dayjs from 'dayjs'
| export default {
| components: {
| QueryForm,
| },
| data() {
| return {
| filters: {
| fastdate: '29',
| queryStartTime: '',
| queryEndTime: ''
| },
| queryFormConfig: {
| formItems: [
| {
| filed: 'status',
| type: 'select',
| label: '状态',
| options: [
| { label: '待处理', value: '0' },
| { label: '已处理', value: '1' },
| { label: '已退回', value: '2' },
| ]
| },
| {
| filed1: 'queryStartTime',
| filed2: 'queryEndTime',
| type: 'datetime',
| label: '提报时间'
| },
| {
| type: 'slot',
| filed: 'fastdate',
| label: ''
| }
| ],
| online: true
| },
| typeList: [],
| deptList: [],
| }
| },
| mounted() {
| this.changeRadio('29')
| // this.getData()
| },
| methods: {
| changeRadio(day) {
| const arr = [dayjs().subtract(day, 'day').format('YYYY-MM-DD') + ' 00:00:00', dayjs().format('YYYY-MM-DD') + ' 23:59:59']
| this.filters.queryStartTime = arr[0]
| this.filters.queryEndTime = arr[1]
| this.getData()
| },
| getData(page) {
| hiddenDangerDataPost({ ...this.filters }).then(res => {
| if (res) {
| this.typeList = res.cateList || []
| this.deptList = res.departmentList || []
| this.$nextTick(() => {
| this.initType()
| this.initDept()
| })
|
| }
| })
|
| },
| changeForm(e) {
| this.getData()
| },
| initType() {
| const myChart = echarts.init(document.querySelector('.echart1'))
| let total = 0
| this.typeList.forEach(i => {
| total += i.total
| })
| let colors = ['#d75a44', '#e39f4d', '#f0d05f', '#7ac7f6', '#4469ee', '#698af0','#86a2f1','#a1b4f6','#a0b5f5', '#9fb5f4', '#b6c7f7', '#c8d5f8']
| let option = {
| grid: {
| left: '0%',
| // right: '4%',
| // bottom: '3%',
| top: '0%',
| containLabel: true
| },
| title: [
| {
| text: '隐患总数',
| top: '46%',
| left: '45%',
| textStyle: {
| color: '#666666',
| fontSize: 16,
| },
| }, {
| text: total,
| top: '50%',
| left: '47.6%',
| textStyle: {
| color: '#080404',
| fontSize: 24,
| fontWeight: 'bold',
| },
| }],
| legend: {
| left: 'center',
| bottom: '8%',
| itemGap: 30,
| itemWidth: 30,
| icon: 'circle',
| formatter: (name) => {
| const item = this.typeList.filter((item) => item.name === name)[0]
|
| if (item) {
| return ` ${name} ${item.total} | ${item.rata}%`
| } else {
| return ` ${name} 0 | 0%`
| }
| }
| },
| series: [
| {
| type: 'pie',
| radius: ['24%', '40%'],
| label: {
| formatter: "{a|{b}}\n\n{c} | {d}%",
| rich: {
| a: {
| color: '#333333',
| fontSize: 14,
| fontWeight: 500
| }
| }
| },
| labelLine: {
| showAbove: true,
| show: true,
| length: 24,
| length2: 64,
| lineStyle: {
| width: 2 // 线条宽度
| }
| },
| data: this.typeList.map((i, index) => {
| return {
| value: i.total,
| name: i.name,
| itemStyle: {
| color: colors[index]
| }
| }
| })
| }
| ]
| }
| myChart.setOption(option)
| window.addEventListener('resize', function () { // 执行
| myChart.resize()
| })
| },
| initDept() {
| const myChart = echarts.init(document.querySelector('.echart2'))
|
| let option = {
| xAxis: {
| type: 'category',
| data: this.deptList.map(i => i.name),
| axisLabel: {
| color: '#333333',
| fontSize: 14,
| fontWeight: 'bold'
| }
| },
| yAxis: {
| type: 'value',
| name: '隐患数',
| axisLine: {
| show: true,
| },
| },
| series: [
| {
| data: this.deptList.map(i => i.total),
| type: 'bar',
| barWidth: 40,
| itemStyle: {
| color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
| { offset: 0, color: '#d75e45' }, // 渐变起始色
| { offset: 1, color: '#db924c' } // 渐变终止色
| ])
| },
|
| label: {
| show: true, // 显示标签
| position: 'top', // 让标签显示在柱子顶部
| color: '#666666', // 文字颜色
| fontSize: 14, // 文字大小
| }
| }
| ]
| }
| myChart.setOption(option)
| window.addEventListener('resize', function () { // 执行
| myChart.resize()
| })
| },
| clear() {
| this.filters = {}
| this.getData()
| }
| }
| }
| </script>
|
| <style lang="scss" scoped>
| /*.main_app {
| height: 100%;
| }*/
|
| .main_content {
| display: flex;
| height: calc(100% - 100px);
|
| .title {
| font-weight: 600;
| font-size: 16px;
| color: #222222;
| margin-bottom: 20px;
| margin-top: 20px;
| }
|
| .type_wrap {
| flex: 11;
| flex-shrink: 0;
| height: calc(100% - 20px);
| border-right: 12px solid #f7f7f7;
|
|
| .echart1 {
| width: 100%;
| height: calc(100% - 60px);
| }
| }
|
| .dept_wrap {
| flex: 10;
| flex-shrink: 0;
| height: calc(100% - 20px);
| padding-left: 20px;
|
| .echart2 {
| width: 100%;
| height: calc(100% - 60px);
| }
| }
| }
| </style>
|
|