forked from drone/command-center-dashboard

罗广辉
2025-04-21 2800fa4f32f3900509cb4d6eefaf2bfaf54efdd7
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
 <!--  巡检任务情况-详情 -->
<template>
    <el-dialog
        class="inspection-rask-details-dialog ztzf-dialog"
        v-model="isShowDetailsDialog"
        :width="pxToRem(1500)"
        :close-on-click-modal="false"
        :destroy-on-close="true"
    >
        <template #header="{ titleId, titleClass }">
            <div class="my-header">
                <img src="/src/assets/images/home/homeLeft/inspection-union.png" alt="" />
                <span :id="titleId" :class="titleClass">巡检任务详情</span>
            </div>
        </template>
        <!-- 搜索 -->
        <el-form :model="searchForm" inline>
            <div class="search-row">
                <el-form-item>
                    <el-input class="ztzf-input" v-model="searchForm.key_word" placeholder="请输入任务/机巢名称" clearable />
                </el-form-item>
                <el-form-item label="关联算法">
                    <el-select :teleported="false" class="ztzf-select" v-model="searchForm.ai_types" placeholder="请选择">
                        <el-option v-for="item in taskAlgorithm" :key="item.id" :label="item.dictValue" :value="item.dictKey" />
                    </el-select>
                </el-form-item>
                <el-form-item label="任务状态">
                    <el-select :teleported="false" class="ztzf-select" v-model="searchForm.status" placeholder="请选择" clearable>
                        <el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
            </div>
            <div class="search-row">
                <el-form-item label="选择机巢">
                    <el-select :teleported="false" class="ztzf-select" v-model="searchForm.device_sn" placeholder="请选择">
                        <el-option
                            v-for="item in deviceList"
                            :label="item.nickname"
                            :value="item.device_sn"
                            :key="item.device_sn"
                        />
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-date-picker
                        popper-class="custom-date-picker"
                        class="ztzf-date-picker"
                        v-model="dateRange"
                        type="daterange"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        value-format="YYYY-MM-DD"
                        @change="changeselect"
                    />
                </el-form-item>
                <el-form-item>
                    <div class="reset" @click="handleReset">重置</div>
                    <div class="searchs" @click="handleSearch">搜索</div>
                </el-form-item>
            </div>
        </el-form>
        <!-- 表格 -->
        <div class="tabledata ztzf-table">
            <el-table
                :data="taskDetailData"
                :row-class-name="tableRowClassName"
                :row-style="{ height: '45px', fontSize: '14px', 'text-align': 'center' }"
                :header-cell-style="{ 'text-align': 'center', height: '36px', fontSize: '14px' }"
            >
                <el-table-column label="序号" type="index" width="60">
                    <template #default="{ $index }">
                        {{ ($index + 1).toString().padStart(2, '0') }}
                    </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="job_info_num" label="任务编号" />
                <el-table-column prop="name" show-overflow-tooltip label="任务名称" />
                <el-table-column prop="device_names" show-overflow-tooltip label="所属机巢" />
                <el-table-column show-overflow-tooltip prop="ai_type_str" label="关联算法" />
                <el-table-column prop="status" label="任务状态">
                    <template #default="scope">
                        <span
                            :class="
                                scope.row.status === 1
                                    ? 'pending '
                                    : scope.row.status === 2
                                    ? 'distributed'
                                    : scope.row.status === 3
                                    ? 'finish '
                                    : scope.row.status === 5
                                    ? 'fail '
                                    : ' '
                            "
                        >
                            {{
                                scope.row.status === 1
                                    ? '待执行'
                                    : scope.row.status === 2
                                    ? '执行中'
                                    : scope.row.status === 3
                                    ? '已执行'
                                    : scope.row.status === 5
                                    ? '执行失败'
                                    : ''
                            }}
                        </span>
                    </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="industry_type_str" label="任务类型" />
                <el-table-column prop="cycle_time_value" label="任务时间" width="150" />
                <el-table-column prop="event_number" label="关联事件">
                    <template #default="scope">
                        <span>{{ scope.row.event_number ? scope.row.event_number : '/' }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="80">
                    <template #default="scope">
                        <div class="ztzf-view" @click="viewDetail(scope.row)">查看</div>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <!-- 分页 -->
        <div style="display: flex; justify-content: center; margin: 15px 0">
            <el-pagination
                class="ztzf-pagination"
                v-model:current-page="pageParams.current"
                v-model:page-size="pageParams.size"
                :page-sizes="[10, 20, 30, 50]"
                background
                layout=" prev, pager, next, jumper"
                :total="total"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
            />
        </div>
    </el-dialog>
    <!-- 当前任务详情 -->
    <CurrentTaskDetails
        v-if="isShowCurrentTaskDetails"
        v-model:show="isShowCurrentTaskDetails"
        :id="rowData.id"
    />
    <!-- 历史任务详情 -->
    <DeviceJobDetails
        v-if="isShowDeviceJobDetails"
        v-model:show="isShowDeviceJobDetails"
        :wayLineJodInfoId="rowData.id"
    />
</template>
<script setup>
import { pxToRem } from '@/utils/rem'
import { jobList } from '@/api/home/task'
import { getDictionary } from '@/api/system/dict'
import { selectDevicePage } from '@/api/home/machineNest'
import { getMultipleDictionary } from '@/api/system/dictbiz'
import CurrentTaskDetails from '@/components/CurrentTaskDetails/CurrentTaskDetails.vue'
import DeviceJobDetails from '@/components/DeviceJobDetails/DeviceJobDetails.vue'
import { ElMessage } from 'element-plus'
const isShowDetailsDialog = defineModel('show')
const dateRange = ref('')
const searchForm = reactive({
    key_word: '', // 模糊搜索关键词(匹配名称/昵称/设备sn)
    ai_types: [], // 算法类型
    device_sn: '', // 设备编号
    end_date: null, // 结束时间
    start_date: null, // 开始时间
    status: '', // 作业状态
})
const statusOptions = [
    { label: '待执行', value: 1 },
    { label: '执行中', value: 2 },
    { label: '已执行', value: 3 },
 
    { label: '执行失败', value: 5 },
]
// 设备页面参数
const devicePageParams = ref({
    current: 1,
    size: 10,
    total: 0,
    nickname: '',
})
const deviceList = ref([])
// 表格
const taskDetailData = ref([])
// 表格参数
const taskDetailParams = reactive({
    current: 1,
    size: 10,
    searchParams: {},
})
// 分页
const total = ref(0)
// 分页参数
let pageParams = reactive({
    current: 1,
    size: 10,
})
// 日期选择
const changeselect = () => {
    searchForm.start_date = dateRange.value.length ? `${dateRange.value[0]} 00:00:00` : null
    searchForm.end_date = dateRange.value.length ? `${dateRange.value[1]} 00:00:00` : null
}
 
// 重置
const handleReset = () => {
    dateRange.value = null
    Object.keys(searchForm).forEach(key => {
        if (key === 'start_date' || key === 'end_date') {
            searchForm[key] = null
        } else if (key === 'ai_types') {
            searchForm[key] = []
        } else {
            searchForm[key] = ''
        }
    })
 
    handleSearch()
}
// 查询
const handleSearch = () => {
    taskDetailParams.current = 1
    taskDetailParams.size = 10
    taskDetailParams.searchParams = searchForm
    getJobList()
}
// 分页大小改变
const handleSizeChange = val => {
    taskDetailParams.size = val
    getJobList()
}
// 页码改变
const handleCurrentChange = val => {
    taskDetailParams.current = val
    getJobList()
}
// 获取任务列表
const getJobList = () => {
    jobList(taskDetailParams).then(res => {
        if (res.data.code !== 0) return
        taskDetailData.value = res.data.data.records
        total.value = res.data.data.total
        
    })
}
// 机巢列表数据
const getDeviceList = async () => {
    const res = await selectDevicePage({ current: 1, size: 99999, type: 1 })
    deviceList.value = res.data?.data?.records || []
}
// 关联算法
 
let taskBusiness = ref([])
let taskAlgorithm = ref([])
// 请求字典字段
const requestDictionary = () => {
    getMultipleDictionary('SF,HYLB').then(res => {
        if (res.code !== 0) {
            // 处理数据
            taskAlgorithm.value = res.data.data['SF']
            taskBusiness.value = res.data.data['HYLB']
        }
    })
}
const algorithmChange = val => {
    searchForm.ai_types = val
}
const tableRowClassName = ({ row, rowIndex }) => {
    if (rowIndex % 2 === 1) {
        return 'warning-row'
    } else {
        return 'success-row'
    }
}
// 查看
const isShowCurrentTaskDetails = ref(false)
const isShowDeviceJobDetails = ref(false)
let rowData = ref({});
const viewDetail = row => {
    if (!row.device_sns.length) return ElMessage.warning('没有device_sns');
    if (row.device_sns.length !== 1) return ElMessage.success('即将跳转到集群调度');
    rowData.value = row? row : {};
    if (row.status === 2 || row.status === 1){
        isShowCurrentTaskDetails.value = true;
    } else{
        isShowDeviceJobDetails.value = true
    }
}
onMounted(() => {
    requestDictionary()
    getJobList()
    getDeviceList()
})
</script>
<style lang="scss">
/* 修改日期单元格背景色 */
.custom-date-picker .el-picker-panel__body {
    background: #012350 !important;
    color: #fff !important;
}
 
</style>
<style scoped lang="scss">
.search-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 37px;
    .el-form-item {
        flex: 1;
    }
}
:deep(.el-form) {
    .el-form-item {
        margin-bottom: 0;
        .el-form-item__label {
            color: #fff;
        }
    }
}
 
:deep() {
    .el-form-item__label {
        font-family: Segoe UI, Segoe UI;
        font-weight: 400;
        font-size: 16px;
        color: #ffffff;
    }
}
 
.el-table__body {
    border-collapse: collapse;
}
 
.my-header {
    display: inline-block;
    vertical-align: middle;
    margin-left: 12px;
}
.reset {
    width: 137px;
    height: 32px;
    cursor: pointer;
    background: url('/src/assets/images/home/homeLeft/‌inspection-reset.png') no-repeat center;
    background-size: 100% 100%;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    text-align: center;
}
.searchs {
    margin-left: 23px;
    cursor: pointer;
    width: 137px;
    height: 32px;
    background: url('/src/assets/images/home/homeLeft/in‌spection-select.png') no-repeat center;
    background-size: 100% 100%;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    text-align: center;
}
.tabledata {
    padding: 0 16px;
    overflow: hidden;
    // height: 640px;
    overflow-y: scroll !important;
}
 
// 任务状态颜色
// 待执行
.pending {
    color: #ffe17e;
}
// 执行中
.distributed {
    color: #ffa768;
}
// 已执行
.finish {
    color: #8effac;
}
 
// 执行失败
.fail {
    color: #ff8e8e;
}
</style>