<el-checkbox-group v-model="agencies" @change="changebox">
<el-checkbox-button v-for="(item, index) in agenciesList" :label="item.id" :key="index" :checked="trueLabelList.indexOf(item.id) != -1 ? true : false">
{{ item.agencyName }}
</el-checkbox-button>
</el-checkbox-group>
<el-button type="primary" @click="submitForm()" :disabled="agencies.length == 0">确认</el-button>
//目前选中企业信息
agencies: [],
//已选中企业信息
trueLabelList: null,
//所有企业信息
agenciesList: [],
//方法:
//选中
changebox(val) {
this.agencies = val;
},
// 查询第二个列表数据
async handleAgency() {
await getAgencies(this.form).then(res => {
if (res.code === 200) {
this.agenciesList = res.data.agencies
//后端返回两个列表,一个是所有数据,一个是已经选中数据
this.trueLabelList = res.data.agreements.map(item => item.targetId)
this.trueLabelList = this.trueLabelList.toString()
}
});
},
el-checkbox根据后端返回显示已勾选的标签
最新推荐文章于 2023-12-12 14:39:16 发布