Skip to content

Commit

Permalink
releases 4.10.15
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Feb 13, 2025
1 parent 18b6d6f commit ddfc2ec
Show file tree
Hide file tree
Showing 5 changed files with 312 additions and 100 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table",
"version": "4.10.14",
"version": "4.10.15",
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟树、拖拽排序,懒加载、快捷菜单、数据校验、树形结构、打印、导入导出、自定义模板、渲染器、JSON 配置式...",
"scripts": {
"update": "npm install --legacy-peer-deps",
Expand Down
10 changes: 5 additions & 5 deletions packages/table/module/edit/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ hooks.add('tableEditModule', {
}
parentChilds[funcName](item)
mapChilds[funcName](item)
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0 }
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
fullDataRowIdData[rowid] = rest
fullAllDataRowIdData[rowid] = rest
} else {
Expand All @@ -97,7 +97,7 @@ hooks.add('tableEditModule', {
}
afterFullData[funcName](item)
tableFullTreeData[funcName](item)
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: tableFullTreeData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0 }
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: tableFullTreeData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
fullDataRowIdData[rowid] = rest
fullAllDataRowIdData[rowid] = rest
}
Expand All @@ -122,7 +122,7 @@ hooks.add('tableEditModule', {
} else {
newRecords.forEach(item => {
const rowid = getRowid($xeTable, item)
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0 }
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
fullDataRowIdData[rowid] = rest
fullAllDataRowIdData[rowid] = rest
afterFullData.unshift(item)
Expand All @@ -144,7 +144,7 @@ hooks.add('tableEditModule', {
} else {
newRecords.forEach(item => {
const rowid = getRowid($xeTable, item)
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, treeIndex: -1, $index: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0 }
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, treeIndex: -1, $index: -1, items: afterFullData, parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
fullDataRowIdData[rowid] = rest
fullAllDataRowIdData[rowid] = rest
afterFullData.push(item)
Expand Down Expand Up @@ -184,7 +184,7 @@ hooks.add('tableEditModule', {
targetIndex = targetIndex + 1
}
parentMapChilds.splice(targetIndex, 0, item)
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0 }
const rest = { row: item, rowid, seq: -1, index: -1, _index: -1, $index: -1, treeIndex: -1, items: parentMapChilds, parent: parentRow, level: parentLevel + 1, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
fullDataRowIdData[rowid] = rest
fullAllDataRowIdData[rowid] = rest
})
Expand Down
110 changes: 60 additions & 50 deletions packages/table/src/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default defineComponent({
const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTablePrivateMethods)

const { xID, props: tableProps, context: tableContext, reactData: tableReactData, internalData: tableInternalData } = $xeTable
const { computeEditOpts, computeMouseOpts, computeAreaOpts, computeDefaultRowHeight, computeEmptyOpts, computeTooltipOpts, computeRadioOpts, computeExpandOpts, computeTreeOpts, computeCheckboxOpts, computeCellOpts, computeValidOpts, computeRowOpts, computeColumnOpts, computeRowDragOpts, computeColumnDragOpts, computeLeftFixedWidth, computeRightFixedWidth, computeResizableOpts } = $xeTable.getComputeMaps()
const { computeEditOpts, computeMouseOpts, computeAreaOpts, computeDefaultRowHeight, computeEmptyOpts, computeTooltipOpts, computeRadioOpts, computeExpandOpts, computeTreeOpts, computeCheckboxOpts, computeCellOpts, computeValidOpts, computeRowOpts, computeColumnOpts, computeRowDragOpts, computeColumnDragOpts, computeResizableOpts } = $xeTable.getComputeMaps()

const refElem = ref() as Ref<HTMLDivElement>
const refBodyScroll = ref() as Ref<HTMLDivElement>
Expand Down Expand Up @@ -429,7 +429,7 @@ export default defineComponent({

const renderRows = (fixedType: 'left' | 'right' | '', isOptimizeMode: boolean, tableData: any[], tableColumn: VxeTableDefines.ColumnInfo[]) => {
const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, editConfig, treeConfig } = tableProps
const { hasFixedColumn, treeExpandedMaps, isColLoading, scrollXLoad, scrollYLoad, isAllOverflow, rowExpandedMaps, expandColumn, selectRadioRow, pendingRowMaps, isDragColMove } = tableReactData
const { hasFixedColumn, treeExpandedMaps, isColLoading, scrollXLoad, scrollYLoad, isAllOverflow, rowExpandedMaps, expandColumn, selectRadioRow, pendingRowMaps, isDragColMove, rowExpandHeightFlag } = tableReactData
const { fullAllDataRowIdData } = tableInternalData
const checkboxOpts = computeCheckboxOpts.value
const radioOpts = computeRadioOpts.value
Expand Down Expand Up @@ -462,18 +462,18 @@ export default defineComponent({
}
}
const rowid = getRowid($xeTable, row)
const rest = fullAllDataRowIdData[rowid]
const rowRest = fullAllDataRowIdData[rowid]
let rowLevel = 0
let seq: string | number = -1
let _rowIndex = 0
if (rest) {
rowLevel = rest.level
if (rowRest) {
rowLevel = rowRest.level
if (treeConfig && transform && seqMode === 'increasing') {
seq = rest._index + 1
seq = rowRest._index + 1
} else {
seq = rest.seq
seq = rowRest.seq
}
_rowIndex = rest._index
_rowIndex = rowRest._index
}
const params = { $table: $xeTable, seq, rowid, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex }
// 行是否被展开
Expand Down Expand Up @@ -537,46 +537,60 @@ export default defineComponent({
// 如果行被展开了
if (isExpandRow) {
const expandOpts = computeExpandOpts.value
const { height: expandHeight, padding } = expandOpts
const cellStyle: any = {}
if (expandHeight) {
cellStyle.height = `${expandHeight}px`
}
if (treeConfig) {
cellStyle.paddingLeft = `${(rowLevel * treeOpts.indent) + 30}px`
}
const { showOverflow } = expandColumn
const hasEllipsis = (XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow)) ? isAllOverflow : showOverflow
const expandParams = { $table: $xeTable, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex }
rows.push(
h('tr', {
class: ['vxe-body--expanded-row', {
'is--padding': padding
}],
key: `expand_${rowid}`,
style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(expandParams) : rowStyle) : null,
...trOn
}, [
h('td', {
class: {
'vxe-body--expanded-column': 1,
'fixed--hidden': fixedType && !hasFixedColumn,
'col--ellipsis': hasEllipsis
},
colspan: tableColumn.length
const { height: expandHeight, padding, mode: expandMode } = expandOpts
if (expandMode === 'fixed') {
rows.push(
h('tr', {
class: 'vxe-body--row-expanded-place',
key: `expand_${rowid}`,
rowid
}, [
h('div', {
class: {
'vxe-body--expanded-cell': 1,
'is--ellipsis': expandHeight
},
style: cellStyle
h('td', {
class: 'vxe-body--row-expanded-place-column',
colspan: tableColumn.length,
style: {
height: `${rowExpandHeightFlag ? (rowRest.expandHeight || expandHeight) : 0}px`
}
})
])
)
} else {
const cellStyle: any = {}
if (expandHeight) {
cellStyle.height = `${expandHeight}px`
}
if (treeConfig) {
cellStyle.paddingLeft = `${(rowLevel * treeOpts.indent) + 30}px`
}
const { showOverflow } = expandColumn
const hasEllipsis = (XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow)) ? isAllOverflow : showOverflow
const expandParams = { $table: $xeTable, seq, column: expandColumn, fixed: fixedType, type: renderType, level: rowLevel, row, rowIndex, $rowIndex, _rowIndex }
rows.push(
h('tr', {
class: ['vxe-body--expanded-row', {
'is--padding': padding
}],
key: `expand_${rowid}`
}, [
h('td', {
class: ['vxe-body--expanded-column', {
'fixed--hidden': fixedType && !hasFixedColumn,
'col--ellipsis': hasEllipsis
}],
colspan: tableColumn.length
}, [
expandColumn.renderData(expandParams)
h('div', {
class: ['vxe-body--expanded-cell', {
'is--ellipsis': expandHeight
}],
style: cellStyle
}, [
expandColumn.renderData(expandParams)
])
])
])
])
)
)
}
}
// 如果是树形表格
if (isExpandTree) {
Expand Down Expand Up @@ -627,15 +641,14 @@ export default defineComponent({
const emptyOpts = computeEmptyOpts.value
const mouseOpts = computeMouseOpts.value
const rowDragOpts = computeRowDragOpts.value
const leftFixedWidth = computeLeftFixedWidth.value
const rightFixedWidth = computeRightFixedWidth.value
const expandOpts = computeExpandOpts.value

let renderDataList = tableData
let renderColumnList = tableColumn as VxeTableDefines.ColumnInfo[]
let isOptimizeMode = false
// 如果是使用优化模式
if (scrollXLoad || scrollYLoad || isAllOverflow) {
if (expandColumn || spanMethod || footerSpanMethod) {
if ((expandColumn && expandOpts.mode !== 'fixed') || spanMethod || footerSpanMethod) {
// 如果不支持优化模式
} else {
isOptimizeMode = true
Expand Down Expand Up @@ -716,9 +729,6 @@ export default defineComponent({
$xeTable.triggerBodyScrollEvent(evnt, fixedType)
}
}
if (scrollYLoad || leftFixedWidth || rightFixedWidth) {
ons.onWheel = $xeTable.triggerBodyWheelEvent
}

return h('div', {
ref: refElem,
Expand Down
Loading

0 comments on commit ddfc2ec

Please sign in to comment.