From 0907a787f343c7a3efc80e6a79c8c14795762d0d Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Thu, 9 Jan 2025 15:14:34 +0800 Subject: [PATCH] releases 3.12.8 --- package.json | 4 ++-- packages/table/src/cell.ts | 29 +++++++++++++++++++---------- packages/table/src/methods.ts | 29 +++++++++++++++++++---------- packages/table/src/util.ts | 11 ++++++----- 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index cd4957e5f4..ec8cccedf1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vxe-table", - "version": "3.12.7", + "version": "3.12.8", "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": "^3.3.72" + "vxe-pc-ui": "^3.3.73" }, "devDependencies": { "@babel/plugin-transform-modules-commonjs": "^7.25.7", diff --git a/packages/table/src/cell.ts b/packages/table/src/cell.ts index 25cc120b36..ac2272549a 100644 --- a/packages/table/src/cell.ts +++ b/packages/table/src/cell.ts @@ -50,12 +50,14 @@ function renderTitleSuffixIcon (h: CreateElement, params: VxeTableDefines.CellRe function renderCellDragIcon (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) { const { $table } = params + const tableSlots = $table.$scopedSlots const tableProps = $table const { dragConfig } = tableProps const rowDragOpts = $table.computeRowDragOpts const { icon, trigger, disabledMethod } = rowDragOpts const rDisabledMethod = disabledMethod || (dragConfig ? dragConfig.rowDisabledMethod : null) const isDisabled = rDisabledMethod && rDisabledMethod(params) + const rowDragIconSlot = tableSlots.rowDragIcon || tableSlots['row-drag-icon'] const ons: Record = {} if (trigger !== 'cell') { ons.mousedown = (evnt: MouseEvent) => { @@ -71,11 +73,13 @@ function renderCellDragIcon (h: CreateElement, params: VxeTableDefines.CellRende 'is--disabled': isDisabled }], on: ons - }, [ - h('i', { - class: icon || (dragConfig ? dragConfig.rowIcon : '') || getIcon().TABLE_DRAG_ROW - }) - ]) + }, rowDragIconSlot + ? $table.callSlot(rowDragIconSlot as any, params, h) + : [ + h('i', { + class: icon || (dragConfig ? dragConfig.rowIcon : '') || getIcon().TABLE_DRAG_ROW + }) + ]) } function renderCellBaseVNs (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, content: VxeComponentSlotType | VxeComponentSlotType[]) { @@ -106,12 +110,15 @@ function renderCellBaseVNs (h: CreateElement, params: VxeTableDefines.CellRender function renderHeaderCellDragIcon (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) { const { $table, column } = params + const tableSlots = $table.$scopedSlots + const { slots } = column const columnOpts = $table.computeColumnOpts const columnDragOpts = $table.computeColumnDragOpts const { showIcon, icon, trigger, isPeerDrag, isCrossDrag, visibleMethod, disabledMethod } = columnDragOpts 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.mousedown = (evnt: MouseEvent) => { @@ -127,11 +134,13 @@ function renderHeaderCellDragIcon (h: CreateElement, params: VxeTableDefines.Cel 'is--disabled': isDisabled }], on: ons - }, [ - h('i', { - class: icon || getIcon().TABLE_DRAG_COLUMN - }) - ]) + }, columnDragIconSlot + ? $table.callSlot(columnDragIconSlot as any, params, h) + : [ + h('i', { + class: icon || getIcon().TABLE_DRAG_COLUMN + }) + ]) } } return renderEmptyElement($table) diff --git a/packages/table/src/methods.ts b/packages/table/src/methods.ts index 3b391fee43..ada74453b8 100644 --- a/packages/table/src/methods.ts +++ b/packages/table/src/methods.ts @@ -332,10 +332,7 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) { 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 } @@ -7380,9 +7377,9 @@ const Methods = { * @param {Number} scrollLeft 左距离 * @param {Number} scrollTop 上距离 */ - scrollTo (scrollLeft: any, scrollTop: any) { - const $xeTable = this - const internalData = $xeTable + scrollTo (scrollLeft: number | null, scrollTop?: number | null) { + const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods + const internalData = $xeTable as unknown as TableInternalData const { $refs } = this const { tableBody, tableHeader, leftBody, rightBody, tableFooter } = $refs @@ -7429,9 +7426,13 @@ const Methods = { * @param {Row} row 行对象 * @param {ColumnInfo} column 列配置 */ - scrollToRow (row: any, fieldOrColumn: any) { - const $xeTable = this + scrollToRow (row: any, fieldOrColumn?: VxeColumnPropTypes.Field | VxeTableDefines.ColumnInfo) { + const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods + const props = $xeTable + const reactData = $xeTable as unknown as TableReactData + const { showOverflow } = props + const { scrollYLoad, scrollXLoad } = reactData const rest = [] if (row) { if (this.treeConfig) { @@ -7443,7 +7444,15 @@ const Methods = { if (fieldOrColumn) { rest.push(handleScrollToRowColumn($xeTable, fieldOrColumn, row)) } - return Promise.all(rest) + return Promise.all(rest).then(() => { + if (row) { + if (!showOverflow && (scrollYLoad || scrollXLoad)) { + calcCellHeight($xeTable) + calcCellWidth($xeTable) + } + return $xeTable.$nextTick() + } + }) }, /** * 如果有滚动条,则滚动到对应的列 diff --git a/packages/table/src/util.ts b/packages/table/src/util.ts index c33c83b56c..815a498f7c 100644 --- a/packages/table/src/util.ts +++ b/packages/table/src/util.ts @@ -349,6 +349,7 @@ export function rowToVisible ($xeTable: any, row: any) { const tableBody: any = $xeTable.$refs.tableBody const { columnStore, scrollYLoad } = reactData const { afterFullData, scrollYStore, fullAllDataRowIdData } = internalData + const { rowHeight } = scrollYStore const { leftList, rightList } = columnStore const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null const rowid = getRowid($xeTable, row) @@ -378,19 +379,19 @@ export function rowToVisible ($xeTable: any, row: any) { // 如果是虚拟渲染滚动 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)