From e84cf2e46a121cbd6161a4a9e5a9064e97e0713d Mon Sep 17 00:00:00 2001 From: wisonic-s <51065359+wisonic-s@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:44:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=9B=BE=E8=A1=A8):=20=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E8=A1=A8=E5=88=86=E7=BB=84=E7=BC=96=E8=BE=91=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8C=89=20shift=20=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=8C=BA=E9=97=B4=E9=80=89=E6=8B=A9=20(#15293)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/TableHeaderGroupConfig.vue | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderGroupConfig.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderGroupConfig.vue index c87c69543f..a6d30582e4 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderGroupConfig.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderGroupConfig.vue @@ -17,9 +17,11 @@ import { S2Event, S2Options, TableSheet, - TooltipShowOptions + TooltipShowOptions, + ColCell, + Node } from '@antv/s2' -import { ElMessageBox } from 'element-plus-secondary' +import ElMessageBox from 'element-plus-secondary' import { cloneDeep, debounce, isEqual, isNumber } from 'lodash-es' import { computed, nextTick, onMounted, onUnmounted, PropType } from 'vue' import { uuid } from 'vue-uuid' @@ -166,6 +168,9 @@ const renderTable = (chart: ChartObj) => { position: 'absolute', borderRadius: '4px' } + }, + interaction: { + rangeSelection: false } } s2 = new TableSheet(containerDom, s2DataConfig, s2Options) @@ -443,6 +448,42 @@ const renderTable = (chart: ChartObj) => { return } }) + s2.on(S2Event.COL_CELL_CLICK, e => { + const lastCell = s2.store.get('lastClickedCell') as ColCell + const originEvent = e.originalEvent as MouseEvent + if (!lastCell || !(originEvent?.ctrlKey || originEvent?.metaKey || originEvent?.shiftKey)) { + const cell = s2.getCell(e.target) + s2.store.set('lastClickedCell', cell) + return + } + if (originEvent?.shiftKey) { + if (!lastCell) { + const cell = s2.getCell(e.target) + s2.store.set('lastClickedCell', cell) + return + } + const curCell = s2.getCell(e.target) + const lastMeta = lastCell.getMeta() + const curMeta = curCell.getMeta() + if ( + lastMeta.key === curMeta.key || + lastMeta.level !== curMeta.level || + lastMeta.parent !== curMeta.parent + ) { + return + } + const parent = curMeta.parent as Node + const lastIndex = parent.children.findIndex(item => item.key === lastMeta.key) + const curIndex = parent.children.findIndex(item => item.key === curMeta.key) + const startIndex = Math.min(lastIndex, curIndex) + const endIndex = Math.max(lastIndex, curIndex) + const activeCells = parent.children.slice(startIndex, endIndex - startIndex + 1) + s2.interaction.clearState() + activeCells.forEach(cell => { + s2.interaction.selectHeaderCell({ cell: cell.belongsCell, isMultiSelection: true }) + }) + } + }) s2.render() }