吉安感知网项目-前端
罗广辉
2026-01-26 beb95fb5fc166804056abafd70fc01ac27de7621
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
<template>
    <van-floating-panel v-model:height="panelHeight" :anchors="anchors">
        <template #header>
            <div class="custom-header">
                <div class="bar"></div>
            </div>
        </template>
        <div class="workDetailContainer">
            <div class="detailTop">
                <div class="image-container">
                    <van-swipe class="detailSwipe" :autoplay="3000" indicator-color="#4C85FF">
                        <van-swipe-item v-for="(img, index) in getImageList" :key="index">
                            <van-image
                                class="detailImage"
                                :src="img"
                                fit="cover"
                                width="100%"
                                height="200px"
                                @click="openPreview(index)"
                                preview-visible="false"
                            />
                        </van-swipe-item>
                    </van-swipe>
 
                    <van-image-preview v-model:show="previewShow" :images="getImageList" :initial-index="previewIndex" />
                    <!-- <van-image class="detailImage" :src="currentDetail.photo_url" fit="cover" width="100%" height="200px" /> -->
                    <div class="detailTitle">
                        <div class="titleText">
                            <div class="itemStatus">
                                <span v-if="currentDetail.status === 0" style="background-color: #ff7411"></span>
                                <span v-else-if="currentDetail.status === 2" style="background-color: #ff472f"></span>
                                <span v-else-if="currentDetail.status === 3" style="background-color: #ffc300"></span>
                                <span v-else-if="currentDetail.status === 4" style="background-color: #06d957"></span>
                                <div>{{ currentDetail.event_name }}</div>
                            </div>
                            <div class="timeNavigation">
                                <p>{{ formatDate(currentDetail.create_time) }}</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 步骤条 -->
            <div class="stepContainer">
                <van-steps direction="vertical" :active="currentStep">
                    <van-step v-for="(step, index) in displayedSteps" :key="step.status">
                        <div class="horizontal-step">
                            <span class="step-title" :class="getStatusClass(index)">{{ step.title }}</span>
 
                            <div class="step-desc" v-if="stepResponse[index]">
                                <span>{{ stepResponse[index].name || '' }}</span>
                                <span>{{ stepResponse[index].create_time || '' }}</span>
                            </div>
                        </div>
                    </van-step>
                </van-steps>
            </div>
            <!-- 工单内容 -->
            <div class="workOrderContent">
                <div class="workOrderTitle">工单内容</div>
                <div class="workOrderContainer">
                    <div class="orderRow">
                        <div class="rowTitle">工单名称</div>
 
                        <div>{{ currentDetail.event_name }}</div>
                    </div>
                    <div class="orderRow">
                        <div class="rowTitle">工单编号</div>
                        <div>{{ currentDetail.event_num }}</div>
                    </div>
                    <div class="orderRow">
                        <div class="rowTitle">工单类型</div>
                        <div>{{ workOrderTypeName }}</div>
                    </div>
                    <div class="orderRow" v-if="currentDetail.work_type == '0'">
                        <div class="rowTitle">关联任务</div>
                        <div>{{ currentDetail.job_name }}</div>
                    </div>
                    <div class="orderRow">
                        <div class="rowTitle">工单创建人</div>
                        <div>{{ currentDetail.event_num?.slice(0, 2) === 'AI' ? 'AI 小飞' : currentDetail.create_user }}</div>
                    </div>
                    <div class="orderRow" v-if="currentDetail.address">
                        <div class="rowTitle">事件地址</div>
                        <div class="rowAddress">{{ currentDetail.address }}</div>
                    </div>
 
                    <div class="orderRow">
                        <div class="guanlian">
                            <div class="rowTitle">关联算法</div>
                        </div>
                        <div>{{ currentDetail.ai_types }}</div>
                    </div>
                    <div class="orderRow">
                        <div class="rowTitle">发起部门</div>
                        <div>{{ currentDetail.dept_name }}</div>
                    </div>
                    <div class="orderRow">
                        <div class="rowTitle">发起任务时间</div>
                        <div>{{ currentDetail.create_time }}</div>
                    </div>
                    <div class="orderRow">
                        <div class="rowTitle">所属机巢</div>
                        <div>{{ currentDetail.device_names }}</div>
                    </div>
                    <div class="orderRow">
                        <div class="rowTitle">工单内容</div>
                        <div>{{ currentDetail.content }}</div>
                    </div>
 
                    <div class="orderRow" v-if="isEditableProcess">
                        <div class="rowTitle">事件处理详情</div>
 
                        <div>{{ currentDetail.processingDetail }}</div>
                    </div>
                </div>
            </div>
        </div>
    </van-floating-panel>
