表格实现
<el-table border :data="Data" @selection-change="selectionChangeHandlerOrder">
<el-table-column
:selectable="checkboxT"
type="selection"
width="55"
align="center"
/>
两种方法配合:
// 表格勾选
selectionChangeHandlerOrder(val) {
if (val.length !== 0) {
this.customer = val[0].customerName//customer为自定义全局变量
} else {
this.customer = ''
}
}
// 复选框勾选限制
checkboxT(row, index) {
if (this.customer !== '') {//勾选时判断相同的名称可勾选
return row.customerName === this.customer
} else {//未勾选时全部可选
return true
}
}
链接: 参考于此
对于出现的一些问题:
1.点击全部勾选有BUG 会把禁用的也勾选上
2.直接勾选框后单击行依然能实现勾选
可查看另一篇博客来解决:链接: here