Element ui 分页记录选中框

    getTableList() {
      //列表数据查询
      queryRoomAudit(this.tableParameter).then(response => {
        this.tableData = response.data
        this.returnTotal = response.total
        this.toggleSelection(this.multipleSelectionAll[this.tableParameter.pageIndex], this.tableData, 'FJSH_ZJ') //当前页选中的list,(注意)需使用当前页tableData,才能选中,比对选中唯一值key
      })
    },
    handleCurrentChange(currentPage) {
      //页面索引改变时
      if (this.multipleSelection.length) {
        //页面改变前赋值
        this.$set(this.multipleSelectionAll, this.tableParameter.pageIndex, this.multipleSelection)
      }
      this.tableParameter.pageIndex = currentPage - 1
      this.getTableList()
    },
    toggleSelection(rows, tableData, key) {
      //记录值list,当前页list,用来比较的唯一值key
      var _this = this
      if (rows) {
        this.$nextTick(() => {
          for (const row of rows) {
            for (const item of tableData) {
              if (row[key] === item[key]) {
                _this.$refs.multipleTable.toggleRowSelection(item, true)
              }
            }
          }
        })
      } else {
        _this.$refs.multipleTable.clearSelection()
      }
    }

 

posted @ 2021-06-28 16:49  ˉ八月  阅读(90)  评论(0编辑  收藏  举报