From fc64edf05e40e53c5daf9c5a0e3947dbed159d60 Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Wed, 7 Aug 2024 22:17:13 +0800 Subject: [PATCH] =?UTF-8?q?fix=20menu-config.enabled=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98=20#2509?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 2 +- README.zh-TW.md | 6 +- package.json | 2 +- packages/table/module/menu/panel.ts | 6 +- packages/table/src/props.ts | 2 +- packages/table/src/table.ts | 88 +++++++++++++++++------------ styles/components/icon.scss | 2 + 7 files changed, 63 insertions(+), 45 deletions(-) diff --git a/README.en.md b/README.en.md index e5cb2a2c85..d63cc91827 100644 --- a/README.en.md +++ b/README.en.md @@ -1,6 +1,6 @@ # vxe-table -[简体中文](README.md) | [繁體中文](README.zh-TW.md) | English +[简体中文](README.md) | [繁體中文](README.zh-TW.md) | English | [日本語](README.ja-JP.md) [![star](https://gitee.com/xuliangzhan_admin/vxe-table/badge/star.svg?theme=gvp)](https://gitee.com/xuliangzhan_admin/vxe-table/stargazers) [![npm version](https://img.shields.io/npm/v/vxe-table.svg?style=flat-square)](https://www.npmjs.com/package/vxe-table) diff --git a/README.zh-TW.md b/README.zh-TW.md index 6f1d16f06a..bd29bece7f 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -1,6 +1,6 @@ # vxe-table -[简体中文](README.md) | 繁體中文 | [English](README.en.md) +[简体中文](README.md) | 繁體中文 | [English](README.en.md) | [日本語](README.ja-JP.md) [![star](https://gitee.com/xuliangzhan_admin/vxe-table/badge/star.svg?theme=gvp)](https://gitee.com/xuliangzhan_admin/vxe-table/stargazers) [![npm version](https://img.shields.io/npm/v/vxe-table.svg?style=flat-square)](https://www.npmjs.com/package/vxe-table) @@ -59,8 +59,8 @@ Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | * [x] 虛擬滾動 * [x] 虛擬合併 * [x] CSS 變量主題 -* [x] (([企業版](https://vxetable.cn/pluginDocs/))) 儲存格區域選取 -* [x] (([企業版](https://vxetable.cn/pluginDocs/))) 儲存格複製/粘貼 +* [x] ([企業版](https://vxetable.cn/pluginDocs/)) 儲存格區域選取 +* [x] ([企業版](https://vxetable.cn/pluginDocs/)) 儲存格複製/粘貼 * [x] ([企業版](https://vxetable.cn/pluginDocs/)) 儲存格查找和替換 * [x] ([企業版](https://vxetable.cn/pluginDocs/)) 全鍵盤操作 diff --git a/package.json b/package.json index d520b471d1..f442a6b577 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "style": "lib/style.css", "typings": "types/index.d.ts", "dependencies": { - "vxe-pc-ui": "^4.0.88" + "vxe-pc-ui": "^4.0.91" }, "devDependencies": { "@types/resize-observer-browser": "^0.1.11", diff --git a/packages/table/module/menu/panel.ts b/packages/table/module/menu/panel.ts index c0facb6cc0..a3f0492d58 100644 --- a/packages/table/module/menu/panel.ts +++ b/packages/table/module/menu/panel.ts @@ -19,7 +19,7 @@ export default defineComponent({ refElem } - const $xemenupanel: any = { + const $xeMenuPanel: any = { xID, props, context, @@ -123,9 +123,9 @@ export default defineComponent({ ]) } - $xemenupanel.renderVN = renderVN + $xeMenuPanel.renderVN = renderVN - return $xemenupanel + return $xeMenuPanel }, render () { return this.renderVN() diff --git a/packages/table/src/props.ts b/packages/table/src/props.ts index 251d5e78bd..e4b6c6269a 100644 --- a/packages/table/src/props.ts +++ b/packages/table/src/props.ts @@ -7,7 +7,7 @@ const { getConfig } = VxeUI export default { /** 基本属性 */ - id: String as PropType, + id: [String, Function] as PropType, // 数据 data: Array as PropType, // 表格的高度 diff --git a/packages/table/src/table.ts b/packages/table/src/table.ts index d3b189119d..e11360a40d 100644 --- a/packages/table/src/table.ts +++ b/packages/table/src/table.ts @@ -363,6 +363,17 @@ export default defineComponent({ const $xeGrid = inject<(VxeGridConstructor & VxeGridPrivateMethods) | null>('$xeGrid', null) let $xeToolbar: VxeToolbarConstructor + const computeTableId = computed(() => { + const { id } = props + if (id) { + if (XEUtils.isFunction(id)) { + return `${id({ $table: $xeTable, $grid: $xeGrid }) || ''}` + } + return `${id}` + } + return '' + }) + const computeValidOpts = computed(() => { return Object.assign({}, getConfig().table.validConfig, props.validConfig) as VxeTablePropTypes.ValidOpts }) @@ -622,6 +633,7 @@ export default defineComponent({ const computeMaps: VxeTablePrivateComputed = { computeSize, + computeTableId, computeValidOpts, computeSXOpts, computeSYOpts, @@ -943,7 +955,8 @@ export default defineComponent({ * 还原自定义列操作状态 */ const restoreCustomStorage = () => { - const { id, customConfig } = props + const { customConfig } = props + const tableId = computeTableId.value const customOpts = computeCustomOpts.value const { storage, restoreStore } = customOpts const isAllCustom = storage === true @@ -953,14 +966,14 @@ export default defineComponent({ const isCustomFixed = isAllCustom || storageOpts.fixed const isCustomSort = isAllCustom || storageOpts.sort if (customConfig && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) { - if (!id) { + if (!tableId) { errLog('vxe.error.reqProp', ['id']) return } - const storeData: VxeTableDefines.CustomStoreData = getCustomStorageMap(id) + const storeData: VxeTableDefines.CustomStoreData = getCustomStorageMap(tableId) if (restoreStore) { return Promise.resolve( - restoreStore({ id, type: 'restore', storeData }) + restoreStore({ id: tableId, type: 'restore', storeData }) ).then(storeData => { if (!storeData) { return @@ -4823,9 +4836,9 @@ export default defineComponent({ $xeTable.clearSelected() } if (areaOpts.autoClear) { - if ($xeTable.clearCellAreas) { + if ($xeTable.getCellAreas) { const cellAreas = $xeTable.getCellAreas() - if (cellAreas.length && !getEventTargetNode(evnt, document.body, 'vxe-table--ignore-areas-clear').flag) { + if (cellAreas && cellAreas.length && !getEventTargetNode(evnt, document.body, 'vxe-table--ignore-areas-clear').flag) { tablePrivateMethods.preventEvent(evnt, 'event.clearAreas', {}, () => { $xeTable.clearCellAreas() $xeTable.clearCopyCellArea() @@ -5503,7 +5516,7 @@ export default defineComponent({ Object.assign(reactData.columnStore, { resizeList, pxList, pxMinList, scaleList, scaleMinList, autoList, remainList }) }, saveCustomStore (type) { - const { id } = props + const tableId = computeTableId.value const customOpts = computeCustomOpts.value const { updateStore, storage } = customOpts const isAllCustom = storage === true @@ -5513,7 +5526,7 @@ export default defineComponent({ const isCustomFixed = isAllCustom || storageOpts.fixed const isCustomSort = isAllCustom || storageOpts.sort if (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort) { - if (!id) { + if (!tableId) { errLog('vxe.error.reqProp', ['id']) return nextTick() } @@ -5527,12 +5540,12 @@ export default defineComponent({ : tableMethods.getCustomStoreData() if (updateStore) { return updateStore({ - id, + id: tableId, type, storeData }) } else { - setCustomStorageMap(id, type === 'reset' ? null : storeData) + setCustomStorageMap(tableId, type === 'reset' ? null : storeData) } } return nextTick() @@ -7093,34 +7106,37 @@ export default defineComponent({ }) : createCommentVNode(), /** - * 通用提示 + * 提示相关 */ VxeUITooltipComponent - ? h(VxeUITooltipComponent, { - ref: refCommTooltip, - isArrow: false, - enterable: false - }) - : createCommentVNode(), - /** - * 工具提示 - */ - VxeUITooltipComponent - ? h(VxeUITooltipComponent, Object.assign({ - ref: refTooltip - }, tipConfig, tooltipStore.currOpts)) - : createCommentVNode(), - /** - * 校验提示 - */ - VxeUITooltipComponent && props.editRules && validOpts.showMessage && (validOpts.message === 'default' ? !height : validOpts.message === 'tooltip') - ? h(VxeUITooltipComponent, { - ref: refValidTooltip, - class: [{ - 'old-cell-valid': editRules && getConfig().cellVaildMode === 'obsolete' - }, 'vxe-table--valid-error'], - ...(validOpts.message === 'tooltip' || tableData.length === 1 ? validTipOpts : {}) as any - }) + ? h('div', {}, [ + /** + * 通用提示 + */ + h(VxeUITooltipComponent, { + ref: refCommTooltip, + isArrow: false, + enterable: false + }), + /** + * 工具提示 + */ + h(VxeUITooltipComponent, Object.assign({ + ref: refTooltip + }, tipConfig, tooltipStore.currOpts)), + /** + * 校验提示 + */ + props.editRules && validOpts.showMessage && (validOpts.message === 'default' ? !height : validOpts.message === 'tooltip') + ? h(VxeUITooltipComponent, { + ref: refValidTooltip, + class: [{ + 'old-cell-valid': editRules && getConfig().cellVaildMode === 'obsolete' + }, 'vxe-table--valid-error'], + ...(validOpts.message === 'tooltip' || tableData.length === 1 ? validTipOpts : {}) as any + }) + : createCommentVNode() + ]) : createCommentVNode() ]) } diff --git a/styles/components/icon.scss b/styles/components/icon.scss index 6e20d2fec5..7ae89bb84c 100644 --- a/styles/components/icon.scss +++ b/styles/components/icon.scss @@ -1,3 +1,5 @@ +@import './old-icon.scss'; + @font-face { font-family: "vxetableiconfont"; src: