el-select change下拉获取对象
<el-select v-if="model" filterable class="w" v-model="ruleForm.allModelId" placeholder="请选择" @change="changeModel($event)" > <el-option v-for="item in model" :key="item.id" :label="item.modelName" :value="item.id" ></el-option> </el-select>
changeModel(id) { let obj = {}; obj = this.model.find((item) => { //model就是上面的数据源 return item.id === id; //筛选出匹配数据 }); console.log(obj); this.ruleForm.allModelName = obj.modelName; this.ruleForm.allModelId = obj.id; },
多选
// 汇总提交人改变 planSubmitChange (val) { console.log(val) let role = { ...this.role } let arr = [];for (let i = 0; i < val.length; i++) { let obj = {}; obj = this.planSubmitOptions.find((item) => { //model就是上面的数据源 return item.id === val[i]; //筛选出匹配数据 }); console.log(obj); if (obj.id) { arr.push({ relationLineId: obj.id, relationLineName: obj.relationLineName }) } } role.planRelationLines = arr; role.lineInfos = arr2; this.role = role console.log(arr) },