From fe64a945d240fcbfe58439fbd5569da2e0c034e5 Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Sat, 14 Dec 2024 23:41:53 +0800 Subject: [PATCH] releases 4.9.27 --- package.json | 4 +- packages/grid/src/grid.ts | 9 +++- packages/table/module/edit/hook.ts | 13 ++++-- packages/table/src/body.ts | 4 +- packages/table/src/table.ts | 66 ++++++++++++++---------------- 5 files changed, 52 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index fe68a660a3..7ddc354186 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/packages/grid/src/grid.ts b/packages/grid/src/grid.ts index 03af929710..ff3b195ae7 100644 --- a/packages/grid/src/grid.ts +++ b/packages/grid/src/grid.ts @@ -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, @@ -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) }) @@ -1236,7 +1243,7 @@ export default defineComponent({ initToolbar() }) - watch(() => props.pagerConfig, () => { + watch(computePageConfFlag, () => { initPages() }) diff --git a/packages/table/module/edit/hook.ts b/packages/table/module/edit/hook.ts index be1dd757a4..faddfd9f32 100644 --- a/packages/table/module/edit/hook.ts +++ b/packages/table/module/edit/hook.ts @@ -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) { @@ -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) diff --git a/packages/table/src/body.ts b/packages/table/src/body.ts index 736fd45716..0e1f83be02 100644 --- a/packages/table/src/body.ts +++ b/packages/table/src/body.ts @@ -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 @@ -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) ] diff --git a/packages/table/src/table.ts b/packages/table/src/table.ts index c820ddc8da..45c8e642a4 100644 --- a/packages/table/src/table.ts +++ b/packages/table/src/table.ts @@ -114,8 +114,6 @@ export default defineComponent({ reColumnFlag: 0, // 已标记的对象集 pendingRowMaps: {}, - // 已标记的行 - pendingRowList: [], // 初始化标识 initStore: { filter: false, @@ -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() }) }, @@ -3279,7 +3274,6 @@ export default defineComponent({ * @param {Array} datas 数据 */ reloadData (datas) { - const { inited } = internalData return tableMethods.clearAll() .then(() => { internalData.inited = true @@ -3288,9 +3282,6 @@ export default defineComponent({ }) .then(() => { handleLoadDefaults() - if (!inited) { - handleInitDefaults() - } return tableMethods.recalculate() }) }, @@ -4520,8 +4511,7 @@ 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] } @@ -4529,7 +4519,6 @@ export default defineComponent({ rows.forEach((row: any) => { const rowid = getRowid($xeTable, row) if (rowid && !pendingMaps[rowid]) { - pendingList.push(row) pendingMaps[rowid] = row } }) @@ -4537,21 +4526,15 @@ export default defineComponent({ 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] } @@ -4559,19 +4542,13 @@ export default defineComponent({ 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) { @@ -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) { @@ -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) }, /** @@ -7732,6 +7729,8 @@ export default defineComponent({ } internalData.lastScrollTop = scrollTop } + reactData.isDragColMove = false + reactData.isDragRowMove = false reactData.lastScrollTime = Date.now() const evntParams = { scrollTop, @@ -8468,7 +8467,7 @@ 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 @@ -8476,9 +8475,6 @@ export default defineComponent({ 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') @@ -8783,8 +8779,8 @@ export default defineComponent({ internalData.inited = true internalData.initStatus = true handleLoadDefaults() - handleInitDefaults() } + handleInitDefaults() updateStyle() }) @@ -8825,8 +8821,6 @@ export default defineComponent({ tablePrivateMethods.preventEvent(null, 'mounted', { $table: $xeTable }) }) - ;(window as any).aaaa = $xeTable - onBeforeUnmount(() => { if (resizeObserver) { resizeObserver.disconnect()