|
@@ -595,7 +595,7 @@
|
|
|
this.form.factoriesId = data[0].factoryId;
|
|
this.form.factoriesId = data[0].factoryId;
|
|
|
this.form.factoriesName = data[0].factoryName;
|
|
this.form.factoriesName = data[0].factoryName;
|
|
|
}
|
|
}
|
|
|
- } else if (type == 'edit' || type == 'detail' || type == 'wordEdit') {
|
|
|
|
|
|
|
+ } else if (type == 'edit' || type == 'detail') {
|
|
|
this.getDetail(row.id);
|
|
this.getDetail(row.id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -704,22 +704,16 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 只使用 id 作为唯一 key(你要求按 id 对比)
|
|
|
|
|
const getKey = (item) => item.id;
|
|
const getKey = (item) => item.id;
|
|
|
-
|
|
|
|
|
- // 新旧数据的 key 集合
|
|
|
|
|
const newKeys = new Set(list.map(getKey));
|
|
const newKeys = new Set(list.map(getKey));
|
|
|
const oldKeys = new Set(this.orderList.map(getKey));
|
|
const oldKeys = new Set(this.orderList.map(getKey));
|
|
|
|
|
|
|
|
- // 1️⃣ 保留原数据中在新数据里依然存在的项(不做任何修改)
|
|
|
|
|
const keptOldList = this.orderList.filter((oldItem) =>
|
|
const keptOldList = this.orderList.filter((oldItem) =>
|
|
|
newKeys.has(getKey(oldItem))
|
|
newKeys.has(getKey(oldItem))
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- // 2️⃣ 找出需要新增的项(id 不在旧数据中)
|
|
|
|
|
const addedItems = list.filter((item) => !oldKeys.has(getKey(item)));
|
|
const addedItems = list.filter((item) => !oldKeys.has(getKey(item)));
|
|
|
|
|
|
|
|
- // 3️⃣ 处理新增项
|
|
|
|
|
const newList = addedItems.map((item) => {
|
|
const newList = addedItems.map((item) => {
|
|
|
const copy = this.deepCopy(item);
|
|
const copy = this.deepCopy(item);
|
|
|
|
|
|
|
@@ -754,59 +748,7 @@
|
|
|
return copy;
|
|
return copy;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // 4️⃣ 合并:保留原来的 + 新增
|
|
|
|
|
this.orderList = [...keptOldList, ...newList];
|
|
this.orderList = [...keptOldList, ...newList];
|
|
|
- // if (!list || list.length === 0) {
|
|
|
|
|
- // this.orderList = [];
|
|
|
|
|
- // return;
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // const getKey = (item) => item.id ?? item.apsWorkOrderCode ?? '';
|
|
|
|
|
- // const existingKeys = new Set(this.orderList.map(getKey));
|
|
|
|
|
-
|
|
|
|
|
- // const commonList = list.filter((item) =>
|
|
|
|
|
- // existingKeys.has(getKey(item))
|
|
|
|
|
- // );
|
|
|
|
|
-
|
|
|
|
|
- // const newList = list.filter((item) => !existingKeys.has(getKey(item)));
|
|
|
|
|
-
|
|
|
|
|
- // const mergedList = [];
|
|
|
|
|
-
|
|
|
|
|
- // commonList.forEach((it) => {
|
|
|
|
|
- // mergedList.push(this.deepCopy(it));
|
|
|
|
|
- // });
|
|
|
|
|
-
|
|
|
|
|
- // newList.forEach((item) => {
|
|
|
|
|
- // Object.assign(item, {
|
|
|
|
|
- // describes: '',
|
|
|
|
|
- // totalCount: item.formingNum,
|
|
|
|
|
- // taskList: [],
|
|
|
|
|
- // taskId: '',
|
|
|
|
|
- // taskName: '',
|
|
|
|
|
- // beEntrustedFactoriesId: '',
|
|
|
|
|
- // beEntrustedFactoriesName: '',
|
|
|
|
|
- // status: '',
|
|
|
|
|
- // beEntrustedDeptName: '',
|
|
|
|
|
- // beEntrustedDeptId: '',
|
|
|
|
|
- // measuringUnit: item.unit,
|
|
|
|
|
- // categoryName: item.productName,
|
|
|
|
|
- // categoryCode: item.productCode,
|
|
|
|
|
- // workOrderId: item.id,
|
|
|
|
|
- // workOrderCode: item.code,
|
|
|
|
|
- // brandNum: item.brandNo,
|
|
|
|
|
- // modelType: item.model,
|
|
|
|
|
- // name: this.form.name,
|
|
|
|
|
- // type: this.form.type,
|
|
|
|
|
- // planDeliveryTime: item.startTime,
|
|
|
|
|
- // applyDeptId: this.form.pleaseEntrustDeptId,
|
|
|
|
|
- // applyDeptName: this.form.pleaseEntrustDeptName,
|
|
|
|
|
- // applyFactoriesId: this.form.factoriesId,
|
|
|
|
|
- // applyFactoriesName: this.form.factoriesName
|
|
|
|
|
- // });
|
|
|
|
|
- // mergedList.push(this.deepCopy(item));
|
|
|
|
|
- // });
|
|
|
|
|
-
|
|
|
|
|
- // this.orderList = mergedList;
|
|
|
|
|
|
|
|
|
|
this.getOrderTaskList();
|
|
this.getOrderTaskList();
|
|
|
},
|
|
},
|
|
@@ -881,23 +823,19 @@
|
|
|
item.status = type == 1 ? 0 : 1;
|
|
item.status = type == 1 ? 0 : 1;
|
|
|
item.approvalStatus = type == 1 ? 0 : 1;
|
|
item.approvalStatus = type == 1 ? 0 : 1;
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
let URL;
|
|
let URL;
|
|
|
|
|
|
|
|
const clearOrderIds = () => {
|
|
const clearOrderIds = () => {
|
|
|
this.orderList.forEach((it) => (it.id = ''));
|
|
this.orderList.forEach((it) => (it.id = ''));
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- if (type === 1 && this.form.id) {
|
|
|
|
|
- // 编辑
|
|
|
|
|
- URL = update;
|
|
|
|
|
- } else if (type === 1) {
|
|
|
|
|
- // 新增
|
|
|
|
|
- URL = save;
|
|
|
|
|
- clearOrderIds();
|
|
|
|
|
|
|
+ if (type === 1) {
|
|
|
|
|
+ URL = this.type === 'edit' ? update : save;
|
|
|
} else {
|
|
} else {
|
|
|
- // 其他类型提交
|
|
|
|
|
URL = addSubmit;
|
|
URL = addSubmit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (this.type === 'add' && (type !== 1 || type === 1)) {
|
|
|
clearOrderIds();
|
|
clearOrderIds();
|
|
|
}
|
|
}
|
|
|
|
|
|