| | |
| | | this.SJ_MJIndex = e.mp.detail.value; |
| | | this.formData.SJ_MJ = this.SJ_MJList[this.SJ_MJIndex]; |
| | | }, |
| | | submitInspection() { |
| | | async submitInspection() { |
| | | if (this.formData.id) { |
| | | // 显示确认提示框 |
| | | uni.showModal({ |
| | | title: '确认提交', |
| | | content: '确定要提交检验结果吗?提交后将无法修改。', |
| | | confirmText: '确定提交', |
| | | cancelText: '取消', |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | | // 用户确认后执行提交 |
| | | this.$post({ |
| | | url: "/SJ/SjSubmit", |
| | | data: { |
| | | id: this.formData.id, |
| | | userNo: this.$loginInfo.account |
| | | } |
| | | }).then(res => { |
| | | if (res.data.tbBillList) { |
| | | this.$showMessage("提交成功"); |
| | | this.init(); |
| | | } |
| | | }); |
| | | try { |
| | | // 验证不合格检验项目 |
| | | await this.validateUnqualifiedItems(); |
| | | |
| | | // 显示确认提示框 |
| | | uni.showModal({ |
| | | title: '确认提交', |
| | | content: '确定要提交检验结果吗?提交后将无法修改。', |
| | | confirmText: '确定提交', |
| | | cancelText: '取消', |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | | // 用户确认后执行提交 |
| | | this.$post({ |
| | | url: "/SJ/SjSubmit", |
| | | data: { |
| | | id: this.formData.id, |
| | | userNo: this.$loginInfo.account |
| | | } |
| | | }).then(res => { |
| | | if (res.data.tbBillList) { |
| | | this.$showMessage("提交成功"); |
| | | this.init(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | } catch (error) { |
| | | this.$showMessage(error.message); |
| | | } |
| | | } |
| | | }, |
| | | |
| | | // 验证不合格检验项目 |
| | | 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; |
| | | } |
| | | } |
| | | }, |
| | | |
| | | // 获取检验项目详细信息 |
| | | async getInspectionItemDetail(itemId) { |
| | | return new Promise((resolve, reject) => { |
| | | this.$post({ |
| | | url: "/SJ/getQSItems", |
| | | data: { |
| | | pid: this.formData.id, |
| | | id: itemId |
| | | } |
| | | }).then(res => { |
| | | const item = res.data.tbBillList[0]; |
| | | if (item) { |
| | | resolve({ |
| | | hasImage: item.imageData && item.imageData.length > 0, |
| | | hasRemarks: item.remarks && item.remarks.trim() !== '' |
| | | }); |
| | | } else { |
| | | reject(new Error('无法获取检验项目详情')); |
| | | } |
| | | }).catch(err => { |
| | | reject(err); |
| | | }); |
| | | }); |
| | | }, |
| | | |
| | | drawingConfirm() { |
| | | this.drawingShow = false |
| | | this.imageShow = false |