fix: 🐛 修复热区弹框优先级问题。优化编辑商品时,可修改分类与商品类型

master
paulGao 2022-09-09 19:40:01 +08:00
parent 0933f1942e
commit 685ec5f679
3 changed files with 87 additions and 80 deletions

View File

@ -1,5 +1,5 @@
<template> <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"> <template v-if="flag">
<goodsDialog @selected="(val) => {goodsData = val;}" <goodsDialog @selected="(val) => {goodsData = val;}"
v-if="goodsFlag" ref="goodsDialog" :selectedWay='goodsData'/> v-if="goodsFlag" ref="goodsDialog" :selectedWay='goodsData'/>

View File

@ -144,7 +144,7 @@ export default {
pageSize: 10, pageSize: 10,
pageNumber: 1, pageNumber: 1,
}, },
templateTotal:0, templateTotal: 0,
}; };
}, },
methods: { methods: {
@ -185,8 +185,8 @@ export default {
GET_GoodsTemplate() { GET_GoodsTemplate() {
API_GOODS.getDraftGoodsListData(this.searchParams).then((res) => { API_GOODS.getDraftGoodsListData(this.searchParams).then((res) => {
if (res.success) { if (res.success) {
this.goodsTemplates.push(...res.result.records) this.goodsTemplates.push(...res.result.records);
this.templateTotal = res.result.total this.templateTotal = res.result.total;
} }
}); });
}, },
@ -234,13 +234,15 @@ export default {
this.$Message.error("必须选择到三级分类"); this.$Message.error("必须选择到三级分类");
return; return;
} else if (this.category[2].name) { } else if (this.category[2].name) {
let params = {
category: this.category,
goodsType: this.goodsType,
};
if (this.selectedTemplate.id) { if (this.selectedTemplate.id) {
this.$emit("change", { tempId: this.selectedTemplate.id }); params.tempId = this.selectedTemplate.id;
this.$emit("change", params);
} else { } else {
this.$emit("change", { this.$emit("change", params);
category: this.category,
goodsType: this.goodsType,
});
} }
} }
}, },
@ -252,7 +254,7 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./addGoods.scss"; @import "./addGoods.scss";
/deep/ .ivu-scroll-container{ /deep/ .ivu-scroll-container {
height:450px !important; height: 450px !important;
} }
</style> </style>

View File

