update 修复商品编辑BUG

This commit is contained in:
qijq 2025-08-12 13:25:41 +08:00
parent 19610292f5
commit 3302fca052

View File

@ -726,6 +726,7 @@ export default {
// 1.
this.productSpec = this.productInfoByPid.shop_product_info.product_spec;
try {
this.productSpec = JSON.parse(this.productSpec);
if (!Array.isArray(this.productSpec)) {
@ -801,9 +802,15 @@ export default {
return item; // item
});
this.cheboxList = this.specificationInfoList.map(
(item) => item.spec_item_id
);
if (this.specificationInfoList.length == 0) {
this.specificationInfoList = this.selectCommodisItems;
this.cheboxList = [];
}
console.log(this.specificationInfoList);
} catch (e) {
console.error("解析productSpec失败:", e);
@ -916,9 +923,9 @@ export default {
main_color_img: mainMColorimg.toString(),
};
if (this.cheboxList.length > 0 || this.productSpec.length > 0) {
console.log(this.cheboxList, this.productSpec);
//
if (this.cheboxList.length > 0) {
obj.product_spec = JSON.stringify([
{
id: item.spec_id,
@ -968,8 +975,7 @@ export default {
});
var productSpec = this.productSpec;
if (this.cheboxList.length > 0 || productSpec.length > 0) {
if (this.cheboxList.length > 0) {
productSpec = this.specificationInfoList.reduce((acc, item) => {
const existingSpec = acc.find((spec) => spec.id === item.spec_id);
@ -993,6 +999,8 @@ export default {
return acc;
}, []);
} else {
productSpec = [];
}
console.log(this.form.product_param);