table

点击按钮显示弹出框,弹出框中有个表格,表格可勾选,勾选后点击下一页,不能保留上一页的状态, 在页面中删除选项,再次打开表格不能正确显示,之前删除的选项,表格中还是勾选状态
image.pngimage.png
table:tooltip-effect=”dark”,:row-key=”getRowKey”
getRowKey(row) {
return row[‘AUCTION.AUCTION_ID’];
},
table-column: 添加:reserve-selection=”true”
当点击弹出框确定按钮后回显到页面
table:@selection-change=”handleSelectionChange”

handleSelectionChange(list) {
this.auctionDialogList = list
},

点击确定按钮函数

  1. this.auctionDialogListCache.push(...this.auctionDialogList);
  2. this.auctionDialogListCache = utils.arrayObjectDeduplication(
  3. this.auctionDialogListCache, "AUCTION.AUCTION_ID");
  4. const utils = {
  5. /**
  6. * 数组对象根据key去重
  7. * @param {*} list 要去重的数组对象
  8. * @param {*} key 根据哪个key去重
  9. */
  10. arrayObjectDeduplication: function(list, key){
  11. let hash = {}
  12. return list.reduceRight((item, next) => {
  13. hash[next[key]] ? '' : hash[next[key]] = true && item.push(next);
  14. return item
  15. }, []);
  16. }
  17. }

显示弹出框

  1. this.$nextTick(() => {
  2. // 清空所有勾选
  3. this.$refs.auctionMultipleTable.clearSelection()
  4. // 给现有元素设置勾选
  5. this.auctionDialogListCache.forEach(row => {
  6. this.$refs.auctionMultipleTable.toggleRowSelection(row, true);
  7. });
  8. });