var level2ValueList = Enumerable.from(list[0].options).select("o=>o.value").toArray(); //所有该一级下二级的value集合
var num=0;
level2ValueList.forEach((value)=>{
this.selectModel2.forEach((model, index)=>{
if(model==value){
this.selectModel2.splice(index, 1); //如有匹配,先删除
num++;
return true;
}
})
})
if(num < level2ValueList.length){ //需要全选
this.selectModel2 = this.selectModel2.concat(level2ValueList); //合并数组
}
}
},
mounted: function(){
this.transMultipleSelectOption();
},
template
<el-select v-model="selectModel" multiple filterable remote reserve-keyword
placeholder="请输入关键词" :remote-method="(queryString)=>{
remoteMethod(queryString, allSelectList);
}">
<el-option-group v-for="group in multipleSelectOption"
:key="group.name"
:label="group.name"
@click.native="checkAll(group.name)">
<el-option v-for="item in group.options"
:key="item.value"
:label="item.name"
:value="item.value">
</el-option>
</el-option-group>
</el-select>










