商品规格回显
parent
8520ca21ea
commit
c24b09d95a
|
@ -335,14 +335,15 @@
|
|||
<el-table
|
||||
:data="skuList"
|
||||
border
|
||||
max-height="500"
|
||||
style="width: 100%">
|
||||
<el-table-column v-for="title in titleList" :prop="title.prop" :label="title.label">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="title.prop.indexOf('prop') > -1">{{scope.row[title.prop]}}</span>
|
||||
<el-input-number v-else-if="['stock','price'].indexOf(title.prop) > -1" v-model="scope.row[title.prop]" :precision="2" :step="0.01"></el-input-number>
|
||||
<image-upload v-else-if="['image'].indexOf(title.prop) > -1" v-model="scope.row[title.prop]"
|
||||
:limit="1"
|
||||
:is-show-tip="false"
|
||||
:limit="1"
|
||||
:is-show-tip="false"
|
||||
></image-upload>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -410,7 +411,14 @@ export default {
|
|||
brandId: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
form: {
|
||||
mianType: '',
|
||||
parentType: '',
|
||||
type:'',
|
||||
image: '',
|
||||
price: '',
|
||||
stock: ''
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [
|
||||
|
@ -495,7 +503,6 @@ export default {
|
|||
},
|
||||
"form.type": {
|
||||
handler(value) {
|
||||
console.log(value)
|
||||
if (value != null){
|
||||
getTemplateAttribute(value).then(response => {
|
||||
const {data} = response;
|
||||
|
@ -515,6 +522,7 @@ export default {
|
|||
methods: {
|
||||
oneSetting(){
|
||||
this.skuList.forEach(skuInfo => {
|
||||
console.log(skuInfo)
|
||||
skuInfo.image = this.oneSettingForm.image;
|
||||
skuInfo.stock = this.oneSettingForm.stock;
|
||||
skuInfo.price = this.oneSettingForm.price;
|
||||
|
@ -523,7 +531,11 @@ export default {
|
|||
changeRule(ruleId){
|
||||
this.titleList = []
|
||||
let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id === ruleId);
|
||||
|
||||
const {ruleAttrList} = ruleInfo;
|
||||
|
||||
console.log(ruleInfo)
|
||||
console.log(ruleAttrList)
|
||||
let skuTotal = 1;
|
||||
for (let ruleAttrListKey in ruleAttrList) {
|
||||
let ruleAttrInfo = ruleAttrList[ruleAttrListKey];
|
||||
|
@ -534,7 +546,6 @@ export default {
|
|||
skuTotal = skuTotal * ruleAttrInfo.valueList.length;
|
||||
}
|
||||
this.titleList.push(...this.templateTitleList) ;
|
||||
console.log(this.titleList);
|
||||
this.skuList = [];
|
||||
for (let i = 0; i < skuTotal; i++) {
|
||||
this.skuList.push(
|
||||
|
@ -573,9 +584,9 @@ export default {
|
|||
if (response.code === 200){
|
||||
// 添加逻辑
|
||||
let attributeId = response.data,
|
||||
code = this.customAttributeForm.code,
|
||||
name = this.customAttributeForm.name,
|
||||
value = this.customAttributeForm.value;
|
||||
code = this.customAttributeForm.code,
|
||||
name = this.customAttributeForm.name,
|
||||
value = this.customAttributeForm.value;
|
||||
// categoryCommonElement / attributeIdCheckedList / attributeCheckedList
|
||||
this.categoryCommonElement.attributeList.push({
|
||||
"id": attributeId,
|
||||
|
@ -626,7 +637,6 @@ export default {
|
|||
listCategory().then(response => {
|
||||
this.categoryOptions = [];
|
||||
this.categoryOptions = this.handleTree(response.data, "id", "parentId");
|
||||
console.log(this.categoryOptions)
|
||||
});
|
||||
},
|
||||
remoteSearchBrandList(queryValue){
|
||||
|
@ -640,7 +650,7 @@ export default {
|
|||
next() {
|
||||
let isValidate = true;
|
||||
this.$refs["form"].validateField(this.rulesTemplateMap[this.stepNumber],(valid) => {
|
||||
console.log(valid)
|
||||
|
||||
if (valid) {
|
||||
isValidate = false;
|
||||
}
|
||||
|
@ -713,24 +723,69 @@ export default {
|
|||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids
|
||||
|
||||
getInfo(id).then(response => {
|
||||
|
||||
console.log(response)
|
||||
this.form = response.data;
|
||||
|
||||
this.initCategoryTree()
|
||||
this.form.mianType=parseInt(response.data.mianType)
|
||||
this.form.type=parseInt(response.data.type)
|
||||
|
||||
this.oneSettingForm = response.data.productSkuModel
|
||||
this.changeRule(response.data.ruleId)
|
||||
this.oneSetting()
|
||||
this.open = true;
|
||||
this.title = "修改商品信息";
|
||||
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
let attrValueList = [];
|
||||
for (const templateAttributeGroup of this.categoryCommonElement.templateAttributeGroupList) {
|
||||
templateAttributeGroup.attributeList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value}))
|
||||
}
|
||||
|
||||
this.categoryCommonElement.templateAttributeList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value}))
|
||||
this.attributeCheckedList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value}))
|
||||
let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id === this.form.ruleId);
|
||||
const {ruleAttrList} = ruleInfo;
|
||||
let ruleAttrSize = ruleAttrList.length;
|
||||
let productSkuList = this.skuList.map(skuInfo => {
|
||||
let sku = "";
|
||||
for (let index = 0; ; index++) {
|
||||
sku += skuInfo["prop"+index];
|
||||
if (index+1 >= ruleAttrSize){
|
||||
break;
|
||||
}else {
|
||||
sku += "-";
|
||||
}
|
||||
}
|
||||
return {
|
||||
sku: sku,
|
||||
image: skuInfo.image,
|
||||
stock: skuInfo.stock,
|
||||
price: skuInfo.price
|
||||
}
|
||||
})
|
||||
let productAddReq = {
|
||||
projectAddModel: this.form,
|
||||
attrValueList: attrValueList,
|
||||
productSkuList: productSkuList
|
||||
};
|
||||
console.log(productAddReq)
|
||||
if (this.form.id != null) {
|
||||
updateInfo(this.form).then(response => {
|
||||
updateInfo(productAddReq).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addInfo(this.form).then(response => {
|
||||
addInfo(productAddReq).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
|
|
Loading…
Reference in New Issue