无人机管理后台前端(已迁走)
罗广辉
2025-10-11 02409bfbe15f22fc3b5dccadabfd860a660a49d9
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
<template>
  <div class="workOrder">
    <div class="card-title">
      <div class="cardtotal">
        <p>工单统计占比</p>
        <img @click="refresh" src="/src/assets/images/workbench/st1.svg" alt="" />
      </div>
      <div class="time-card">
        <div
          class="card-item"
          :class="item === checked ? 'active' : ''"
          v-for="(item, index) in timeListEnum"
          :key="index"
          @click="timeClick(item, index)"
        >
          {{ timeListStr[index] }}
        </div>
      </div>
    </div>
    <div class="workorderbox">
      <div class="card-group">
        <div class="main-card">
          <div class="status-grid">
            <div class="status-item" v-for="(item, index) in eventTypeList" :key="index">
              <div class="statusCon">
                <div class="status-label">{{ item.name }}</div>
                <div class="status-value">{{ item.value }}<span>个</span></div>
                <div class="ratio">
                  占比
                  <span :style="{ color: item.color }"
                    >{{ ((item.rate * 100) / 100).toFixed(2) }}%</span
                  >
                </div>
              </div>
              <img :src="item.img" alt="" />
            </div>
          </div>
        </div>
      </div>
      <div class="charts">
        <div class="chart" ref="echartsRef"></div>
      </div>
    </div>
  </div>
</template>
 
<script setup>
import useEchartsResize from '@/hooks/useEchartsResize';
import { getJobEventByStatus } from '@/api/home/index';
import overviewImg2 from '@/assets/images/workbench/tc2.svg';
import overviewImg3 from '@/assets/images/workbench/tc3.svg';
import overviewImg4 from '@/assets/images/workbench/tc4.svg';
import overviewImg5 from '@/assets/images/workbench/tc5.svg';
let checked = ref('CURRENT_YEAR');
let timeListStr = ['本周', '本月', '本年'];
let timeListEnum = ['CURRENT_WEEK', 'CURRENT_MONTH', 'CURRENT_YEAR'];
const params = ref({
  date_enum: 'CURRENT_YEAR',
  device_sn: '',
  end_date: undefined,
  start_date: undefined,
});
const dateSelect = ref('CURRENT_YEAR');
const eventTypeList = ref([
  { name: '待审核', value: 0, img: overviewImg2, color: '#FF472F', status: '2', rate: 0 },
  { name: '待处理', value: 0, img: overviewImg3, color: '#FF7411', status: '0', rate: 0 },
  { name: '处理中', value: 0, img: overviewImg4, color: '#FFC300', status: '3', rate: 0 },
  { name: '已完成', value: 0, img: overviewImg5, color: '#0291A1', status: '4', rate: 0 },
]);
//  工单统计
const getTypeData = () => {
  getJobEventByStatus(params.value).then(res => {
    const resList = res?.data?.data || [];
    resList.forEach(item => {
      eventTypeList.value.forEach(item1 => {
        if (item1.name === item.name) {
          item1.value = item.num;
          item1.rate = item.rate;
        }
      });
    });
    initChart(resList);
  });
};
const refresh = () => {
  // params.value.date_enum = 'CURRENT_YEAR';
  // checked.value = 'CURRENT_YEAR';
  // dateSelect.value = 'CURRENT_YEAR';
  getTypeData();
};
 
