Commit d5b341b8 by wangzhihui

修复

1 parent f3b6b629
......@@ -944,12 +944,25 @@ export default {
},
deep: true,
},
serviceItemList: {
handler(list) {
if (!list?.length) {
return;
}
this.syncServiceItemOptionsToFormBlocks(list);
},
},
},
async mounted() {
// 先加载服务项目选项,再赋值 formData,避免 filterForm 时 optionList 为空导致编辑回显失败
await this.loadServiceItemList();
this.formData = deepClone(this.originData);
this.normalizeGroundingGoodsServiceItemIds();
this.checkMinPrice();
await this.loadServiceItemList();
(this.formData.groundingGoodsList || []).forEach((_, index) => {
this.filterForm(index);
});
},
methods: {
......@@ -963,15 +976,44 @@ export default {
pageSize: 10000,
currentPage: 1,
});
this.serviceItemList = (serviceItemRes?.list || []).map((item) => ({
...item,
serviceItemId: item.serviceItemId ?? item.id,
}));
this.serviceItemList = (serviceItemRes?.list || []).map((item) => {
const serviceItemId = item.serviceItemId ?? item.id;
const normalizedId = serviceItemId === "" || serviceItemId === null || serviceItemId === undefined
? ""
: Number(serviceItemId);
return {
...item,
serviceItemId: Number.isNaN(normalizedId) ? serviceItemId : normalizedId,
};
});
} catch (err) {
console.log(err);
this.serviceItemList = [];
}
},
normalizeGroundingGoodsServiceItemIds() {
(this.formData.groundingGoodsList || []).forEach((item, index) => {
if (item.serviceItemId === "" || item.serviceItemId === null || item.serviceItemId === undefined) {
return;
}
const normalizedId = Number(item.serviceItemId);
if (!Number.isNaN(normalizedId)) {
this.$set(this.formData.groundingGoodsList[index], "serviceItemId", normalizedId);
}
});
},
syncServiceItemOptionsToFormBlocks(list = this.serviceItemList) {
(this.formData.groundingGoodsList || []).forEach((_, index) => {
const formBlock = this.formList[2]?.formBlock?.[index];
if (!formBlock) {
return;
}
const serviceField = formBlock.find((v) => v.name === "serviceItemId");
if (serviceField) {
this.$set(serviceField, "optionList", list || []);
}
});
},
getEmptyGroundingGoodsItem() {
return {
upgradeGoodsId: "",
......
......@@ -299,7 +299,13 @@ export default {
virtualAccountCost: val?.virtualAccountCost, // 虚拟对账成本
djCost: val?.djCost, // 嘀加成本
thirdPartyCost: val?.thirdPartyCost, // 第三方成本
serviceItemId: val?.serviceItemId ?? "", // 服务项目
serviceItemId: (() => {
if (val?.serviceItemId == null || val?.serviceItemId === "") {
return "";
}
const id = Number(val.serviceItemId);
return Number.isNaN(id) ? "" : id;
})(), // 服务项目
productCostType: (() => {
const supplierCode = val?.goodsInfo?.supplierCode;
// 自营延保/权益:编辑回显时 productCostType 固定为 1
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!