update 修复商品编辑BUG
This commit is contained in:
parent
19610292f5
commit
3302fca052
@ -726,6 +726,7 @@ export default {
|
|||||||
|
|
||||||
// 1. 解析产品规格模板
|
// 1. 解析产品规格模板
|
||||||
this.productSpec = this.productInfoByPid.shop_product_info.product_spec;
|
this.productSpec = this.productInfoByPid.shop_product_info.product_spec;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.productSpec = JSON.parse(this.productSpec);
|
this.productSpec = JSON.parse(this.productSpec);
|
||||||
if (!Array.isArray(this.productSpec)) {
|
if (!Array.isArray(this.productSpec)) {
|
||||||
@ -801,9 +802,15 @@ export default {
|
|||||||
return item; // 如果没有匹配项,返回原 item
|
return item; // 如果没有匹配项,返回原 item
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.cheboxList = this.specificationInfoList.map(
|
||||||
|
(item) => item.spec_item_id
|
||||||
|
);
|
||||||
|
|
||||||
if (this.specificationInfoList.length == 0) {
|
if (this.specificationInfoList.length == 0) {
|
||||||
this.specificationInfoList = this.selectCommodisItems;
|
this.specificationInfoList = this.selectCommodisItems;
|
||||||
|
this.cheboxList = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(this.specificationInfoList);
|
console.log(this.specificationInfoList);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("解析productSpec失败:", e);
|
console.error("解析productSpec失败:", e);
|
||||||
@ -916,9 +923,9 @@ export default {
|
|||||||
main_color_img: mainMColorimg.toString(),
|
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([
|
obj.product_spec = JSON.stringify([
|
||||||
{
|
{
|
||||||
id: item.spec_id,
|
id: item.spec_id,
|
||||||
@ -968,8 +975,7 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var productSpec = this.productSpec;
|
var productSpec = this.productSpec;
|
||||||
|
if (this.cheboxList.length > 0) {
|
||||||
if (this.cheboxList.length > 0 || productSpec.length > 0) {
|
|
||||||
productSpec = this.specificationInfoList.reduce((acc, item) => {
|
productSpec = this.specificationInfoList.reduce((acc, item) => {
|
||||||
const existingSpec = acc.find((spec) => spec.id === item.spec_id);
|
const existingSpec = acc.find((spec) => spec.id === item.spec_id);
|
||||||
|
|
||||||
@ -993,6 +999,8 @@ export default {
|
|||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
} else {
|
||||||
|
productSpec = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(this.form.product_param);
|
console.log(this.form.product_param);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user