From 9a943cc21704ca843dc5b00f5342f3c731f7391c Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Thu, 9 Jan 2025 15:14:27 +0800 Subject: [PATCH] releases 4.10.4 --- package.json | 4 ++-- packages/table/src/cell.ts | 34 +++++++++++++++++++++++----------- packages/table/src/table.ts | 19 +++++++++++++------ packages/table/src/util.ts | 11 ++++++----- 4 files changed, 44 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index f2c7a8598a..50a6949c99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vxe-table", - "version": "4.10.3", + "version": "4.10.4", "description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟树、拖拽排序,懒加载、快捷菜单、数据校验、树形结构、打印、导入导出、自定义模板、渲染器、JSON 配置式...", "scripts": { "update": "npm install --legacy-peer-deps", @@ -28,7 +28,7 @@ "style": "lib/style.css", "typings": "types/index.d.ts", "dependencies": { - "vxe-pc-ui": "^4.3.67" + "vxe-pc-ui": "^4.3.68" }, "devDependencies": { "@types/resize-observer-browser": "^0.1.11", diff --git a/packages/table/src/cell.ts b/packages/table/src/cell.ts index eef1a4a116..74919287fa 100644 --- a/packages/table/src/cell.ts +++ b/packages/table/src/cell.ts @@ -45,14 +45,18 @@ function renderTitleSuffixIcon (params: VxeTableDefines.CellRenderHeaderParams & } function renderCellDragIcon (params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) { - const { $table } = params + const { $table, column } = params + const { context } = $table + const tableSlots = context.slots const tableProps = $table.props + const { slots } = column const { dragConfig } = tableProps const { computeRowDragOpts } = $table.getComputeMaps() const rowDragOpts = computeRowDragOpts.value const { icon, trigger, disabledMethod } = rowDragOpts const rDisabledMethod = disabledMethod || (dragConfig ? dragConfig.rowDisabledMethod : null) const isDisabled = rDisabledMethod && rDisabledMethod(params) + const rowDragIconSlot = (slots ? slots.rowDragIcon || slots['row-drag-icon'] : null) || tableSlots.rowDragIcon || tableSlots['row-drag-icon'] const ons: Record = {} if (trigger !== 'cell') { ons.onMousedown = (evnt: MouseEvent) => { @@ -68,11 +72,13 @@ function renderCellDragIcon (params: VxeTableDefines.CellRenderBodyParams & { $t 'is--disabled': isDisabled }], ...ons - }, [ - h('i', { - class: icon || (dragConfig ? dragConfig.rowIcon : '') || getIcon().TABLE_DRAG_ROW - }) - ]) + }, rowDragIconSlot + ? $table.callSlot(rowDragIconSlot, params) + : [ + h('i', { + class: icon || (dragConfig ? dragConfig.rowIcon : '') || getIcon().TABLE_DRAG_ROW + }) + ]) } function renderCellBaseVNs (params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, content: VxeComponentSlotType | VxeComponentSlotType[]) { @@ -104,6 +110,9 @@ function renderCellBaseVNs (params: VxeTableDefines.CellRenderBodyParams & { $ta function renderHeaderCellDragIcon (params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) { const { $table, column } = params + const { context } = $table + const tableSlots = context.slots + const { slots } = column const { computeColumnOpts, computeColumnDragOpts } = $table.getComputeMaps() const columnOpts = computeColumnOpts.value const columnDragOpts = computeColumnDragOpts.value @@ -111,6 +120,7 @@ function renderHeaderCellDragIcon (params: VxeTableDefines.CellRenderHeaderParam if (columnOpts.drag && showIcon && (!visibleMethod || visibleMethod(params))) { if (!column.fixed && (isPeerDrag || isCrossDrag || !column.parentId)) { const isDisabled = disabledMethod && disabledMethod(params) + const columnDragIconSlot = (slots ? slots.columnDragIcon || slots['column-drag-icon'] : null) || tableSlots.columnDragIcon || tableSlots['column-drag-icon'] const ons: Record = {} if (trigger !== 'cell') { ons.onMousedown = (evnt: MouseEvent) => { @@ -126,11 +136,13 @@ function renderHeaderCellDragIcon (params: VxeTableDefines.CellRenderHeaderParam 'is--disabled': isDisabled }], ...ons - }, [ - h('i', { - class: icon || getIcon().TABLE_DRAG_COLUMN - }) - ]) + }, columnDragIconSlot + ? $table.callSlot(columnDragIconSlot, params) + : [ + h('i', { + class: icon || getIcon().TABLE_DRAG_COLUMN + }) + ]) } } return renderEmptyElement($table) diff --git a/packages/table/src/table.ts b/packages/table/src/table.ts index 61838a55dc..d7a3e90ea9 100644 --- a/packages/table/src/table.ts +++ b/packages/table/src/table.ts @@ -894,10 +894,7 @@ export default defineComponent({ const row = afterFullData[rIndex] const rowid = getRowid($xeTable, row) const rowRest = fullAllDataRowIdData[rowid] - if (!rowRest) { - break - } - offsetTop += rowRest.height || rowHeight + offsetTop += rowRest ? (rowRest.height || rowHeight) : rowHeight if (toVisibleIndex === -1 && scrollTop < offsetTop) { toVisibleIndex = rIndex } @@ -5146,7 +5143,7 @@ export default defineComponent({ * @param {Number} scrollLeft 左距离 * @param {Number} scrollTop 上距离 */ - scrollTo (scrollLeft: number, scrollTop?: number) { + scrollTo (scrollLeft, scrollTop) { const tableBody = refTableBody.value const tableHeader = refTableHeader.value const tableFooter = refTableFooter.value @@ -5196,6 +5193,8 @@ export default defineComponent({ * @param {ColumnInfo} fieldOrColumn 列配置 */ scrollToRow (row, fieldOrColumn) { + const { showOverflow } = props + const { scrollYLoad, scrollXLoad } = reactData const rest = [] if (row) { if (props.treeConfig) { @@ -5207,7 +5206,15 @@ export default defineComponent({ if (fieldOrColumn) { rest.push(handleScrollToRowColumn(fieldOrColumn, row)) } - return Promise.all(rest) + return Promise.all(rest).then(() => { + if (row) { + if (!showOverflow && (scrollYLoad || scrollXLoad)) { + calcCellHeight() + calcCellWidth() + } + return nextTick() + } + }) }, /** * 如果有滚动条,则滚动到对应的列 diff --git a/packages/table/src/util.ts b/packages/table/src/util.ts index 4a5c75d01b..eb3ee25883 100644 --- a/packages/table/src/util.ts +++ b/packages/table/src/util.ts @@ -385,6 +385,7 @@ export function rowToVisible ($xeTable: VxeTableConstructor & VxeTablePrivateMet const { refTableBody } = $xeTable.getRefMaps() const { columnStore, scrollYLoad } = reactData const { afterFullData, scrollYStore, fullAllDataRowIdData } = internalData + const { rowHeight } = scrollYStore const tableBody = refTableBody.value const { leftList, rightList } = columnStore const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null @@ -415,19 +416,19 @@ export function rowToVisible ($xeTable: VxeTableConstructor & VxeTablePrivateMet // 如果是虚拟渲染滚动 if (scrollYLoad) { if (showOverflow) { - return $xeTable.scrollTo(null, ($xeTable.findRowIndexOf(afterFullData, row) - 1) * scrollYStore.rowHeight) + return $xeTable.scrollTo(null, ($xeTable.findRowIndexOf(afterFullData, row) - 1) * rowHeight) } let scrollTop = 0 - const rest = fullAllDataRowIdData[rowid] - const rHeight = rest ? rest.height : 0 + const rowRest = fullAllDataRowIdData[rowid] + const rHeight = rowRest ? (rowRest.height || rowHeight) : rowHeight for (let i = 0; i < afterFullData.length; i++) { const currRow = afterFullData[i] const currRowid = getRowid($xeTable, currRow) if (currRow === row || currRowid === rowid) { break } - const rest = fullAllDataRowIdData[currRowid] - scrollTop += rest ? rest.height : 0 + const rowRest = fullAllDataRowIdData[currRowid] + scrollTop += rowRest ? (rowRest.height || rowHeight) : rowHeight } if (scrollTop < bodyScrollTop) { return $xeTable.scrollTo(null, scrollTop - offsetFixedLeft - 1)