全选、反选checkbox复选框的

 

 

 

 

 

html部分:
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange" label="全选"></el-checkbox>
<el-checkbox v-model="checkInvert" @change="handleCheckInvertChange()" label="反选"></el-checkbox>

js部分:

//全选
handleCheckAllChange(val) {
    let me = this;
    let checkedCount = this.checkedSubStation.length;
    if(checkedCount === this.subStationList.length){
        this.checkedSubStation = [];
        this.checkAll = false;
    }else if(val || (checkedCount < this.subStationList.length)){
        let array = [];
        for(let v of this.subStationList){
            array.push(v.subStationNO+"-"+v.subStationName);
        }
        this.checkedSubStation = array;
        this.checkAll = true;
    }else{
        this.checkedSubStation = [];
        this.checkAll = false;
    }
    this.isIndeterminate = false;
},
handleCheckedSubstationChange(value) {
    let checkedCount = value.length;
    this.checkAll = checkedCount === this.subStationList.length;
    this.isIndeterminate = checkedCount > 0 && checkedCount < this.subStationList.length;
},
//反选
handleCheckInvertChange(val){
    let me = this;
    let noCheckedArray = [];
    for(let v of this.subStationList){
        if(me.checkedSubStation.indexOf(v.subStationNO+"-"+v.subStationName)===-1){
            noCheckedArray.push(v.subStationNO+"-"+v.subStationName);
        }
    }
    let checkedCount = noCheckedArray.length;
    this.checkedSubStation = noCheckedArray.length===0 ? [] : noCheckedArray;
    this.checkAll = noCheckedArray.length !== 0 ;
    this.isIndeterminate = checkedCount < this.subStationList.length && noCheckedArray.length !== 0;
},
//查询数据列表
getSubStation(data){
    let me = this;
    me.$axios.get(me.$url + '/getXXXXXXXXXXXXXXXXXXXXXXX', {
        params: {
            searchParam: JSON.stringify({
                mineCode: data.mineCode
            })
        }
    })
        .then(result => {
            if (result.data.success) {
                me.subStationList = result.data.data;
            }
        })
},

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值