From 800d8839a29cfe311e501612fe5aa86af2ec4f66 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 3 Feb 2023 18:11:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=80=9A=E7=94=A8=E5=8A=9F=E8=83=BD):=20?= =?UTF-8?q?=E5=85=A8=E9=80=89=E6=A1=86=E4=B8=8B=E6=8B=89=E5=88=97=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E7=82=B9=E5=87=BB=E9=80=89=E6=8B=A9=E6=89=80=E6=9C=89?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=88=96=E8=80=85=E5=8F=AF=E8=A7=81=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=EF=BC=8C=E4=B8=8D=E5=87=BA=E7=8E=B0=E5=8B=BE=E9=80=89?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1022406 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001022406 --- .../frontend/src/components/table/MsTable.vue | 23 ++++++++++++++----- .../frontend/src/utils/tableUtils.js | 22 +++++++++++++++--- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/framework/sdk-parent/frontend/src/components/table/MsTable.vue b/framework/sdk-parent/frontend/src/components/table/MsTable.vue index e1abe4175f..6869ae3942 100644 --- a/framework/sdk-parent/frontend/src/components/table/MsTable.vue +++ b/framework/sdk-parent/frontend/src/components/table/MsTable.vue @@ -137,13 +137,13 @@ import { _sort, checkTableRowIsSelect, clearShareDragParam, + deleteTableRow, getCustomTableHeader, getSelectDataCounts, handleRowDrop, saveCustomTableWidth, saveLastTableSortField, setUnSelectIds, - toggleAllSelection, } from "../../utils/tableUtils"; import MsTableHeaderSelectPopover from "./MsTableHeaderSelectPopover"; import MsTablePagination from "../pagination/TablePagination"; @@ -337,6 +337,7 @@ export default { } this.doLayout(); this.checkTableRowIsSelect(); + this.deleteTableRow(); this.listenRowDrop(); }); } @@ -421,11 +422,7 @@ export default { this.condition ); setUnSelectIds(selection, this.condition, this.selectRows); - this.selectDataCounts = getSelectDataCounts( - this.condition, - this.total, - this.selectRows - ); + this.selectDataCounts = this.selectRows.size this.selectIds = Array.from(this.selectRows).map((o) => o.id); //有的组件需要回调父组件的函数,做下一步处理 this.$emit("callBackSelectAll", selection); @@ -458,6 +455,11 @@ export default { this.condition.selectAll = data; //显示隐藏菜单 _handleSelectAll(this, this.data, this.data, this.selectRows); + //选中行 + this.selectRows.forEach(t => { + this.$refs.table.toggleRowSelection(t, true); + }) + this.deleteTableRow(); //设置未选择ID(更新) this.condition.unSelectIds = []; //更新统计信息 @@ -553,6 +555,15 @@ export default { this.selectRows ); }, + deleteTableRow() { + deleteTableRow( + this, + this.condition, + this.data, + this.$refs.table, + this.selectRows + ); + }, clearSelection() { this.clearSelectRows(); }, diff --git a/framework/sdk-parent/frontend/src/utils/tableUtils.js b/framework/sdk-parent/frontend/src/utils/tableUtils.js index 9b29bcf7f0..d7dda93b86 100644 --- a/framework/sdk-parent/frontend/src/utils/tableUtils.js +++ b/framework/sdk-parent/frontend/src/utils/tableUtils.js @@ -31,9 +31,9 @@ export function _handleSelectAll(component, selection, tableData, selectRows, co tableData.forEach(item => { component.$set(item, "showMore", false); }); - if (condition) { - condition.selectAll = false; - } + } + if (condition) { + condition.selectAll = false; } } @@ -115,6 +115,22 @@ export function checkTableRowIsSelect(component, condition, tableData, table, se } } +//删除不需要的row(使用场景:点击表格下拉框全选时,在翻页的时候会把翻页的数据也加勾选,如果勾选了,table认为已经选中,当点击只选此页数据时,前几页的数据不会消失) +export function deleteTableRow(component, condition, tableData, table, selectRows) { + //所有以选中的数据 + let selectRowMap = new Map(); + for (let selectRow of selectRows) { + selectRowMap.set(selectRow.id, selectRow); + } + //表格标为选中的数据 + table.selection.forEach(t => { + if (!selectRowMap.get(t.id)) { + table.toggleRowSelection(t, false); + } + }) + +} + // nexttick:表格加载完成之后触发。判断是否需要勾选行 export function checkTableRowIsSelected(veuObj, table) { veuObj.$nextTick(function () {