</template>
 
<script setup>
import { useRoute } from 'vue-router'
import { getStepInfo, getList, flowEvent, getTicketInfo } from '/src/api/work/index.js'
import { getShowImg, getSmallImg } from '@/utils/util'
 
import dayjs from 'dayjs'
import { showImagePreview } from 'vant'
const anchors = [65, Math.round(0.9 * window.innerHeight)]
const panelHeight = ref(anchors[0])
 
const allAlgorithms = ref([])
const algorithms = ref([])
const types = ref([]) //工单类型
 
const stepResponse = ref([])
const currentStep = ref(0)
const route = useRoute()
const currentDetail = ref({})
 
const isEditableProcess = computed(() => currentDetail.value.status === 3)
const props = defineProps({
    mapCurrentDetail: {
        type: Object,
    },
})
 
// 工单内容
const formatDate = dateString => {
    return dayjs(dateString).format('MM/DD HH:mm')
}
const allStepConfigs = ref([
    { title: '待审核', status: '2' },
    { title: '待处理', status: '0' },
    { title: '处理中', status: '3' },
    { title: '已完成', status: '4' },
])
 
const getStatusClass = index => {
    if (index <= currentStep.value) {
        const status = stepResponse.value[index]?.status
        const statusClasses = {
            '2': 'status-pending', // 待审核
            '0': 'status-waiting', // 待处理
            '3': 'status-processing', // 处理中
            '4': 'status-completed', // 已完成
        }
        return statusClasses[String(status)] || ''
    }
 
    return 'status-default'
}
// 关联算法
const getTicketInfoData = async () => {
    const response = await getTicketInfo()
    const { dept_data, event_type, ai_type, info } = response.data.data
    allAlgorithms.value = info
 
    types.value = Object.entries(event_type).map(([key, value]) => ({
        label: value,
        value: key,
    }))
}
 
// 计算要显示的步骤
const displayedSteps = computed(() => {
    return allStepConfigs.value.filter(stepConfig => {
        return stepResponse.value.some(stepData => String(stepData?.status) === stepConfig.status)
    })
})
// 计算工单类型显示名称
const workOrderTypeName = computed(() => {
    const type = types.value.find(item => item.value === currentDetail.value.work_order_type_dict_key)
    return type ? type.label : currentDetail.value.work_order_type_dict_key
})
// 步骤条
const calculateCurrentStep = status => {
    const stepIndex = displayedSteps.value.findIndex(step => step.status === String(status))
    return stepIndex !== -1 ? stepIndex : 0
}
 
const getStepInfoData = async val => {
    const res = await getStepInfo(val)
    stepResponse.value = res.data.data
    currentStep.value = calculateCurrentStep(currentDetail.value.status)
}
// 预览图片
const previewShow = ref(false)
const previewIndex = ref(0)
 
const getImageList = computed(() => {
    const imageArr = []
    const detail = currentDetail.value
 
    if (detail.photo_url) {
        const smallUrl = getSmallImg(detail.photo_url)
        imageArr.push(smallUrl)
    }
 
    if (detail.update_photo_url) {
        const smallUrl = getSmallImg(detail.update_photo_url)
        imageArr.push(smallUrl)
    }
 
    return imageArr
})
 
const openPreview = index => {
    const detail = currentDetail.value
    const showUrl = getShowImg(detail.photo_url || detail.update_photo_url)
    showImagePreview({
        images: [showUrl],
        startPosition: 0,
    })
    previewIndex.value = index
    previewShow.value = true
}
watch(
    () => props.mapCurrentDetail,
    newVal => {
        if (newVal?.event_num) {
            currentDetail.value = newVal
            getStepInfoData(currentDetail.value.event_num)
        }
    },
    { immediate: true, deep: true }
)
onMounted(() => {
    getTicketInfoData()
})
</script>
 
