From 5232de2cb3b5e06b1038eb27e3dd5c24b158a7f3 Mon Sep 17 00:00:00 2001 From: ljlong_2630 Date: Tue, 26 Mar 2024 17:13:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eam/device/devicemaintenancejob/index.vue | 39 ++++++++++++++++--- .../eam/mold/moldmaintenancejob/index.vue | 32 ++++++++++++++- 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/views/eam/device/devicemaintenancejob/index.vue b/src/views/eam/device/devicemaintenancejob/index.vue index c9f1181..61f0bf6 100644 --- a/src/views/eam/device/devicemaintenancejob/index.vue +++ b/src/views/eam/device/devicemaintenancejob/index.vue @@ -753,8 +753,10 @@ function turnOrder(type, row) { // 完成 function finishOrder(row) { - showTempIdeaRefView.value = true - tempIdeaRefViewData.value = row + if (validateRow(row)) { + showTempIdeaRefView.value = true + tempIdeaRefViewData.value = row + } } function confirmFinish(row) { @@ -926,6 +928,7 @@ const detailSubmitForm = async (formType, data, formRef, tableList) => { message.success(t('common.updateSuccess')) } formRef.dialogVisible = false + await detailRef.value.getList() // 刷新当前列表 detailRef.value.tableObject.tableList.forEach(item=>{ if (item.itemNumbers?.length>0) { @@ -935,10 +938,8 @@ const detailSubmitForm = async (formType, data, formRef, tableList) => { }) item.itemNumbers1 = str.substring(0, str.length - 1) } - }) - await detailRef.value.getList() - await getList() + await getList() } finally { formRef.formLoading = false @@ -1012,9 +1013,10 @@ function isReceiver(orderPerson) { const confirmIsTemporary = () => { - confirmFinish(tempIdeaRefViewData.value) + confirmFinish(tempIdeaRefViewData.value) } + const cancel = () => { showTempIdeaRefView.value = false; }; @@ -1034,6 +1036,31 @@ const judgeIfDeviceRole = () => { } } +const validateRow = (row) => { + let flag = true; + const validateResult = ref([]); + for (const [key, rules] of Object.entries(DeviceMaintenanceMainRules)) { + for (const rule of rules) { + if (rule.required) { + const schemaItem = DeviceMaintenanceMain.allSchemas.formSchema.find(item => item.field == key); + if (schemaItem && (row[key] === undefined || row[key] === null || row[key] === '')) { + validateResult.value.push({ + msg: '[' + schemaItem.label + ']' + }); + flag = false; + } + } + } + } + if (!flag) { + // 如果验证失败,将错误信息转换为HTML字符串并弹窗提示 + const errorMessage = validateResult.value.map(error => error.msg).join(', '); + message.alert('请填写以下必填项:'+errorMessage); // 使用支持HTML的弹窗显示所有错误信息 + return false; // 验证失败,立即返回 + } + // 所有规则验证通过 + return true; +}; /** 初始化 **/ onMounted(async () => { diff --git a/src/views/eam/mold/moldmaintenancejob/index.vue b/src/views/eam/mold/moldmaintenancejob/index.vue index b723662..bae3576 100644 --- a/src/views/eam/mold/moldmaintenancejob/index.vue +++ b/src/views/eam/mold/moldmaintenancejob/index.vue @@ -513,8 +513,10 @@ function turnOrder() { } // 完成 function finishOrder(row) { - showTempIdeaRefView.value = true - tempIdeaRefViewData.value = row + if (validateRow(row)) { + showTempIdeaRefView.value = true + tempIdeaRefViewData.value = row + } } function confirmFinish(row) { @@ -984,6 +986,32 @@ const cancel = () => { showTempIdeaRefView.value = false; }; +const validateRow = (row) => { + let flag = true; + const validateResult = ref([]); + for (const [key, rules] of Object.entries(MoldMaintenanceMainRules)) { + for (const rule of rules) { + if (rule.required) { + const schemaItem = MoldMaintenanceMain.allSchemas.formSchema.find(item => item.field == key); + if (schemaItem && (row[key] === undefined || row[key] === null || row[key] === '')) { + validateResult.value.push({ + msg: '[' + schemaItem.label + ']' + }); + flag = false; + } + } + } + } + if (!flag) { + // 如果验证失败,将错误信息转换为HTML字符串并弹窗提示 + const errorMessage = validateResult.value.map(error => error.msg).join(', '); + message.alert('请填写以下必填项:'+errorMessage); // 使用支持HTML的弹窗显示所有错误信息 + return false; // 验证失败,立即返回 + } + // 所有规则验证通过 + return true; +}; + /** 初始化 **/ onMounted(async () => {