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
| <!-- 巡检任务详情 -->
| <template>
| <common-title title="巡检任务情况" :style="{ marginLeft: pxToRem(14) }" @details="detailsFun"></common-title>
| <div class="inspection-rask-details">
| <div class="inspection-num">
| <div class="total">
| <div class="value">{{ total }}</div>
| <div class="name">总任务数</div>
| </div>
| <div class="status">
| <div class="item" v-for="(item, index) in list" :key="index">
| <div>
| <div :style="{ color: item.color }" class="value">
| {{ jobStatistics[item.field] }}
| </div>
| <div class="name">{{ item.name }}</div>
| </div>
| <div v-if="index !== 2 && index !== 4" class="right-line"></div>
| </div>
| </div>
| </div>
| <CommonDateTime :style="{ top: pxToRem(19) }" v-model="newTime" @change="getData" />
| <div class="chart-container" ref="chartRef"></div>
| </div>
| <InspectionRaskDetailsDialog v-model:show="isShowDetailsDialog"></InspectionRaskDetailsDialog>
| </template>
|
| <script setup>
| import * as echarts from 'echarts'
| import { pxToRem } from '@/utils/rem'
| import CommonTitle from '@/components/CommonTitle.vue'
| import CommonDateTime from '@/components/CommonDateTime.vue'
| import { getJobNumBar, getJobStatistics, getTotalJobNum } from '@/api/home'
| import dayjs from 'dayjs'
| import InspectionRaskDetailsDialog from '@/views/Home/HomeLeft/InspectionRaskDetails/InspectionRaskDetailsDialog.vue'
| import useEchartsResize from '@/hooks/useEchartsResize'
| const currenDate = dayjs().format('YYYY-MM-DD')
| const newTime = ref([currenDate, currenDate])
| const list = ref([
| { name: '计划执行', value: 0, color: '#FFFFFF', field: 'planned_executions' },
| { name: '执行中', value: 0, color: '#FFA768', field: 'running_num' },
| { name: '待执行', value: 0, color: '#FFE17E', field: 'pending_executions' },
| { name: '已执行', value: 0, color: '#8EFFAC', field: 'executed' },
| { name: '执行失败', value: 0, color: '#FF8E8E', field: 'failed_executions' },
| ])
| const option = {
| grid: {
| top: '15%',
| left: '3%',
| right: '4%',
| bottom: '3%',
| containLabel: true,
| },
| tooltip: {
| trigger: 'axis',
| backgroundColor: 'rgba(0,0,0,0.7)',
| borderColor: '#0070FF',
| borderWidth: 1,
| textStyle: {
| color: '#fff',
| },
| formatter: '{b}: {c}次',
| },
| xAxis: {
| type: 'category',
| data: ['1'],
| axisLine: {
| show: false, // 隐藏轴线
| },
| axisTick: {
| show: true,
| length: 2,
| lineStyle: {
| color: '#ffffff',
| },
| },
| axisLabel: {
| color: '#ffffff',
| margin: 8,
| },
| },
| yAxis: {
| type: 'value',
| axisLine: {
| lineStyle: {
| color: '#ffffff',
| },
| },
| axisLabel: {
| color: '#ffffff',
| },
| splitLine: {
| lineStyle: {
| color: 'rgba(255, 255, 255, 0.1)',
| },
| },
| },
| series: {
| data: [10],
| type: 'bar',
| barWidth: '60%',
| itemStyle: {
| color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
| { offset: 0, color: '#1EE7E7' },
| { offset: 1, color: 'rgba(0, 112, 255, 0.1)' },
| ]),
| },
| },
| }
|
| // 是否展示巡检任务详情
| const isShowDetailsDialog = ref(false)
| const detailsFun = () => {
| isShowDetailsDialog.value = true
| }
| const chartRef = ref(null)
| let { chart } = useEchartsResize(chartRef)
|
| // TODAY,CURRENT_WEEK,CURRENT_MONTH,CURRENT_YEAR
| const getData = (value, date_enum) => {
| const params = {
| date_enum,
| // start_date: newTime.value[0],
| // end_date: newTime.value[1]
| }
| getJobStatistics(params).then(res => {
| jobStatistics.value = res.data?.data || {}
| })
| getJobNumBar(params).then(res => {
| option.xAxis.data = res.data?.data.map(item => item.name)
| option.series.data = res.data?.data.map(item => item.value)
| chart.value.setOption(option)
| })
| }
|
| const total = ref(0)
| const jobStatistics = ref({
| planned_executions: 0,
| executed: 0,
| running_num: 0,
| failed_executions: 0,
| pending_executions: 0,
| })
|
| onMounted(() => {
| getTotalJobNum().then(res => {
| total.value = res.data?.data || 0
| })
| getData(newTime.value, 'TODAY')
| })
| </script>
|
| <style scoped lang="scss">
| .inspection-rask-details {
| margin-left: 29px;
| padding: 16px 16px;
| width: 390px;
| height: 414px;
| background: linear-gradient(270deg, rgba(31, 62, 122, 0) 0%, rgba(31, 62, 122, 0.35) 21%, #1f3e7a 100%);
| border-radius: 0px 0px 0px 0px;
| opacity: 0.85;
|
| .inspection-num {
| background: url('@/assets/images/home/homeLeft/inspection-num.png') no-repeat center / 100% 100%;
| width: 378px;
| height: 110px;
| position: relative;
|
| .total {
| position: absolute;
| left: 20px;
| top: 36px;
| font-weight: 500;
| font-size: 14px;
| color: #ffffff;
| text-align: center;
| font-family: Source Han Sans CN, Source Han Sans CN;
| line-height: 19px;
|
| .value {
| font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
| font-size: 26px;
| }
| }
|
| .status {
| position: absolute;
| left: 115px;
| width: 250px;
| height: 110px;
| display: grid;
| grid-template-columns: repeat(3, 1fr);
| grid-template-rows: repeat(1, 30px); // 设置每行高度
| gap: 10px 0; // 调整行间距
| align-content: center;
|
| .item {
| display: flex;
| align-items: center;
| }
| .right-line {
| width: 0px;
| height: 36px;
| border-radius: 0px 0px 0px 0px;
| border: 1px solid;
| border-image: linear-gradient(180deg, rgba(27, 148, 255, 0), rgba(27, 148, 255, 1), rgba(27, 148, 255, 0)) 1 1;
| margin-left: 10px;
| }
| .name {
| width: 56px;
| text-align: center;
| font-family: Source Han Sans CN, Source Han Sans CN;
| font-weight: 400;
| font-size: 14px;
| color: #ffffff;
| margin-top: -4px;
| }
|
| .value {
| width: 56px;
| text-align: center;
| font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
| font-weight: 400;
| font-size: 26px;
| }
| }
| }
|
| .chart-container {
| width: 100%;
| height: 200px;
| margin-top: 20px;
| }
| }
| </style>
|
|