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
| <!-- 任务数量统计 -->
| <template>
| <div class="task-time">
| <div class="title">任务数量统计</div>
| <div class="chart" ref="chartRef"></div>
| </div>
| </template>
|
| <script setup>
| import * as echarts from 'echarts';
| import { jobNumBar } from '@/api/home/task';
| import dayjs from 'dayjs';
| import useEchartsResize from '@/hooks/useEchartsResize'
| import { useStore } from 'vuex';
|
| const store = useStore();
|
| // 日期
| const currenDate = dayjs().format('YYYY-MM-DD');
| const newTime = ref([currenDate, currenDate]);
|
| const chartRef = ref(null);
| let { chart } = useEchartsResize(chartRef)
|
|
| const option = {
| tooltip: {
| trigger: 'axis',
| axisPointer: {
| type: 'shadow'
| },
| formatter: '{b}: {c} 件'
| },
| legend: {
| top: '2%',
| textStyle: {
| color: '#6B90B5',
| fontSize: 12,
| }
| },
| grid: {
| top: '15%',
| left: '3%',
| right: '4%',
| bottom: '2%',
| containLabel: true
| },
| // xAxis: {
| // type: 'category',
| // axisLine: {
| // lineStyle: {
| // color: '#fff'
| // }
| // },
| // axisLabel: {
| // color: '#fff',
| // interval: 0,
| // rotate: 30
| // }
| // },
| xAxis: {
| type: 'category',
| data: ['1'],
| axisLine: {
| show: false, // 隐藏轴线
| },
| axisTick: {
| show: true,
| length: 2,
| lineStyle: {
| color: '#ffffff',
| },
| },
| axisLabel: {
| color: '#ffffff',
| margin: 8,
| },
| },
| yAxis: {
| type: 'value',
| name: '单位:件',
| nameTextStyle: {
| color: '#E6F7FF',
| fontSize: 12,
| padding: [0, 0, 0, 0] // 调整单位文字位置
| },
| axisLine: {
| lineStyle: {
| color: '#fff'
| }
| },
| splitLine: {
| lineStyle: {
| color: 'rgba(255, 255, 255, 0.1)'
| }
| },
| axisLabel: {
| color: '#fff'
| }
| },
| series: [
| {
| name: '任务数量',
| type: 'bar',
| barWidth: '6px',
| itemStyle: {
| color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
| { offset: 0, color: '#0EECE4' },
| { offset: 1, color: '#058FE7' }
| ])
| }
| }
| ]
| };
|
| // 获取任务时间统计数据
| const getJobNumBar = (value) => {
| jobNumBar(value).then(res => {
| if (res.data.code !== 0) return;
| option.xAxis.data = res.data.data.map(item => item.name);
| option.series[0].data = res.data.data.map(item => item.value);
| chart.value.setOption(option);
| });
| };
|
| // 添加监听
| watch(() => store.state.task.taskSearchParams, (newVal) => {
| if (newVal) {
| getJobNumBar(newVal);
| (newVal);
| }
| }, { deep: true });
|
| onMounted(() => {
| getJobNumBar({date_enum: 'TODAY'});
| });
|
| </script>
|
| <style lang="scss" scoped>
| .task-time {
| font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
| width: 502px;
| height: 100%;
| margin-left: 14px;
| .title {
| font-size: 14px;
| margin-top: 10px;
| width: 502px;
| height: 28.6px;
| background: url('@/assets/images/task/task-num-total.png') no-repeat center / 100% 100%;
| color: #CFEAFF;
| padding-left: 44px;
| line-height: 8px;
| }
| .chart {
| width: 100%;
| height: 200px;
| }
| }
| </style>
|
|