diff --git a/src/views/modules/quality/com_qualityIssuePoList.vue b/src/views/modules/quality/com_qualityIssuePoList.vue index 7f3afbb..c2b23e8 100644 --- a/src/views/modules/quality/com_qualityIssuePoList.vue +++ b/src/views/modules/quality/com_qualityIssuePoList.vue @@ -14,7 +14,7 @@ :height="tableHeight" :header-cell-style="{ textAlign: 'center' }"> @@ -332,6 +332,12 @@ export default { this.$nextTick(() => { if (this.$refs.availablePoTable) { this.$refs.availablePoTable.clearSelection() + // 将已关联到当前质量问题的PO自动勾选 + this.availablePoList.forEach(row => { + if (this.isRowLinked(row)) { + this.$refs.availablePoTable.toggleRowSelection(row, true) + } + }) } }) if (this.availablePoList.length === 0) { @@ -350,12 +356,26 @@ export default { }) }, + // 判断可用PO列表中的某行是否已关联到当前质量问题 + // 后端 getAvailablePoList 返回的真实 PO 号为 orderNo,而 srm_quality_issue_po 中存的 poNo 实际就是 orderNo + isRowLinked(row) { + if (!row || !this.issuePoList || this.issuePoList.length === 0) { + return false + } + return this.issuePoList.some(item => + item.poNo === row.orderNo && String(item.itemNo) === String(row.itemNo) + ) + }, + // 选择行变化 handleSelectionChange(selection) { this.selectedPoRows = selection }, // 保存选中的PO + // 后端 bindIssuePo 采用"全量覆盖"策略(先 deleteByIssueNo 再 batchInsert), + // 因此前端需将弹窗中当前勾选的所有 PO 全量提交,不能过滤已关联的行, + // 否则后端会把未提交的旧关联一并删除。 handleSavePo() { if (this.selectedPoRows.length === 0) { this.$message.warning('请至少选择一条PO记录') @@ -376,8 +396,9 @@ export default { return } + // 后端 DTO 中 poNo 字段实际存的是真实 PO 号(前端 row.orderNo),row.poNo 仅用于展示 const poList = this.selectedPoRows.map(row => ({ - poNo: row.poNo, + poNo: row.orderNo, itemNo: row.itemNo, partNo: row.partNo, qty: row.qty