IVew中table的选择框设置禁选

725 阅读1分钟

场景

  • vue3.0
  • ivew
  • table

需求

要求根据列表数据中某个字段判断,比如状态值,只允许批量删除数据状态为新建的.然后让状态不是新建的编程不可选的方式.

image.png

代码 [不可选]

在列表数据获取的时候,进行设置操作

this.$http.get(api.workTicket.list, this.searchParams).then(res => {
    this.loading = false;
    if (res && res.total >= 0) {
        this.total = res.total;
        this.listData = res.items ? res.items : [];

        this.listData.forEach(e => {
            if(e.status != 'unstart') {
                e._disabled = true
            }
        })
    }
});

代码[默认选择]

image.png

this.$http.get(api.workTicket.list, this.searchParams).then(res => {
    this.loading = false;
    if (res && res.total >= 0) {
        this.total = res.total;
        this.listData = res.items ? res.items : [];

        this.listData.forEach(e => {
            if(e.status != 'unstart') {
                e._checked = true
            }
        })
    }
});