优化商家发布商品丢失规格问题,修改开启cdn

master
lemon橪 2022-02-10 14:26:53 +08:00
parent 5960df31bd
commit 925365018b
4 changed files with 444 additions and 172 deletions

View File

@ -7,6 +7,6 @@ module.exports = {
}, //公司信息 }, //公司信息
icpMessage: "京ICP备20009696号-1", //icp备案 icpMessage: "京ICP备20009696号-1", //icp备案
aMapKey: "b440952723253aa9fe483e698057bf7d", //高德web端申请的api key aMapKey: "b440952723253aa9fe483e698057bf7d", //高德web端申请的api key
enableCDN: false, //生产环境 是否启用cdn加载 vue等js enableCDN: true, //生产环境 是否启用cdn加载 vue等js
port: 10000, //端口 port: 10000, //端口
}; };

View File

@ -2,6 +2,6 @@ module.exports = {
title: "lilishop", //配置显示在浏览器标签的title title: "lilishop", //配置显示在浏览器标签的title
aMapKey: "b440952723253aa9fe483e698057bf7d", //高德web端申请的api key aMapKey: "b440952723253aa9fe483e698057bf7d", //高德web端申请的api key
website: "https://www.pickmall.cn", //官网地址 website: "https://www.pickmall.cn", //官网地址
enableCDN: false, //生产环境 是否启用cdn加载 vue等js enableCDN: true, //生产环境 是否启用cdn加载 vue等js
port: 10003, //端口 port: 10003, //端口
}; };

View File

@ -2,6 +2,6 @@ module.exports = {
title: "lilishop", //配置显示在浏览器标签的title title: "lilishop", //配置显示在浏览器标签的title
aMapKey: "b440952723253aa9fe483e698057bf7d", //高德web端申请的api key aMapKey: "b440952723253aa9fe483e698057bf7d", //高德web端申请的api key
website: "https://www.pickmall.cn", //官网地址 website: "https://www.pickmall.cn", //官网地址
enableCDN: false, //生产环境 是否启用cdn加载 vue等js enableCDN: true, //生产环境 是否启用cdn加载 vue等js
port:10002, //端口 port: 10002, //端口
}; };

View File

@ -45,7 +45,11 @@
/> />
</FormItem> </FormItem>
<FormItem label="商品品牌" prop="brandId"> <FormItem label="商品品牌" prop="brandId">
<Select v-model="baseInfoForm.brandId" filterable style="width: 200px"> <Select
v-model="baseInfoForm.brandId"
filterable
style="width: 200px"
>
<Option <Option
v-for="item in brandList" v-for="item in brandList"
:value="item.id" :value="item.id"
@ -57,14 +61,25 @@
</div> </div>
<h4>商品交易信息</h4> <h4>商品交易信息</h4>
<div class="form-item-view"> <div class="form-item-view">
<FormItem class="form-item-view-el" label="计量单位" prop="goodsUnit"> <FormItem
class="form-item-view-el"
label="计量单位"
prop="goodsUnit"
>
<Select v-model="baseInfoForm.goodsUnit" style="width: 100px"> <Select v-model="baseInfoForm.goodsUnit" style="width: 100px">
<Option v-for="(unit, i) in goodsUnitList" :key="i" :value="unit" <Option
v-for="(unit, i) in goodsUnitList"
:key="i"
:value="unit"
>{{ unit }} >{{ unit }}
</Option> </Option>
</Select> </Select>
</FormItem> </FormItem>
<FormItem class="form-item-view-el" label="销售模式" prop="salesModel"> <FormItem
class="form-item-view-el"
label="销售模式"
prop="salesModel"
>
<RadioGroup <RadioGroup
type="button" type="button"
v-if="baseInfoForm.goodsType != 'VIRTUAL_GOODS'" v-if="baseInfoForm.goodsType != 'VIRTUAL_GOODS'"
@ -94,7 +109,10 @@
prop="goodsGalleryFiles" prop="goodsGalleryFiles"
> >
<div style="display: flex; flex-wrap: flex-start"> <div style="display: flex; flex-wrap: flex-start">
<vuedraggable :list="baseInfoForm.goodsGalleryFiles" :animation="200"> <vuedraggable
:list="baseInfoForm.goodsGalleryFiles"
:animation="200"
>
<div <div
class="demo-upload-list" class="demo-upload-list"
v-for="(item, __index) in baseInfoForm.goodsGalleryFiles" v-for="(item, __index) in baseInfoForm.goodsGalleryFiles"
@ -163,12 +181,15 @@
<Button <Button
type="primary" type="primary"
slot="extra" slot="extra"
@click="handleCloseSkuItem($index)" @click="handleCloseSkuItem(item, $index)"
> >
删除规格 删除规格
</Button> </Button>
<div> <Form :model="item" class="flex">
<FormItem label="规格名" class="sku-item-content-val flex"> <FormItem
label="规格名"
class="sku-item-content-val flex"
>
<AutoComplete <AutoComplete
style="width: 150px" style="width: 150px"
v-model="item.name" v-model="item.name"
@ -176,11 +197,11 @@
placeholder="请输入规格项名称" placeholder="请输入规格项名称"
:filter-method="filterMethod" :filter-method="filterMethod"
:data="skuData" :data="skuData"
@on-change="editSkuItem" @on-change="handleSkuTitle($event, $index)"
> >
</AutoComplete> </AutoComplete>
</FormItem> </FormItem>
</div> </Form>
<div class="flex sku-val"> <div class="flex sku-val">
<Form :model="item" class="flex"> <Form :model="item" class="flex">
<!--规格值文本列表--> <!--规格值文本列表-->
@ -200,7 +221,14 @@
:filter-method="filterMethod" :filter-method="filterMethod"
:data="skuVal" :data="skuVal"
@on-focus="changeSkuVals(item.name)" @on-focus="changeSkuVals(item.name)"
@on-change="skuValueChange(val.value, $index, item)" @on-change="
handleSkuValue(
val.value,
$index,
val,
index
)
"
> >
</AutoComplete> </AutoComplete>
<Button <Button
@ -215,7 +243,9 @@
</Form> </Form>
</div> </div>
<div> <div>
<Button @click="addSpec($index, item)">添加规格值</Button> <Button @click="addSpec($index, item)"
>添加规格值</Button
>
</div> </div>
</Card> </Card>
</div> </div>
@ -233,9 +263,97 @@
规格详细 规格详细
<div slot="content"> <div slot="content">
<div slot="content"> <div slot="content">
<ul class="flex sku-ul">
<li
v-for="(item, index) in skuTableColumn"
:key="index"
>
{{ item.title }}
</li>
</ul>
<div
class="mt_10 flex sku-editor"
v-for="(item, index) in skuTableData"
:key="index"
>
<div
v-for="(spec, specIndex) in skuTableColumn.filter(
(val) => {
return val.key;
}
)"
:key="specIndex"
>
{{
skuTableData[index][
spec.title || spec.key || spec.___key
]
}}
</div>
<div
v-if="
skuTableColumn.find((val) => {
return val.slot == 'weight';
})
"
>
<Input
clearable
:min="0"
v-model="item.weight"
placeholder="请输入重量"
@on-change="updateSkuTable(item, 'weight', index)"
/>
</div>
<div>
<Input
clearable
v-model="item.sn"
placeholder="请输入货号"
@on-change="updateSkuTable(item, 'sn', index)"
/>
</div>
<div>
<InputNumber
clearable
class="input-number"
:min="0"
v-model="item.quantity"
placeholder="请输入库存"
@on-change="updateSkuTable(item, 'quantity', index)"
/>
</div>
<div>
<InputNumber
clearable
class="input-number"
:min="0"
v-model="item.cost"
placeholder="请输入成本价"
@on-change="updateSkuTable(item, 'cost', index)"
/>
</div>
<div>
<InputNumber
class="input-number"
clearable
:min="0"
v-model="item.price"
placeholder="请输入价格"
@on-change="updateSkuTable(item, 'price', index)"
/>
</div>
<div>
<Button @click="editSkuPicture(item)"
>编辑图片</Button
>
</div>
</div>
<!-- #TODO 此处有待优化 --> <!-- #TODO 此处有待优化 -->
<Table <!-- <Table
class="mt_10"
:columns="skuTableColumn" :columns="skuTableColumn"
:data="skuTableData" :data="skuTableData"
style=" style="
@ -291,6 +409,15 @@
</template> </template>
<template slot-scope="{ row }" slot="images"> <template slot-scope="{ row }" slot="images">
<Button @click="editSkuPicture(row)"></Button> <Button @click="editSkuPicture(row)"></Button>
</template>
</Table> -->
</div>
</div>
</Panel>
</Collapse>
</div>
<Modal <Modal
v-model="showSkuPicture" v-model="showSkuPicture"
:styles="{ top: '30px' }" :styles="{ top: '30px' }"
@ -349,18 +476,15 @@
</div> </div>
</Upload> </Upload>
</Modal> </Modal>
</template>
</Table>
</div>
</div>
</Panel>
</Collapse>
</div>
</div> </div>
<h4>商品详情描述</h4> <h4>商品详情描述</h4>
<div class="form-item-view"> <div class="form-item-view">
<div class="tree-bar"> <div class="tree-bar">
<FormItem class="form-item-view-el" label="店内分类" prop="shopCategory"> <FormItem
class="form-item-view-el"
label="店内分类"
prop="shopCategory"
>
<Tree <Tree
ref="tree" ref="tree"
style="text-align: left" style="text-align: left"
@ -375,14 +499,25 @@
<FormItem class="form-item-view-el" label="商品描述" prop="intro"> <FormItem class="form-item-view-el" label="商品描述" prop="intro">
<editor eid="intro" v-model="baseInfoForm.intro"></editor> <editor eid="intro" v-model="baseInfoForm.intro"></editor>
</FormItem> </FormItem>
<FormItem class="form-item-view-el" label="移动端描述" prop="skuList"> <FormItem
<editor eid="mobileIntro" v-model="baseInfoForm.mobileIntro"></editor> class="form-item-view-el"
label="移动端描述"
prop="skuList"
>
<editor
eid="mobileIntro"
v-model="baseInfoForm.mobileIntro"
></editor>
</FormItem> </FormItem>
</div> </div>
<div v-if="baseInfoForm.goodsType != 'VIRTUAL_GOODS'"> <div v-if="baseInfoForm.goodsType != 'VIRTUAL_GOODS'">
<h4>商品物流信息</h4> <h4>商品物流信息</h4>
<div class="form-item-view"> <div class="form-item-view">
<FormItem class="form-item-view-el" label="物流模板" prop="templateId"> <FormItem
class="form-item-view-el"
label="物流模板"
prop="templateId"
>
<Select v-model="baseInfoForm.templateId" style="width: 200px"> <Select v-model="baseInfoForm.templateId" style="width: 200px">
<Option <Option
v-for="item in logisticsTemplate" v-for="item in logisticsTemplate"
@ -395,7 +530,11 @@
</div> </div>
<h4>其他信息</h4> <h4>其他信息</h4>
<div class="form-item-view"> <div class="form-item-view">
<FormItem class="form-item-view-el" label="商品发布" prop="release"> <FormItem
class="form-item-view-el"
label="商品发布"
prop="release"
>
<RadioGroup <RadioGroup
type="button" type="button"
button-style="solid" button-style="solid"
@ -409,7 +548,11 @@
</Radio> </Radio>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
<FormItem class="form-item-view-el" label="商品推荐" prop="skuList"> <FormItem
class="form-item-view-el"
label="商品推荐"
prop="skuList"
>
<RadioGroup <RadioGroup
type="button" type="button"
button-style="solid" button-style="solid"
@ -656,6 +799,7 @@ export default {
], ],
}; };
}, },
methods: { methods: {
/** /**
* 选择参数 * 选择参数
@ -674,14 +818,15 @@ export default {
}; };
} }
//id //id
this.baseInfoForm.goodsParamsDTOList[groupIndex].groupId = paramsGroup.groupId; this.baseInfoForm.goodsParamsDTOList[groupIndex].groupId =
this.baseInfoForm.goodsParamsDTOList[groupIndex].groupName = paramsGroup.groupName; paramsGroup.groupId;
this.baseInfoForm.goodsParamsDTOList[groupIndex].groupName =
paramsGroup.groupName;
// //
if ( if (
!this.baseInfoForm.goodsParamsDTOList[groupIndex].goodsParamsItemDTOList[ !this.baseInfoForm.goodsParamsDTOList[groupIndex]
paramsIndex .goodsParamsItemDTOList[paramsIndex]
]
) { ) {
this.baseInfoForm.goodsParamsDTOList[groupIndex].goodsParamsItemDTOList[ this.baseInfoForm.goodsParamsDTOList[groupIndex].goodsParamsItemDTOList[
paramsIndex paramsIndex
@ -707,7 +852,8 @@ export default {
}, },
// sku // sku
editSkuPicture(row) { editSkuPicture(row) {
if (row.images && row.images.length > 0) { console.log(row);
if (row.images && row.images.length) {
this.previewPicture = row.images[0].url; this.previewPicture = row.images[0].url;
} }
this.selectedSku = row; this.selectedSku = row;
@ -724,7 +870,9 @@ export default {
}, },
// //
handleRemove(item, index) { handleRemove(item, index) {
this.selectedSku.images = this.selectedSku.images.filter((i) => i.url !== item.url); this.selectedSku.images = this.selectedSku.images.filter(
(i) => i.url !== item.url
);
if (this.selectedSku.images.length > 0 && index === 0) { if (this.selectedSku.images.length > 0 && index === 0) {
this.previewPicture = this.selectedSku.images[0].url; this.previewPicture = this.selectedSku.images[0].url;
} else if (this.selectedSku.images.length < 0) { } else if (this.selectedSku.images.length < 0) {
@ -738,9 +886,8 @@ export default {
}, },
// //
handleRemoveGoodsPicture(file) { handleRemoveGoodsPicture(file) {
this.baseInfoForm.goodsGalleryFiles = this.baseInfoForm.goodsGalleryFiles.filter( this.baseInfoForm.goodsGalleryFiles =
(i) => i.url !== file.url this.baseInfoForm.goodsGalleryFiles.filter((i) => i.url !== file.url);
);
}, },
// sku // sku
updateSkuPicture() { updateSkuPicture() {
@ -762,7 +909,6 @@ export default {
}, },
// //
handleSuccessGoodsPicture(res, file) { handleSuccessGoodsPicture(res, file) {
console.log(res);
if (file.response) { if (file.response) {
file.url = file.response.result; file.url = file.response.result;
this.baseInfoForm.goodsGalleryFiles.push(file); this.baseInfoForm.goodsGalleryFiles.push(file);
@ -795,7 +941,8 @@ export default {
// sku // sku
handleBeforeUpload(file) { handleBeforeUpload(file) {
const check = const check =
this.selectedSku.images !== undefined && this.selectedSku.images.length > 5; this.selectedSku.images !== undefined &&
this.selectedSku.images.length > 5;
if (check) { if (check) {
this.$Notice.warning({ title: "图片数量不能大于五张" }); this.$Notice.warning({ title: "图片数量不能大于五张" });
return false; return false;
@ -804,9 +951,11 @@ export default {
/** 查询商品品牌列表 */ /** 查询商品品牌列表 */
getGoodsBrandList() { getGoodsBrandList() {
API_GOODS.getCategoryBrandListDataSeller(this.categoryId).then((response) => { API_GOODS.getCategoryBrandListDataSeller(this.categoryId).then(
(response) => {
this.brandList = response; this.brandList = response;
}); }
);
}, },
// //
GET_GoodsUnit() { GET_GoodsUnit() {
@ -860,12 +1009,11 @@ export default {
response.result.goodsGalleryList && response.result.goodsGalleryList &&
response.result.goodsGalleryList.length > 0 response.result.goodsGalleryList.length > 0
) { ) {
this.baseInfoForm.goodsGalleryFiles = response.result.goodsGalleryList.map( this.baseInfoForm.goodsGalleryFiles =
(i) => { response.result.goodsGalleryList.map((i) => {
let files = { url: i }; let files = { url: i };
return files; return files;
} });
);
} }
this.Get_SkuInfoByCategory(this.categoryId); this.Get_SkuInfoByCategory(this.categoryId);
@ -892,12 +1040,18 @@ export default {
cost: e.cost, cost: e.cost,
quantity: e.quantity, quantity: e.quantity,
weight: e.weight, weight: e.weight,
// ___keys: [],
}; };
e.specList.forEach((u) => { e.specList.forEach((u) => {
if (u.specName === "images") { if (u.specName === "images") {
sku.images = u.specImage; sku.images = u.specImage;
} else { } else {
sku[u.specName] = u.specValue; sku[u.specName] = u.specValue;
// keys
// sku.___keys.push({
// key: u.specName,
// value: u.specValue,
// });
if ( if (
!skusInfo.some((s) => s.name === u.specName) && !skusInfo.some((s) => s.name === u.specName) &&
!this.ignoreColumn.includes(u.specName) !this.ignoreColumn.includes(u.specName)
@ -910,6 +1064,7 @@ export default {
id: u.specValueId, id: u.specValueId,
name: u.specName, name: u.specName,
value: u.specValue || "", value: u.specValue || "",
___key: u.specValue || "",
}, },
], ],
}); });
@ -923,6 +1078,7 @@ export default {
id: u.specValueId, id: u.specValueId,
name: u.specName, name: u.specName,
value: u.specValue || "", value: u.specValue || "",
___key: u.specValue || "",
}); });
} }
if (!sk.spec_id && u.specName === "specId") { if (!sk.spec_id && u.specName === "specId") {
@ -937,12 +1093,14 @@ export default {
}); });
this.skuInfo = skusInfo; this.skuInfo = skusInfo;
this.renderTableData(); this.renderTableData();
this.skuTableData = skus; this.skuTableData = skus;
}, },
/** 根据当前分类id查询商品应包含的参数 */ /** 根据当前分类id查询商品应包含的参数 */
GET_GoodsParams() { GET_GoodsParams() {
API_GOODS.getCategoryParamsListDataSeller(this.categoryId).then((response) => { API_GOODS.getCategoryParamsListDataSeller(this.categoryId).then(
(response) => {
if (!response || response.length <= 0) { if (!response || response.length <= 0) {
return; return;
} }
@ -974,7 +1132,8 @@ export default {
} else { } else {
this.baseInfoForm.goodsParamsDTOList = []; this.baseInfoForm.goodsParamsDTOList = [];
} }
}); }
);
}, },
/** 添加规格项 */ /** 添加规格项 */
addSkuItem() { addSkuItem() {
@ -985,18 +1144,11 @@ export default {
// //
this.$set(this.skuInfo, this.skuInfo.length, { this.$set(this.skuInfo, this.skuInfo.length, {
spec_values: [], spec_values: [],
name: "规格名", name: "规格名" + (this.skuInfo.length + 1),
}); });
this.renderTableData(); // this.renderTableData();
},
//
editSkuItem() {
this.renderTableData();
},
//
async skuValueChange(val, index, item) {
this.renderTableData();
}, },
// //
changeSkuVals(name) { changeSkuVals(name) {
if (name) { if (name) {
@ -1009,14 +1161,7 @@ export default {
}); });
} }
}, },
/** 移除当前规格项 进行数据变化*/
handleCloseSkuItem($index) {
this.skuInfo.splice($index, 1);
/**
* 渲染规格详细表格
*/
this.renderTableData();
},
// //
validateEmpty(params) { validateEmpty(params) {
let flag = true; let flag = true;
@ -1042,6 +1187,7 @@ export default {
this.$set(item.spec_values, item.spec_values.length, { this.$set(item.spec_values, item.spec_values.length, {
name: item.name, name: item.name,
value: "", value: "",
___key: "",
}); });
this.baseInfoForm.regeneratorSkuFlag = true; this.baseInfoForm.regeneratorSkuFlag = true;
/** /**
@ -1051,27 +1197,99 @@ export default {
} }
}, },
/** 移除当前规格值 */ /** 移除当前规格项 进行数据变化*/
handleCloseSkuValue(item, index) { handleCloseSkuItem(item, $index) {
item.spec_values.splice(index, 1); console.log(item);
let oldsSkuTableData = cloneObj(this.skuTableData);
oldsSkuTableData.forEach((sku, i) => {
if (sku[item.name]) {
delete sku[item.name];
}
});
this.skuTableData = oldsSkuTableData;
this.skuTableColumn.forEach((column, i) => {
if (column.key == item.name) {
this.skuTableColumn.splice(i, 1);
}
});
this.skuInfo.splice($index, 1);
},
this.baseInfoForm.regeneratorSkuFlag = true;
/** /**
* 渲染规格详细表格 * 移除当前规格值
* 找到一样规格的值进行移出
*/ */
this.renderTableData(); handleCloseSkuValue(item, index) {
let oldsSkuTableData = cloneObj(this.skuTableData);
console.log("oldsSkuTableData", oldsSkuTableData);
this.skuTableData = oldsSkuTableData.filter((sku, i) => {
if (
sku[item.spec_values[index].name] != item.spec_values[index].value
) {
return sku;
}
});
item.spec_values.splice(index, 1);
this.baseInfoForm.regeneratorSkuFlag = true;
},
/**
* 编辑规格值
* 根据当前___keys的索引指定需修改的值
* @param {*} change 返回input更改的值
* @param {*} index 修改规格名的索引
* @param {*} item 当前规格值
*/
async handleSkuValue(change, index, item) {
this.skuTableData.map((sku, i) => {
// key
if (sku[item.name] == item.___key) {
sku[item.name] = change;
console.log(1);
} else if (!item.___key && !sku[item.name]) {
//
sku[item.name] = change;
console.log("赋值", sku);
}
});
item.___key = change;
},
/**
* 编辑规格名
* 根据修改的规格名将skuTableData的key(规格名)进行修改
* @param {*} change 返回input更改的值
* @param {*} index 修改规格名的索引
*/
handleSkuTitle(change, index) {
let oldSkuTableColumn = cloneObj(this.skuTableColumn);
this.skuTableData.forEach((sku, i) => {
Object.keys(sku).forEach((key) => {
if (oldSkuTableColumn[index].key == key) {
// sku
sku = {
[change]: sku[key],
...sku,
};
delete sku[key];
this.skuTableData[i] = sku;
}
});
});
this.skuTableColumn[index].key = change;
this.skuTableColumn[index].title = change;
}, },
/** /**
* 渲染table所需要的column data * 渲染table所需要的column data
*/ */
renderTableData() { renderTableData() {
this.skuTableColumn = [];
this.skuTableData = [];
let pushData = []; let pushData = [];
// //
this.skuInfo.forEach((sku) => { this.skuInfo.forEach((sku) => {
// !sku.name ? (sku.name = "") : "";
// //
let columnName = sku.name; let columnName = sku.name;
pushData.push({ pushData.push({
@ -1112,14 +1330,20 @@ export default {
this.skuTableColumn = pushData; this.skuTableColumn = pushData;
// //
let cloneTemp = cloneObj(this.skuInfo); let cloneTemp = cloneObj(this.skuInfo);
if (cloneTemp.length) {
cloneTemp.map((temp) => {
return {
[temp.name]: temp.value,
images: this.baseInfoForm.goodsGalleryFiles || [],
};
});
}
//
this.$set(this, "skuTableData", []);
// //
if (cloneTemp[0]) { if (cloneTemp[0]) {
// //
let result = []; let result = [];
// sku //
cloneTemp[0].spec_values.forEach((specItem) => { cloneTemp[0].spec_values.forEach((specItem) => {
result.push({ result.push({
[cloneTemp[0].name]: specItem.value, [cloneTemp[0].name]: specItem.value,
@ -1128,8 +1352,14 @@ export default {
}); });
cloneTemp.splice(0, 1); cloneTemp.splice(0, 1);
result = this.specIterator(result, cloneTemp); result = this.specIterator(result, cloneTemp);
// skuTable
let oldData = cloneObj(this.skuTableData);
this.skuTableData = result; this.skuTableData = result;
console.log(this.skuTableData); // skuTable
this.skuTableData = Object.assign(this.skuTableData, oldData);
console.log(result, this.skuTableData);
} }
}, },
/** /**
@ -1141,16 +1371,25 @@ export default {
// //
if (cloneTemp.length > 0) { if (cloneTemp.length > 0) {
let table = []; let table = [];
result.forEach((resItem) => { let newVal = []; //
result.forEach((resItem, i) => {
cloneTemp[0].spec_values.forEach((valItem) => { cloneTemp[0].spec_values.forEach((valItem) => {
let obj = cloneObj(resItem); let obj = cloneObj(resItem);
obj[cloneTemp[0].name] = valItem.value; obj[cloneTemp[0].name] = valItem.value;
if (valItem.value) {
table.push(obj); table.push(obj);
} else {
newVal.push(obj);
}
}); });
}); });
result = []; result = [];
table.push(...newVal);
table.forEach((t) => { table.forEach((t) => {
console.log("t", t);
result.push(t); result.push(t);
}); });
// //
@ -1160,6 +1399,7 @@ export default {
} }
return this.specIterator(result, cloneTemp); return this.specIterator(result, cloneTemp);
}, },
/** 根据分类id获取系统设置规格信息*/ /** 根据分类id获取系统设置规格信息*/
Get_SkuInfoByCategory(categoryId) { Get_SkuInfoByCategory(categoryId) {
if (categoryId) { if (categoryId) {
@ -1179,8 +1419,7 @@ export default {
return option.toUpperCase().indexOf(value.toUpperCase()) !== -1; return option.toUpperCase().indexOf(value.toUpperCase()) !== -1;
}, },
/** 数据改变之后 抛出数据 */ /** 数据改变之后 抛出数据 */
updateSkuTable(row, item, type = "deafult") { updateSkuTable(row, item, index) {
let index = row._index;
this.baseInfoForm.regeneratorSkuFlag = true; this.baseInfoForm.regeneratorSkuFlag = true;
/** 进行自定义校验 判断是否是数字(小数也能通过)重量 */ /** 进行自定义校验 判断是否是数字(小数也能通过)重量 */
if (item === "weight") { if (item === "weight") {
@ -1218,6 +1457,7 @@ export default {
} }
} }
this.$nextTick(() => { this.$nextTick(() => {
console.log(index, item);
this.skuTableData[index][item] = row[item]; this.skuTableData[index][item] = row[item];
}); });
// this.$set(this.skuTableData,[index][item],row[item]) // this.$set(this.skuTableData,[index][item],row[item])
@ -1257,7 +1497,10 @@ export default {
this.$refs["baseInfoForm"].validate((valid) => { this.$refs["baseInfoForm"].validate((valid) => {
if (valid) { if (valid) {
let submit = JSON.parse(JSON.stringify(this.baseInfoForm)); let submit = JSON.parse(JSON.stringify(this.baseInfoForm));
if (submit.goodsGalleryFiles && submit.goodsGalleryFiles.length <= 0) { if (
submit.goodsGalleryFiles &&
submit.goodsGalleryFiles.length <= 0
) {
this.submitLoading = false; this.submitLoading = false;
this.$Message.error("请上传商品图片"); this.$Message.error("请上传商品图片");
return; return;
@ -1281,13 +1524,17 @@ export default {
}); });
if (submit.goodsGalleryFiles.length > 0) { if (submit.goodsGalleryFiles.length > 0) {
submit.goodsGalleryList = submit.goodsGalleryFiles.map((i) => i.url); submit.goodsGalleryList = submit.goodsGalleryFiles.map(
(i) => i.url
);
} }
/** 参数校验 **/ /** 参数校验 **/
/* Object.keys(submit.goodsParamsList).forEach((item) => { /* Object.keys(submit.goodsParamsList).forEach((item) => {
});*/ });*/
submit.release ? (submit.release = true) : (submit.release = false); submit.release ? (submit.release = true) : (submit.release = false);
submit.recommend ? (submit.recommend = true) : (submit.recommend = false); submit.recommend
? (submit.recommend = true)
: (submit.recommend = false);
if (this.goodsId) { if (this.goodsId) {
API_GOODS.editGoods(this.goodsId, submit).then((res) => { API_GOODS.editGoods(this.goodsId, submit).then((res) => {
@ -1320,9 +1567,8 @@ export default {
saveToDraft() { saveToDraft() {
this.baseInfoForm.skuList = this.skuTableData; this.baseInfoForm.skuList = this.skuTableData;
if (this.baseInfoForm.goodsGalleryFiles.length > 0) { if (this.baseInfoForm.goodsGalleryFiles.length > 0) {
this.baseInfoForm.goodsGalleryList = this.baseInfoForm.goodsGalleryFiles.map( this.baseInfoForm.goodsGalleryList =
(i) => i.url this.baseInfoForm.goodsGalleryFiles.map((i) => i.url);
);
} }
this.baseInfoForm.categoryName = []; this.baseInfoForm.categoryName = [];
this.baseInfoForm.saveType = "TEMPLATE"; this.baseInfoForm.saveType = "TEMPLATE";
@ -1412,4 +1658,30 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./addGoods.scss"; @import "./addGoods.scss";
.sku-ul {
align-items: center;
padding: 10px 0;
border-radius: 0.4em;
background: #f3f5f7;
> li {
flex: 1;
text-align: center;
font-weight: bold;
padding: 10px;
}
}
.sku-editor {
> div {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
padding: 10px;
}
}
.input-number {
width: 100%;
}
</style> </style>