| | |
| | | return; |
| | | } |
| | | |
| | | // 检查钉钉推送条件:PSZT为待判,且不良原因、不良描述、所属车间不为空 |
| | | const shouldPushToDingTalk = this.PSTYPE === '待判' && |
| | | this.badreason && |
| | | this.formData.fngDesc && |
| | | this.WORKSHOP; |
| | | // 验证不合格检验项目必须上传图片并填写不良描述 |
| | | this.validateUnqualifiedItems().then(() => { |
| | | // 检查钉钉推送条件:PSZT为待判,且不良原因、不良描述、所属车间不为空 |
| | | const shouldPushToDingTalk = this.PSTYPE === '待判' && |
| | | this.badreason && |
| | | this.formData.fngDesc && |
| | | this.WORKSHOP; |
| | | |
| | | let confirmMessage = '确定要提交此检验单吗?提交后将无法修改。'; |
| | | if (shouldPushToDingTalk) { |
| | | confirmMessage += '\n\n满足钉钉推送条件,将自动推送到钉钉审批流程。'; |
| | | } |
| | | |
| | | // 确认提交 |
| | | uni.showModal({ |
| | | title: '确认提交', |
| | | content: confirmMessage, |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | | this.$post({ |
| | | url: "/RKJ/submitInspection", |
| | | data: { |
| | | id: this.formData.id, |
| | | userNo: this.$loginInfo.account |
| | | } |
| | | }).then(res => { |
| | | if (res.status == 0) { |
| | | let successMessage = "检验单提交成功!"; |
| | | if (shouldPushToDingTalk) { |
| | | successMessage += "\n已推送到钉钉审批流程。"; |
| | | } |
| | | this.$showMessage(successMessage); |
| | | // 更新本地状态 |
| | | this.formData.fsubmit = 1; |
| | | // 刷新数据 |
| | | this.init(); |
| | | } else { |
| | | this.$showMessage(res.message || "提交失败"); |
| | | } |
| | | }).catch(error => { |
| | | console.error("提交失败:", error); |
| | | this.$showMessage("提交失败,请重试"); |
| | | }); |
| | | } |
| | | let confirmMessage = '确定要提交此检验单吗?提交后将无法修改。'; |
| | | if (shouldPushToDingTalk) { |
| | | confirmMessage += '\n\n满足钉钉推送条件,将自动推送到钉钉审批流程。'; |
| | | } |
| | | |
| | | // 确认提交 |
| | | uni.showModal({ |
| | | title: '确认提交', |
| | | content: confirmMessage, |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | | this.$post({ |
| | | url: "/RKJ/submitInspection", |
| | | data: { |
| | | id: this.formData.id, |
| | | userNo: this.$loginInfo.account |
| | | } |
| | | }).then(res => { |
| | | if (res.status == 0) { |
| | | let successMessage = "检验单提交成功!"; |
| | | if (shouldPushToDingTalk) { |
| | | successMessage += "\n已推送到钉钉审批流程。"; |
| | | } |
| | | this.$showMessage(successMessage); |
| | | // 更新本地状态 |
| | | this.formData.fsubmit = 1; |
| | | // 刷新数据 |
| | | this.init(); |
| | | } else { |
| | | this.$showMessage(res.message || "提交失败"); |
| | | } |
| | | }).catch(error => { |
| | | console.error("提交失败:", error); |
| | | this.$showMessage("提交失败,请重试"); |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }).catch(error => { |
| | | this.$showMessage(error); |
| | | }); |
| | | }, |
| | | |
| | | // 验证不合格检验项目 |
| | | async validateUnqualifiedItems() { |
| | | const unqualifiedItems = this.tableData.filter(item => item.result === '不合格'); |
| | | |
| | | if (unqualifiedItems.length === 0) { |
| | | return Promise.resolve(); |
| | | } |
| | | |
| | | // 检查每个不合格项目是否有图片和描述 |
| | | for (const item of unqualifiedItems) { |
| | | try { |
| | | const detail = await this.getInspectionItemDetail(item.id); |
| | | if (!detail.hasImage || !detail.hasRemarks) { |
| | | const missingItems = []; |
| | | if (!detail.hasImage) missingItems.push('图片'); |
| | | if (!detail.hasRemarks) missingItems.push('不良描述'); |
| | | |
| | | throw new Error(`检验项目"${item.projName}"不合格,但缺少:${missingItems.join('、')},请完善后重新提交!`); |
| | | } |
| | | } catch (error) { |
| | | throw error; |
| | | } |
| | | } |
| | | |
| | | return Promise.resolve(); |
| | | }, |
| | | |
| | | // 获取检验项目详细信息 |
| | | getInspectionItemDetail(itemId) { |
| | | return new Promise((resolve, reject) => { |
| | | this.$post({ |
| | | url: "/RKJ/getXjDetail02ById", |
| | | data: { id: itemId } |
| | | }).then(res => { |
| | | const itemData = res.data.tbBillList.itemXj01; |
| | | resolve({ |
| | | hasImage: itemData.imageData && itemData.imageData.length > 0, |
| | | hasRemarks: itemData.remarks && itemData.remarks.trim() !== '' |
| | | }); |
| | | }).catch(error => { |
| | | reject('获取检验项目详情失败'); |
| | | }); |
| | | }); |
| | | }, |
| | | |
| | | viewAttachmentInfo() { |
| | | this.showAttachmentPopup = true; // 先弹窗 |
| | | this.attachmentsLoading = true; |