forked from drone/command-center-dashboard

shuishen
2025-04-16 a7e6761ba0cfccdf33ed552eb2d3b783c8e4ab4a
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
<template>
    <div class="event-overviewdetail-right" :class="{ isMore }">
        <CommonTitle title="工单列表" />
 
        <div class="content">
            <img class="leftArrow" :src="isMore ? rightArrowImg : leftArrowImg" @click="leftArrowFun" alt="" />
 
            <el-date-picker
                class="ztzf-date-picker"
                v-model="timeArr"
                type="daterange"
                :value-format="timeFormat"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                @change="timeChange"
            />
 
            <el-select
                class="ztzf-select"
                :style="{ width: pxToRem(174) }"
                v-model="params.device_sn"
                placeholder="机巢"
                filterable
                clearable
                @change="getList"
            >
                <el-option v-for="item in deviceList" :label="item.nickname" :value="item.device_sn" :key="item.device_sn" />
            </el-select>
 
            <el-select
                class="ztzf-select"
                :style="{ width: pxToRem(174) }"
                v-model="params.word_order_type"
                placeholder="工单类型"
                filterable
                clearable
                @change="getList"
            >
                <el-option v-for="item in workOrderType" :label="item.dictValue" :value="item.dictKey" :key="item.dictKey" />
            </el-select>
 
            <div class="statusList">
                <div
                    class="statusItem"
                    v-for="item in isMore ? statusList : statusList.filter(i => i.few)"
                    @click="statusClick(item)"
                    :class="{ active: item.active }"
                >
                    <img class="statusItemImg" :src="item.img" alt="" />
                    <div class="statusItemInfo">
                        <div class="statusItemName">{{ item.name }}</div>
                        <div class="statusItemNum">{{ item.num || 0 }}</div>
                    </div>
                </div>
            </div>
 
            <el-checkbox-group v-model="params.event_keys" @change="getList">
                <el-checkbox v-for="item in eventList" :value="item.status" :key="item.dictKey">
                    <template #default>
                        <span class="eventListItemCheckboxName">{{ item.name }}</span>
                        <span class="eventListItemCheckboxNum">({{ item.value }})</span>
                    </template>
                </el-checkbox>
            </el-checkbox-group>
 
            <div class="eventList">
                <div class="eventListItem" v-for="item in list">
                    <img
                        class="eventListItemImg"
                        :src="getSmallImg(item.photo_url)"
                        alt=""
                    />
                    <div class="eventListItemPosition" :title="item.address" @click="positioning(item)">
                        <img :src="positioningImg" alt="" title="点击定位" />
                        <div class="address">{{ item.address }}</div>
                    </div>
                    <div class="eventListItemText">
                        <div class="eventListItemName">{{ item.event_name }}</div>
                        <div class="eventListItemTime">{{ item.create_time }}</div>
                    </div>
                </div>
            </div>
 
            <div class="pagination">
                <el-pagination
                    class="ztzf-pagination"
                    background
                    v-model:current-page="params.current"
                    v-model:page-size="params.size"
                    layout="total,  prev, pager, next"
                    :total="total"
                    @change="pageChange"
                />
            </div>
        </div>
    </div>
</template>
<script setup>
import status0Img from '@/assets/images/home/eventOverviewDetail/status0.png'
import status1Img from '@/assets/images/home/eventOverviewDetail/status1.png'
import status2Img from '@/assets/images/home/eventOverviewDetail/status2.png'
import status3Img from '@/assets/images/home/eventOverviewDetail/status3.png'
import status4Img from '@/assets/images/home/eventOverviewDetail/status4.png'
import status5Img from '@/assets/images/home/eventOverviewDetail/status5.png'
import positioningImg from '@/assets/images/home/eventOverviewDetail/positioning.png'
import leftArrowImg from '@/assets/images/home/eventOverviewDetail/leftArrow.png'
import rightArrowImg from '@/assets/images/home/eventOverviewDetail/rightArrow.png'
 
import dayjs from 'dayjs'
import { selectDevicePage } from '@/api/home/machineNest'
import { getMultipleDictionary } from '@/api/system/dictbiz'
import { getEvenNum, getEventPage, getEventStatusNum } from '@/api/home/event'
import cesiumOperation from '@/utils/cesium-tsa'
import CommonTitle from '@/components/CommonTitle.vue'
import { pxToRem } from '@/utils/rem'
import { useStore } from 'vuex'
 
const store = useStore()
// const eventTimeRange = computed(() => store.state.home.eventTimeRange)
const timeFormat = 'YYYY-MM-DD HH:mm:ss'
const today = dayjs().format(timeFormat)
// const oneWeekAgo = dayjs().subtract(7, 'day').format(timeFormat)
// const timeArr = ref([oneWeekAgo, today])
const startOfWeek = dayjs().startOf('week').add(1, 'day').format(timeFormat)
const endOfWeek = dayjs().endOf('week').add(1, 'day').format(timeFormat)
const timeArr = ref([startOfWeek, endOfWeek])
const deviceList = ref([])
 
const total = ref(0)
const params = ref({
    start_date: timeArr.value[0],
    end_date: timeArr.value[1],
    device_sn: undefined,
    word_order_type: undefined,
    status: undefined,
    event_keys: [],
    current: 1,
    size: 8,
})
 
const getSmallImg = (url) => {
    return url ? url.substring(0, url.lastIndexOf('.')) + '_small' + url.substring(url.lastIndexOf('.')) : ''
}
 
const isMore = ref(false)
const leftArrowFun = () => {
    isMore.value = !isMore.value
    params.value.size = isMore.value ? 16 : 8
    params.value.current = 1
    getList()
}
 
const statusClick = row => {
    params.value.status = row.id || undefined
    statusList.value = statusList.value.map(item => ({
        ...item,
        active: item.name === row.name,
    }))
    getList()
}
 
const getDeviceList = async () => {
    const res = await selectDevicePage({ current: 1, size: 99999, type: 1 })
    deviceList.value = res.data?.data?.records || []
}
 
// 工单类型
const workOrderType = ref([])
const getDictList = () => {
    getMultipleDictionary('WORK_ORDER_TYPE,SF').then(res => {
        workOrderType.value = res.data.data?.['WORK_ORDER_TYPE'] || []
    })
}
const { flyTo } = cesiumOperation()
const positioning = row => {
    const longitude = Number(row.longitude)
    const latitude = Number(row.latitude)
    flyTo({ longitude, latitude }, 1, 1000)
}
 
// 事件状态+数量
const statusList = ref([
    { name: '全部状态', img: status0Img, id: undefined,few: true },
    { name: '待审核', img: status1Img, id: 2 },
    { name: '待处理', img: status2Img, id: 0, few: true },
    { name: '处理中', img: status3Img, id: 3, few: true },
    { name: '已完成', img: status4Img, id: 4, few: true },
    { name: '待分拨', img: status5Img, id: 1 },
])
 
const getEventStatusNumFun = () => {
    const [start_date, end_date] = timeArr.value
    getEventStatusNum({ start_date, end_date }).then(res => {
        const list = res.data?.data || []
        statusList.value = statusList.value.map(item => {
            const find = list.find(item1 => item.id === item1.id) || {}
            return {
                ...item,
                ...find,
            }
        })
        statusList.value[0].active = true
    })
}
 
// 事件+数量
const eventList = ref([])
const getEventList = () => {
    const [start_date, end_date] = timeArr.value
    getEvenNum({ start_date, end_date }).then(res => {
        eventList.value = res.data.data
    })
}
 
const timeChange = value => {
    const [start_date, end_date] = timeArr.value
    params.value.start_date = start_date
    params.value.end_date = end_date
    // 提交数据,更新聚合
    store.commit('setEventTimeRang', timeArr.value);
    // 重置
    getEventStatusNumFun()
    getEventList()
    params.value.status = undefined
    params.value.event_keys = undefined
    getList()
}
 
const pageChange = val => {
    params.value.current = val
    getList()
}
 
const list = ref([])
const getList = () => {
    const pageParams = {
        current: params.value.current,
        size: params.value.size,
    }
    getEventPage(params.value, pageParams).then(res => {
        const resData = res.data.data
        list.value = (resData?.records || [])
        total.value = resData.total
    })
}
 
