el-checkbox全选和自定义

el-checkbox全选和自定义

<div
        v-for="(item, idx) in selectList"
        :key="item.name"
        class="list"
        :class="{ number: item.type === 'number' }"
      >
        <span class="title">{{ item.name }} </span>
        <el-checkbox
          :indeterminate="item.indeterminate"
          v-model="item.selectAll"
          @change="selectAll(item, idx)"
          >全部</el-checkbox
        >
        <el-checkbox-group
          v-model="item.value"
          :class="{ jieClass: item.type === 'jie' }"
        >
          <el-checkbox
            :label="child.prop"
            v-for="child in item.children"
            :key="child.label"
            :checked="child.isSelect"
            @change="changeLabel(child, item, idx)"
            >{{ child.label }}</el-checkbox
          >
        </el-checkbox-group>
        <div class="custom-div" v-if="item.type === 'number'">
          <el-checkbox
            v-model="item.customProduction"
            @change="labelChange(idx, item)"
            >自定义</el-checkbox
          >
          <div class="custom-div-show inner" v-show="item.opencustomProduction">
            <input
              type="number"
              class="inputnumber inner"
              placeholder="最小值"
              v-model.number="item.minproduction"
            />-
            <input
              type="number"
              class="inputnumber inner"
              placeholder="最大值"
              v-model.number="item.maxproduction"
            />
            <div
              class="custom-div-show-btn inner"
              @click="clickAffirm(item, idx)"
            >
              确定
            </div>
            <div
              class="custom-div-show-btn inner"
              @click="clearCustom(item, idx)"
            >
              清除
            </div>
          </div>
        </div>
      </div>
jzAreaList: {
          name: '总建筑面积(m²)',
          type: 'number',
          value: [],
          customProduction: false,
          opencustomProduction: false,
          indeterminate: false,
          selectAll: false,
          maxproduction: '',
          minproduction: '',
          children: [
            { label: '10000以下', prop: { max: 10000 }, isSelect: false },
            {
              label: '10000-50000',
              prop: { min: 10000, max: 50000 },
              isSelect: false
            },
            {
              label: '50000-100000',
              prop: { min: 50000, max: 100000 },
              isSelect: false
            },
            {
              label: '100000-200000',
              prop: { min: 100000, max: 200000 },
              isSelect: false
            },
            { label: '200000以上', prop: { min: 200000 }, isSelect: false }
          ]
        },
//全选
    selectAll(item, idx) {
      item.indeterminate = false
      if (item.selectAll) {
        item.children.forEach((e) => {
          e.type === 'number'
            ? item.value.push(e.label)
            : item.value.push(e.prop)
        })
      } else {
        item.value = []
      }
      this.param[idx] = JSON.parse(JSON.stringify(item.value))
    },
    //自定义
labelChange(idx, item) {
      item.opencustomProduction = item.customProduction ? true : false
      let index = -1
      this.param[idx].forEach((item, i) => {
        if (item.type) {
          index = i
        }
      })
      if (!item.customProduction) {
        index > -1 && this.param[idx].splice(index, 1)
      } else {
        if (index === -1 && item.minproduction) {
          this.param[idx].push({
            min: item.minproduction,
            max: item.maxproduction,
            type: 1
          })
        }
      }
      if (!this.customProductionIdx) {
        this.customProductionIdx = idx
        window.addEventListener('click', this.handleClick, { bubbles: true })
      } else {
        this.customProductionIdx = ''
        window.removeEventListener('click', this.handleClick, { bubbles: true })
      }
    },
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值