@ -12,8 +12,8 @@
<div class="form-item-view"> <div class="form-item-view">
<FormItem label="商品分类"> <FormItem label="商品分类">
<span class="goods-category-name">{{ <span class="goods-category-name">{{
this.baseInfoForm.categoryName[0] this.baseInfoForm.categoryName[0]
}}</span> }}</span>
<span> &gt; {{ this.baseInfoForm.categoryName[1] }}</span> <span> &gt; {{ this.baseInfoForm.categoryName[1] }}</span>
<span> &gt; {{ this.baseInfoForm.categoryName[2] }}</span> <span> &gt; {{ this.baseInfoForm.categoryName[2] }}</span>
</FormItem> </FormItem>
@ -71,7 +71,7 @@
v-for="(item, index) in goodsUnitList" v-for="(item, index) in goodsUnitList"
:key="index" :key="index"
:value="item" :value="item"
>{{ item }} >{{ item }}
</Option> </Option>
</Select> </Select>
</FormItem> </FormItem>
@ -124,8 +124,8 @@
@on-blur="checkWholesaleNum(index)" @on-blur="checkWholesaleNum(index)"
> >
<span slot="append">{{ <span slot="append">{{
baseInfoForm.goodsUnit || "" baseInfoForm.goodsUnit || ""
}}</span> }}</span>
</Input> </Input>
</div> </div>
</template> </template>
@ -153,9 +153,8 @@
style="margin-left: 5px" style="margin-left: 5px"
type="error" type="error"
@click="handleDeleteWholesaleData(index)" @click="handleDeleteWholesaleData(index)"
>删除 >删除
</Button </Button>
>
</div> </div>
</template> </template>
</Table> </Table>
@ -197,7 +196,7 @@
class="demo-upload-list" class="demo-upload-list"
> >
<template> <template>
<img :src="item.url"/> <img :src="item.url" />
<div class="demo-upload-list-cover"> <div class="demo-upload-list-cover">
<div> <div>
<Icon <Icon
@ -318,9 +317,8 @@
</div> </div>
<div> <div>
<Button @click="addSpec($index, item)" <Button @click="addSpec($index, item)"
>添加规格值 >添加规格值
</Button </Button>
>
</div> </div>
</Card> </Card>
</div> </div>
@ -330,18 +328,16 @@
size="small" size="small"
type="primary" type="primary"
@click="addSkuItem" @click="addSkuItem"
>添加规格项 >添加规格项
</Button </Button>
>
&nbsp; &nbsp;
<Button <Button
class="add-sku-btn" class="add-sku-btn"
size="small" size="small"
type="warning" type="warning"
@click="handleClearSku" @click="handleClearSku"
>清空规格项 >清空规格项
</Button </Button>
>
</div> </div>
</Panel> </Panel>
<Panel name="2"> <Panel name="2">
@ -389,8 +385,8 @@
@on-change="updateSkuTable(row, 'quantity')" @on-change="updateSkuTable(row, 'quantity')"
> >
<span slot="append">{{ <span slot="append">{{
baseInfoForm.goodsUnit || "" baseInfoForm.goodsUnit || ""
}}</span> }}</span>
</Input> </Input>
</template> </template>
<template slot="cost" slot-scope="{ row }"> <template slot="cost" slot-scope="{ row }">
@ -460,7 +456,7 @@
:src="previewPicture" :src="previewPicture"
/> />
</div> </div>
<Divider/> <Divider />
<vuedraggable <vuedraggable
:animation="200" :animation="200"
:list="selectedSku.images" :list="selectedSku.images"
@ -472,7 +468,7 @@
class="sku-upload-list" class="sku-upload-list"
> >
<template> <template>
<img :src="img.url"/> <img :src="img.url" />
<div class="sku-upload-list-cover"> <div class="sku-upload-list-cover">
<Icon <Icon
type="md-search" type="md-search"
@ -547,9 +543,8 @@
></editor> ></editor>
<div class="promise-intro-btn"> <div class="promise-intro-btn">
<Button type="primary" @click="promiseIntroEditor" <Button type="primary" @click="promiseIntroEditor"
>将PC商品描述同步到移动端描述 >将PC商品描述同步到移动端描述
</Button </Button>
>
</div> </div>
</FormItem> </FormItem>
@ -580,7 +575,7 @@
v-for="item in logisticsTemplate" v-for="item in logisticsTemplate"
:key="item.id" :key="item.id"
:value="item.id" :value="item.id"
>{{ item.name }} >{{ item.name }}
</Option> </Option>
</Select> </Select>
</FormItem> </FormItem>
@ -688,12 +683,7 @@
<!-- 底部按钮 --> <!-- 底部按钮 -->
<div class="footer"> <div class="footer">
<ButtonGroup> <ButtonGroup>
<Button <Button type="primary" @click="pre"> </Button>
v-if="!$route.query.id && !$route.query.draftId"
type="primary"
@click="pre"
>上一步
</Button>
<Button :loading="submitLoading" type="primary" @click="save"> <Button :loading="submitLoading" type="primary" @click="save">
{{ this.$route.query.id ? "保存" : "保存商品" }} {{ this.$route.query.id ? "保存" : "保存商品" }}
</Button> </Button>
@ -708,9 +698,9 @@ import * as API_Shop from "@/api/shops";
import cloneObj from "@/utils/index"; import cloneObj from "@/utils/index";
import vuedraggable from "vuedraggable"; import vuedraggable from "vuedraggable";
import Editor from "@tinymce/tinymce-vue"; import Editor from "@tinymce/tinymce-vue";
import {initEditor} from "@/views/lili-components/editor/config"; import { initEditor } from "@/views/lili-components/editor/config";
import {uploadFile} from "@/libs/axios"; import { uploadFile } from "@/libs/axios";
import {regular} from "@/utils"; import { regular } from "@/utils";
export default { export default {
name: "goodsOperationSec", name: "goodsOperationSec",
@ -860,9 +850,9 @@ export default {
validateError: [], validateError: [],
baseInfoFormRule: { baseInfoFormRule: {
goodsName: [regular.REQUIRED, regular.WHITE_SPACE, regular.VARCHAR60], goodsName: [regular.REQUIRED, regular.WHITE_SPACE, regular.VARCHAR60],
price: [regular.REQUIRED, {validator: checkPrice}], price: [regular.REQUIRED, { validator: checkPrice }],
sellingPoint: [regular.REQUIRED, regular.VARCHAR60], sellingPoint: [regular.REQUIRED, regular.VARCHAR60],
goodsUnit: [{required: true, message: "请选择计量单位"}], goodsUnit: [{ required: true, message: "请选择计量单位" }],
name: [regular.REQUIRED, regular.VARCHAR5], name: [regular.REQUIRED, regular.VARCHAR5],
value: [regular.REQUIRED, regular.VARCHAR60], value: [regular.REQUIRED, regular.VARCHAR60],
templateId: [regular.REQUIRED], templateId: [regular.REQUIRED],
@ -924,7 +914,7 @@ export default {
) { ) {
this.baseInfoForm.goodsParamsDTOList[groupIndex].goodsParamsItemDTOList[ this.baseInfoForm.goodsParamsDTOList[groupIndex].goodsParamsItemDTOList[
paramsIndex paramsIndex
] = { ] = {
paramName: "", paramName: "",
paramValue: "", paramValue: "",
isIndex: "", isIndex: "",
@ -935,7 +925,7 @@ export default {
} }
this.baseInfoForm.goodsParamsDTOList[groupIndex].goodsParamsItemDTOList[ this.baseInfoForm.goodsParamsDTOList[groupIndex].goodsParamsItemDTOList[
paramsIndex paramsIndex
] = { ] = {
paramName: params.paramName, paramName: params.paramName,
paramValue: value, paramValue: value,
isIndex: params.isIndex, isIndex: params.isIndex,
@ -1100,7 +1090,7 @@ export default {
this.selectedSku.images !== undefined && this.selectedSku.images !== undefined &&
this.selectedSku.images.length > 5; this.selectedSku.images.length > 5;
if (check) { if (check) {
this.$Notice.warning({title: "图片数量不能大于五张"}); this.$Notice.warning({ title: "图片数量不能大于五张" });
return false; return false;
} }
}, },
@ -1159,7 +1149,7 @@ export default {
response.result.recommend response.result.recommend
? (response.result.recommend = 1) ? (response.result.recommend = 1)
: (response.result.recommend = 0); : (response.result.recommend = 0);
this.baseInfoForm = {...this.baseInfoForm, ...response.result}; this.baseInfoForm = { ...this.baseInfoForm, ...response.result };
this.baseInfoForm.release = 1; //使 this.baseInfoForm.release = 1; //使
this.categoryId = response.result.categoryPath.split(",")[2]; this.categoryId = response.result.categoryPath.split(",")[2];
@ -1169,7 +1159,7 @@ export default {
) { ) {
this.baseInfoForm.goodsGalleryFiles = this.baseInfoForm.goodsGalleryFiles =
response.result.goodsGalleryList.map((i) => { response.result.goodsGalleryList.map((i) => {
return {url: i}; return { url: i };
}); });
} }
@ -1192,15 +1182,28 @@ export default {
this.getGoodsBrandList(); this.getGoodsBrandList();
/** 查询商品参数 */ /** 查询商品参数 */
this.GET_GoodsParams(); this.GET_GoodsParams();
/** 查询店铺商品分类 */ /** 查询店铺商品分类 */
this.GET_ShopGoodsLabel(); this.GET_ShopGoodsLabel();
this.GET_GoodsUnit(); 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 // sku
renderGoodsDetailSku(skuList) { renderGoodsDetailSku(skuList) {
let skus = []; let skus = [];
let skusInfo = []; let skusInfo = [];
console.log(skuList);
skuList.map((e) => { skuList.map((e) => {
let sku = { let sku = {
id: e.id, id: e.id,
@ -1311,7 +1314,7 @@ export default {
} }
// //
this.$set(this.skuInfo, this.skuInfo.length, { this.$set(this.skuInfo, this.skuInfo.length, {
spec_values: [{name: "", value: ""}], spec_values: [{ name: "", value: "" }],
name: "", name: "",
}); });
@ -1386,10 +1389,10 @@ export default {
// 1n(n - 1) // 1n(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 index = 1;
let totalLength = 1; let totalLength = 1;
filterSkuInfo.forEach(skuInfo => { filterSkuInfo.forEach((skuInfo) => {
totalLength *= skuInfo.spec_values.length; totalLength *= skuInfo.spec_values.length;
}); });
// //
@ -1401,7 +1404,8 @@ export default {
} }
} else { } 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--) { for (let i = this.skuInfo.length - 2; i > itemIndex; i--) {
// //
currentNum *= this.skuInfo[i].spec_values.length; currentNum *= this.skuInfo[i].spec_values.length;
@ -1409,20 +1413,21 @@ export default {
// //
let beginIndex = currentNum + 1; 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; let totalLength = 1;
filterSkuInfo.forEach(skuInfo => { filterSkuInfo.forEach((skuInfo) => {
totalLength *= skuInfo.spec_values.length; totalLength *= skuInfo.spec_values.length;
}); });
for (let i = 0; i < totalLength; i++) { for (let i = 0; i < totalLength; i++) {
// * - 1 // * - 1
this.skuTableData.splice(beginIndex, currentNum * (item.spec_values.length - 1)); this.skuTableData.splice(
beginIndex,
currentNum * (item.spec_values.length - 1)
);
beginIndex += currentNum; beginIndex += currentNum;
} }
} }
this.skuInfo.splice($index, 1) this.skuInfo.splice($index, 1);
this.skuTableData = this.skuTableData.map((e) => { this.skuTableData = this.skuTableData.map((e) => {
delete e[item.name]; delete e[item.name];
@ -1463,9 +1468,9 @@ export default {
}); });
if (item.spec_values.length > 1) { if (item.spec_values.length > 1) {
let index = beforeLength; 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; let totalLength = 1;
filterSkuInfo.forEach(skuInfo => { filterSkuInfo.forEach((skuInfo) => {
totalLength *= skuInfo.spec_values.length; totalLength *= skuInfo.spec_values.length;
}); });
for (let i = 0; i < totalLength; i++) { for (let i = 0; i < totalLength; i++) {
@ -1481,7 +1486,6 @@ export default {
this.skuTableData.splice(index, 0, find); this.skuTableData.splice(index, 0, find);
index += beforeLength + 1; index += beforeLength + 1;
} }
} }
this.baseInfoForm.regeneratorSkuFlag = true; this.baseInfoForm.regeneratorSkuFlag = true;
} }
@ -1535,7 +1539,7 @@ export default {
title: "价格", title: "价格",
slot: "price", slot: "price",
} }
) );
} }
if (this.baseInfoForm.salesModel === "WHOLESALE" && this.wholesaleData) { if (this.baseInfoForm.salesModel === "WHOLESALE" && this.wholesaleData) {
@ -1548,8 +1552,10 @@ export default {
} }
// //
if (this.baseInfoForm.goodsType !== "VIRTUAL_GOODS" && if (
this.baseInfoForm.salesModel !== "WHOLESALE") { this.baseInfoForm.goodsType !== "VIRTUAL_GOODS" &&
this.baseInfoForm.salesModel !== "WHOLESALE"
) {
pushData.push({ pushData.push({
title: "重量", title: "重量",
slot: "weight", slot: "weight",
@ -1578,11 +1584,14 @@ export default {
let result = []; let result = [];
this.skuIndex = 0; this.skuIndex = 0;
this.skuTableData = this.specIterator(result, this.skuInfo, this.skuTableData); this.skuTableData = this.specIterator(
result,
this.skuInfo,
this.skuTableData
);
} }
}, },
/** /**
* 迭代属性形成表格 * 迭代属性形成表格
* result 渲染的数据 * result 渲染的数据
@ -1591,12 +1600,10 @@ export default {
specIterator(result, spec, skus) { specIterator(result, spec, skus) {
let table = result; let table = result;
if (spec.length > 0) { if (spec.length > 0) {
// //
let cloneTemp = cloneObj(spec); let cloneTemp = cloneObj(spec);
cloneTemp.shift(); cloneTemp.shift();
spec[0].spec_values.forEach(specItem => { spec[0].spec_values.forEach((specItem) => {
let index = this.skuIndex; let index = this.skuIndex;
if (table[index]) { if (table[index]) {
table[index][spec[0].name] = specItem.value; table[index][spec[0].name] = specItem.value;
@ -1627,7 +1634,7 @@ export default {
} }
table = this.specIterator(table, cloneTemp, skus, index); table = this.specIterator(table, cloneTemp, skus, index);
}) });
} else { } else {
this.skuIndex++; this.skuIndex++;
} }
@ -1849,11 +1856,9 @@ export default {
onOk: () => { onOk: () => {
delete this.baseInfoForm.id; delete this.baseInfoForm.id;
this.SAVE_DRAFT_GOODS(); this.SAVE_DRAFT_GOODS();
}, },
onCancel: () => { onCancel: () => {
this.SAVE_DRAFT_GOODS(); this.SAVE_DRAFT_GOODS();
}, },
}); });
return; return;
@ -1877,7 +1882,7 @@ export default {
API_GOODS.saveDraftGoods(this.baseInfoForm).then((res) => { API_GOODS.saveDraftGoods(this.baseInfoForm).then((res) => {
if (res.success) { if (res.success) {
this.$Message.info("保存成功!"); this.$Message.info("保存成功!");
this.$router.push({name: "template-goods"}); this.$router.push({ name: "template-goods" });
} }
}); });
}, },