forked from drone/command-center-dashboard

罗广辉
2025-04-19 f6fd494699bcfee4457b415fcbbc02b753a3ff28
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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<!-- 巡检任务列表 -->
<template>
    <CommonTitle title="巡检任务列表" />
    <div :style="{ marginLeft: pxToRem(14) }">
        <div class="inspection-rask-list">
            <div class="tab-search">
                <div class="tab-btn">
                    <div :class="tabIndex === 1 ? 'active' : ''" @click="tabClick(1)">当前任务</div>
                    <div :class="tabIndex === 2 ? 'active' : ''" @click="tabClick(2)">历史任务</div>
                </div>
                <div class="search-box">
                    <el-input v-model="searchText" placeholder="请输入搜索内容" class="input-with-select">
                        <template #append>
                            <el-button :icon="Search" @click="searchNickName" />
                        </template>
                    </el-input>
                </div>
            </div>
            <div
                class="table-list"
                v-if="tableList.length > 0"
                infinite-scroll-distance="6"
                v-infinite-scroll="loadMore"
                :infinite-scroll-disabled="busy"
                infinite-scroll-immediate="true"
            >
                >
                <div class="item" v-for="(item, index) in tableList">
                    <div class="left" @click="taskClick(item)">
                        <div class="left-t">
                            <span>{{ index + 1 }}.</span>
                            {{ item.name }}
                            <span class="status" :class="item.status === 2 ? 'active' : ''">
                                {{ getStatusText(item.status) }}
                            </span>
                        </div>
                        <div class="left-b">
                            <img src="../../../assets/images/signMachineNest/machineRight/date.png" alt="" />
                            {{ item.begin_time }}
                            <img src="../../../assets/images/signMachineNest/machineRight/name.png" alt="" />
                            {{ item.creator_name || '' }}
                        </div>
                    </div>
                    <div class="right" v-if="tabIndex === 1" @click="reExecute(item.dock_sn)">
                        <span>立即返航</span>
                        <img src="../../../assets/images/signMachineNest/machineRight/return-fly.png" alt="" />
                    </div>
                    <div class="right" v-else @click="returnImmediately(item.job_id)">
                        <span>再次执行</span>
                        <img src="../../../assets/images/signMachineNest/machineRight/return-fly.png" alt="" />
                    </div>
                </div>
            </div>
            <el-empty class="custom-empty" v-else>
                <template #description>
                    <span class="custom-text">暂无数据</span>
                </template>
            </el-empty>
        </div>
    </div>
    <!-- 当前任务详情 -->
    <CurrentTaskDetails v-if="isShowCurrentTaskDetails" v-model:show="isShowCurrentTaskDetails" :id="currentInfoId" />
    <!-- 历史任务详情 -->
    <DeviceJobDetails
        v-if="isShowDeviceJobDetails"
        v-model:show="isShowDeviceJobDetails"
        :wayLineJodInfoId="wayLineJodInfoId"
    />
</template>
 
<script setup>
import { Search } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import CommonTitle from '@/components/CommonTitle.vue'
import CurrentTaskDetails from '@/components/CurrentTaskDetails/CurrentTaskDetails.vue'
import DeviceJobDetails from '@/components/DeviceJobDetails/DeviceJobDetails.vue'
import { getBeforeJob, getTodayJob, flyByJobId, returnHome } from '@/api/home'
import { useStore } from 'vuex'
import { useTaskWayline } from '@/hooks/useTaskWayline/useTaskWayline'
import { useTaskDetails } from '@/hooks/useTaskDetails/useTaskDetails'
import { useTaskViewInfo } from '@/hooks/useTaskViewInfo/useTaskViewInfo'
import { useDroneWS } from '@/hooks/useDroneWS'
let viewer = null
 
let { taskDetails, workspace_id, getTaskDetails } = useTaskDetails()
let { wsInfo, removeWS } = useDroneWS(workspace_id) //ws信息,是一个ref对象
 
const store = useStore()
// 设备任务详情
let currentInfoId = ref('')
let isShowCurrentTaskDetails = ref(false)
let wayLineJodInfoId = ref('')
let isShowDeviceJobDetails = ref(false)
 
// 单个机巢信息
const singleUavHome = computed(() => store.state.home.singleUavHome)
 
const isMore = ref(true)
// 控制加载状态
const busy = ref(false)
 
let searchText = ref('')
const tableList = ref([])
 
// 分页
const pageParams = ref({
    current: 1,
    size: 5,
    total: 0,
})
 
// 当前任务和历史任务切换
let tabIndex = ref(1)
const tabClick = value => {
    tabIndex.value = value
    clearData()
}
 
// 状态文字判断
const getStatusText = status => {
    switch (status) {
        case 1:
            return '待执行'
        case 2:
            return '执行中'
        case 3:
            return '完成'
        case 4:
            return '取消'
        case 5:
            return '失败'
        default:
            return '未知'
    }
}
 
// 获取历史巡检任务列表
const getJobList = async () => {
    const params = {
        area_code: '',
        device_sn: singleUavHome.value.device_sn,
        job_name: searchText.value,
        current: pageParams.value.current,
        size: pageParams.value.size,
    }
    let result = null
    if (tabIndex.value === 1) {
        result = await getTodayJob(params)
    } else {
        result = await getBeforeJob(params)
    }
    if (result.data.code !== 0) return
    if (result.data.data.records.length === 0) return (isMore.value = false)
    pageParams.value.current += 1
    tableList.value = [...tableList.value, ...result.data.data.records]
 
    busy.value = false
}
 
// 清除数据
const clearData = () => {
    tableList.value = []
    pageParams.value.current = 1
    isMore.value = true
    getJobList()
}
 
// 加载更多数据
const loadMore = async () => {
    busy.value = true
    if (!isMore.value) return
    getJobList()
}
 
// 搜索数据
const searchNickName = () => {
    clearData()
}
 
// 立即返航
const returnImmediately = id => {
    flyByJobId(id).then(result => {
        if (result.data.code === 0) {
            ElMessage.success('执行成功')
        } else {
            ElMessage.error(result.data.message)
        }
    })
}
// 重新执行
const reExecute = dock_sn => {
    returnHome(dock_sn).then(result => {
        if (result.data.code === 0) {
            ElMessage.success('返航成功')
        } else {
            ElMessage.error(result.data.message)
        }
    })
}
 
// 点击当前任务显示当前任务详情
const taskClick = item => {
    if (tabIndex.value === 1) {
        // 展示当前任务详情
        currentInfoId.value = item.wayline_job_info_id
        isShowCurrentTaskDetails.value = true
    } else {
        // 展示历史任务详情
        wayLineJodInfoId.value = item.wayline_job_info_id
        isShowDeviceJobDetails.value = true
    }
}
 
