From 0e9570ca37476da25404053bd85ae6bb50e73549 Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Tue, 30 Dec 2025 14:02:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E8=AE=A1=E5=88=92=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ComSearchForm/index.vue | 35 +- src/views/planMange/dailyPlan/addForm.vue | 5 + src/views/planMange/dailyPlan/config.js | 254 ++++-- src/views/planMange/dailyPlan/edit.vue | 242 ++++- .../planMange/dailyPlan/forms/projectForm.vue | 859 ++++++++++++++++-- .../planMange/dailyPlan/forms/repairForm.vue | 15 +- .../planMange/dailyPlan/forms/runForm.vue | 14 +- src/views/planMange/dailyPlan/index.vue | 61 +- src/views/planMange/plan/config.js | 4 + src/views/planMange/plan/index.vue | 9 + 10 files changed, 1292 insertions(+), 206 deletions(-) diff --git a/src/components/ComSearchForm/index.vue b/src/components/ComSearchForm/index.vue index fb0a89b..2f70e6e 100644 --- a/src/components/ComSearchForm/index.vue +++ b/src/components/ComSearchForm/index.vue @@ -115,6 +115,7 @@ const getComponentProps = (item) => { rangeSeparator: item.rangeSeparator || '-', startPlaceholder: item.startPlaceholder, endPlaceholder: item.endPlaceholder, + style: item.style, } case 'month': return { @@ -133,21 +134,49 @@ const getComponentProps = (item) => { } } +// 处理表单数据,将 paramsList 配置的数组值转换为指定参数名 +const processFormData = (data) => { + const processedData = { ...data } + + props.formColumns.forEach((item) => { + // 检查是否有 paramsList 配置 + if (item.paramsList && Array.isArray(item.paramsList) && item.paramsList.length > 0) { + const value = processedData[item.prop] + + // 如果值是数组且不为空,将其拆分为指定的参数名 + if (Array.isArray(value) && value.length > 0) { + item.paramsList.forEach((paramName, index) => { + if (value[index] !== undefined && value[index] !== null && value[index] !== '') { + processedData[paramName] = value[index] + } + }) + } + + // 删除原来的数组字段,避免出现 month[0] 和 month[1] 的形式 + delete processedData[item.prop] + } + }) + + return processedData +} + // 搜索 const handleSearch = () => { - emit('search', { ...formData }) + const processedData = processFormData(formData) + emit('search', processedData) } // 重置 const handleReset = () => { formRef.value?.resetFields() initFormData() - emit('reset', { ...formData }) + const processedData = processFormData(formData) + emit('reset', processedData) } // 暴露方法供父组件调用 defineExpose({ - getFormData: () => ({ ...formData }), + getFormData: () => processFormData(formData), resetForm: handleReset, formRef, }) diff --git a/src/views/planMange/dailyPlan/addForm.vue b/src/views/planMange/dailyPlan/addForm.vue index 6c7d62d..a660490 100644 --- a/src/views/planMange/dailyPlan/addForm.vue +++ b/src/views/planMange/dailyPlan/addForm.vue @@ -17,6 +17,7 @@ v-model="formData.nowDate" value-format="YYYY-MM-DD" placeholder="请选择计划日期" + @change="onHandleDateChange" /> @@ -122,6 +123,10 @@ const onSelectionChange = (rows) => { selectedRows.value = rows } +const onHandleDateChange = (value) => { + fetchData() +} + // 暴露方法给父组件:获取选中任务、触发查询、校验 defineExpose({ getSelectedTasks: () => selectedRows.value, diff --git a/src/views/planMange/dailyPlan/config.js b/src/views/planMange/dailyPlan/config.js index 2ee202a..234d868 100644 --- a/src/views/planMange/dailyPlan/config.js +++ b/src/views/planMange/dailyPlan/config.js @@ -1,33 +1,16 @@ import { reactive } from 'vue' -// 静态选项(可后续替换为接口下拉) -const stationOptions = [ - { label: '昆明运检站', value: 1 }, - { label: '大理运检站', value: 2 }, -] - -const majorOptions = [ - { label: '输电专业', value: 1 }, - { label: '变电专业', value: 2 }, -] - -const businessTypeOptions = [ - { label: '日常巡视', value: 1 }, - { label: '缺陷处理', value: 2 }, -] - -const riskLevelOptions = [ - { label: '低风险', value: 1 }, - { label: '中风险', value: 2 }, - { label: '高风险', value: 3 }, -] - // 月计划列表搜索表单配置 export const buildFormColumns = () => [ { - type: 'month', + type: 'date', + dateType: 'daterange', + paramsList: ['startDate', 'endDate'], prop: 'month', - placeholder: '请选择月份', + style: { + width: '240px', + }, + placeholder: '请选择日期', }, { @@ -37,37 +20,42 @@ export const buildFormColumns = () => [ }, { type: 'input', - prop: 'keyword', + prop: 'projectName', placeholder: '请输入项目名称', }, { type: 'input', - prop: 'keyword', + prop: 'workContent', placeholder: '请输入工作任务', }, { type: 'select', - prop: 'riskLevel', + prop: 'planCompletionStatus', placeholder: '请选择计划状态', - options: riskLevelOptions, + options: [ + { label: '未开始', value: '未开始' }, + { label: '进行中', value: '进行中' }, + { label: '完成', value: '完成' }, + ], }, ] // 月计划列表表格列 export const tableColumns = [ { prop: 'dayPlan', label: '日期', fixed: true, width: '140' }, - { prop: 'inspectionStationName', label: '运检站', fixed: true }, - { prop: 'planMajorName', label: '专业', fixed: true }, - { prop: 'projectName', label: '项目名称', fixed: true }, - { prop: 'workContent', label: '工作任务' }, - { prop: 'riskLevel', label: '风险等级' }, - { prop: 'plannedWorkload', label: '计划工作量(基)' }, + { prop: 'inspectionStationName', label: '运检站', fixed: true, width: '140' }, + { prop: 'planMajorName', label: '专业', fixed: true, width: '80' }, + { prop: 'projectName', label: '项目名称', fixed: true, width: '140' }, + { prop: 'workContent', label: '工作任务', width: '140' }, + { prop: 'riskLevel', label: '风险等级', width: '80' }, + { prop: 'plannedWorkload', label: '计划工作量(基)', width: '80' }, ] export const tableColumns_1 = [ { prop: 'stationName', label: '拟投入作业人员数量', fixed: false, + width: '80', formatter: (row) => { return row.proposedPersonnelList?.filter((item) => item.dataSource == 0).length || '' @@ -77,7 +65,7 @@ export const tableColumns_1 = [ prop: 'majorName', label: '拟投入作业人员姓名', fixed: false, - width: '180', + width: '200', formatter: (row) => { return ( row.proposedPersonnelList @@ -91,15 +79,14 @@ export const tableColumns_1 = [ prop: 'proposedLongTimeCar', label: '拟投入车辆', fixed: false, - width: '180', - formatter: (row) => { - return `长租车${row.proposedLongTimeCar}辆,临租车${row.proposedTemporaryCar}辆` || '' - }, + width: '200', + slot: 'proposedLongTimeCar', }, { prop: 'projectName', label: '实际投入作业人员数量', fixed: false, + width: '80', formatter: (row) => { return row.proposedPersonnelList?.filter((item) => item.dataSource == 1).length || '' }, @@ -108,6 +95,7 @@ export const tableColumns_1 = [ prop: 'workTask', label: '实际投入作业人员姓名', fixed: false, + width: '200', formatter: (row) => { return ( row.proposedPersonnelList @@ -121,44 +109,184 @@ export const tableColumns_1 = [ prop: 'actualLongTimeCar', label: '实际投入车辆', fixed: false, + width: '200', + slot: 'actualLongTimeCar', + // formatter: (row) => { + // return `长租车${row.actualLongTimeCar}辆,临租车${row.actualTemporaryCar}辆` || '' + // }, + }, + { prop: 'actualWorkContent', label: '实际完成工作内容', fixed: false, width: '200' }, + { prop: 'actualWorkload', label: '实际完成工作量(基)', fixed: false, width: '80' }, + { + prop: 'completionPercentage', + label: '完成比例', + fixed: false, + width: '80', formatter: (row) => { - return `长租车${row.actualLongTimeCar}辆,临租车${row.actualTemporaryCar}辆` || '' + return row.completionPercentage || '' }, }, - { prop: 'actualWorkContent', label: '实际完成工作内容', fixed: false }, - { prop: 'actualWorkload', label: '实际完成工作量(基)', fixed: false }, - { prop: 'completionPercentage', label: '完成比例', fixed: false }, - { prop: 'planCompletionStatus', label: '作业计划完成情况', fixed: false }, - { prop: 'planChanges', label: '计划变更及未完成情况说明', fixed: false }, + { prop: 'planCompletionStatus', label: '作业计划完成情况', fixed: false, width: '200' }, + { prop: 'planChanges', label: '计划变更及未完成情况说明', fixed: false, width: '200' }, ] export const tableColumns_2 = [ - { prop: 'stationName', label: '拟投入高处作业人员数量', fixed: false }, - { prop: 'majorName', label: '高处作业人员姓名', fixed: false }, - { prop: 'businessTypeName', label: '拟投入地面作业人员数量', fixed: false }, - { prop: 'projectName', label: '地面作业人员姓名', fixed: false }, - { prop: 'workTask', label: '拟投入检修熟练工数量(分包高空作业人员)', fixed: false }, - { prop: 'riskLevelName', label: '拟投入检修辅助工数量(分包地面作业人员)', fixed: false }, - { prop: 'categoryName', label: '拟投入车辆', fixed: false }, - { prop: 'categoryName', label: '实际投入高处作业人员数量', fixed: false }, - { prop: 'categoryName', label: '高处作业人员姓名', fixed: false }, - { prop: 'categoryName', label: '实际投入地面作业人员数量', fixed: false }, - { prop: 'categoryName', label: '地面作业人员姓名', fixed: false }, { - prop: 'categoryName', + prop: 'stationName', + label: '拟投入高处作业人员数量', + fixed: false, + width: '80', + formatter: (row) => { + return row.proposedPersonnelList?.filter((item) => item.dataSource == 2).length || '' + }, + }, + { + prop: 'proposedPersonnelListHigh', + label: '高处作业人员姓名', + fixed: false, + width: '200', + formatter: (row) => { + return ( + row.proposedPersonnelList + ?.filter((item) => item.dataSource == 2) + .map((item) => item.name) + .join(',') || '' + ) + }, + }, + { + prop: 'proposedPersonnelListGroundNum', + label: '拟投入地面作业人员数量', + fixed: false, + width: '80', + formatter: (row) => { + return row.proposedPersonnelList?.filter((item) => item.dataSource == 3).length || '' + }, + }, + { + prop: 'proposedPersonnelListGround', + label: '地面作业人员姓名', + width: '200', + fixed: false, + formatter: (row) => { + return ( + row.proposedPersonnelList + ?.filter((item) => item.dataSource == 3) + .map((item) => item.name) + .join(',') || '' + ) + }, + }, + { + prop: 'proposedProficientPersonnel', + label: '拟投入检修熟练工数量(分包高空作业人员)', + fixed: false, + width: '80', + }, + { + prop: 'proposedAssistancePersonnel', + label: '拟投入检修辅助工数量(分包地面作业人员)', + fixed: false, + width: '80', + }, + { + prop: 'proposedLongTimeCar', + label: '拟投入车辆', + fixed: false, + width: '200', + slot: 'proposedLongTimeCar', + // formatter: (row) => { + // return `长租车${row.proposedLongTimeCar}辆,临租车${row.proposedTemporaryCar}辆` || '' + // }, + }, + { + prop: 'proposedPersonnelListHighNum', + label: '实际投入高处作业人员数量', + fixed: false, + width: '80', + formatter: (row) => { + return row.proposedPersonnelList?.filter((item) => item.dataSource == 4).length || '' + }, + }, + { + prop: 'proposedPersonnelListHighName', + label: '高处作业人员姓名', + width: '200', + fixed: false, + formatter: (row) => { + return ( + row.proposedPersonnelList + ?.filter((item) => item.dataSource == 4) + .map((item) => item.name) + .join(',') || '' + ) + }, + }, + { + prop: 'proposedPersonnelListNum', + label: '实际投入地面作业人员数量', + width: '80', + fixed: false, + formatter: (row) => { + return row.proposedPersonnelList?.filter((item) => item.dataSource == 5).length || '' + }, + }, + { + prop: 'proposedPersonnelList', + label: '地面作业人员姓名', + width: '200', + fixed: false, + formatter: (row) => { + return ( + row.proposedPersonnelList + ?.filter((item) => item.dataSource == 5) + .map((item) => item.name) + .join(',') || '' + ) + }, + }, + { + prop: 'actualProficientPersonnel', label: '实际投入检修熟练工数量(分包高空作业人员)', fixed: false, + width: '80', }, { - prop: 'categoryName', + prop: 'actualAssistancePersonnel', label: '实际投入检修辅助工数量(分包高空作业人员)', fixed: false, + width: '80', }, - { prop: 'categoryName', label: '实际投入车辆', fixed: false }, - { prop: 'categoryName', label: '实际完成工作内容', fixed: false }, - { prop: 'categoryName', label: '完成比例', fixed: false }, - { prop: 'categoryName', label: '作业计划完成情况', fixed: false }, - { prop: 'categoryName', label: '计划变更及未完成情况说明', fixed: false }, + { + prop: 'actualLongTimeCar', + label: '实际投入车辆', + width: '200', + fixed: false, + slot: 'actualLongTimeCar', + // formatter: (row) => { + // return `长租车${row.actualLongTimeCar}辆,临租车${row.actualTemporaryCar}辆` || '' + // }, + }, + { + prop: 'workloadCategoryName', + label: '实际完成工作内容', + width: '200', + fixed: false, + formatter: (row) => { + return row.actualWorkloadList?.map((item) => item.workloadCategoryName).join(',') || '' + }, + }, + { + prop: 'completionPercentage', + label: '完成比例', + fixed: false, + width: '80', + formatter: (row) => { + return row.completionPercentage || '' + }, + }, + { prop: 'planCompletionStatus', label: '作业计划完成情况', fixed: false, width: '200' }, + { prop: 'planChanges', label: '计划变更及未完成情况说明', fixed: false, width: '200' }, ] export const dialogConfig = reactive({ diff --git a/src/views/planMange/dailyPlan/edit.vue b/src/views/planMange/dailyPlan/edit.vue index 8fd9114..08f6a32 100644 --- a/src/views/planMange/dailyPlan/edit.vue +++ b/src/views/planMange/dailyPlan/edit.vue @@ -307,22 +307,34 @@ const getRepairFormData = () => ({ planChanges: '', // 计划变更及未完成情况说明 }) -// 项目部类型表单数据结构(占位,待后续填充) +// 项目部类型表单数据结构(与检修类型基本一致,但实际完成情况中无工作量字段,改为实际完成工作内容) const getProjectFormData = () => ({ dayPlanId: routeParams.value.dayPlanId, - // 基本信息(禁用,从路由参数获取,不传给后端) inspectionStationName: routeParams.value.inspectionStationName, projectName: routeParams.value.projectName, planMajorName: routeParams.value.planMajorName, dayPlan: routeParams.value.dayPlan, - // 计划投入资源情况(待填充) - // TODO: 项目部类型字段待确定 - planPersonnelList: [], // 拟投入作业人员(数组,暂时不确定字段名) - planPersonnel: '', // 拟投入作业人员(字符串,提交时使用) - // 实际完成情况(待填充) - actualPersonnelList: [], // 实际入作业人员(数组,暂时不确定字段名) - actualPersonnel: '', // 实际入作业人员(字符串,提交时使用) - // TODO: 项目部类型实际完成情况字段待确定 + plannedWorkload: null, + highAltitudePersonnelList: [], + groundPersonnelList: [], + proposedProficientPersonnel: null, + proposedProficientDay: null, + proposedAssistancePersonnel: null, + proposedAssistanceDay: null, + proposedLongTimeCar: null, + proposedTemporaryCar: null, + proposedSubCar: null, + actualHighAltitudePersonnelList: [], + actualGroundPersonnelList: [], + actualProficientPersonnel: null, + actualAssistancePersonnel: null, + actualLongTimeCar: null, + actualTemporaryCar: null, + actualSubCar: null, + actualWorkContent: '', + completionPercentage: null, + planCompletionStatus: null, + planChanges: '', }) // 根据类型获取对应的表单数据结构 @@ -347,19 +359,17 @@ const rules = computed(() => ({})) const onBack = () => { proxy.$tab.closeOpenPage({ path: '/plan/dailyPlan', + query: { + dayPlanType: dayPlanType.value, + }, }) } const onSubmit = async () => { try { - // 调用子组件的校验方法(子组件的 validate 返回 Promise) const valid = await formRef.value?.validate() - console.log(valid, 'valid') if (!valid) { - console.log('校验没有通过') - // 如果校验失败,尝试滚动到第一个错误字段 - // 注意:子组件的 validate 方法不返回 fields,所以这里无法获取具体错误字段 return } @@ -374,7 +384,7 @@ const onSubmit = async () => { proposedPersonnelList.push({ dayPlanId: route.query.id, inspectionStationName: item.inspectionStationName, - personnelld: item.id, + personnelId: item.id, name: item.name, dataSource: 0, // 拟投入作业人员 }) @@ -383,18 +393,18 @@ const onSubmit = async () => { proposedPersonnelList.push({ dayPlanId: route.query.id, inspectionStationName: item.inspectionStationName, - personnelld: item.id, + personnelId: item.id, name: item.name, dataSource: 1, // 实际入作业人员 }) }) - } else if (type === '1' || type === 1) { - // 检修类型:高处/地面,拟投入 & 实际投入 + } else if (type === '1' || type === 1 || type === '2' || type === 2) { + // 检修类型和项目部类型:高处/地面,拟投入 & 实际投入 ;(formData.value.highAltitudePersonnelList || []).forEach((item) => { proposedPersonnelList.push({ dayPlanId: route.query.id, inspectionStationName: item.inspectionStationName, - personnelld: item.id, + personnelId: item.id, name: item.name, dataSource: 2, // 拟投入高处作业人员 }) @@ -403,7 +413,7 @@ const onSubmit = async () => { proposedPersonnelList.push({ dayPlanId: route.query.id, inspectionStationName: item.inspectionStationName, - personnelld: item.id, + personnelId: item.id, name: item.name, dataSource: 3, // 拟投入地面作业人员 }) @@ -412,7 +422,7 @@ const onSubmit = async () => { proposedPersonnelList.push({ dayPlanId: route.query.id, inspectionStationName: item.inspectionStationName, - personnelld: item.id, + personnelId: item.id, name: item.name, dataSource: 4, // 实际投入高处作业人员 }) @@ -421,7 +431,7 @@ const onSubmit = async () => { proposedPersonnelList.push({ dayPlanId: route.query.id, inspectionStationName: item.inspectionStationName, - personnelld: item.id, + personnelId: item.id, name: item.name, dataSource: 5, // 实际投入地面作业人员 }) @@ -447,17 +457,17 @@ const onSubmit = async () => { } = formData.value submitData.proposedPersonnelList = proposedPersonnelList - submitData.workloadList = formData.value.actualWorkloadList + submitData.dayPlanType = type + if (type === '1' || type === 1) { + submitData.workloadList = formData.value.actualWorkloadList + } - console.log('submitData(日计划提交参数)', submitData) - // 暂不调用接口,后续再接入: const result = await updateDailyPlanAPI(submitData) if (result.code === 200) { proxy.$modal.msgSuccess('保存成功') onBack() } } catch (error) { - console.log(error, 'error') return Promise.reject(error) } } @@ -504,9 +514,12 @@ const filteredPersons = computed(() => { }) const selectedManagerNames = computed(() => { - // 根据不同的表单类型返回对应的人员名称 - if (dayPlanType.value === '1' || dayPlanType.value === 1) { - // 检修类型:返回高处作业人员和地面作业人员的名称 + if ( + dayPlanType.value === '1' || + dayPlanType.value === 1 || + dayPlanType.value === '2' || + dayPlanType.value === 2 + ) { const highAltitude = (formData.value.highAltitudePersonnelList || []) .map((item) => item.name) .join('、') @@ -515,7 +528,6 @@ const selectedManagerNames = computed(() => { .join('、') return [highAltitude, ground].filter(Boolean).join('、') || '' } - // 运行类型和项目部类型:使用 planPersonnelList return (formData.value.planPersonnelList || []).map((item) => item.name).join('、') }) @@ -525,7 +537,6 @@ const onOpenPersonPicker = async (type = 'plan') => { await nextTick() if (personTableRef.value) { personTableRef.value.clearSelection() - // 根据类型获取对应的人员列表 let currentList = [] if (type === 'plan') { currentList = formData.value.planPersonnelList || [] @@ -612,12 +623,167 @@ const onCloseDialogOuter = (visible) => { // 获取详情(如果需要从后端获取数据) const getDetail = async () => { - // TODO: 如果有详情API,在这里调用 - // const result = await getDailyPlanDetailAPI({ dayPlanId: route.query.id }) - // if (result.code === 200 && result.data) { - // const data = result.data - // // 填充表单数据 - // } + try { + const result = await getDailyPlanDetailAPI({ dayPlanId: route.query.id }) + if (result.code === 200 && result.data) { + const data = result.data + const type = dayPlanType.value + + // 基础字段回显 + const baseFields = { + dayPlanId: data.dayPlanId, + plannedWorkload: data.plannedWorkload, + proposedLongTimeCar: data.proposedLongTimeCar, + proposedTemporaryCar: data.proposedTemporaryCar, + actualLongTimeCar: data.actualLongTimeCar, + actualTemporaryCar: data.actualTemporaryCar, + actualWorkContent: data.actualWorkContent, + actualWorkload: data.actualWorkload, + completionPercentage: data.completionPercentage, + planCompletionStatus: data.planCompletionStatus, + planChanges: data.planChanges, + } + + // 处理人员数据:从 proposedPersonnelList 中按照 dataSource 区分获取并重新组装 + const proposedPersonnelList = data.proposedPersonnelList || [] + + if (type === '0' || type === 0) { + // 运行类型:使用 planPersonnelList 和 actualPersonnelList + baseFields.planPersonnelList = proposedPersonnelList + .filter((item) => item.dataSource === 0 || item.dataSource === '0') + .map((item) => ({ + id: item.personnelId, + name: item.name || '', + inspectionStationName: item.inspectionStationName || '', + })) + + baseFields.actualPersonnelList = proposedPersonnelList + .filter((item) => item.dataSource === 1 || item.dataSource === '1') + .map((item) => ({ + id: item.personnelId, + name: item.name || '', + inspectionStationName: item.inspectionStationName || '', + })) + } else if (type === '1' || type === 1 || type === '2' || type === 2) { + // 检修类型和项目部类型:使用 highAltitudePersonnelList、groundPersonnelList、actualHighAltitudePersonnelList、actualGroundPersonnelList + baseFields.highAltitudePersonnelList = proposedPersonnelList + .filter((item) => item.dataSource === 2 || item.dataSource === '2') + .map((item) => ({ + id: item.personnelId, + name: item.name || '', + inspectionStationName: item.inspectionStationName || '', + })) + + baseFields.groundPersonnelList = proposedPersonnelList + .filter((item) => item.dataSource === 3 || item.dataSource === '3') + .map((item) => ({ + id: item.personnelId, + name: item.name || '', + inspectionStationName: item.inspectionStationName || '', + })) + + baseFields.actualHighAltitudePersonnelList = proposedPersonnelList + .filter((item) => item.dataSource === 4 || item.dataSource === '4') + .map((item) => ({ + id: item.personnelId, + name: item.name || '', + inspectionStationName: item.inspectionStationName || '', + })) + + baseFields.actualGroundPersonnelList = proposedPersonnelList + .filter((item) => item.dataSource === 5 || item.dataSource === '5') + .map((item) => ({ + id: item.personnelId, + name: item.name || '', + inspectionStationName: item.inspectionStationName || '', + })) + + // 检修和项目部共有的字段 + baseFields.proposedProficientPersonnel = data.proposedProficientPersonnel + baseFields.proposedProficientDay = data.proposedProficientDay + baseFields.proposedAssistancePersonnel = data.proposedAssistancePersonnel + baseFields.proposedAssistanceDay = data.proposedAssistanceDay + baseFields.proposedSubCar = data.proposedSubCar + baseFields.actualProficientPersonnel = data.actualProficientPersonnel + baseFields.actualAssistancePersonnel = data.actualAssistancePersonnel + baseFields.actualSubCar = data.actualSubCar + + // 检修类型:工作内容从 workloadList 取值 + if (type === '1' || type === 1) { + baseFields.actualWorkloadList = + data.workloadList && data.workloadList.length > 0 + ? data.workloadList.map((item) => ({ + workloadCategoryId: item.workloadCategoryId || '', + workloadCategoryName: item.workloadCategoryName || '', + unitPrice: item.unitPrice || '', + workloadNum: item.workloadNum || '', + })) + : [ + { + workloadCategoryId: '', + workloadCategoryName: '', + unitPrice: '', + workloadNum: '', + }, + ] + } + } + + // 合并到表单数据 + formData.value = { + ...formData.value, + ...baseFields, + } + + // 如果有实际完成情况的数据,自动显示实际完成情况表单 + let hasActualData = false + if (type === '0' || type === 0) { + // 运行类型:检查实际入作业人员、实际完成工作量等 + hasActualData = + baseFields.actualPersonnelList?.length > 0 || + baseFields.actualWorkload || + baseFields.actualWorkContent || + baseFields.actualLongTimeCar || + baseFields.actualTemporaryCar || + baseFields.planCompletionStatus + } else if (type === '1' || type === 1) { + // 检修类型:检查实际投入人员、工作量列表、实际完成工作量等 + hasActualData = + baseFields.actualHighAltitudePersonnelList?.length > 0 || + baseFields.actualGroundPersonnelList?.length > 0 || + (baseFields.actualWorkloadList?.length > 0 && + baseFields.actualWorkloadList[0]?.workloadCategoryId) || + baseFields.actualWorkload || + baseFields.actualProficientPersonnel || + baseFields.actualAssistancePersonnel || + baseFields.actualLongTimeCar || + baseFields.actualTemporaryCar || + baseFields.actualSubCar || + baseFields.planCompletionStatus + } else if (type === '2' || type === 2) { + // 项目部类型:检查实际投入人员、实际完成工作内容等 + hasActualData = + baseFields.actualHighAltitudePersonnelList?.length > 0 || + baseFields.actualGroundPersonnelList?.length > 0 || + baseFields.actualWorkContent || + baseFields.actualWorkload || + baseFields.actualProficientPersonnel || + baseFields.actualAssistancePersonnel || + baseFields.actualLongTimeCar || + baseFields.actualTemporaryCar || + baseFields.actualSubCar || + baseFields.planCompletionStatus + } + + if (hasActualData) { + nextTick(() => { + formRef.value?.showActualCompletionForm?.() + }) + } + } + } catch (error) { + console.error('获取详情失败:', error) + } } // 监听类型变化,切换组件并重新初始化表单数据 diff --git a/src/views/planMange/dailyPlan/forms/projectForm.vue b/src/views/planMange/dailyPlan/forms/projectForm.vue index 882ca73..862a911 100644 --- a/src/views/planMange/dailyPlan/forms/projectForm.vue +++ b/src/views/planMange/dailyPlan/forms/projectForm.vue @@ -1,82 +1,514 @@