商品共有元素 - 新增

master
DongZeLiang 2024-03-07 10:34:52 +08:00
parent 50ceef857a
commit a1f08feb16
1 changed files with 32 additions and 9 deletions

View File

@ -241,9 +241,9 @@
<el-tab-pane label="商品属性" name="attribute"> <el-tab-pane label="商品属性" name="attribute">
<el-row style="overflow-x: auto; height: 300px;"> <el-row style="overflow-x: auto; height: 300px;">
<el-form ref="form" :model="form" label-width="80px"> <el-form ref="form" :model="form" label-width="80px">
<el-col :span="6" v-for="index in 10"> <el-col :span="6" v-for="templateAttribute in categoryCommonElement.templateAttributeList">
<el-form-item :label="'属性'+index"> <el-form-item :label="templateAttribute.name" >
<el-input v-model="form.name"></el-input> <el-input v-model="templateAttribute.value"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-form> </el-form>
@ -278,9 +278,9 @@
<span>选择属性</span> <span>选择属性</span>
</div> </div>
<el-row style="height: 80px; overflow-y: auto"> <el-row style="height: 80px; overflow-y: auto">
<el-checkbox-group v-model="attributeCheckedList"> <el-checkbox-group v-model="attributeIdCheckedList" @change="attributeCheckedFun">
<el-col :span="4" v-for="index in 40" style="margin: 5px 0"> <el-col :span="4" v-for="attribute in categoryCommonElement.attributeList" style="margin: 5px 0">
<el-checkbox :label="'复选框'+index" border></el-checkbox> <el-checkbox :label="attribute.id" :value="attribute.id" :key="attribute.id" border>{{attribute.name}}</el-checkbox>
</el-col> </el-col>
</el-checkbox-group> </el-checkbox-group>
</el-row> </el-row>
@ -291,9 +291,9 @@
</div> </div>
<el-row style="overflow-x: auto; height: 300px;"> <el-row style="overflow-x: auto; height: 300px;">
<el-form ref="form" :model="form" label-width="80px"> <el-form ref="form" :model="form" label-width="80px">
<el-col :span="6" v-for="index in 10"> <el-col :span="6" v-for="attribute in attributeCheckedList">
<el-form-item :label="'属性'+index"> <el-form-item :label="attribute.name">
<el-input v-model="form.name"></el-input> <el-input v-model="attribute.value"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-form> </el-form>
@ -396,6 +396,7 @@ export default {
}, },
customPropertiesFormStatus: false, customPropertiesFormStatus: false,
attributeIdCheckedList: [],
attributeCheckedList: [], attributeCheckedList: [],
categoryCommonElement: { categoryCommonElement: {
templateAttributeGroupList: [], templateAttributeGroupList: [],
@ -438,6 +439,28 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
attributeCheckedFun(checkedValue) {
console.log(checkedValue)
// attributeIdCheckedList -> attributeCheckedList
// 1 -> ID 1 : attributeCheckedList[] -> 1
// 2 -> ID 3 : attributeCheckedList[1] -> 3
let attributeId =this.attributeIdCheckedList
.find(attributeId =>
this.attributeCheckedList.map(attributeChecked => attributeChecked.id).indexOf(attributeId) === -1
)
if (attributeId !== undefined){
let attributeInfo = this.categoryCommonElement.attributeList.find(attributeInfo => attributeInfo.id === attributeId);
this.attributeCheckedList.push(attributeInfo);
}else {
// attributeIdCheckedList [3] : attributeCheckedList [] -> [3]
// attributeIdCheckedList [3,5] : attributeCheckedList [3] -> [3,5]
// attributeIdCheckedList [3,5,9] : attributeCheckedList [3,5] -> [3,5,9]
// attributeIdCheckedList [3,9] : attributeCheckedList [3,5,9] -> [3,9]
// attributeCheckedList attributeIdCheckedList
}
},
initRuleList(){ initRuleList(){
listRule({"params[isPage]": false}).then(response => { listRule({"params[isPage]": false}).then(response => {
this.ruleList = response.data; this.ruleList = response.data;