vue+antd的树形选择器符合条件的选项禁用

树形选择器选项是便利的数字对象,那么我可操作数组从而来达到符合条件的选项禁用,话不多说上代码

//置灰

    setGray() {

      let that = this,

        list = [...that.options]

      let getIds = function (list) {

        list.forEach((k) => {

          if (k.children && k.children.length > 0) {

            k.children.forEach((e) => {

              if (['1', '2', '3', '4', '5', '6'].indexOf(e.dataStatus) >= 0) {

                e.class = 'gray'

              } else {

                if ([null, '3', '4'].indexOf(e.auditStatus) >= 0) {

                  e.class = 'gray'

                }

              }

            })

          }

        })

      }

      getIds(list)

      that.options = [...list]

    },

  //禁用

    setDisabled() {

      let that = this,

        list = [...that.options]

      let getIds = function (list) {

        list.forEach((k) => {

          if (k.childList && k.childList.length > 0) {

            k.children.forEach((e) => {

              if (['1', '2', '3', '4', '5', '6'].indexOf(e.dataStatus) >= 0) {

                e.disabled = true

              } else {

                if ([null, '3', '4'].indexOf(e.auditStatus) >= 0) {

                  e.disabled = true

                }

              }

            })

          }

        })

      }

      getIds(list)

      that.options = [...list]

    },

上面就是将符合条件的数据状态dataStatus或者审核状态auditStatus符合条件的加上class类目gray和disabled属性,

然后我们再a-tree-select的标签中操作即可

<a-tree-select-node
        v-show="items.children"
        v-for="item in items.children"
        :key="item.id"
        :value="item.id"
        :title="item.label"
        :selectable="item.children?false:true"
        :disabled="item.class!=undefined"
      >

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值