| | |
| | | <table> |
| | | <thead> |
| | | <tr> |
| | | <th width="20%" style="text-align: center;">检验项目</th> |
| | | <th width="8%" style="text-align: center;">序号</th> |
| | | <th width="17%" style="text-align: center;">检验项目</th> |
| | | <th width="50%" style="text-align: center;">检验描述</th> |
| | | <th width="15%" style="text-align: center;">记录(点击)</th> |
| | | </tr> |
| | | </thead> |
| | | <tbody> |
| | | <tr v-for="(item, index) in tableData" :key="index"> |
| | | <td style="text-align: center;">{{ item.forder || (index + 1) }}</td> |
| | | <td>{{ item.projName }}</td> |
| | | <td> |
| | | <view v-if="item.result=='合格'" class="watermark approved"> |
| | |
| | | } |
| | | }).then(res1 => { |
| | | let tableData = res1.data.tbBillList || []; |
| | | |
| | | //当已检验个数都不为空时按照检测结构排序 |
| | | |
| | | // 按FORDER序号排序 |
| | | tableData.sort((a, b) => { |
| | | if (a.result === '未完成' && b.result === '合格') { |
| | | return -1; |
| | | } else if (a.result === '合格' && b.result === '未完成') { |
| | | return 1; |
| | | } else { |
| | | return 0; |
| | | } |
| | | return (a.forder || 0) - (b.forder || 0); |
| | | }); |
| | | this.tableData = tableData; |
| | | |
| | |
| | | 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; |
| | |
| | | padding: 12px 15px; |
| | | border: 1px solid #ddd; |
| | | text-align: left; |
| | | vertical-align: middle; |
| | | } |
| | | |
| | | .inspection-table th { |
| | |
| | | } |
| | | |
| | | /* 调整表格单元格 */ |
| | | .inspection-table td:nth-child(2) { |
| | | .inspection-table td:nth-child(3) { |
| | | position: relative; |
| | | overflow: hidden; |
| | | padding: 0; |
| | | min-height: 80px; |
| | | } |
| | | |
| | | /* 表单上方操作按钮区样式 */ |