onMounted(async () => {
    viewer = window.$viewer
 
    await getJobList()
 
    // tableList.value = [
    //     {
    //         id: 11563,
    //         status: 5,
    //         begin_time: '2025/04/19 05:46:25',
    //         end_time: '2025/04/19 05:46:25',
    //         create_time: '2025-04-19T05:46:36.032+00:00',
    //         name: '智引即飞202504191252',
    //         event_number: 0,
    //         dock_sn: '7CTDLCR00BQBM2',
    //         wayline_job_info_id: 340,
    //         job_id: '484a7846-60e0-4ec3-b9fb-272a055c6938',
    //     },
    //     {
    //         id: 11559,
    //         status: 5,
    //         begin_time: '2025/04/19 05:39:42',
    //         end_time: '2025/04/19 05:39:42',
    //         create_time: '2025-04-19T05:39:52.022+00:00',
    //         name: '智引即飞202504191252',
    //         event_number: 0,
    //         dock_sn: '7CTDLCR00BQBM2',
    //         wayline_job_info_id: 340,
    //         job_id: 'b8c58bfb-4352-47c5-ba33-242eec8df188',
    //     },
    //     {
    //         id: 11558,
    //         status: 3,
    //         begin_time: '2025/04/19 05:39:17',
    //         end_time: '2025/04/19 05:39:17',
    //         create_time: '2025-04-19T05:39:27.407+00:00',
    //         name: '智引即飞202504191252',
    //         event_number: 0,
    //         dock_sn: '7CTDLCR00BQBM2',
    //         wayline_job_info_id: 340,
    //         job_id: '839773ce-bd46-4947-a2ef-d859eaea82f6',
    //     },
    //     {
    //         id: 11557,
    //         status: 5,
    //         begin_time: '2025/04/19 04:52:04',
    //         end_time: '2025/04/19 04:52:04',
    //         create_time: '2025-04-19T04:52:14.503+00:00',
    //         name: '智引即飞202504191252',
    //         event_number: 0,
    //         dock_sn: '7CTDLCR00BQBM2',
    //         wayline_job_info_id: 340,
    //         job_id: '58366fd4-8361-456f-8ad9-3b881f933620',
    //     },
    //     {
    //         id: 11556,
    //         status: 5,
    //         begin_time: '2025/04/19 03:45:06',
    //         end_time: '2025/04/19 03:45:06',
    //         create_time: '2025-04-19T03:45:16.522+00:00',
    //         name: '智引即飞202504191145',
    //         event_number: 0,
    //         dock_sn: '7CTDLCR00BQBM2',
    //         wayline_job_info_id: 338,
    //         job_id: '39c60fb8-e5c4-4474-912a-c3af3f1b9054',
    //     },
    //     {
    //         id: 11555,
    //         status: 5,
    //         begin_time: '2025/04/19 03:27:55',
    //         end_time: '2025/04/19 03:27:55',
    //         create_time: '2025-04-19T03:28:05.196+00:00',
    //         name: '智引即飞202504191127',
    //         event_number: 0,
    //         dock_sn: '7CTDLCR00BQBM2',
    //         wayline_job_info_id: 336,
    //         job_id: '78c42532-45e4-4a01-b698-69bca19286ff',
    //     },
    //     {
    //         id: 11554,
    //         status: 5,
    //         begin_time: '2025/04/19 02:58:53',
    //         end_time: '2025/04/19 02:58:53',
    //         create_time: '2025-04-19T02:59:03.602+00:00',
    //         name: '智引即飞202504191058',
    //         event_number: 0,
    //         dock_sn: '7CTDLCR00BQBM2',
    //         wayline_job_info_id: 335,
    //         job_id: 'd3b25edc-ec23-4ad6-800a-0f659a72bff3',
    //     },
    //     {
    //         id: 11553,
    //         status: 5,
    //         begin_time: '2025/04/19 02:52:21',
    //         end_time: '2025/04/19 02:52:21',
    //         create_time: '2025-04-19T02:52:31.415+00:00',
    //         name: '智引即飞202504191052',
    //         event_number: 0,
    //         dock_sn: '7CTDLCR00BQBM2',
    //         wayline_job_info_id: 334,
    //         job_id: 'e27090f1-e740-4ae4-8d4d-301354eb0bbc',
    //     },
    //     {
    //         id: 11548,
    //         status: 5,
    //         begin_time: '2025/04/19 02:23:06',
    //         end_time: '2025/04/19 02:23:06',
    //         create_time: '2025-04-19T02:23:16.151+00:00',
    //         name: '智引即飞202504191023',
    //         event_number: 0,
    //         dock_sn: '7CTDLCR00BQBM2',
    //         wayline_job_info_id: 332,
    //         job_id: '9e1f7283-fe34-4cfd-b468-cd2b34a96d34',
    //     },
    //     {
    //         id: 11547,
    //         status: 3,
    //         begin_time: '2025/04/19 02:18:24',
    //         end_time: '2025/04/19 02:18:24',
    //         create_time: '2025-04-19T02:18:34.590+00:00',
    //         name: '智引即飞202504191018',
    //         event_number: 0,
    //         dock_sn: '7CTDLCR00BQBM2',
    //         wayline_job_info_id: 331,
    //         job_id: '7aa5222c-2f8b-401e-b6ba-d6a550398829',
    //     },
    // ]
 
    if (tableList.value.length > 0) {
        await getTaskDetails(tableList.value[0].wayline_job_info_id)
    }
})
 
const { removeEntitys } = useTaskWayline(viewer || window.$viewer, taskDetails)
 
