fix: 🐛 修复热区弹框优先级问题。优化编辑商品时,可修改分类与商品类型
parent
0933f1942e
commit
685ec5f679
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<Modal :styles="{ top: '120px' }" width="1160" @on-cancel="clickClose" @on-ok="clickOK" v-model="flag" :mask-closable="false" scrollable>
|
||||
<Modal :styles="{ top: '120px' }" width="1160" z-index="10000" @on-cancel="clickClose" @on-ok="clickOK" v-model="flag" :mask-closable="false" scrollable>
|
||||
<template v-if="flag">
|
||||
<goodsDialog @selected="(val) => {goodsData = val;}"
|
||||
v-if="goodsFlag" ref="goodsDialog" :selectedWay='goodsData'/>
|
||||
|
|
|
@ -185,8 +185,8 @@ export default {
|
|||
GET_GoodsTemplate() {
|
||||
API_GOODS.getDraftGoodsListData(this.searchParams).then((res) => {
|
||||
if (res.success) {
|
||||
this.goodsTemplates.push(...res.result.records)
|
||||
this.templateTotal = res.result.total
|
||||
this.goodsTemplates.push(...res.result.records);
|
||||
this.templateTotal = res.result.total;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -234,13 +234,15 @@ export default {
|
|||
this.$Message.error("必须选择到三级分类");
|
||||
return;
|
||||
} else if (this.category[2].name) {
|
||||
if (this.selectedTemplate.id) {
|
||||
this.$emit("change", { tempId: this.selectedTemplate.id });
|
||||
} else {
|
||||
this.$emit("change", {
|
||||
let params = {
|
||||
category: this.category,
|
||||
goodsType: this.goodsType,
|
||||
});
|
||||
};
|
||||
if (this.selectedTemplate.id) {
|
||||
params.tempId = this.selectedTemplate.id;
|
||||
this.$emit("change", params);
|
||||
} else {
|
||||
this.$emit("change", params);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -154,8 +154,7 @@
|
|||
type="error"
|
||||
@click="handleDeleteWholesaleData(index)"
|
||||
>删除
|
||||
</Button
|
||||
>
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
</Table>
|
||||
|
@ -319,8 +318,7 @@
|
|||
<div>
|
||||
<Button @click="addSpec($index, item)"
|
||||
>添加规格值
|
||||
</Button
|
||||
>
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
@ -331,8 +329,7 @@
|
|||
type="primary"
|
||||
@click="addSkuItem"
|
||||
>添加规格项
|
||||
</Button
|
||||
>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
class="add-sku-btn"
|
||||
|
@ -340,8 +337,7 @@
|
|||
type="warning"
|
||||
@click="handleClearSku"
|
||||
>清空规格项
|
||||
</Button
|
||||
>
|
||||
</Button>
|
||||
</div>
|
||||
</Panel>
|
||||
<Panel name="2">
|
||||
|
@ -548,8 +544,7 @@
|
|||
<div class="promise-intro-btn">
|
||||
<Button type="primary" @click="promiseIntroEditor"
|
||||
>将PC商品描述同步到移动端描述
|
||||
</Button
|
||||
>
|
||||
</Button>
|
||||
</div>
|
||||
</FormItem>
|
||||
|
||||
|
@ -688,12 +683,7 @@
|
|||
<!-- 底部按钮 -->
|
||||
<div class="footer">
|
||||
<ButtonGroup>
|
||||
<Button
|
||||
v-if="!$route.query.id && !$route.query.draftId"
|
||||
type="primary"
|
||||
@click="pre"
|
||||
>上一步
|
||||
</Button>
|
||||
<Button type="primary" @click="pre">上一步 </Button>
|
||||
<Button :loading="submitLoading" type="primary" @click="save">
|
||||
{{ this.$route.query.id ? "保存" : "保存商品" }}
|
||||
</Button>
|
||||
|
@ -1192,15 +1182,28 @@ export default {
|
|||
this.getGoodsBrandList();
|
||||
/** 查询商品参数 */
|
||||
this.GET_GoodsParams();
|
||||
/** 查询店铺商品分类 */
|
||||
/** 查询店铺商品分类 */
|
||||
this.GET_ShopGoodsLabel();
|
||||
this.GET_GoodsUnit();
|
||||
|
||||
if (this.firstData.category) {
|
||||
const cateId = [];
|
||||
this.baseInfoForm.categoryName = [];
|
||||
this.firstData.category.forEach((cate) => {
|
||||
this.baseInfoForm.categoryName.push(cate.name);
|
||||
cateId.push(cate.id);
|
||||
});
|
||||
this.categoryId = cateId[2];
|
||||
|
||||
this.baseInfoForm.categoryPath = cateId.toString();
|
||||
}
|
||||
this.baseInfoForm.goodsType &&
|
||||
(this.baseInfoForm.goodsType = this.firstData.goodsType);
|
||||
},
|
||||
// 渲染sku数据
|
||||
renderGoodsDetailSku(skuList) {
|
||||
let skus = [];
|
||||
let skusInfo = [];
|
||||
console.log(skuList);
|
||||
skuList.map((e) => {
|
||||
let sku = {
|
||||
id: e.id,
|
||||
|
@ -1386,10 +1389,10 @@ export default {
|
|||
// 最后一个规格项生成规格数据规则: 如为最后一个规格项,则在规格列表每隔1个中删除n(n为最后一个规格项的规格值列表数量 - 1)个规格数据,生成一个规格数据
|
||||
|
||||
// 除了当前操作的规格项的规格项列表,用于获取所有规格项的规格值列表总数
|
||||
let filterSkuInfo = this.skuInfo.filter(i => i.name !== item.name);
|
||||
let filterSkuInfo = this.skuInfo.filter((i) => i.name !== item.name);
|
||||
let index = 1;
|
||||
let totalLength = 1;
|
||||
filterSkuInfo.forEach(skuInfo => {
|
||||
filterSkuInfo.forEach((skuInfo) => {
|
||||
totalLength *= skuInfo.spec_values.length;
|
||||
});
|
||||
// 去除第一个,因为第一个不需要生成新的规格数据
|
||||
|
@ -1401,7 +1404,8 @@ export default {
|
|||
}
|
||||
} else {
|
||||
// 当前规格项生成规格数据的时候,每次应该生成的条数
|
||||
let currentNum = this.skuInfo[this.skuInfo.length - 1].spec_values.length;
|
||||
let currentNum =
|
||||
this.skuInfo[this.skuInfo.length - 1].spec_values.length;
|
||||
for (let i = this.skuInfo.length - 2; i > itemIndex; i--) {
|
||||
// 计算每次删除规格数据后移动的位置(计算规则为,以最后的规格项的规格值数量为基础,乘以其他规格项的规格值总数)
|
||||
currentNum *= this.skuInfo[i].spec_values.length;
|
||||
|
@ -1409,20 +1413,21 @@ export default {
|
|||
// 移除对应规格数据的起始索引,起始位置为每次生成条数的下一位
|
||||
let beginIndex = currentNum + 1;
|
||||
|
||||
let filterSkuInfo = this.skuInfo.filter(i => i.name !== item.name);
|
||||
let filterSkuInfo = this.skuInfo.filter((i) => i.name !== item.name);
|
||||
let totalLength = 1;
|
||||
filterSkuInfo.forEach(skuInfo => {
|
||||
filterSkuInfo.forEach((skuInfo) => {
|
||||
totalLength *= skuInfo.spec_values.length;
|
||||
});
|
||||
for (let i = 0; i < totalLength; i++) {
|
||||
// 移除对应的规格数据,删除数量为 每次生成条数 * (当前规格项的规格值总数 - 1)
|
||||
this.skuTableData.splice(beginIndex, currentNum * (item.spec_values.length - 1));
|
||||
this.skuTableData.splice(
|
||||
beginIndex,
|
||||
currentNum * (item.spec_values.length - 1)
|
||||
);
|
||||
beginIndex += currentNum;
|
||||
}
|
||||
|
||||
}
|
||||
this.skuInfo.splice($index, 1)
|
||||
|
||||
this.skuInfo.splice($index, 1);
|
||||
|
||||
this.skuTableData = this.skuTableData.map((e) => {
|
||||
delete e[item.name];
|
||||
|
@ -1463,9 +1468,9 @@ export default {
|
|||
});
|
||||
if (item.spec_values.length > 1) {
|
||||
let index = beforeLength;
|
||||
let filterSkuInfo = this.skuInfo.filter(i => i.name !== item.name);
|
||||
let filterSkuInfo = this.skuInfo.filter((i) => i.name !== item.name);
|
||||
let totalLength = 1;
|
||||
filterSkuInfo.forEach(skuInfo => {
|
||||
filterSkuInfo.forEach((skuInfo) => {
|
||||
totalLength *= skuInfo.spec_values.length;
|
||||
});
|
||||
for (let i = 0; i < totalLength; i++) {
|
||||
|
@ -1481,7 +1486,6 @@ export default {
|
|||
this.skuTableData.splice(index, 0, find);
|
||||
index += beforeLength + 1;
|
||||
}
|
||||
|
||||
}
|
||||
this.baseInfoForm.regeneratorSkuFlag = true;
|
||||
}
|
||||
|
@ -1535,7 +1539,7 @@ export default {
|
|||
title: "价格",
|
||||
slot: "price",
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (this.baseInfoForm.salesModel === "WHOLESALE" && this.wholesaleData) {
|
||||
|
@ -1548,8 +1552,10 @@ export default {
|
|||
}
|
||||
|
||||
// 有重量的情况
|
||||
if (this.baseInfoForm.goodsType !== "VIRTUAL_GOODS" &&
|
||||
this.baseInfoForm.salesModel !== "WHOLESALE") {
|
||||
if (
|
||||
this.baseInfoForm.goodsType !== "VIRTUAL_GOODS" &&
|
||||
this.baseInfoForm.salesModel !== "WHOLESALE"
|
||||
) {
|
||||
pushData.push({
|
||||
title: "重量",
|
||||
slot: "weight",
|
||||
|
@ -1578,11 +1584,14 @@ export default {
|
|||
let result = [];
|
||||
this.skuIndex = 0;
|
||||
|
||||
this.skuTableData = this.specIterator(result, this.skuInfo, this.skuTableData);
|
||||
this.skuTableData = this.specIterator(
|
||||
result,
|
||||
this.skuInfo,
|
||||
this.skuTableData
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 迭代属性,形成表格
|
||||
* result 渲染的数据
|
||||
|
@ -1591,12 +1600,10 @@ export default {
|
|||
specIterator(result, spec, skus) {
|
||||
let table = result;
|
||||
if (spec.length > 0) {
|
||||
|
||||
//清除当前循环的分组
|
||||
let cloneTemp = cloneObj(spec);
|
||||
cloneTemp.shift();
|
||||
spec[0].spec_values.forEach(specItem => {
|
||||
|
||||
spec[0].spec_values.forEach((specItem) => {
|
||||
let index = this.skuIndex;
|
||||
if (table[index]) {
|
||||
table[index][spec[0].name] = specItem.value;
|
||||
|
@ -1627,7 +1634,7 @@ export default {
|
|||
}
|
||||
|
||||
table = this.specIterator(table, cloneTemp, skus, index);
|
||||
})
|
||||
});
|
||||
} else {
|
||||
this.skuIndex++;
|
||||
}
|
||||
|
@ -1849,11 +1856,9 @@ export default {
|
|||
onOk: () => {
|
||||
delete this.baseInfoForm.id;
|
||||
this.SAVE_DRAFT_GOODS();
|
||||
|
||||
},
|
||||
onCancel: () => {
|
||||
this.SAVE_DRAFT_GOODS();
|
||||
|
||||
},
|
||||
});
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue