ant table分页,保存所有勾选数据

data() {
     return {
     		mySelfData: [],
      		mySelfData1: []
	}
}
        <a-table
          preserveSelectedRowKeys:true
          ref="firstMetaTableData"
          :rowKey="firstMetaTableData => firstMetaTableData.tableName"
          :columns="firstMetadataColumns"
          :dataSource="firstMetaTableData"
          :rowSelection="{
            selectedRowKeys: firstMetaTableSelectedRowKeys,
            onChange: firstMetaTableSelectChange,
            onSelect: firsMetaTtableSelect
          }"
          :pagination="firstMetaTablePagination"
          @change="firsMetaTtableChange"
        />
    // firstMetaTableChange 表格勾选事件
    firstMetaTableSelectChange(firstMetaTableSelectedRowKeys, firstMetaTableselectedRows) {
      console.log(firstMetaTableSelectedRowKeys, 'firstMetaTableSelectedRowKeys')
      console.log(firstMetaTableselectedRows, 'firstMetaTableselectedRows')
      this.firstMetaTableSelectedRowKeys = firstMetaTableSelectedRowKeys
      this.firstMetaTableselectedRows = firstMetaTableselectedRows
    },

    firsMetaTtableSelect(record) {
      console.log(record, 'record')

      // 保存所有选中过的数据并去重
      let data = []
      // 把每次勾选的数据存下来
      this.mySelfData.push(record)
      // 数据去重
      this.mySelfData = [...new Set(this.mySelfData)]
      // 对去重的数据进行比对,留下选中的数据
      this.firstMetaTableSelectedRowKeys.forEach(item => {
        data.push(
          this.mySelfData.find(items => {
            return item == items.tableName
          })
        )
      })
      // 最后进行赋值
      this.mySelfData1 = data
    }
上一篇:Oracle 11gR2完整安装步骤


下一篇:[codeforces] 暑期训练之打卡题