const getDateRange = unit => {
  if (unit === 'today') {
    return [dayjs().format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')];
  }
  return [dayjs().startOf(unit).format('YYYY-MM-DD HH:mm:ss'), dayjs().endOf(unit).format('YYYY-MM-DD HH:mm:ss')];
};
 
// 监听事件时间范围变化
watch(() => store.state.home.eventTimeType, (newVal) => {
    timeArr.value = getDateRange(newVal);
    const [start_date, end_date] = getDateRange(newVal);
    params.value.start_date = start_date
    params.value.end_date = end_date
    getEventStatusNumFun()
    getEventList()
    getList()
}, { immediate: false,deep: true })
 
onMounted(() => {
    getDeviceList()
    getDictList()
    getEventStatusNumFun()
    getEventList()
    getList()
})
</script>
<style scoped lang="scss">
.event-overviewdetail-right {
    position: absolute;
    right: 36px;
    top: 122px;
    display: flex;
    flex-direction: column;
    align-items: end;
    height: 922px;
    width: 405px;
    font-size: 18px;
 
    &.isMore {
        width: 807px;
 
        .content {
            width: 792px;
        }
    }
 
    .content {
        width: 390px;
        height: 877px;
        background: linear-gradient(270deg, #1f3e7a 0%, rgba(31, 62, 122, 0.35) 79%, rgba(31, 62, 122, 0) 100%);
        display: flex;
        justify-content: space-between;
        align-content: start;
        flex-wrap: wrap;
        padding: 7px 15px 0 11px;
        gap: 10px;
 
        .leftArrow {
            position: absolute;
            left: -11px;
            top: 50%;
            transform: translateY(-50%);
            cursor: pointer;
        }
 
        .statusList {
            width: 100%;
            display: flex;
 
            .statusItem {
                width: 95px;
                height: 44px;
                display: flex;
                flex: 1;
                justify-content: center;
                position: relative;
                cursor: pointer;
 
                &.active {
                    background: linear-gradient(
                        180deg,
                        rgba(19, 80, 141, 0) 0%,
                        rgba(22, 56, 91, 0.48) 48%,
                        #053462 91%,
                        #259dff 91%,
                        #259dff 98%
                    );
                }
 
                .statusItemImg {
                    width: 35px;
                    height: 35px;
                }
 
                .statusItemInfo {
                    .statusItemName {
                        width: 59px;
                        height: 17px;
                        font-family: Segoe UI, Segoe UI;
                        font-weight: 400;
                        font-size: 14px;
                        color: #ffffff;
                        line-height: 17px;
                        text-align: left;
                        font-style: normal;
                        text-transform: none;
                    }
 
                    .statusItemNum {
                        width: 32px;
                        height: 16px;
                        font-family: Segoe UI, Segoe UI;
                        font-weight: bold;
                        font-size: 16px;
                        color: #ffd509;
                        line-height: 16px;
                        text-align: left;
                        font-style: normal;
                        text-transform: none;
                    }
                }
            }
        }
 
        .el-checkbox-group {
            :deep() {
                .el-checkbox {
                    height: 20px;
                    margin-right: 10px;
                }
 
                .el-checkbox__inner {
                    background: transparent;
                    width: 18px;
                    height: 18px;
                    border: 1px solid #3194ef;
                }
 
                .el-checkbox__label {
                    font-family: Segoe UI, Segoe UI;
                    font-weight: 400;
                    font-size: 14px;
                    color: #ffffff;
                    line-height: 17px;
 
                    .eventListItemCheckboxNum {
                        color: #ffa500;
                    }
                }
            }
        }
 
        .eventList {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            gap: 20px 0;
 
            .eventListItem {
                width: 175px;
                height: 140px;
                position: relative;
 
                .eventListItemImg {
                    width: 174px;
                    height: 116px;
                    border-radius: 4px 4px 4px 4px;
                    margin-bottom: 7px;
                }
 
                .eventListItemPosition {
                    position: absolute;
                    right: 0;
                    top: 116px;
                    width: 174px;
                    height: 20px;
                    transform: translateY(-100%);
                    background: rgba(22, 22, 22, 0.68);
                    border-radius: 0 0 4px 4px;
                    font-family: Segoe UI, Segoe UI;
                    font-weight: 400;
                    font-size: 12px;
                    line-height: 17px;
                    color: #51a8ff;
                    cursor: pointer;
                    padding-right: 5px;
                    display: flex;
                    justify-content: end;
 
                    img {
                        margin-right: 5px;
                    }
 
                    .address {
                        display: inline-block;
                        width: 60px;
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                    }
                }
 
                .eventListItemText {
                    display: flex;
                    justify-content: space-between;
                    font-family: Segoe UI, Segoe UI;
                    font-weight: 400;
                    font-size: 14px;
                    color: #ffffff;
                    line-height: 17px;
 
                    .eventListItemTime {
                        font-family: Segoe UI, Segoe UI;
                        font-weight: 400;
                        font-size: 14px;
                        color: #96a3cc;
                        line-height: 17px;
                    }
                }
            }
        }
    }
}
 
.pagination {
    width: 100%;
    display: flex;
    justify-content: center;
}
</style>