|
|
@@ -1243,17 +1243,19 @@ export default {
|
|
|
},
|
|
|
onItemChange(acuid, scope, detailType) {
|
|
|
const row = scope.row;
|
|
|
+ // 在任何修改之前记录该行是否已有值(区分修改和新增)
|
|
|
+ const hadPreviousValue = !!row.acuid;
|
|
|
+
|
|
|
const table = this.getDetailTable(detailType);
|
|
|
const exists = table.find(
|
|
|
(item) => item.acuid === acuid && item.id !== row.id,
|
|
|
);
|
|
|
if (exists) {
|
|
|
this.$message.error("不可重复选择");
|
|
|
- row.acuid = "";
|
|
|
- row.name = "";
|
|
|
- row.acuname = "";
|
|
|
+ // 不重置行数据,保留原有值,让 :value 绑定自动回显
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
const optionsList = this.getSearchOptions(detailType);
|
|
|
const selected = optionsList.find((item) => item.acuid === acuid);
|
|
|
if (selected) {
|
|
|
@@ -1268,7 +1270,10 @@ export default {
|
|
|
row.count = Number(selected.num) || 1;
|
|
|
}
|
|
|
}
|
|
|
- this.addDetailRow(scope, detailType);
|
|
|
+ // 只有新增(原来没有值)才添加新行,修改不添加
|
|
|
+ if (!hadPreviousValue) {
|
|
|
+ this.addDetailRow(scope, detailType);
|
|
|
+ }
|
|
|
},
|
|
|
onDetailInput(scope, detailType) {
|
|
|
// 其他详情输入文字后自动新增一行
|