【vue+element table 全选和取消全选】

  <el-table ref="multipleTable" :data="InpExamList" tooltip-effect="dark" style="width: 100%"
          @selection-change="selectionChange" @select-all="selectAll" @select="select"
          :tree-props="{ children: 'list', hasChildren: 'hasChildren' }" row-key="ids" :span-method="arrayNewSpanMethod"
          default-expand-all highlight-current-row :select-on-indeterminate="true">
          <el-table-column type="selection" width="55" />
          <el-table-column label="" show-overflow-tooltip prop="title" width="1" />
          <el-table-column label="检查子类型" show-overflow-tooltip prop="EXAM_SUB_CLASS" width="130" />
          <el-table-column prop="EXAM_ITEM" label="检查项目" show-overflow-tooltip />
          <el-table-column prop="REQ_DATE_TIME" label="申请时间" show-overflow-tooltip />
          <el-table-column prop="COSTS" label="费用" show-overflow-tooltip />
          <el-table-column prop="REQ_PHYSICIAN" label="申请人" show-overflow-tooltip />
          <el-table-column prop="REQ_DEPT" label="申请科室" show-overflow-tooltip />
          <el-table-column prop="PERFORMED_DEPT" label="执行科室" show-overflow-tooltip />
          <el-table-column prop="RESULT_STATUS" label="结果状态" show-overflow-tooltip />
          <el-table-column prop="BILLING_INDICATOR" label="计费状态" show-overflow-tooltip />
          <el-table-column prop="EXAM_STATUS" label="状态" show-overflow-tooltip />
          <el-table-column prop="" label="注意事项" show-overflow-tooltip />
          <el-table-column prop="" label="症状" show-overflow-tooltip />
          <el-table-column prop="PHYS_SIGN" label="体征" show-overflow-tooltip />
        </el-table>
    

    selectionChange(val) {
      this.multipleSelection = val
      console.log(this.multipleSelection)
    },
    select(selection) {
      this.multipleSelection = selection
      console.log(this.multipleSelection)
    },
    selectAll(selection) {
      const isSelect = selection.some((el) => {
        const tableDataIds = this.InpExamList.map((j) => j.ids)
        return tableDataIds.includes(el.ids)
      })
      // tableDate第一层只要有不在selection里面就是全不选
      const isCancel = !this.InpExamList.every((el) => {
        const selectIds = selection.map((j) => j.ids)
        return selectIds.includes(el.ids)
      })
      if (isSelect) {
        selection.map((el) => {
          if (el.list) {
            el.list.map((j) => {
              this.toggleSelection(j, true)
            })
          }
        })
      }
      if (isCancel) {
        this.InpExamList.map((el) => {
          if (el.list) {
            el.list.map((j) => {
              this.toggleSelection(j, false)
            })
          }
        })
      }
    },

    toggleSelection(row, select) {
      if (row) {
        this.$nextTick(() => {
          this.$refs.multipleTable && this.$refs.multipleTable.toggleRowSelection(row, select)
        })
      }
    },
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值