文章目录
表格里面的下拉框和进行联动产生的代码
<!-- //给行添加鼠标点击事件 -->
<el-table-column
prop="rulcon" label="规则条件" width="300">
<template slot-scope="scope">
<el-select clearable
v-model="dataList2[scope.$index].rulcon"
@change="changeByCustom(scope.row)"
style="width: 140px;"
>
<el-option label="重叠5%" value="1"></el-option>
<el-option label="不重叠" value="2"></el-option>
<el-option label="自定义比例" value="3" ></el-option>
</el-select>
<el-input
style="width: 160px;" v-if="scope.row.isShow" v-model="dataList2[scope.$index].ruldata">
<template
slot="append"
>%</template
>
</el-input>
</template>
</el-table-column>
1.this.$set(isshow,datalist,false),给数组里面的对象加上一个标识字段
this.$set(isshow,dataList,false); 设置这个数组里面的每个对象加上一个字段默认为false.
this.dataList2.forEach((item)=>{
this.$set(item,'isShow',false)
if(item.rulcon==3){
item.isShow = true;
}
})
2.然后在里面加上了if条例用于判断一个联动是否要显示
3.然后用change事件传过来那个参数进行判断你自己选中的哪个一行
changeByCustom(row){
this.dataList2.forEach(item =>{
// 判断一下选中的是哪一行
if(item.rulid == row.rulid){
// 联动框先设置为false
item.isShow = false;
// 如果选中的联动的值是3,不是置为true;
if(item.rulcon == 3){
item.isShow = true
}
}
});
console.info(row,"row----------------");
},