Skip to content

Commit

Permalink
releases 3.12.8
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Jan 9, 2025
1 parent ed953d4 commit 0907a78
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 27 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
29 changes: 19 additions & 10 deletions packages/table/src/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any> = {}
if (trigger !== 'cell') {
ons.mousedown = (evnt: MouseEvent) => {
Expand All @@ -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[]) {
Expand Down Expand Up @@ -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<string, any> = {}
if (trigger !== 'cell') {
ons.mousedown = (evnt: MouseEvent) => {
Expand All @@ -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)
Expand Down
29 changes: 19 additions & 10 deletions packages/table/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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()
}
})
},
/**
* 如果有滚动条,则滚动到对应的列
Expand Down
11 changes: 6 additions & 5 deletions packages/table/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0907a78

Please sign in to comment.