From 911bf14e585047ac5dd5a98a451fa07ab3ac2ecc Mon Sep 17 00:00:00 2001 From: zhenglingpeng Date: Fri, 19 Jul 2024 09:33:11 +0800 Subject: [PATCH] fix: the problem of unable to page across columns in the same row Hufe921#41 --- src/editor/core/draw/Draw.ts | 9 ++++----- src/editor/interface/table/Td.ts | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index b77f1c8..0d64518 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -1413,9 +1413,7 @@ export class Draw { } } } - for (let i = tr.tdList.length - 1; i >= item.col; i--) { - tr.tdList[i + 1] = tr.tdList[i] - } + tr.tdList.splice(item.col, 0, tr.tdList[tr.tdList.length - 1]) const tempRow = item.row - item.count tr.tdList[mdColIndex] = { ...cell, @@ -1424,7 +1422,7 @@ export class Draw { height: height - initHeight, realHeight: height - initRealHeight, realMinHeight: height - initRealMinHeight, - tempFlag: true, + temporaryFlag: true, parentTr: `${mdColIndex}-${mdRowIndex}`, value: cell.value.map(item => ({ ...item, value: '' })) } @@ -1438,9 +1436,10 @@ export class Draw { deleteStart = r + 1 deleteCount = trList.length - deleteStart preTrHeight += trHeight + // 重新记录临时的td for (let i = 0; i < trList.length; i++) { for (let j = trList[i]?.tdList.length - 1; j >= 0; j--) { - if (trList[i]?.tdList[j]?.tempFlag) { + if (trList[i]?.tdList[j]?.temporaryFlag) { const tempTd = trList[i].tdList[j] if (tempTd.parentTr) { const mdRowIndex = parseInt( diff --git a/src/editor/interface/table/Td.ts b/src/editor/interface/table/Td.ts index cdb2a79..e3a00f6 100644 --- a/src/editor/interface/table/Td.ts +++ b/src/editor/interface/table/Td.ts @@ -29,6 +29,6 @@ export interface ITd { mainHeight?: number // 内容 + 内边距高度 realHeight?: number // 真实高度(包含跨列) realMinHeight?: number // 真实最小高度(包含跨列) - tempFlag?: boolean, - parentTr?: string + temporaryFlag?: boolean, // 临时单元格标识 + parentTr?: string // 记录临时单元格的父级tr,用于合并单元格 }