商品自由属性 完善
parent
1d8134c5eb
commit
095fc4d78a
|
@ -216,7 +216,8 @@ export default {
|
|||
introduction: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
form: {
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
name: [
|
||||
|
@ -261,6 +262,7 @@ export default {
|
|||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
|
||||
/** 查询品类信息列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
|
@ -346,6 +348,7 @@ export default {
|
|||
this.getTreeselect();
|
||||
if (row != null) {
|
||||
this.form.parentId = row.parentId;
|
||||
this.form.attributeIdList
|
||||
}
|
||||
getCategory(row.id).then(response => {
|
||||
this.form = response.data;
|
||||
|
@ -364,6 +367,7 @@ export default {
|
|||
this.getList();
|
||||
});
|
||||
} else {
|
||||
console.log(this.form)
|
||||
addCategory(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
|
|
|
@ -163,7 +163,7 @@
|
|||
<el-radio-group v-model="form.status">
|
||||
<el-radio
|
||||
v-for="dict in dict.type.sys_yes_no"
|
||||
:key="dict.value"
|
||||
:key="dict.id"
|
||||
:label="dict.value"
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
|
@ -184,12 +184,12 @@
|
|||
<el-option
|
||||
v-for="brand in brandList"
|
||||
:key="brand.id"
|
||||
:label="brand.name"
|
||||
:label="brand.nam"
|
||||
:value="brand.id">
|
||||
<el-row>
|
||||
<image-preview :height="40" :width="40" :src="brand.logo" style="float: left;"/>
|
||||
<div style="float: left;
|
||||
margin: 2px 18px 0 15px; font-size: 20px;">{{brand.name}}</div>
|
||||
margin: 2px 10px 0 15px; font-size: 20px;color: #787be8">{{brand.nam}}</div>
|
||||
</el-row>
|
||||
</el-option>
|
||||
</el-select>
|
||||
|
@ -307,7 +307,7 @@
|
|||
</div>
|
||||
<div v-show="stepNumber === 2">
|
||||
<el-form-item label="规格" prop="ruleId">
|
||||
<el-select v-model="form.ruleId" placeholder="请选择" style="width: 100%;">
|
||||
<el-select v-model="form.ruleId" placeholder="请选择" @change="changeRule" style="width: 100%;">
|
||||
<el-option
|
||||
v-for="rule in ruleList"
|
||||
:key="rule.id"
|
||||
|
@ -317,6 +317,42 @@
|
|||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form :inline="true" :model="oneSettingForm" class="demo-from-inline">
|
||||
<el-form-item label="图片">
|
||||
<image-upload
|
||||
:limit="1"
|
||||
:is-show-tip="false"
|
||||
v-model="oneSettingForm.image" placeholder="审批人"></image-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="价格">
|
||||
<el-input v-model="oneSettingForm.price" placeholder="价格"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="库存">
|
||||
<el-input v-model="oneSettingForm.stock" placeholder="库存"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item >
|
||||
<el-button type="primary" @click="oneSetting" >一键设置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table
|
||||
:data="skuList"
|
||||
border
|
||||
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">
|
||||
</image-upload>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div v-show="stepNumber === 3">
|
||||
<el-form-item label="商品描述">
|
||||
|
@ -395,7 +431,7 @@ export default {
|
|||
categoryOptions: [],
|
||||
categoryOptionValue: [],
|
||||
ruleList: [],
|
||||
activeName: "attributeName",
|
||||
activeName: "attributeGroup",
|
||||
customAttributeForm: {
|
||||
|
||||
},
|
||||
|
@ -406,6 +442,26 @@ export default {
|
|||
templateAttributeGroupList: [],
|
||||
templateAttributeList: [],
|
||||
attributeList: []
|
||||
},
|
||||
templateTitleList: [
|
||||
{
|
||||
"label":"规格图片",
|
||||
"prop":"image"
|
||||
},
|
||||
{
|
||||
"label":"商品库存",
|
||||
"prop":"stock"
|
||||
},{
|
||||
"label":"商品价格",
|
||||
"prop":"price"
|
||||
}
|
||||
],
|
||||
titleList: [],
|
||||
skuList: [],
|
||||
oneSettingForm: {
|
||||
"image":null,
|
||||
"stock": null,
|
||||
"price": null
|
||||
}
|
||||
};
|
||||
},
|
||||
|
@ -444,30 +500,88 @@ export default {
|
|||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
oneSetting(){
|
||||
this.skuList.forEach(skuInfo => {
|
||||
skuInfo.image = this.oneSettingForm.image,
|
||||
skuInfo.stock = this.oneSettingForm.stock,
|
||||
skuInfo.price = this.oneSettingForm.price
|
||||
})
|
||||
},
|
||||
changeRule(ruleId){
|
||||
this.titleList = []
|
||||
let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id === ruleId);
|
||||
const {ruleAttrList} = ruleInfo;
|
||||
let skuTotal = 1;
|
||||
for (let ruleAttrListKey in ruleAttrList) {
|
||||
let ruleAttrInfo = ruleAttrList[ruleAttrListKey];
|
||||
this.titleList.push({
|
||||
"label":ruleAttrInfo.name,
|
||||
"prop":"prop"+ruleAttrListKey
|
||||
})
|
||||
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(
|
||||
{
|
||||
"image": null,
|
||||
"price": 85.62,
|
||||
"stock": 236
|
||||
}
|
||||
);
|
||||
}
|
||||
// currentIndex 当前下标
|
||||
for (let currentIndex in ruleAttrList) {
|
||||
let ruleAttrInfo = ruleAttrList[currentIndex];
|
||||
// 连续出现次数 循环出现次数
|
||||
let continuousSize = 1, forSize = 1;
|
||||
for (let continuousIndex = parseInt(currentIndex) + 1 ; continuousIndex < ruleAttrList.length ; continuousIndex++ ){
|
||||
continuousSize = continuousSize * ruleAttrList[continuousIndex].valueList.length;
|
||||
}
|
||||
for (let forIndex = parseInt(currentIndex) - 1; forIndex >= 0; forIndex--){
|
||||
forSize = forSize * ruleAttrList[forIndex].valueList.length
|
||||
}
|
||||
console.log(`${ruleAttrInfo.name} 规格 连续出现次数:${continuousSize} 循环出现次数:${forSize}`)
|
||||
let counter = 0;
|
||||
for (let forIndex = 0; forIndex < forSize; forIndex++) {
|
||||
const {valueList} = ruleAttrInfo;
|
||||
valueList.forEach(value => {
|
||||
for (let continuousIndex = 0; continuousIndex < continuousSize; continuousIndex++) {
|
||||
this.skuList[counter++]["prop"+currentIndex] = value;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
saveCustomAttribute(){
|
||||
addAttribute({"code": this.customAttributeForm.code, "name": this.customAttributeForm.name}).then(response => {
|
||||
if (response.code === 200){
|
||||
// 添加逻辑
|
||||
console.log(response)
|
||||
let attributeId = response.data,
|
||||
code = this.customAttributeForm.code,
|
||||
name = this.customAttributeForm.name,
|
||||
value = this.customAttributeForm.value;
|
||||
// categoryCommonElement / attributeIdCheckedList / attributeCheckedList
|
||||
this.categoryCommonElement.attributeList.push({
|
||||
"id":attributeId,
|
||||
"name":name,
|
||||
"code":code
|
||||
"id": attributeId,
|
||||
"name": name,
|
||||
"code": code
|
||||
});
|
||||
this.attributeIdCheckedList.push(attributeId);
|
||||
this.attributeCheckedList.push({
|
||||
"id":attributeId,
|
||||
"name":name,
|
||||
"value":value
|
||||
});
|
||||
this.customAttributeForm = {}
|
||||
this.customAttributeFormStatus = false;
|
||||
}
|
||||
this.attributeCheckedList.push(
|
||||
{
|
||||
"id": attributeId,
|
||||
"name": name,
|
||||
"value": value
|
||||
}
|
||||
);
|
||||
this.customAttributeForm = {}
|
||||
this.customAttributeFormStatus = false
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
attributeCheckedFun() {
|
||||
// attributeIdCheckedList -> attributeCheckedList 不在
|
||||
|
@ -493,7 +607,9 @@ export default {
|
|||
},
|
||||
initRuleList(){
|
||||
listRule({"params[isPage]": false}).then(response => {
|
||||
this.ruleList = response.data.result;
|
||||
console.log(response)
|
||||
this.ruleList = response.data.rows;
|
||||
console.log(this.ruleList)
|
||||
});
|
||||
},
|
||||
initCategoryTree(){
|
||||
|
@ -504,8 +620,10 @@ export default {
|
|||
});
|
||||
},
|
||||
remoteSearchBrandList(queryValue){
|
||||
listBrand({"name": queryValue, "params[isPage]": false}).then(response => {
|
||||
this.brandList = response.data;
|
||||
listBrand({"nam": queryValue, "params[isPage]": false}).then(response => {
|
||||
this.brandList = response.data.rows;
|
||||
console.log(response)
|
||||
console.log(this.brandList)
|
||||
});
|
||||
},
|
||||
last() {
|
||||
|
|
Loading…
Reference in New Issue