From c9bf25a4322923adda8e3c9cb0c86410e2adb5e1 Mon Sep 17 00:00:00 2001 From: xuliangzhan Date: Sat, 3 Aug 2024 23:17:44 +0800 Subject: [PATCH] releases 4.7.60 --- package.json | 4 +-- packages/grid/src/grid.ts | 45 ++++++++++++++++++++-------- packages/table/module/export/hook.ts | 16 ++++++++-- packages/table/render/index.ts | 18 +++++------ styles/theme/base.scss | 9 ++---- styles/theme/dark.scss | 5 +++- styles/theme/light.scss | 5 +++- 7 files changed, 67 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index 2182f66e8e..82d552e04e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vxe-table", - "version": "4.7.59", + "version": "4.7.60", "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.0.82" + "vxe-pc-ui": "^4.0.86" }, "devDependencies": { "@types/resize-observer-browser": "^0.1.11", diff --git a/packages/grid/src/grid.ts b/packages/grid/src/grid.ts index a9ec10ee32..d1bd0b22af 100644 --- a/packages/grid/src/grid.ts +++ b/packages/grid/src/grid.ts @@ -113,7 +113,7 @@ export default defineComponent({ }) const computeProxyOpts = computed(() => { - return Object.assign({}, getConfig().grid.proxyConfig, props.proxyConfig) as VxeGridPropTypes.ProxyConfig + return XEUtils.merge({}, getConfig().grid.proxyConfig, props.proxyConfig) as VxeGridPropTypes.ProxyConfig }) const computeIsRespMsg = computed(() => { @@ -788,12 +788,14 @@ export default defineComponent({ case 'reload': case 'query': { const ajaxMethods = ajax.query + const querySuccessMethods = ajax.querySuccess + const queryErrorMethods = ajax.queryError if (ajaxMethods) { const isInited = code === '_init' const isReload = code === 'reload' let sortList: any[] = [] let filterList: VxeTableDefines.FilterCheckedParams[] = [] - let pageParams = {} + let pageParams: any = {} if (pagerConfig) { if (isInited || isReload) { tablePage.currentPage = 1 @@ -844,8 +846,7 @@ export default defineComponent({ reactData.sortData = sortList reactData.filterData = filterList reactData.tableLoading = true - const applyArgs = [commitParams].concat(args) - return Promise.resolve((beforeQuery || ajaxMethods)(...applyArgs)) + return Promise.resolve((beforeQuery || ajaxMethods)(commitParams, ...args)) .then(rest => { reactData.tableLoading = false if (rest) { @@ -868,11 +869,17 @@ export default defineComponent({ reactData.tableData = [] } if (afterQuery) { - afterQuery(...applyArgs) + afterQuery(commitParams, ...args) + } + if (querySuccessMethods) { + querySuccessMethods({ ...commitParams, response: rest }) } return { status: true } - }).catch(() => { + }).catch((rest) => { reactData.tableLoading = false + if (queryErrorMethods) { + queryErrorMethods({ ...commitParams, response: rest }) + } return { status: false } }) } else { @@ -884,19 +891,20 @@ export default defineComponent({ } case 'delete': { const ajaxMethods = ajax.delete + const deleteSuccessMethods = ajax.deleteSuccess + const deleteErrorMethods = ajax.deleteError if (ajaxMethods) { const selectRecords = gridExtendTableMethods.getCheckboxRecords() const removeRecords = selectRecords.filter(row => !$xeTable.isInsertByRow(row)) const body = { removeRecords } const commitParams = { $grid: $xeGrid, code, button, body, form: formData, options: ajaxMethods } - const applyArgs = [commitParams].concat(args) if (selectRecords.length) { return handleDeleteRow(code, 'vxe.grid.deleteSelectRecord', () => { if (!removeRecords.length) { return $xeTable.remove(selectRecords) } reactData.tableLoading = true - return Promise.resolve((beforeDelete || ajaxMethods)(...applyArgs)) + return Promise.resolve((beforeDelete || ajaxMethods)(commitParams, ...args)) .then(rest => { reactData.tableLoading = false $xeTable.setPendingRow(removeRecords, false) @@ -906,10 +914,13 @@ export default defineComponent({ } } if (afterDelete) { - afterDelete(...applyArgs) + afterDelete(commitParams, ...args) } else { gridMethods.commitProxy('query') } + if (deleteSuccessMethods) { + deleteSuccessMethods({ ...commitParams, response: rest }) + } return { status: true } }) .catch(rest => { @@ -919,6 +930,9 @@ export default defineComponent({ VxeUI.modal.message({ id: code, content: getRespMsg(rest, 'vxe.grid.operError'), status: 'error' }) } } + if (deleteErrorMethods) { + deleteErrorMethods({ ...commitParams, response: rest }) + } return { status: false } }) }) @@ -938,11 +952,12 @@ export default defineComponent({ } case 'save': { const ajaxMethods = ajax.save + const saveSuccessMethods = ajax.saveSuccess + const saveErrorMethods = ajax.saveError if (ajaxMethods) { const body = $xeTable.getRecordset() const { insertRecords, removeRecords, updateRecords, pendingRecords } = body const commitParams = { $grid: $xeGrid, code, button, body, form: formData, options: ajaxMethods } - const applyArgs = [commitParams].concat(args) // 排除掉新增且标记为删除的数据 if (insertRecords.length) { body.pendingRecords = pendingRecords.filter((row) => $xeTable.findRowIndexOf(insertRecords, row) === -1) @@ -963,7 +978,7 @@ export default defineComponent({ } if (body.insertRecords.length || removeRecords.length || updateRecords.length || body.pendingRecords.length) { reactData.tableLoading = true - return Promise.resolve((beforeSave || ajaxMethods)(...applyArgs)) + return Promise.resolve((beforeSave || ajaxMethods)(commitParams, ...args)) .then(rest => { reactData.tableLoading = false $xeTable.clearPendingRow() @@ -973,10 +988,13 @@ export default defineComponent({ } } if (afterSave) { - afterSave(...applyArgs) + afterSave(commitParams, ...args) } else { gridMethods.commitProxy('query') } + if (saveSuccessMethods) { + saveSuccessMethods({ ...commitParams, response: rest }) + } return { status: true } }) .catch(rest => { @@ -986,6 +1004,9 @@ export default defineComponent({ VxeUI.modal.message({ id: code, content: getRespMsg(rest, 'vxe.grid.operError'), status: 'error' }) } } + if (saveErrorMethods) { + saveErrorMethods({ ...commitParams, response: rest }) + } return { status: false } }) } else { diff --git a/packages/table/module/export/hook.ts b/packages/table/module/export/hook.ts index b2228b5c0d..87acc6e57a 100644 --- a/packages/table/module/export/hook.ts +++ b/packages/table/module/export/hook.ts @@ -1171,9 +1171,12 @@ hooks.add('tableExportModule', { if ($xeGrid && !opts.remote) { const { reactData: gridReactData } = $xeGrid const { computeProxyOpts } = $xeGrid.getComputeMaps() + const { sortData } = gridReactData const proxyOpts = computeProxyOpts.value const { beforeQueryAll, afterQueryAll, ajax = {}, props = {} } = proxyOpts const ajaxMethods = ajax.queryAll + const queryAllSuccessMethods = ajax.queryAllSuccess + const queryAllErrorMethods = ajax.queryAllError if (process.env.VUE_APP_VXE_ENV === 'development') { if (!ajaxMethods) { @@ -1185,21 +1188,28 @@ hooks.add('tableExportModule', { const params = { $table: $xeTable, $grid: $xeGrid, - sort: gridReactData.sortData, + sort: sortData.length ? sortData[0] : {} as any, + sorts: sortData as any[], filters: gridReactData.filterData, form: gridReactData.formData, - target: ajaxMethods, options: opts } return Promise.resolve((beforeQueryAll || ajaxMethods)(params)) - .catch(e => e) .then(rest => { opts.data = (props.list ? XEUtils.get(rest, props.list) : rest) || [] if (afterQueryAll) { afterQueryAll(params) } + if (queryAllSuccessMethods) { + queryAllSuccessMethods({ ...params, response: rest }) + } return handleExport(opts) }) + .catch((rest) => { + if (queryAllErrorMethods) { + queryAllErrorMethods({ ...params, response: rest }) + } + }) } } } else if (mode === 'current') { diff --git a/packages/table/render/index.ts b/packages/table/render/index.ts index 18108b7625..bfba5792d4 100644 --- a/packages/table/render/index.ts +++ b/packages/table/render/index.ts @@ -505,7 +505,7 @@ function getSelectCellValue (renderOpts: any, { row, column }: any) { let selectItem: any const labelProp = optionProps.label || 'label' const valueProp = optionProps.value || 'value' - if (!isEmptyValue(cellValue)) { + if (!(cellValue === null || cellValue === undefined)) { return XEUtils.map(XEUtils.isArray(cellValue) ? cellValue : [cellValue], optionGroups ? (value) => { @@ -540,7 +540,7 @@ function getTreeSelectCellValue (renderOpts: any, { row, column }: any) { const labelProp = optionProps.label || 'label' const valueProp = optionProps.value || 'value' const childrenProp = optionProps.children || 'children' - if (!isEmptyValue(cellValue)) { + if (!(cellValue === null || cellValue === undefined)) { const keyMaps: Record = {} XEUtils.eachTree(options, item => { keyMaps[XEUtils.get(item, valueProp)] = item @@ -596,7 +596,7 @@ renderer.mixin({ exportMethod: handleExportSelectMethod }, VxeInput: { - autofocus: '.vxe-input--inner', + autofocus: 'input', renderEdit: defaultEditRender, renderCell (renderOpts, params) { const { props = {} } = renderOpts @@ -624,7 +624,7 @@ renderer.mixin({ defaultFilterMethod: handleInputFilterMethod }, VxeNumberInput: { - autofocus: '.vxe-number-input--inner', + autofocus: 'input', renderEdit: defaultEditRender, renderCell (renderOpts, params) { const { props = {} } = renderOpts @@ -645,7 +645,7 @@ renderer.mixin({ defaultFilterMethod: handleInputFilterMethod }, VxeDatePicker: { - autofocus: '.vxe-date-picker--inner', + autofocus: 'input', renderEdit: defaultEditRender, renderCell (renderOpts, params) { const { props = {} } = renderOpts @@ -669,7 +669,7 @@ renderer.mixin({ defaultFilterMethod: handleFilterMethod }, VxeTextarea: { - autofocus: '.vxe-textarea--inner' + autofocus: 'VxeTextarea' }, VxeButton: { renderDefault: buttonCellRender @@ -687,7 +687,7 @@ renderer.mixin({ } }, VxeSelect: { - autofocus: '.vxe-input--inner', + autofocus: 'input', renderEdit: defaultSelectEditRender, renderDefault: defaultSelectEditRender, renderCell (renderOpts, params) { @@ -709,7 +709,7 @@ renderer.mixin({ exportMethod: handleExportSelectMethod }, VxeTreeSelect: { - autofocus: '.vxe-input--inner', + autofocus: 'input', renderEdit: defaultTreeSelectEditRender, renderCell (renderOpts, params) { return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params)) @@ -723,7 +723,7 @@ renderer.mixin({ renderDefault: radioAndCheckboxEditRender }, VxeSwitch: { - autofocus: '.vxe-switch--button', + autofocus: 'button', renderEdit: defaultEditRender, renderDefault: defaultEditRender }, diff --git a/styles/theme/base.scss b/styles/theme/base.scss index ec7ac6719c..39f4279358 100644 --- a/styles/theme/base.scss +++ b/styles/theme/base.scss @@ -8,11 +8,6 @@ --vxe-ui-font-size-small: 13px; --vxe-ui-font-size-mini: 12px; - /*font color*/ - --vxe-ui-font-primary-color: #409eff; - --vxe-ui-font-lighten-color: lighten(#606266, 10%); - --vxe-ui-font-disabled-color: #BFBFBF; - /*base border*/ --vxe-ui-border-radius: 4px; @@ -79,8 +74,8 @@ --vxe-ui-table-checkbox-range-border-color: #006af1; --vxe-ui-table-checkbox-range-background-color: rgba(50,128,252,0.2); - --vxe-ui-table-fixed-left-scrolling-box-shadow: 8px 0px 10px -5px rgba(0, 0, 0, 0.12); - --vxe-ui-table-fixed-right-scrolling-box-shadow: -8px 0px 10px -5px rgba(0, 0, 0, 0.12); + --vxe-ui-table-fixed-left-scrolling-box-shadow: 8px 0px 10px -5px var(--vxe-ui-table-fixed-scrolling-box-shadow-color); + --vxe-ui-table-fixed-right-scrolling-box-shadow: -8px 0px 10px -5px var(--vxe-ui-table-fixed-scrolling-box-shadow-color); --vxe-ui-table-menu-item-width: 178px; --vxe-ui-table-menu-background-color: #fff; diff --git a/styles/theme/dark.scss b/styles/theme/dark.scss index e886007741..936e0934ea 100644 --- a/styles/theme/dark.scss +++ b/styles/theme/dark.scss @@ -3,10 +3,12 @@ [data-vxe-ui-theme="dark"] { color-scheme: dark; - /*font*/ + /*font color*/ --vxe-ui-font-color: #a0a3a7; + --vxe-ui-font-primary-color: #409eff; --vxe-ui-font-lighten-color: #babdc0; --vxe-ui-font-darken-color: #86898e; + --vxe-ui-font-disabled-color: #BFBFBF; /*base*/ --vxe-ui-base-popup-border-color: var(--vxe-ui-layout-background-color); @@ -35,4 +37,5 @@ --vxe-ui-table-row-hover-checkbox-checked-background-color: #6e5326; --vxe-ui-table-row-current-background-color: #18222c; --vxe-ui-table-row-hover-current-background-color: #262727; + --vxe-ui-table-fixed-scrolling-box-shadow-color: rgba(0, 0, 0, 0.8); } diff --git a/styles/theme/light.scss b/styles/theme/light.scss index 37b875e143..915fb987a6 100644 --- a/styles/theme/light.scss +++ b/styles/theme/light.scss @@ -1,10 +1,12 @@ @import './base.scss'; [data-vxe-ui-theme="light"] { - /*font*/ + /*font color*/ --vxe-ui-font-color: #606266; + --vxe-ui-font-primary-color: #409eff; --vxe-ui-font-lighten-color: #797b80; --vxe-ui-font-darken-color: #47494c; + --vxe-ui-font-disabled-color: #BFBFBF; /*base*/ --vxe-ui-base-popup-border-color: #DADCE0; @@ -33,4 +35,5 @@ --vxe-ui-table-row-hover-checkbox-checked-background-color: #ffebbc; --vxe-ui-table-row-current-background-color: #e6f7ff; --vxe-ui-table-row-hover-current-background-color: #d7effb; + --vxe-ui-table-fixed-scrolling-box-shadow-color: rgba(0, 0, 0, 0.12); } \ No newline at end of file