Skip to content

Commit

Permalink
releases 4.9.27
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 14, 2024
1 parent 6668697 commit fe64a94
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 44 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.26",
"version": "4.9.27",
"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.31"
"vxe-pc-ui": "^4.3.32"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
9 changes: 8 additions & 1 deletion packages/grid/src/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ export default defineComponent({
return getConfig().grid.layouts || ['Form', 'Toolbar', 'Top', 'Table', 'Bottom', 'Pager']
})

const computePageConfFlag = computed(() => {
const pagerOpts = computePagerOpts.value
return `${pagerOpts.currentPage}${pagerOpts.pageSize}`
})

const refMaps: GridPrivateRef = {
refElem,
refTable,
Expand Down Expand Up @@ -374,7 +379,9 @@ export default defineComponent({
const { proxyConfig } = props
const { $event } = params
const proxyOpts = computeProxyOpts.value
const $xeTable = refTable.value
if (proxyConfig && isEnableConf(proxyOpts)) {
$xeTable.clearScroll()
gridMethods.commitProxy('reload').then((rest) => {
gridMethods.dispatchEvent('proxy-query', { ...rest, isReload: true }, $event)
})
Expand Down Expand Up @@ -1236,7 +1243,7 @@ export default defineComponent({
initToolbar()
})

watch(() => props.pagerConfig, () => {
watch(computePageConfFlag, () => {
initPages()
})

Expand Down
13 changes: 10 additions & 3 deletions packages/table/module/edit/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ hooks.add('tableEditModule', {
const treeOpts = computeTreeOpts.value
const { transform, mapChildrenField } = treeOpts
const childrenField = treeOpts.children || treeOpts.childrenField
const { actived, removeMaps, insertMaps } = editStore
const { actived, removeMaps } = editStore
const insertDataRowMaps = Object.assign({}, editStore.insertMaps)
const pendingDataRowMaps = Object.assign({}, reactData.pendingRowMaps)
const { checkField } = checkboxOpts
let delList: any[] = []
if (!rows) {
Expand Down Expand Up @@ -428,10 +430,15 @@ hooks.add('tableEditModule', {
// 从新增中移除已删除的数据
rows.forEach((row: any) => {
const rowid = getRowid($xeTable, row)
if (insertMaps[rowid]) {
delete insertMaps[rowid]
if (insertDataRowMaps[rowid]) {
delete insertDataRowMaps[rowid]
}
if (pendingDataRowMaps[rowid]) {
delete pendingDataRowMaps[rowid]
}
})
editStore.insertMaps = insertDataRowMaps
reactData.pendingRowMaps = pendingDataRowMaps
$xeTable.updateFooter()
$xeTable.cacheRowMap()
$xeTable.handleTableData(treeConfig && transform)
Expand Down
4 changes: 2 additions & 2 deletions packages/table/src/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export default defineComponent({

const renderRows = (fixedType: any, tableData: any, tableColumn: any) => {
const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, showOverflow: allColumnOverflow, editConfig, treeConfig } = tableProps
const { hasFixedColumn, treeExpandedMaps, scrollYLoad, rowExpandedMaps, expandColumn, selectRadioRow, pendingRowMaps, pendingRowList, isDragColMove } = tableReactData
const { hasFixedColumn, treeExpandedMaps, scrollYLoad, rowExpandedMaps, expandColumn, selectRadioRow, pendingRowMaps, isDragColMove } = tableReactData
const { fullAllDataRowIdData } = tableInternalData
const checkboxOpts = computeCheckboxOpts.value
const radioOpts = computeRadioOpts.value
Expand Down Expand Up @@ -463,7 +463,7 @@ export default defineComponent({
'row--new': isNewRow && (editOpts.showStatus || editOpts.showInsertStatus),
'row--radio': radioOpts.highlight && $xeTable.eqRow(selectRadioRow, row),
'row--checked': checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
'row--pending': pendingRowList.length && !!pendingRowMaps[rowid]
'row--pending': !!pendingRowMaps[rowid]
},
getPropClass(rowClassName, params)
]
Expand Down
66 changes: 30 additions & 36 deletions packages/table/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ export default defineComponent({
reColumnFlag: 0,
// 已标记的对象集
pendingRowMaps: {},
// 已标记的行
pendingRowList: [],
// 初始化标识
initStore: {
filter: false,
Expand Down Expand Up @@ -3261,16 +3259,13 @@ export default defineComponent({
* @param {Array} datas 数据
*/
loadData (datas) {
const { inited, initStatus } = internalData
const { initStatus } = internalData
return loadTableData(datas).then(() => {
internalData.inited = true
internalData.initStatus = true
if (!initStatus) {
handleLoadDefaults()
}
if (!inited) {
handleInitDefaults()
}
return tableMethods.recalculate()
})
},
Expand All @@ -3279,7 +3274,6 @@ export default defineComponent({
* @param {Array} datas 数据
*/
reloadData (datas) {
const { inited } = internalData
return tableMethods.clearAll()
.then(() => {
internalData.inited = true
Expand All @@ -3288,9 +3282,6 @@ export default defineComponent({
})
.then(() => {
handleLoadDefaults()
if (!inited) {
handleInitDefaults()
}
return tableMethods.recalculate()
})
},
Expand Down Expand Up @@ -4520,58 +4511,44 @@ export default defineComponent({
return nextTick()
},
setPendingRow (rows: any | any[], status: boolean) {
const pendingMaps = { ...reactData.pendingRowMaps }
const pendingList = [...reactData.pendingRowList]
const pendingMaps = Object.assign({}, reactData.pendingRowMaps)
if (rows && !XEUtils.isArray(rows)) {
rows = [rows]
}
if (status) {
rows.forEach((row: any) => {
const rowid = getRowid($xeTable, row)
if (rowid && !pendingMaps[rowid]) {
pendingList.push(row)
pendingMaps[rowid] = row
}
})
} else {
rows.forEach((row: any) => {
const rowid = getRowid($xeTable, row)
if (rowid && pendingMaps[rowid]) {
const pendingIndex = $xeTable.findRowIndexOf(pendingList, row)
if (pendingIndex > -1) {
pendingList.splice(pendingIndex, 1)
}
delete pendingMaps[rowid]
}
})
}
reactData.pendingRowMaps = pendingMaps
reactData.pendingRowList = pendingList
return nextTick()
},
togglePendingRow (rows: any | any[]) {
const pendingMaps = { ...reactData.pendingRowMaps }
const pendingList = [...reactData.pendingRowList]
const pendingMaps = Object.assign({}, reactData.pendingRowMaps)
if (rows && !XEUtils.isArray(rows)) {
rows = [rows]
}
rows.forEach((row: any) => {
const rowid = getRowid($xeTable, row)
if (rowid) {
if (pendingMaps[rowid]) {
const pendingIndex = $xeTable.findRowIndexOf(pendingList, row)
if (pendingIndex > -1) {
pendingList.splice(pendingIndex, 1)
}
delete pendingMaps[rowid]
} else {
pendingList.push(row)
pendingMaps[rowid] = row
}
}
})
reactData.pendingRowMaps = pendingMaps
reactData.pendingRowList = pendingList
return nextTick()
},
hasPendingByRow (row) {
Expand All @@ -4583,12 +4560,18 @@ export default defineComponent({
return !!pendingRowMaps[rowid]
},
getPendingRecords () {
const { pendingRowList } = reactData
return pendingRowList.slice(0)
const { pendingRowMaps } = reactData
const { fullAllDataRowIdData } = internalData
const insertRecords: any[] = []
XEUtils.each(pendingRowMaps, (row, rowid) => {
if (fullAllDataRowIdData[rowid]) {
insertRecords.push(row)
}
})
return insertRecords
},
clearPendingRow () {
reactData.pendingRowMaps = {}
reactData.pendingRowList = []
return nextTick()
},
sort (sortConfs: any, sortOrder?: VxeTablePropTypes.SortOrder) {
Expand Down Expand Up @@ -6944,6 +6927,20 @@ export default defineComponent({
}
}
}
// 如果是双击编辑模式
if (isEnableConf(editConfig) && editOpts.trigger === 'dblclick') {
if (actived.row && actived.column) {
if (editOpts.mode === 'row') {
if (!$xeTable.eqRow(actived.row, row)) {
$xeTable.handleClearEdit(evnt)
}
} else if (editOpts.mode === 'cell') {
if (!$xeTable.eqRow(actived.row, row) || actived.column.id !== column.id) {
$xeTable.handleClearEdit(evnt)
}
}
}
}
dispatchEvent('cell-click', params, evnt)
},
/**
Expand Down Expand Up @@ -7732,6 +7729,8 @@ export default defineComponent({
}
internalData.lastScrollTop = scrollTop
}
reactData.isDragColMove = false
reactData.isDragRowMove = false
reactData.lastScrollTime = Date.now()
const evntParams = {
scrollTop,
Expand Down Expand Up @@ -8468,17 +8467,14 @@ export default defineComponent({
dataFlag.value++
})
watch(dataFlag, () => {
const { inited, initStatus } = internalData
const { initStatus } = internalData
loadTableData(props.data || []).then(() => {
const { scrollXLoad, scrollYLoad, expandColumn } = reactData
internalData.inited = true
internalData.initStatus = true
if (!initStatus) {
handleLoadDefaults()
}
if (!inited) {
handleInitDefaults()
}
if (process.env.VUE_APP_VXE_ENV === 'development') {
// const checkboxOpts = computeCheckboxOpts.value
// const checkboxColumn = internalData.tableFullColumn.find(column => column.type === 'checkbox')
Expand Down Expand Up @@ -8783,8 +8779,8 @@ export default defineComponent({
internalData.inited = true
internalData.initStatus = true
handleLoadDefaults()
handleInitDefaults()
}
handleInitDefaults()
updateStyle()
})

Expand Down Expand Up @@ -8825,8 +8821,6 @@ export default defineComponent({
tablePrivateMethods.preventEvent(null, 'mounted', { $table: $xeTable })
})

;(window as any).aaaa = $xeTable

onBeforeUnmount(() => {
if (resizeObserver) {
resizeObserver.disconnect()
Expand Down

0 comments on commit fe64a94

Please sign in to comment.