![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ce15d30649d3447afbf9ca878256509d.png)
<el-select multiple collapse-tags v-model="searchForm.auditResult" @change="changeSelect" @remove-tag="removeTag" placeholder="请选择">
<el-option label="全选" value="全选" @click.native="selectAll"></el-option>
<el-option v-for="(item, index) in auditResultData" :key="item.value" :label="item.label" :value="item.value">
<span class="check"></span>
<span style="margin-left: 8px">{{ item.label }}</span>
</el-option>
</el-select>
searchForm: {
auditResult: []
},
下拉框数据
auditResultData: [
{ label: '全部' value: '0' },
{ label:'有违规', value: '1' },
{ label:'无违规', value: '2' }
],
selectAll() {
if (this.searchForm.auditResult.length < this.auditResultData.length) {
this.searchForm.auditResult = [];
this.auditResultData.map(item => {
this.searchForm.auditResult.push(item.value);
});
} else {
this.searchForm.auditResult = [];
}
},
changeSelect(val) {
this.searchForm.auditResult = this.searchForm.auditResult.filter(item => {
return item;
});
},
removeTag(val) {
this.searchForm.auditResult = [];
},