Skip to content

Commit

Permalink
重构复选框,大幅提升渲染速度
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 13, 2024
1 parent 86e1281 commit d2c0778
Show file tree
Hide file tree
Showing 4 changed files with 314 additions and 359 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.9.25",
"version": "4.9.26-beta.1",
"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.29"
"vxe-pc-ui": "^4.3.30"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
44 changes: 26 additions & 18 deletions packages/table/module/custom/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,37 @@ VxeUI.hooks.add('tableCustomModule', {

const openCustom = () => {
const { initStore, customStore } = reactData
const { collectColumn } = internalData
const sortMaps: Record<string, number> = {}
const fixedMaps: Record<string, VxeColumnPropTypes.Fixed> = {}
const visibleMaps: Record<string, boolean> = {}
XEUtils.eachTree(collectColumn, column => {
const colid = column.getKey()
column.renderFixed = column.fixed
column.renderVisible = column.visible
column.renderResizeWidth = column.renderWidth
sortMaps[colid] = column.renderSortNumber
fixedMaps[colid] = column.fixed
visibleMaps[colid] = column.visible
})
customStore.oldSortMaps = sortMaps
customStore.oldFixedMaps = fixedMaps
customStore.oldVisibleMaps = visibleMaps
reactData.customColumnList = collectColumn.slice(0)
customStore.visible = true
initStore.custom = true
handleUpdateCustomColumn()
checkCustomStatus()
calcMaxHeight()
return nextTick().then(() => calcMaxHeight())
}

const handleUpdateCustomColumn = () => {
const { customStore } = reactData
const { collectColumn } = internalData
if (customStore.visible) {
const sortMaps: Record<string, number> = {}
const fixedMaps: Record<string, VxeColumnPropTypes.Fixed> = {}
const visibleMaps: Record<string, boolean> = {}
XEUtils.eachTree(collectColumn, column => {
const colid = column.getKey()
column.renderFixed = column.fixed
column.renderVisible = column.visible
column.renderResizeWidth = column.renderWidth
sortMaps[colid] = column.renderSortNumber
fixedMaps[colid] = column.fixed
visibleMaps[colid] = column.visible
})
customStore.oldSortMaps = sortMaps
customStore.oldFixedMaps = fixedMaps
customStore.oldVisibleMaps = visibleMaps
reactData.customColumnList = collectColumn.slice(0)
}
}

const closeCustom = () => {
const { customStore } = reactData
const customOpts = computeCustomOpts.value
Expand Down Expand Up @@ -252,7 +259,8 @@ VxeUI.hooks.add('tableCustomModule', {
$xeTable.closeCustom()
$xeTable.emitCustomEvent('close', evnt)
}
}
},
handleUpdateCustomColumn
}

return { ...customMethods, ...customPrivateMethods }
Expand Down
2 changes: 1 addition & 1 deletion packages/table/module/keyboard/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ hooks.add('tableKeyboardModule', {
lastRangeRows = rangeRows
if (evnt.ctrlKey) {
rangeRows.forEach((row: any) => {
$xeTable.handleSelectRow({ row }, selectRecords.indexOf(row) === -1)
$xeTable.handleBatchSelectRows([row], selectRecords.indexOf(row) === -1)
})
} else {
$xeTable.setAllCheckboxRow(false)
Expand Down
Loading

0 comments on commit d2c0778

Please sign in to comment.