属性组多选及取消

day-04
Saisai Liu 2024-03-01 21:27:03 +08:00
parent 02662998c0
commit f764ff6e0e
1 changed files with 43 additions and 23 deletions

View File

@ -137,19 +137,21 @@
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>属性关联关系</span> <span>属性关联关系</span>
</div> </div>
<el-card class="box-card" > <el-card class="box-card" >
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>已选属性</span> <span>已选属性</span>
{{this.form.checkedAttributeIds}}
</div> </div>
<el-row :gutter="20" style="margin: 0 10px"> <el-row :gutter="20" style="height: 100px">
<el-col :span="3" v-for="(attribute,index) in checkedAttribute">
<el-tag <el-tag
v-for="attribute in checkedAttribute" style="margin: 0 10px"
:key="attribute.id" :key="attribute.name"
closable closable
@close="handleClose(attribute)"> @close="removeCheck(index)">
{{attribute.name}} {{attribute.name}}
</el-tag> </el-tag>
</el-col>
</el-row> </el-row>
</el-card> </el-card>
@ -158,18 +160,20 @@
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>可选属性</span> <span>可选属性</span>
</div> </div>
<el-checkbox-group <el-row>
v-model="checkedAttribute"> <el-col :span="3" v-for="attribute in attributeList">
<el-checkbox <el-checkbox
v-for="attribute in attributeList" v-model="form.checkedAttributeIds"
:value="attribute" :value="attribute.id"
:key="attribute.id" :key="attribute.id"
:label="attribute" :label="attribute.id"
@change="handleCheckedAttributeChange(attribute)" @change="handleCheckedAttributeChange(attribute)"
> border>
{{attribute.name}} {{attribute.id}}
</el-checkbox> {{attribute.name}}
</el-checkbox-group> </el-checkbox>
</el-col>
</el-row>
</el-card> </el-card>
</el-card> </el-card>
</el-row> </el-row>
@ -195,6 +199,7 @@ export default {
inputVisible: false, inputVisible: false,
// //
checkedAttribute: [], checkedAttribute: [],
//id
// //
attributeList: [], attributeList: [],
// //
@ -241,13 +246,23 @@ export default {
methods: { methods: {
// //
handleCheckedAttributeChange(attribute){ handleCheckedAttributeChange(attribute){
console.log(this.checkedAttribute) let isChecked = this.form.checkedAttributeIds.indexOf(attribute.id) > -1;
console.log(attribute) if (isChecked){
this.checkedAttribute.push(attribute)
}else {
//
this.checkedAttribute.splice(
this.checkedAttribute.indexOf(attribute),1
)
}
// this.checkedAttribute.splice(this.checkedAttributeIds.indexOf(attribute.id),1)
}, },
// //
handleClose(attribute) { removeCheck(index) {
this.checkedAttribute.splice(this.checkedAttribute.indexOf(attribute), 1); console.log(index)
this.checkedAttribute.splice(index,1);
this.form.checkedAttributeIds.splice(index,1)
}, },
/** 查询属性组列表 */ /** 查询属性组列表 */
getList() { getList() {
@ -281,9 +296,11 @@ export default {
createBy: null, createBy: null,
createTime: null, createTime: null,
updateBy: null, updateBy: null,
updateTime: null updateTime: null,
checkedAttributeIds: [],
}; };
this.resetForm("form"); this.resetForm("form");
this.checkedAttribute= []
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
@ -310,13 +327,16 @@ export default {
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
console.log(row)
this.getAttribute(); this.getAttribute();
this.reset(); this.reset();
const id = row.id || this.ids const id = row.id || this.ids
getGroup(id).then(response => { getGroup(id).then(response => {
console.log(response)
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
this.title = "修改属性组"; this.title = "修改属性组";
this.form.checkedAttributeIds= []
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */