Skip to content

Commit

Permalink
releases 4.7.60
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Aug 3, 2024
1 parent d9d146a commit c9bf25a
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 35 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.7.59",
"version": "4.7.60",
"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.0.82"
"vxe-pc-ui": "^4.0.86"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
45 changes: 33 additions & 12 deletions packages/grid/src/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand All @@ -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)
Expand All @@ -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 => {
Expand All @@ -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 }
})
})
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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 => {
Expand All @@ -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 {
Expand Down
16 changes: 13 additions & 3 deletions packages/table/module/export/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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') {
Expand Down
18 changes: 9 additions & 9 deletions packages/table/render/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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<string, any> = {}
XEUtils.eachTree(options, item => {
keyMaps[XEUtils.get(item, valueProp)] = item
Expand Down Expand Up @@ -596,7 +596,7 @@ renderer.mixin({
exportMethod: handleExportSelectMethod
},
VxeInput: {
autofocus: '.vxe-input--inner',
autofocus: 'input',
renderEdit: defaultEditRender,
renderCell (renderOpts, params) {
const { props = {} } = renderOpts
Expand Down Expand Up @@ -624,7 +624,7 @@ renderer.mixin({
defaultFilterMethod: handleInputFilterMethod
},
VxeNumberInput: {
autofocus: '.vxe-number-input--inner',
autofocus: 'input',
renderEdit: defaultEditRender,
renderCell (renderOpts, params) {
const { props = {} } = renderOpts
Expand All @@ -645,7 +645,7 @@ renderer.mixin({
defaultFilterMethod: handleInputFilterMethod
},
VxeDatePicker: {
autofocus: '.vxe-date-picker--inner',
autofocus: 'input',
renderEdit: defaultEditRender,
renderCell (renderOpts, params) {
const { props = {} } = renderOpts
Expand All @@ -669,7 +669,7 @@ renderer.mixin({
defaultFilterMethod: handleFilterMethod
},
VxeTextarea: {
autofocus: '.vxe-textarea--inner'
autofocus: 'VxeTextarea'
},
VxeButton: {
renderDefault: buttonCellRender
Expand All @@ -687,7 +687,7 @@ renderer.mixin({
}
},
VxeSelect: {
autofocus: '.vxe-input--inner',
autofocus: 'input',
renderEdit: defaultSelectEditRender,
renderDefault: defaultSelectEditRender,
renderCell (renderOpts, params) {
Expand All @@ -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))
Expand All @@ -723,7 +723,7 @@ renderer.mixin({
renderDefault: radioAndCheckboxEditRender
},
VxeSwitch: {
autofocus: '.vxe-switch--button',
autofocus: 'button',
renderEdit: defaultEditRender,
renderDefault: defaultEditRender
},
Expand Down
9 changes: 2 additions & 7 deletions styles/theme/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion styles/theme/dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
5 changes: 4 additions & 1 deletion styles/theme/light.scss
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}

0 comments on commit c9bf25a

Please sign in to comment.