| | |
| | | @closed="visible = false" |
| | | destroy-on-close |
| | | width="60%" |
| | | :close-on-click-modal="false" |
| | | > |
| | | <div class="gd-dialog-form"> |
| | | <!-- 关联工单选择 --> |
| | | <div class="work-order-section"> |
| | | <div class="form-item-row"> |
| | | <span class="label required">选择工单:</span> |
| | | <el-select |
| | | class="gd-select" |
| | | style="width: 150px" |
| | | popper-class="gd-select-popper" |
| | | v-model="selectedWorkOrderId" |
| | | placeholder="请选择" |
| | | clearable |
| | | filterable |
| | | :disabled="dialogMode !== 'add'" |
| | | @change="handleWorkOrderChange" |
| | | > |
| | | <el-option v-for="item in workOrderList" :key="item.id" :label="item.workOrderName" :value="item.id" /> |
| | | </el-select> |
| | | </div> |
| | | <div class="detail-title" :style="{ marginBottom: 0, marginRight: pxToRem(10) }">选择工单</div> |
| | | <el-select |
| | | class="gd-select" |
| | | style="width: 150px" |
| | | popper-class="gd-select-popper" |
| | | v-model="selectedWorkOrderId" |
| | | placeholder="请选择" |
| | | clearable |
| | | filterable |
| | | :disabled="dialogMode !== 'add'" |
| | | @change="handleWorkOrderChange" |
| | | > |
| | | <el-option v-for="item in workOrderList" :key="item.id" :label="item.workOrderName" :value="item.id" /> |
| | | </el-select> |
| | | </div> |
| | | |
| | | <!-- 工单信息展示 --> |
| | |
| | | </div> |
| | | |
| | | <!-- 子任务表格表单 --> |
| | | <div class="task-table-section"> |
| | | <div class="section-title">添加子任务:</div> |
| | | <div class="task-table-section" v-if="selectedWorkOrderId"> |
| | | <div class="detail-title" :style="{ marginTop: pxToRem(10) }">添加子任务</div> |
| | | <div class="task-table-container"> |
| | | <el-table :data="taskList"> |
| | | <el-table-column width="50" label=""> |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="patrolTaskType" label="巡查任务类型" min-width="140"> |
| | | <template v-slot="{ row }"> |
| | | <template v-slot="{ row, $index }"> |
| | | <el-select |
| | | class="gd-select" |
| | | popper-class="gd-select-popper" |
| | | v-model="row.patrolTaskType" |
| | | placeholder="请选择" |
| | | :disabled="dialogReadonly" |
| | | @change="handlePatrolTaskTypeChange($index, $event)" |
| | | > |
| | | <el-option |
| | | v-for="item in dictObj.patrolTaskType" |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="recommendFlyerName" label="推荐飞手" min-width="120"> |
| | | <template v-slot="{ row }"> |
| | | <template v-slot="{ row, $index }"> |
| | | <el-select |
| | | class="gd-select" |
| | | popper-class="gd-select-popper" |
| | | v-model="row.recommendFlyerName" |
| | | placeholder="请选择" |
| | | filterable |
| | | :disabled="dialogReadonly" |
| | | :disabled="dialogReadonly || !taskList[$index].patrolTaskType" |
| | | > |
| | | <el-option v-for="item in flyerList" :key="item.id" :label="item.flyerName" :value="item.flyerName" /> |
| | | <el-option |
| | | v-for="item in flyerListMap[$index] || []" |
| | | :key="item.id" |
| | | :label="item.flyerName" |
| | | :value="item.flyerName" |
| | | /> |
| | | </el-select> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | import { gdPatrolTaskSaveApi, gdFlyerPageApi, gdPatrolTaskAuditApi } from './inspectionRequestApi' |
| | | import { gdWorkOrderPageApi } from '../orderManage/orderManageApi' |
| | | import { gdManageDeviceListApi } from '../orderManage/gdManageDeviceApi' |
| | | import { pxToRem } from '@/utils/rem' |
| | | |
| | | // 初始化任务行 |
| | | const initTaskRow = () => ({ |
| | |
| | | deviceId: null, |
| | | taskDesc: '', |
| | | }) |
| | | |
| | | // todo 时间线 |
| | | const dictObj = inject('dictObj') |
| | | |
| | | const emit = defineEmits(['success']) |
| | |
| | | const selectedWorkOrder = ref(null) // 选中的工单信息 |
| | | |
| | | // 下拉选项 |
| | | const flyerList = ref([]) // 飞手列表 |
| | | const flyerListMap = ref({}) // 飞手列表,按行索引存储 |
| | | const deviceList = ref([]) // 设备列表 |
| | | const routeOptions = ref([ |
| | | { name: '航线1', id: '1' }, |
| | |
| | | function removeTaskRow(index) { |
| | | if (taskList.value.length > 1) { |
| | | taskList.value.splice(index, 1) |
| | | // 重新整理 flyerListMap 的索引 |
| | | const newFlyerListMap = {} |
| | | Object.keys(flyerListMap.value).forEach(key => { |
| | | const keyIndex = parseInt(key) |
| | | if (keyIndex < index) { |
| | | newFlyerListMap[keyIndex] = flyerListMap.value[keyIndex] |
| | | } else if (keyIndex > index) { |
| | | newFlyerListMap[keyIndex - 1] = flyerListMap.value[keyIndex] |
| | | } |
| | | }) |
| | | flyerListMap.value = newFlyerListMap |
| | | } |
| | | } |
| | | |
| | | // 获取工单列表 |
| | | async function getWorkOrderList() { |
| | | const res = await gdWorkOrderPageApi({ size: 999 }) |
| | | const res = await gdWorkOrderPageApi({ size: 999, workOrderStatus: '20' }) |
| | | workOrderList.value = res?.data?.data?.records ?? [] |
| | | } |
| | | |
| | | // 处理巡查任务类型变化 |
| | | async function handlePatrolTaskTypeChange(index, skilledTaskType) { |
| | | // 清空该行已选择的飞手 |
| | | taskList.value[index].recommendFlyerName = '' |
| | | // 获取对应的飞手列表 |
| | | await getFlyerList(index, skilledTaskType) |
| | | } |
| | | |
| | | // 获取飞手列表 |
| | | async function getFlyerList() { |
| | | const res = await gdFlyerPageApi({ size: 999 }) |
| | | flyerList.value = res?.data?.data?.records ?? [] |
| | | async function getFlyerList(index, skilledTaskType) { |
| | | const res = await gdFlyerPageApi({ |
| | | size: 999, |
| | | skilledTaskType, |
| | | }) |
| | | flyerListMap.value[index] = res?.data?.data?.records ?? [] |
| | | } |
| | | |
| | | // 获取设备列表 |
| | | async function getDeviceList() { |
| | | const res = await gdManageDeviceListApi() |
| | | const res = await gdManageDeviceListApi({ |
| | | deviceIds: selectedWorkOrder.value.recommendDeviceIds, |
| | | }) |
| | | deviceList.value = res?.data?.data ?? [] |
| | | } |
| | | |
| | | watch( |
| | | () => selectedWorkOrderId.value, |
| | | () => { |
| | | getDeviceList() |
| | | } |
| | | ) |
| | | |
| | | // 提交新增 |
| | | async function handleSubmit() { |
| | |
| | | })) |
| | | await gdPatrolTaskSaveApi(dataList) |
| | | dialogMode.value === 'add' ? ElMessage.success('新增成功') : ElMessage.success('修改成功') |
| | | dialogMode.value === 'edit' && await gdPatrolTaskAuditApi({ auditStatus: 7, id: preID }) |
| | | dialogMode.value === 'edit' && (await gdPatrolTaskAuditApi({ auditStatus: 7, id: preID })) |
| | | visible.value = false |
| | | emit('success') |
| | | } finally { |
| | |
| | | |
| | | // 打开弹框 |
| | | async function open({ mode = 'add', row } = {}) { |
| | | console.log(row,'rowrow') |
| | | console.log(row, 'rowrow') |
| | | dialogMode.value = mode |
| | | if (mode === 'add') { |
| | | selectedWorkOrderId.value = null |
| | | selectedWorkOrder.value = null |
| | | taskList.value = [initTaskRow()] |
| | | flyerListMap.value = {} |
| | | } else { |
| | | // 编辑/查看模式 - 加载已有数据 |
| | | selectedWorkOrderId.value = row?.workOrderId |
| | | handleWorkOrderChange(row?.workOrderId) |
| | | taskList.value = [{ ...row }] |
| | | flyerListMap.value = {} |
| | | // 如果有巡查类型,加载对应的飞手列表 |
| | | if (row?.patrolTaskType) { |
| | | getFlyerList(0, row.patrolTaskType) |
| | | } |
| | | } |
| | | } |
| | | |
| | | onMounted(() => { |
| | | getWorkOrderList() |
| | | getFlyerList() |
| | | getDeviceList() |
| | | }) |
| | | |
| | | defineExpose({ open }) |
| | | </script> |
| | | |
| | | <style scoped lang="scss"></style> |
| | | <style scoped lang="scss"> |
| | | .detail-row-view { |
| | | margin-top: 10px; |
| | | } |
| | | .work-order-section { |
| | | display: flex; |
| | | align-items: center; |
| | | } |
| | | </style> |