From 22d0b1381926ba74999133789d5576d59149d054 Mon Sep 17 00:00:00 2001 From: kqgitee <14811630+kqgitee@user.noreply.gitee.com> Date: Mon, 26 Aug 2024 08:51:02 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A4=A7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=87=8F=E7=9A=84=E8=A1=A8=E6=A0=BC=E5=9C=A8=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=8D=95=E5=85=83=E6=A0=BC=E6=97=B6=E7=9A=84=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kqgitee <14811630+kqgitee@user.noreply.gitee.com> --- packages/table/src/body.ts | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/packages/table/src/body.ts b/packages/table/src/body.ts index b9415d409..2c9fdbbfd 100644 --- a/packages/table/src/body.ts +++ b/packages/table/src/body.ts @@ -41,7 +41,7 @@ export default defineComponent({ const refBodyXSpace = ref() as Ref const refBodyYSpace = ref() as Ref const refBodyEmptyBlock = ref() as Ref - + let mergeObj = {} as any const getOffsetSize = () => { if (xesize) { const vSize = xesize.value @@ -208,7 +208,7 @@ export default defineComponent({ } // 合并行或列 if (mergeList.length) { - const spanRest = mergeBodyMethod(mergeList, _rowIndex, _columnIndex) + const spanRest = mergeObj[_rowIndex + ':' + _columnIndex] if (spanRest) { const { rowspan, colspan } = spanRest if (!rowspan || !colspan) { @@ -707,6 +707,37 @@ export default defineComponent({ } } + /** + * 合并预处理 + */ + const mergeResolution = () => { + const { mergeList } = tableReactData + mergeObj = {} + if (mergeList.length) { + for (let mIndex = 0; mIndex < mergeList.length; mIndex++) { + const _a = mergeList[mIndex] + if (_a.row > -1 && _a.col > -1 && _a.rowspan && _a.colspan) { + if (!mergeObj[_a.row + ':' + _a.col]) { // 避免设置了已被合并的单元格 导致合并项重复渲染 + // 合并目标默认行列 + mergeObj[_a.row + ':' + _a.col] = { rowspan: _a.rowspan, colspan: _a.colspan } + } + + // 遍历合并目标之后的单元格(包含合并目标单元格) + for (let j = 0; j < _a.rowspan; j++) { + for (let c = 0; c < _a.colspan; c++) { + if (j === 0 && c === 0) { + // 排除需要设置合并的单元格 + } else { + // 合并后不需要重复渲染的单元格 + mergeObj[(_a.row + j) + ':' + (_a.col + c)] = { rowspan: 0, colspan: 0 } + } + } + } + } + } + } + } + onMounted(() => { nextTick(() => { const { fixedType } = props @@ -759,6 +790,7 @@ export default defineComponent({ const emptyOpts = computeEmptyOpts.value const keyboardOpts = computeKeyboardOpts.value const mouseOpts = computeMouseOpts.value + mergeResolution() // 合并预处理 // const isMergeLeftFixedExceeded = computeIsMergeLeftFixedExceeded.value // const isMergeRightFixedExceeded = computeIsMergeRightFixedExceeded.value // 如果是使用优化模式 -- Gitee