let timeClick = (item, index) => {
  checked.value = item;
  params.value.date_enum = item;
  dateSelect.value = item;
  getTypeData();
};
// 图表
const echartsRef = ref(null);
let { chart } = useEchartsResize(echartsRef);
const initChart = val => {
  const totalNum = val.reduce((sum, item) => sum + item.num, 0);
  const data = {
    total: {
      title: '总计',
      figure: totalNum.toString(), // 动态计算总数
    },
    data: val.map(item => ({
      value: item.num,
      name: item.name,
      rate: item.rate,
    })),
  };
  const containerWidth = chart.value.clientWidth;
  const isSmallScreen = containerWidth < 768; // 移动端判断
  const echartsOption = {
    color: ['#FF472F', '#FF7411', '#FFC300', '#0291A1'],
    tooltip: {
      trigger: 'item',
      padding: 0,
      borderWidth: 0,
      formatter: params => {
        return `<div style="background-color: rgba($color: #FFFFFF, $alpha: 0.95);
          box-shadow: 0 0.4rem 0.9rem 0 rgba($color: #000000, $alpha: 0.1);
          padding:0 1.2rem;
          display: flex;
          align-items: center;
          border-radius: 0.4rem;
          font-size: 1.2rem;" class="tooltip-area">
          <p>${params.marker}${params.name}</p>
          <h4 style="margin-left: 1rem;">${params.data.rate || params.percent}%</h4>
        </div>`;
      },
    },
    legend: {
      show: false,
    },
    title: {
      text: data.total.title,
      textStyle: {
        color: 'rgba(28, 31, 35, 0.80)',
        fontSize: '1.2rem',
        fontWeight: 'bold',
      },
      subtext: data.total.figure,
      subtextStyle: {
        color: '#1C1F23',
        fontSize: '2rem',
        fontWeight: '600',
      },
      top: '40%',
      left: '48%',
      textAlign: 'center', // 文本对齐
    },
    series: [
      {
        name: '',
        type: 'pie',
        radius: ['55%', '83%'],
 
        label: {
          show: false,
        },
        labelLine: {
          show: false,
          length: 3, // 调整引导线长度
          length2: 5,
          lineStyle: {
            cap: 'round',
          },
          minTurnAngle: 45, // 防止小角度重叠
        },
        data: data.data,
      },
    ],
  };
 
  chart.value.setOption(echartsOption);
};
onMounted(() => {
  getTypeData();
});
</script>
 
<style scoped lang="scss">
.workOrder {
  border-radius: 8px 8px 8px 8px;
  padding: 4px 14px 0 15px;
  background: #ffffff !important;
 
  height: pxToVh(282);
  margin-bottom: 10px;
  .card-title {
    display: flex;
    margin-bottom: 4px;
    align-items: center;
    justify-content: space-between;
    .cardtotal {
      display: flex;
      align-items: center;
      margin-left: 9px;
      img {
        width: 17px;
        height: 17px;
        margin-left: 6px;
        cursor: pointer;
      }
      p {
        font-weight: bold;
        font-size: 14px;
        color: #363636;
      }
 
      span {
        font-weight: 400;
        font-size: 14px;
        color: #7c8091;
      }
 
      .total-number {
        font-family: 'Source Han Sans CN';
 
        font-weight: bold;
        font-size: 32px;
        color: #2a54ff;
      }
    }
 
    img {
      width: 36px;
      height: 40px;
    }
  }
  .workorderbox {
    display: flex;
    justify-content: space-between;
    .card-group {
      width: 60%;
 
      .status-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        .status-item {
          display: flex;
          text-align: center;
          justify-content: space-between;
          height: pxToVh(97);
          margin-bottom: 10px;
          margin-right: 14px;
          width: 144px;
          background: #f6f8fe;
          border-radius: 8px 8px 8px 8px;
 
          img {
            width: 26px;
            height: 26px;
            padding: 9px 10px 9px 2px;
          }
 
          .statusCon {
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
          justify-content: space-between;
            padding: 10px 4px 39px 10px;
            text-align: left;
 
            .status-label {
              font-weight: 400;
              font-size: 14px;
              text-align: left;
              color: #383838;
              margin: 0;
            }
 
            .ratio {
              font-weight: 400;
              font-size: 12px;
              color: #363636;
              white-space: nowrap;
              text-align: left;
              margin-top: 10px;
            }
 
            .status-value {
              font-family: 'Source Han Sans CN';
              font-weight: bold;
              font-size: 28px;
              height: 28px;
              color: #363636;
            margin-top: -6px;
              display: inline-block;
              transform: skewX(-5deg);
 
              span {
                font-weight: 400;
                font-size: 14px;
                color: #7c8091;
              }
            }
          }
        }
      }
    }
 
    .charts {
      margin-top: 20px;
      width: 40%;
      height: auto;
 
      .chart {
        width: 100%;
        height: 100%;
      }
    }
  }
}
.time-card {
  text-align: center;
  // height: 30px;
  height: pxToVh(30);
  background: #ffffff;
 
  border: 1px solid #e5e5e5;
  font-weight: 400;
  font-size: 14px;
  color: #7c8091;
  display: flex;
  width: 282px;
  margin-left: 15px;
  border-radius: 4px;
 
  .card-item {
    width: 94px;
    height: 100%;
    line-height: 28px;
    cursor: pointer;
    font-family: 'Source Han Sans CN';
    font-weight: 400;
    font-size: 14px;
    color: #7c8091;
  }
 
  .card-item:first-child {
    border-right: 1px solid #e5e5e5;
  }
 
  .card-item:nth-child(2) {
    border-right: 1px solid #e5e5e5;
  }
 
  .card-item.active {
    color: #1441ff;
    border: 1px solid #1c5cff;
  }
}
</style>