index.vue
10 KB
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
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-08-25 08:59:04
-->
<template>
<div class="tjltj">
<div class="inquire">
<el-form :model="queryForm" ref="queryForm" label-width="100px">
<el-row>
<el-col :span="19">
<div class="rowAc">
<div
v-for="(item, index) in dateQuickSelection"
:key="index"
class="rowAc dateQuickItem"
@click="chooseDateQuick(index)"
>
{{ item.name }}
</div>
<el-date-picker
v-model="dateRange"
type="daterange"
value-format="yyyy-MM-dd"
end-placeholder="结束日期"
start-placeholder="开始日期"
:clearable="false"
range-separator="-"
class="dataRangePicker"
@change="chooseDateRange"
></el-date-picker>
</div>
</el-col>
<el-col :span="5" class="btnColRight">
<el-form-item>
<el-button
type="primary"
native-type="submit"
@click="handleSearch"
>查询</el-button
>
<el-button type="primary" native-type="submit" @click="derive"
>导出</el-button
>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<div ref="chart" style="width: 100%; height: 92%"></div>
</div>
</template>
<script>
import * as echarts from "echarts"
import XLSX from 'xlsx';
export default {
components: {},
data() {
return {
dateQuickSelection: [
// 日期快捷选择列表
{ code: "1", name: "今日" },
{ code: "2", name: "昨日" },
{ code: "3", name: "本周" },
{ code: "4", name: "上周" },
{ code: "5", name: "本月" },
{ code: "6", name: "上月" },
{ code: "7", name: "今年" },
{ code: "8", name: "去年" },
],
chooseIndex: 0, // 日期快捷选择项索引
dateRange: [], // 自定义列表 - 日期范围
queryForm: {},
data1: [12, 10, 15, 12, 15, 19, 15],
data2: [1, 2, 2, 3, 2, 3, 2],
data3: [],
xAxisData: [
"赵龙龙",
"刘龙龙",
"田龙龙",
"任龙龙",
"孙龙龙",
"李龙龙",
"周龙龙",
],
};
},
mounted() {
this.setdata();
// 创建一个 ECharts 实例
this.chart = echarts.init(this.$refs.chart);
// 在 ECharts 实例中配置图表
this.chart.setOption(this.getOption());
this.chooseDateQuick(0);
},
methods: {
setdata() {
for (let i = 0; i < this.data1.length; i++) {
let sum = (this.data2[i] / this.data1[i]) * 100;
this.data3.push(Number(sum).toFixed(0));
}
},
// 导出
derive() {
this.exdata = [
['受理人员', '收件数','退件数','推荐率']
];
this.xAxisData.forEach((item,index) => {
console.log("this.exdata[index+1]",this.exdata[index+1]);
this.exdata.push([])
this.exdata[index+1].push(item)
this.exdata[index+1].push(this.data1[index])
this.exdata[index+1].push(this.data2[index])
this.exdata[index+1].push(this.data3[index])
})
console.log("this.exdata",this.exdata);
const ws = XLSX.utils.aoa_to_sheet(this.exdata);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
XLSX.writeFile(wb, '收件与超时统计情况.xlsx');
},
// 查询
handleSearch() {
console.log("dateRange", this.dateRange);
},
getOption() {
return {
title: {
text: "收件与超时统计情况 ", // 主标题名称
textStyle: {
//主标题文本设置
fontSize: 26, //大小
},
itemGap: 3, //主副标题间距
x: "center", //主副标题的水平位置
y: "top", //主副标题的垂直位置
},
tooltip: {
trigger: "item",
textStyle: {
fontSize: 14,
lineHeight: 22,
},
// 如果需要自定义 tooltip样式,需要使用formatter
formatter: (params) => {
console.log("paramsssssssssssssssssss", params);
return `<div font-size: 14px;line-height: 24px>
${params.seriesName}
<br>
<span font-size: 16px; font-weight: 600;"> ${params.name}: ${
Number(params.value).toFixed(2) + "%"
} </span>
</div>`;
},
},
legend: {
data: ["办件数", "超时数", "超时时间"],
bottom: "3%",
itemWidth: 20,
itemHeight: 20,
//文字样式
textStyle: {
fontSize: 17, //设置文字大小
},
},
grid: [{ right: "3%", top: "10%", bottom: "15%", left: "3%" }],
color: ["#94ae0a", "#115fa6", "#a61120"],
xAxis: {
data: this.xAxisData,
axisLabel: {
// 轴文字
fontSize: 18,
},
},
yAxis: {
axisLabel: {
// 轴文字
fontSize: 18,
},
},
series: [
{
name: "办件数",
type: "bar",
data: this.data1,
label: {
normal: {
show: true,
fontSize: 13,
position: "top",
},
},
},
{
name: "超时数",
type: "bar",
data: this.data2,
label: {
normal: {
show: true,
fontSize: 13,
position: "top",
},
},
},
{
name: "超时时间",
type: "bar",
data: this.data3,
label: {
normal: {
show: true,
fontSize: 13,
position: "top",
},
},
},
],
};
},
// 日期快捷选择事件
chooseDateQuick(index) {
this.chooseIndex = index;
var tempCode = this.dateQuickSelection.find(
(ele) => this.chooseIndex === Number(ele.code) - 1
).code;
var tempDate = new Date();
var year = tempDate.getFullYear();
var month = tempDate.getMonth();
var day = tempDate.getDate();
var week = tempDate.getDay();
this.dateRange = [];
if (tempCode === "1") {
// 今日
this.dateRange.push(
this.formatDate(tempDate),
this.formatDate(tempDate)
);
} else if (tempCode === "2") {
// 昨日
this.dateRange.push(
this.jumpNumDay(tempDate, -1, "-"),
this.jumpNumDay(tempDate, -1, "-")
);
} else if (tempCode === "3") {
// 本周
this.dateRange.push(
this.formatDate(new Date(year, month, day - week + 1)),
this.formatDate(tempDate)
);
} else if (tempCode === "4") {
// 上周
this.dateRange.push(
this.formatDate(new Date(year, month, day - week - 6)),
this.formatDate(new Date(year, month, day - week))
);
} else if (tempCode === "5") {
// 本月
this.dateRange.push(
this.formatDate(new Date(year, month, 1)),
this.formatDate(tempDate)
);
} else if (tempCode === "6") {
// 上月
this.dateRange.push(
this.formatDate(new Date(year, month - 1, 1)),
this.formatDate(new Date(year, month, 0))
);
} else if (tempCode === "7") {
// 今年
this.dateRange.push(
this.formatDate(new Date(year, 0, 1)),
this.formatDate(tempDate)
);
} else if (tempCode === "8") {
// 去年
this.dateRange.push(
this.formatDate(new Date(year - 1, 0, 1)),
this.formatDate(new Date(year - 1, 11, 31))
);
}
},
// 日期范围选择器事件
chooseDateRange() {
this.chooseIndex = null;
},
// 数字转换
changeNum(num) {
if (num >= 10) {
return num;
} else {
return "0" + num;
}
},
// 格式化日期
formatDate(date) {
var year = date.getFullYear();
var month = this.changeNum(date.getMonth() + 1);
var day = this.changeNum(date.getDate());
return `${year}-${month}-${day}`;
},
// 某日期向前/向后num天
jumpNumDay(date, num, linkStr = "-") {
date = new Date(date.getTime() + num * 24 * 60 * 60 * 1000);
return (
date.getFullYear() +
linkStr +
this.changeNum(date.getMonth() + 1) +
linkStr +
this.changeNum(date.getDate())
);
},
},
};
</script>
<style scoped lang="scss">
.tjltj {
width: 100%;
height: 100%;
.inquire {
width: 100%;
height: 40px;
padding-top: 3px;
background-color: #ffffff;
margin-bottom: 10px;
}
.rowAc {
margin-left: 10px;
display: flex;
justify-content: flex-start;
align-items: center;
}
.dateQuickItem {
padding: 1px 8px;
margin-right: 16px;
color: #3c4353;
font-size: 14px;
line-height: 22px;
font-weight: 400;
border: 1px solid #dcdee0;
border-radius: 16px;
background: #ffffff;
cursor: pointer;
box-sizing: border-box;
}
.dateQuickItem:hover,
.dateQuickItem.active {
color: #1b58f4;
border: 1px solid #1b58f4;
}
.dateQuickItem.disabled {
color: #c8c9cc;
border: 1px solid #dcdee0;
background: #f7f8f9;
cursor: not-allowed; // 禁止鼠标事件
}
.dataRangePicker {
width: 240px !important;
height: 32px !important;
}
.dataRangePicker.el-date-editor .el-range-separator {
line-height: 24px;
}
.dataRangePicker.el-date-editor .el-range__icon {
margin-left: 0px;
line-height: 24px;
}
.dataRangePicker.el-date-editor .el-range-input {
width: 95px;
}
}
</style>