Skip to content

Commit

Permalink
releases 4.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Jan 9, 2025
1 parent 19a6b0d commit 9a943cc
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 24 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": "4.10.3",
"version": "4.10.4",
"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": "^4.3.67"
"vxe-pc-ui": "^4.3.68"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
34 changes: 23 additions & 11 deletions packages/table/src/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any> = {}
if (trigger !== 'cell') {
ons.onMousedown = (evnt: MouseEvent) => {
Expand All @@ -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[]) {
Expand Down Expand Up @@ -104,13 +110,17 @@ 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
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.onMousedown = (evnt: MouseEvent) => {
Expand All @@ -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)
Expand Down
19 changes: 13 additions & 6 deletions packages/table/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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()
}
})
},
/**
* 如果有滚动条,则滚动到对应的列
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 @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9a943cc

Please sign in to comment.