useTaskViewInfo(viewer || window.$viewer, wsInfo, removeEntitys)
</script>
 
<style lang="scss" scoped>
.inspection-rask-list {
    width: 390px;
    height: 325px;
    background: linear-gradient(270deg, #1f3e7a 0%, rgba(31, 62, 122, 0.35) 79%, rgba(31, 62, 122, 0) 100%);
    opacity: 0.85;
    margin: 2px 0 13 0;
    padding: 11px 27px 0;
    .tab-search {
        width: 358px;
        height: 76px;
        margin-bottom: 12px;
        .tab-btn {
            display: flex;
            justify-content: center;
            margin-bottom: 16px;
            div {
                width: 104px;
                height: 32px;
                background: #0e2042;
                border: 1px solid #8ea3d1;
                font-family: Source Han Sans CN, Source Han Sans CN;
                font-weight: 400;
                font-size: 16px;
                color: #8ea3d1;
                line-height: 32px;
                text-align: center;
                cursor: pointer;
            }
            .active {
                width: 104px;
                height: 32px;
                background: linear-gradient(180deg, rgba(0, 82, 248, 0.58) 0%, rgba(103, 209, 251, 0.8) 100%);
                color: #fff;
                border: 1px solid rgba(103, 209, 251, 0.8);
            }
        }
        .search-box {
            :deep(.el-input__wrapper) {
                background-color: rgba(0, 112, 255, 0.1);
                background: rgba(0, 15, 34, 0.5);
                box-shadow: 0 0 0 1px #0070ff inset;
            }
 
            :deep(.el-input-group__append) {
                background: rgba(0, 112, 255, 0.38);
                .el-button {
                    background-color: transparent;
                    border: 1px solid #0070ff;
                    border-left: none;
                    color: #fff;
                }
            }
        }
    }
    .table-list {
        width: 358px;
        height: 202px;
        overflow: auto;
        &::-webkit-scrollbar {
            width: 0;
            display: none;
        }
        -ms-overflow-style: none; /* IE and Edge */
        scrollbar-width: none; /* Firefox */
        .item {
            width: 100%;
            height: 72px;
            padding: 12px 16px;
            margin-bottom: 8px;
            font-family: Source Han Sans CN, Source Han Sans CN;
            font-weight: 500;
            font-size: 14px;
            color: #fff;
            display: flex;
            justify-content: space-between;
            background: linear-gradient(
                90deg,
                rgba(71, 157, 255, 0) 0%,
                rgba(71, 157, 255, 0.12) 50%,
                rgba(71, 157, 255, 0) 100%
            );
            .left {
                cursor: pointer;
                .left-t {
                    height: 24px;
                    font-size: 16px;
                    margin-bottom: 4px;
                    .status {
                        text-align: center;
                        font-size: 12px;
                        display: inline-block;
                        width: 48px;
                        height: 20px;
                        background: rgba(76, 166, 255, 0.08);
                        border-radius: 4px 4px 4px 4px;
                        border: 1px solid #4ca6ff;
                        color: #4ca6ff;
                        margin-left: 10px;
                    }
                    .active {
                        border: 1px solid #04f0d1;
                        color: #04f0d1;
                    }
                }
                .left-b {
                    height: 21px;
                    line-height: 21px;
                    img {
                        width: 16px;
                        height: 16px;
                        margin-right: 2px;
                        &:last-child {
                            margin-left: 42px;
                        }
                    }
                }
            }
            .right {
                cursor: pointer;
                position: relative;
                span {
                    position: absolute;
                    display: inline-block;
                    top: 12px;
                    left: 12px;
                    width: 26px;
                    line-height: 12px;
                    font-size: 12px;
                    font-family: YouSheBiaoTiHei, YouSheBiaoTiHei, serif;
                    color: rgb(4, 18, 44);
                }
                img {
                    width: 46px;
                    height: 46px;
                }
            }
        }
    }
    .custom-empty {
        color: #fff;
        margin: 16px 0;
        padding: 0;
        :deep(.el-empty__image) {
            width: 100px;
            height: 100px;
        }
    }
}
</style>