<style lang="scss" scoped>
.van-floating-panel {
    background: transparent;
    ::v-deep(.custom-header) {
        .bar {
            margin: 0 auto;
            width: 42px;
            height: 4px;
            background: rgba(0, 0, 0, 0.5);
            border-radius: 2px;
            margin-bottom: 4px;
        }
    }
    ::v-deep(.van-floating-panel__content) {
        border-radius: 20px 20px 0 0;
    }
}
.workDetailContainer {
    padding: 30px 10px 0 10px;
    .required-mark {
        color: #ff4d4f; // 红色
        margin-left: 4px;
    }
    .detailTop {
        .image-container {
            position: relative;
            width: 100%;
            height: 205px;
 
            .detailImage {
                width: 100%;
                height: 100%;
                display: block;
                object-fit: cover;
            }
 
            .detailTitle {
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                padding: 5px;
                height: 30px;
                background: rgba(7, 7, 7, 0.4);
            }
 
            .titleText {
                display: flex;
                width: 100%;
                justify-content: space-between;
                align-items: center;
                font-family: Source Han Sans CN, Source Han Sans CN;
                font-weight: 400;
                font-size: 13px;
                color: #ffffff;
                .itemStatus {
                    display: flex;
                    align-items: center;
 
                    span {
                        display: inline-block;
                        width: 10px;
                        height: 10px;
                        border-radius: 50%;
                        margin-right: 7px;
                    }
                }
            }
            .timeNavigation {
                display: flex;
                align-items: center;
                img {
                    width: 11px;
                    height: 13px;
                    margin-left: 13px;
                }
            }
        }
    }
 
    .stepContainer {
        display: flex;
 
        border-radius: 5px;
        padding: 0 10px 0 10px;
        background: #fff;
        :deep() {
            .van-step__circle-container {
                font-size: 20px;
            }
            .van-step__circle {
                width: 15px;
                height: 15px;
            }
            .van-step--vertical {
                padding: 20px 20px 20px 0;
            }
            .van-step__circle-container,
            .van-step__line {
                top: 50%;
            }
            .van-step--vertical:not(:last-child):after {
                border-bottom-width: 0;
            }
        }
        .horizontal-step {
            display: flex;
            align-items: center;
            gap: 12px;
 
            .step-title {
                min-width: 60px;
                background: #e8e8e8;
                padding: 5px;
                border-radius: 5px;
                text-align: center;
 
                &.status-pending {
                    background-color: #ffebeb; // 待审核
                    color: #ff1414;
                }
 
                &.status-waiting {
                    background-color: #fff1e6; // 待处理
                    color: #ff7411;
                }
 
                &.status-processing {
                    background-color: #fff6d8; // 处理中
                    color: #ffbb00;
                }
 
                &.status-completed {
                    background-color: #e5fcff; // 已完成
                    color: #0291a1;
                }
 
                &.status-default {
                    background-color: #e8e8e8; // 默认背景色
                    color: #191919;
                }
            }
 
            .step-desc {
                display: flex;
                justify-content: space-between;
                gap: 28px;
                color: #222324;
                font-size: 14px;
            }
            .step-desc span:first-child {
                width: 60px;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
            span:last-child {
                margin-left: auto;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }
        }
    }
 
    :deep(.van-step__circle) {
        width: 8px;
        height: 8px;
    }
 
    .workOrderContent {
        margin-top: 15px;
 
        .workOrderTitle {
            font-family: Source Han Sans CN, Source Han Sans CN;
            font-weight: bold;
            font-size: 16px;
            color: #222324;
            margin-bottom: 16px;
        }
 
        .workOrderContainer {
            .orderRow {
                display: flex;
                justify-content: space-between;
                align-items: center;
                min-height: 48px;
                border-bottom: 1px solid #f5f5f5;
                color: #7b7b7b;
                .guanlian {
                    display: flex;
                }
                .rowTitle {
                    font-family: Source Han Sans CN, Source Han Sans CN;
                    font-weight: 400;
                    font-size: 15px;
                    color: #222324;
                    white-space: nowrap;
 
                    span {
                        font-family: Source Han Sans CN, Source Han Sans CN;
                        font-weight: 400;
                        font-size: 10px;
                        color: #3a3a3a;
                    }
                }
                .rowAddress {
                    font-size: 14px;
                    // color: #1d6fe9;
                    white-space: nowrap; /* 禁止换行 */
                    overflow: hidden;
                    text-overflow: ellipsis;
                    max-width: 75%;
                }
                .selectTrigger {
                    font-family: Source Han Sans CN, Source Han Sans CN;
                    font-weight: 400;
                    font-size: 14px;
                    color: #222324;
                }
            }
 
            .titketName {
                display: flex;
                align-items: center;
            }
        }
    }
 
    .upload-link {
        color: #1989fa;
        cursor: pointer;
        text-decoration: underline;
    }
}
</style>