Browse Source

fix(quality): 修复质量问题PO关联表格字段映射和自动勾选功能

- 将表格列prop从poNo改为orderRef1以匹配正确的数据字段
- 添加已关联PO的自动勾选逻辑,在表格初始化后自动选中已绑定的行
- 新增isRowLinked方法判断PO列表中的行是否已关联到当前质量问题
- 修改handleSavePo方法中poNo字段映射,使用row.orderNo作为真实的PO号
- 添加注释说明后端数据结构和全量覆盖策略的实现细节
master
qiankanghui 4 weeks ago
parent
commit
b50f9aa8c4
  1. 25
      src/views/modules/quality/com_qualityIssuePoList.vue

25
src/views/modules/quality/com_qualityIssuePoList.vue

@ -14,7 +14,7 @@
:height="tableHeight" :height="tableHeight"
:header-cell-style="{ textAlign: 'center' }"> :header-cell-style="{ textAlign: 'center' }">
<el-table-column <el-table-column
prop="poNo"
prop="orderRef1"
label="PO" label="PO"
width="120" width="120"
align="center"/> align="center"/>
@ -332,6 +332,12 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.availablePoTable) { if (this.$refs.availablePoTable) {
this.$refs.availablePoTable.clearSelection() this.$refs.availablePoTable.clearSelection()
// 将已关联到当前质量问题的PO自动勾选
this.availablePoList.forEach(row => {
if (this.isRowLinked(row)) {
this.$refs.availablePoTable.toggleRowSelection(row, true)
}
})
} }
}) })
if (this.availablePoList.length === 0) { 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) { handleSelectionChange(selection) {
this.selectedPoRows = selection this.selectedPoRows = selection
}, },
// 保存选中的PO // 保存选中的PO
// 后端 bindIssuePo 采用"全量覆盖"策略(先 deleteByIssueNo 再 batchInsert),
// 因此前端需将弹窗中当前勾选的所有 PO 全量提交,不能过滤已关联的行,
// 否则后端会把未提交的旧关联一并删除。
handleSavePo() { handleSavePo() {
if (this.selectedPoRows.length === 0) { if (this.selectedPoRows.length === 0) {
this.$message.warning('请至少选择一条PO记录') this.$message.warning('请至少选择一条PO记录')
@ -376,8 +396,9 @@ export default {
return return
} }
// 后端 DTO 中 poNo 字段实际存的是真实 PO 号(前端 row.orderNo),row.poNo 仅用于展示
const poList = this.selectedPoRows.map(row => ({ const poList = this.selectedPoRows.map(row => ({
poNo: row.poNo,
poNo: row.orderNo,
itemNo: row.itemNo, itemNo: row.itemNo,
partNo: row.partNo, partNo: row.partNo,
qty: row.qty qty: row.qty

Loading…
Cancel
Save