vxe-table 4.7.10 → 4.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/table/module/custom/panel.js +12 -22
- package/es/table/src/header.js +1 -1
- package/es/table/src/table.js +117 -252
- package/es/ui/index.js +2 -2
- package/es/ui/src/log.js +1 -1
- package/lib/index.umd.js +142 -323
- package/lib/index.umd.min.js +1 -1
- package/lib/table/module/custom/panel.js +11 -26
- package/lib/table/module/custom/panel.min.js +1 -1
- package/lib/table/src/header.js +1 -1
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/table.js +129 -294
- package/lib/table/src/table.min.js +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +2 -2
- package/packages/table/module/custom/panel.ts +12 -23
- package/packages/table/src/header.ts +1 -1
- package/packages/table/src/table.ts +116 -257
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vxe-table",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.11",
|
|
4
4
|
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟树、列拖拽,懒加载、快捷菜单、数据校验、树形结构、打印、导入导出、自定义模板、渲染器、JSON 配置式...",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"update": "npm install --legacy-peer-deps",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"style": "lib/style.css",
|
|
29
29
|
"typings": "types/index.d.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"vxe-pc-ui": "^4.0.
|
|
31
|
+
"vxe-pc-ui": "^4.0.9"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/resize-observer-browser": "^0.1.11",
|
|
@@ -19,7 +19,7 @@ export default defineComponent({
|
|
|
19
19
|
setup (props) {
|
|
20
20
|
const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods)
|
|
21
21
|
|
|
22
|
-
const {
|
|
22
|
+
const { reactData } = $xeTable
|
|
23
23
|
const { computeCustomOpts, computeColumnOpts, computeIsMaxFixedColumn } = $xeTable.getComputeMaps()
|
|
24
24
|
|
|
25
25
|
const refElem = ref() as Ref<HTMLDivElement>
|
|
@@ -46,19 +46,6 @@ export default defineComponent({
|
|
|
46
46
|
}, 300)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const handleSaveStore = (type: 'confirm' | 'reset') => {
|
|
50
|
-
const { id } = tableProps
|
|
51
|
-
const customOpts = computeCustomOpts.value
|
|
52
|
-
const { storage, updateStore } = customOpts
|
|
53
|
-
if (storage && id && updateStore) {
|
|
54
|
-
updateStore({
|
|
55
|
-
id,
|
|
56
|
-
type,
|
|
57
|
-
storeData: $xeTable.getCustomStoreData()
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
49
|
const confirmCustomEvent = (evnt: Event) => {
|
|
63
50
|
const { customColumnList } = reactData
|
|
64
51
|
const customOpts = computeCustomOpts.value
|
|
@@ -77,6 +64,7 @@ export default defineComponent({
|
|
|
77
64
|
if (column.renderVisible && (!column.children || column.children.length)) {
|
|
78
65
|
if (column.renderResizeWidth !== column.renderWidth) {
|
|
79
66
|
column.resizeWidth = column.renderResizeWidth
|
|
67
|
+
column.renderWidth = column.renderResizeWidth
|
|
80
68
|
}
|
|
81
69
|
}
|
|
82
70
|
}
|
|
@@ -86,7 +74,7 @@ export default defineComponent({
|
|
|
86
74
|
})
|
|
87
75
|
$xeTable.closeCustom()
|
|
88
76
|
$xeTable.emitCustomEvent('confirm', evnt)
|
|
89
|
-
|
|
77
|
+
$xeTable.saveCustomStore('confirm')
|
|
90
78
|
}
|
|
91
79
|
|
|
92
80
|
const cancelCustomEvent = (evnt: Event) => {
|
|
@@ -122,7 +110,6 @@ export default defineComponent({
|
|
|
122
110
|
$xeTable.resetColumn(true)
|
|
123
111
|
$xeTable.closeCustom()
|
|
124
112
|
$xeTable.emitCustomEvent('reset', evnt)
|
|
125
|
-
handleSaveStore('reset')
|
|
126
113
|
}
|
|
127
114
|
|
|
128
115
|
const resetCustomEvent = (evnt: Event) => {
|
|
@@ -164,6 +151,7 @@ export default defineComponent({
|
|
|
164
151
|
handleOptionCheck(column)
|
|
165
152
|
if (customOpts.immediate) {
|
|
166
153
|
$xeTable.handleCustom()
|
|
154
|
+
$xeTable.saveCustomStore('update:visible')
|
|
167
155
|
}
|
|
168
156
|
$xeTable.checkCustomStatus()
|
|
169
157
|
}
|
|
@@ -497,8 +485,9 @@ export default defineComponent({
|
|
|
497
485
|
const { customStore } = props
|
|
498
486
|
const { customColumnList } = reactData
|
|
499
487
|
const customOpts = computeCustomOpts.value
|
|
500
|
-
const { allowVisible, allowSort, allowFixed, allowResizable, checkMethod, visibleMethod } = customOpts
|
|
488
|
+
const { modalOptions, allowVisible, allowSort, allowFixed, allowResizable, checkMethod, visibleMethod } = customOpts
|
|
501
489
|
const columnOpts = computeColumnOpts.value
|
|
490
|
+
const modalOpts = Object.assign({}, modalOptions)
|
|
502
491
|
const isMaxFixedColumn = computeIsMaxFixedColumn.value
|
|
503
492
|
const trVNs: VNode[] = []
|
|
504
493
|
XEUtils.eachTree(customColumnList, (column, index, items, path, parent) => {
|
|
@@ -617,13 +606,13 @@ export default defineComponent({
|
|
|
617
606
|
const isAllIndeterminate = customStore.isIndeterminate
|
|
618
607
|
return h(resolveComponent('vxe-modal') as VxeModalComponent, {
|
|
619
608
|
key: 'popup',
|
|
620
|
-
className: 'vxe-table-custom-popup-wrapper vxe-table--ignore-clear',
|
|
609
|
+
className: ['vxe-table-custom-popup-wrapper', 'vxe-table--ignore-clear', modalOpts.className || ''].join(' '),
|
|
621
610
|
modelValue: customStore.visible,
|
|
622
|
-
title: getI18n('vxe.custom.cstmTitle'),
|
|
623
|
-
width:
|
|
624
|
-
minWidth: 700,
|
|
625
|
-
height:
|
|
626
|
-
minHeight: 400,
|
|
611
|
+
title: modalOpts.title || getI18n('vxe.custom.cstmTitle'),
|
|
612
|
+
width: modalOpts.width || '50vw',
|
|
613
|
+
minWidth: modalOpts.minWidth || 700,
|
|
614
|
+
height: modalOpts.height || '50vh',
|
|
615
|
+
minHeight: modalOpts.minHeight || 400,
|
|
627
616
|
mask: true,
|
|
628
617
|
lockView: true,
|
|
629
618
|
showFooter: true,
|
|
@@ -116,7 +116,7 @@ export default defineComponent({
|
|
|
116
116
|
tableInternalData._lastResizeTime = Date.now()
|
|
117
117
|
$xeTable.analyColumnWidth()
|
|
118
118
|
$xeTable.recalculate(true).then(() => {
|
|
119
|
-
$xeTable.
|
|
119
|
+
$xeTable.saveCustomStore('update:visible')
|
|
120
120
|
$xeTable.updateCellAreas()
|
|
121
121
|
$xeTable.dispatchEvent('resizable-change', { ...params, resizeWidth }, evnt)
|
|
122
122
|
})
|
|
@@ -24,10 +24,7 @@ const { getConfig, getI18n, renderer, formats, createEvent, globalResize, interc
|
|
|
24
24
|
|
|
25
25
|
const isWebkit = browse['-webkit'] && !browse.edge
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
const visibleStorageKey = 'VXE_TABLE_CUSTOM_COLUMN_VISIBLE'
|
|
29
|
-
const fixedStorageKey = 'VXE_TABLE_CUSTOM_COLUMN_FIXED'
|
|
30
|
-
const sortStorageKey = 'VXE_TABLE_CUSTOM_COLUMN_SORT'
|
|
27
|
+
const customStorageKey = 'VXE_CUSTOM_STORE'
|
|
31
28
|
|
|
32
29
|
export default defineComponent({
|
|
33
30
|
name: 'VxeTable',
|
|
@@ -680,10 +677,19 @@ export default defineComponent({
|
|
|
680
677
|
return orders[oIndex < orders.length ? oIndex : 0]
|
|
681
678
|
}
|
|
682
679
|
|
|
683
|
-
const getCustomStorageMap = (
|
|
680
|
+
const getCustomStorageMap = (id?: string) => {
|
|
684
681
|
const version = getConfig().version
|
|
685
|
-
const rest = XEUtils.toStringJSON(localStorage.getItem(
|
|
686
|
-
|
|
682
|
+
const rest = XEUtils.toStringJSON(localStorage.getItem(customStorageKey) || '')
|
|
683
|
+
const maps = rest && rest._v === version ? rest : { _v: version }
|
|
684
|
+
return (id ? maps[id] : maps) || {}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
const setCustomStorageMap = (id: string, data: any) => {
|
|
688
|
+
const version = getConfig().version
|
|
689
|
+
const maps = getCustomStorageMap()
|
|
690
|
+
maps[id] = data || undefined
|
|
691
|
+
maps._v = version
|
|
692
|
+
localStorage.setItem(customStorageKey, XEUtils.toJSONString(maps))
|
|
687
693
|
}
|
|
688
694
|
|
|
689
695
|
const getRecoverRowMaps = (keyMaps: Record<string, any>) => {
|
|
@@ -888,8 +894,9 @@ export default defineComponent({
|
|
|
888
894
|
/**
|
|
889
895
|
* 还原自定义列操作状态
|
|
890
896
|
*/
|
|
891
|
-
const restoreCustomStorage = () => {
|
|
897
|
+
const restoreCustomStorage = async () => {
|
|
892
898
|
const { id, customConfig } = props
|
|
899
|
+
const { tableFullColumn } = internalData
|
|
893
900
|
const customOpts = computeCustomOpts.value
|
|
894
901
|
const { storage, restoreStore } = customOpts
|
|
895
902
|
const isAllCustom = storage === true
|
|
@@ -898,119 +905,45 @@ export default defineComponent({
|
|
|
898
905
|
const isCustomVisible = isAllCustom || storageOpts.visible
|
|
899
906
|
const isCustomFixed = isAllCustom || storageOpts.fixed
|
|
900
907
|
const isCustomSort = isAllCustom || storageOpts.sort
|
|
901
|
-
if (storage && id && restoreStore) {
|
|
902
|
-
restoreStore({ id })
|
|
903
|
-
}
|
|
904
908
|
if (customConfig && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
|
|
905
|
-
const customMap: {
|
|
906
|
-
[key: string]: {
|
|
907
|
-
field?: VxeColumnPropTypes.Field
|
|
908
|
-
resizeWidth?: number
|
|
909
|
-
visible?: boolean
|
|
910
|
-
fixed?: string
|
|
911
|
-
renderSortNumber?: number
|
|
912
|
-
}
|
|
913
|
-
} = {}
|
|
914
909
|
if (!id) {
|
|
915
910
|
errLog('vxe.error.reqProp', ['id'])
|
|
916
911
|
return
|
|
917
912
|
}
|
|
918
|
-
|
|
919
|
-
if (
|
|
920
|
-
|
|
921
|
-
if (columnWidthStorage) {
|
|
922
|
-
XEUtils.each(columnWidthStorage, (resizeWidth: number, colKey) => {
|
|
923
|
-
customMap[colKey] = { resizeWidth }
|
|
924
|
-
})
|
|
925
|
-
}
|
|
913
|
+
let storeData: VxeTableDefines.CustomStoreData = getCustomStorageMap(id)
|
|
914
|
+
if (restoreStore) {
|
|
915
|
+
storeData = await restoreStore({ id, type: 'restore', storeData })
|
|
926
916
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
const columnFixedStorage = getCustomStorageMap(fixedStorageKey)[id]
|
|
930
|
-
if (columnFixedStorage) {
|
|
931
|
-
const colFixeds = columnFixedStorage.split(',')
|
|
932
|
-
colFixeds.forEach((fixConf: any) => {
|
|
933
|
-
const [colKey, fixed] = fixConf.split('|')
|
|
934
|
-
if (customMap[colKey]) {
|
|
935
|
-
customMap[colKey].fixed = fixed
|
|
936
|
-
} else {
|
|
937
|
-
customMap[colKey] = { fixed }
|
|
938
|
-
}
|
|
939
|
-
})
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
// 自定义顺序
|
|
943
|
-
let hasCustomSort = false
|
|
944
|
-
if (isCustomSort) {
|
|
945
|
-
const columnSortStorage = getCustomStorageMap(sortStorageKey)[id]
|
|
946
|
-
if (columnSortStorage) {
|
|
947
|
-
XEUtils.each(columnSortStorage, (renderSortNumber: number, colKey) => {
|
|
948
|
-
if (customMap[colKey]) {
|
|
949
|
-
customMap[colKey].renderSortNumber = renderSortNumber
|
|
950
|
-
} else {
|
|
951
|
-
customMap[colKey] = { renderSortNumber }
|
|
952
|
-
}
|
|
953
|
-
if (!hasCustomSort) {
|
|
954
|
-
hasCustomSort = true
|
|
955
|
-
}
|
|
956
|
-
})
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
// 自定义隐藏列
|
|
960
|
-
if (isCustomVisible) {
|
|
961
|
-
const columnVisibleStorage = getCustomStorageMap(visibleStorageKey)[id]
|
|
962
|
-
if (columnVisibleStorage) {
|
|
963
|
-
const colVisibles = columnVisibleStorage.split('|')
|
|
964
|
-
const colHides: string[] = colVisibles[0] ? colVisibles[0].split(',') : []
|
|
965
|
-
const colShows: string[] = colVisibles[1] ? colVisibles[1].split(',') : []
|
|
966
|
-
colHides.forEach((colKey) => {
|
|
967
|
-
if (customMap[colKey]) {
|
|
968
|
-
customMap[colKey].visible = false
|
|
969
|
-
} else {
|
|
970
|
-
customMap[colKey] = { visible: false }
|
|
971
|
-
}
|
|
972
|
-
})
|
|
973
|
-
colShows.forEach((colKey) => {
|
|
974
|
-
if (customMap[colKey]) {
|
|
975
|
-
customMap[colKey].visible = true
|
|
976
|
-
} else {
|
|
977
|
-
customMap[colKey] = { visible: true }
|
|
978
|
-
}
|
|
979
|
-
})
|
|
980
|
-
}
|
|
917
|
+
if (!storeData) {
|
|
918
|
+
return
|
|
981
919
|
}
|
|
982
920
|
let { collectColumn } = internalData
|
|
983
|
-
const
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
})
|
|
992
|
-
XEUtils.each(customMap, ({ visible, resizeWidth, fixed, renderSortNumber }, colKey) => {
|
|
993
|
-
const column = keyMap[colKey]
|
|
994
|
-
if (column) {
|
|
995
|
-
if (XEUtils.isNumber(resizeWidth)) {
|
|
996
|
-
column.resizeWidth = resizeWidth
|
|
921
|
+
const { resizableData, sortData, visibleData, fixedData } = storeData
|
|
922
|
+
let hasCustomSort = false
|
|
923
|
+
// 处理还原
|
|
924
|
+
if (resizableData || sortData || visibleData || fixedData) {
|
|
925
|
+
tableFullColumn.forEach(column => {
|
|
926
|
+
const colKey = column.getKey()
|
|
927
|
+
if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
|
|
928
|
+
column.resizeWidth = resizableData[colKey]
|
|
997
929
|
}
|
|
998
|
-
if (XEUtils.isBoolean(
|
|
999
|
-
column.visible =
|
|
930
|
+
if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
|
|
931
|
+
column.visible = visibleData[colKey]
|
|
1000
932
|
}
|
|
1001
|
-
if (
|
|
1002
|
-
column.fixed =
|
|
933
|
+
if (fixedData && fixedData[colKey]) {
|
|
934
|
+
column.fixed = fixedData[colKey]
|
|
1003
935
|
}
|
|
1004
|
-
if (
|
|
1005
|
-
|
|
936
|
+
if (sortData && XEUtils.isNumber(sortData[colKey])) {
|
|
937
|
+
hasCustomSort = true
|
|
938
|
+
column.renderSortNumber = sortData[colKey]
|
|
1006
939
|
}
|
|
940
|
+
})
|
|
941
|
+
// 如果自定义了顺序
|
|
942
|
+
if (hasCustomSort) {
|
|
943
|
+
collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber')
|
|
944
|
+
internalData.collectColumn = collectColumn
|
|
945
|
+
internalData.tableFullColumn = getColumnList(collectColumn)
|
|
1007
946
|
}
|
|
1008
|
-
})
|
|
1009
|
-
// 如果自定义了顺序
|
|
1010
|
-
if (hasCustomSort) {
|
|
1011
|
-
collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber')
|
|
1012
|
-
internalData.collectColumn = collectColumn
|
|
1013
|
-
internalData.tableFullColumn = getColumnList(collectColumn)
|
|
1014
947
|
}
|
|
1015
948
|
}
|
|
1016
949
|
}
|
|
@@ -2561,26 +2494,27 @@ export default defineComponent({
|
|
|
2561
2494
|
const tableFullColumn = getColumnList(collectColumn)
|
|
2562
2495
|
internalData.tableFullColumn = tableFullColumn
|
|
2563
2496
|
initColumnSort()
|
|
2564
|
-
restoreCustomStorage()
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
}
|
|
2579
|
-
return nextTick().then(() => {
|
|
2580
|
-
if ($xeToolbar) {
|
|
2581
|
-
$xeToolbar.syncUpdate({ collectColumn, $table: $xeTable })
|
|
2497
|
+
return restoreCustomStorage().then(() => {
|
|
2498
|
+
cacheColumnMap()
|
|
2499
|
+
parseColumns().then(() => {
|
|
2500
|
+
if (reactData.scrollXLoad) {
|
|
2501
|
+
loadScrollXData()
|
|
2502
|
+
}
|
|
2503
|
+
})
|
|
2504
|
+
tableMethods.clearMergeCells()
|
|
2505
|
+
tableMethods.clearMergeFooterItems()
|
|
2506
|
+
tablePrivateMethods.handleTableData(true)
|
|
2507
|
+
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
2508
|
+
if ((reactData.scrollXLoad || reactData.scrollYLoad) && reactData.expandColumn) {
|
|
2509
|
+
warnLog('vxe.error.scrollErrProp', ['column.type=expand'])
|
|
2510
|
+
}
|
|
2582
2511
|
}
|
|
2583
|
-
return
|
|
2512
|
+
return nextTick().then(() => {
|
|
2513
|
+
if ($xeToolbar) {
|
|
2514
|
+
$xeToolbar.syncUpdate({ collectColumn, $table: $xeTable })
|
|
2515
|
+
}
|
|
2516
|
+
return tableMethods.recalculate()
|
|
2517
|
+
})
|
|
2584
2518
|
})
|
|
2585
2519
|
}
|
|
2586
2520
|
|
|
@@ -3284,7 +3218,7 @@ export default defineComponent({
|
|
|
3284
3218
|
XEUtils.eachTree([targetColumn], (column) => {
|
|
3285
3219
|
column.fixed = fixed
|
|
3286
3220
|
})
|
|
3287
|
-
tablePrivateMethods.
|
|
3221
|
+
tablePrivateMethods.saveCustomStore('update:fixed')
|
|
3288
3222
|
return tableMethods.refreshColumn()
|
|
3289
3223
|
}
|
|
3290
3224
|
return nextTick()
|
|
@@ -3299,7 +3233,7 @@ export default defineComponent({
|
|
|
3299
3233
|
XEUtils.eachTree([targetColumn], (column) => {
|
|
3300
3234
|
column.fixed = null
|
|
3301
3235
|
})
|
|
3302
|
-
tablePrivateMethods.
|
|
3236
|
+
tablePrivateMethods.saveCustomStore('update:fixed')
|
|
3303
3237
|
return tableMethods.refreshColumn()
|
|
3304
3238
|
}
|
|
3305
3239
|
return nextTick()
|
|
@@ -3378,15 +3312,7 @@ export default defineComponent({
|
|
|
3378
3312
|
}
|
|
3379
3313
|
column.renderResizeWidth = column.renderWidth
|
|
3380
3314
|
})
|
|
3381
|
-
|
|
3382
|
-
tablePrivateMethods.saveCustomResizable(true)
|
|
3383
|
-
}
|
|
3384
|
-
if (opts.sort) {
|
|
3385
|
-
tablePrivateMethods.saveCustomSort(true)
|
|
3386
|
-
}
|
|
3387
|
-
if (opts.fixed) {
|
|
3388
|
-
tablePrivateMethods.saveCustomFixed()
|
|
3389
|
-
}
|
|
3315
|
+
$xeTable.saveCustomStore('reset')
|
|
3390
3316
|
return tablePrivateMethods.handleCustom()
|
|
3391
3317
|
},
|
|
3392
3318
|
/**
|
|
@@ -4536,22 +4462,27 @@ export default defineComponent({
|
|
|
4536
4462
|
const sortData: Record<string, number> = {}
|
|
4537
4463
|
const visibleData: Record<string, boolean> = {}
|
|
4538
4464
|
const fixedData: Record<string, VxeColumnPropTypes.Fixed> = {}
|
|
4539
|
-
const storeData = {
|
|
4540
|
-
resizableData,
|
|
4541
|
-
sortData,
|
|
4542
|
-
visibleData,
|
|
4543
|
-
fixedData
|
|
4465
|
+
const storeData: VxeTableDefines.CustomStoreData = {
|
|
4466
|
+
resizableData: undefined,
|
|
4467
|
+
sortData: undefined,
|
|
4468
|
+
visibleData: undefined,
|
|
4469
|
+
fixedData: undefined
|
|
4544
4470
|
}
|
|
4545
4471
|
if (!id) {
|
|
4546
4472
|
errLog('vxe.error.reqProp', ['id'])
|
|
4547
4473
|
return storeData
|
|
4548
4474
|
}
|
|
4475
|
+
let hasResizable = 0
|
|
4476
|
+
let hasSort = 0
|
|
4477
|
+
let hasFixedt = 0
|
|
4478
|
+
let hasVisible = 0
|
|
4549
4479
|
XEUtils.eachTree(collectColumn, (column, index, items, path, parent) => {
|
|
4550
4480
|
// 排序只支持一级
|
|
4551
4481
|
if (!parent) {
|
|
4552
4482
|
collectColumn.forEach((column) => {
|
|
4553
4483
|
const colKey = column.getKey()
|
|
4554
4484
|
if (colKey) {
|
|
4485
|
+
hasSort = 1
|
|
4555
4486
|
sortData[colKey] = column.renderSortNumber
|
|
4556
4487
|
}
|
|
4557
4488
|
})
|
|
@@ -4559,12 +4490,14 @@ export default defineComponent({
|
|
|
4559
4490
|
if (column.resizeWidth) {
|
|
4560
4491
|
const colKey = column.getKey()
|
|
4561
4492
|
if (colKey) {
|
|
4493
|
+
hasResizable = 1
|
|
4562
4494
|
resizableData[colKey] = column.renderWidth
|
|
4563
4495
|
}
|
|
4564
4496
|
}
|
|
4565
4497
|
if (column.fixed && column.fixed !== column.defaultFixed) {
|
|
4566
4498
|
const colKey = column.getKey()
|
|
4567
4499
|
if (colKey) {
|
|
4500
|
+
hasFixedt = 1
|
|
4568
4501
|
fixedData[colKey] = column.fixed
|
|
4569
4502
|
}
|
|
4570
4503
|
}
|
|
@@ -4572,16 +4505,30 @@ export default defineComponent({
|
|
|
4572
4505
|
if (!column.visible && column.defaultVisible) {
|
|
4573
4506
|
const colKey = column.getKey()
|
|
4574
4507
|
if (colKey) {
|
|
4508
|
+
hasVisible = 1
|
|
4575
4509
|
visibleData[colKey] = false
|
|
4576
4510
|
}
|
|
4577
4511
|
} else if (column.visible && !column.defaultVisible) {
|
|
4578
4512
|
const colKey = column.getKey()
|
|
4579
4513
|
if (colKey) {
|
|
4514
|
+
hasVisible = 1
|
|
4580
4515
|
visibleData[colKey] = true
|
|
4581
4516
|
}
|
|
4582
4517
|
}
|
|
4583
4518
|
}
|
|
4584
4519
|
})
|
|
4520
|
+
if (hasResizable) {
|
|
4521
|
+
storeData.resizableData = resizableData
|
|
4522
|
+
}
|
|
4523
|
+
if (hasSort) {
|
|
4524
|
+
storeData.sortData = sortData
|
|
4525
|
+
}
|
|
4526
|
+
if (hasFixedt) {
|
|
4527
|
+
storeData.fixedData = fixedData
|
|
4528
|
+
}
|
|
4529
|
+
if (hasVisible) {
|
|
4530
|
+
storeData.visibleData = visibleData
|
|
4531
|
+
}
|
|
4585
4532
|
return storeData
|
|
4586
4533
|
},
|
|
4587
4534
|
focus () {
|
|
@@ -5366,126 +5313,40 @@ export default defineComponent({
|
|
|
5366
5313
|
})
|
|
5367
5314
|
Object.assign(reactData.columnStore, { resizeList, pxList, pxMinList, scaleList, scaleMinList, autoList })
|
|
5368
5315
|
},
|
|
5369
|
-
|
|
5370
|
-
const { id
|
|
5371
|
-
const customOpts = computeCustomOpts.value
|
|
5372
|
-
const { collectColumn } = internalData
|
|
5373
|
-
const { storage } = customOpts
|
|
5374
|
-
const isAllStorage = storage === true
|
|
5375
|
-
const storageOpts = isAllStorage ? {} : Object.assign({}, storage || {})
|
|
5376
|
-
const isResizable = isAllStorage || storageOpts.resizable
|
|
5377
|
-
if (customConfig && isResizable) {
|
|
5378
|
-
const columnWidthStorageMap = getCustomStorageMap(resizableStorageKey)
|
|
5379
|
-
let columnWidthStorage: any
|
|
5380
|
-
if (!id) {
|
|
5381
|
-
errLog('vxe.error.reqProp', ['id'])
|
|
5382
|
-
return
|
|
5383
|
-
}
|
|
5384
|
-
if (!isReset) {
|
|
5385
|
-
columnWidthStorage = XEUtils.isPlainObject(columnWidthStorageMap[id]) ? columnWidthStorageMap[id] : {}
|
|
5386
|
-
XEUtils.eachTree(collectColumn, (column) => {
|
|
5387
|
-
if (column.resizeWidth) {
|
|
5388
|
-
const colKey = column.getKey()
|
|
5389
|
-
if (colKey) {
|
|
5390
|
-
columnWidthStorage[colKey] = column.renderWidth
|
|
5391
|
-
}
|
|
5392
|
-
}
|
|
5393
|
-
})
|
|
5394
|
-
}
|
|
5395
|
-
columnWidthStorageMap[id] = XEUtils.isEmpty(columnWidthStorage) ? undefined : columnWidthStorage
|
|
5396
|
-
localStorage.setItem(resizableStorageKey, XEUtils.toJSONString(columnWidthStorageMap))
|
|
5397
|
-
}
|
|
5398
|
-
},
|
|
5399
|
-
saveCustomSort (isReset?: boolean) {
|
|
5400
|
-
const { id, customConfig } = props
|
|
5316
|
+
saveCustomStore (type) {
|
|
5317
|
+
const { id } = props
|
|
5401
5318
|
const customOpts = computeCustomOpts.value
|
|
5402
|
-
const {
|
|
5403
|
-
const
|
|
5404
|
-
const
|
|
5405
|
-
const
|
|
5406
|
-
const
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5319
|
+
const { updateStore, storage } = customOpts
|
|
5320
|
+
const isAllCustom = storage === true
|
|
5321
|
+
const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {})
|
|
5322
|
+
const isCustomResizable = isAllCustom || storageOpts.resizable
|
|
5323
|
+
const isCustomVisible = isAllCustom || storageOpts.visible
|
|
5324
|
+
const isCustomFixed = isAllCustom || storageOpts.fixed
|
|
5325
|
+
const isCustomSort = isAllCustom || storageOpts.sort
|
|
5326
|
+
if (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort) {
|
|
5410
5327
|
if (!id) {
|
|
5411
5328
|
errLog('vxe.error.reqProp', ['id'])
|
|
5412
|
-
return
|
|
5329
|
+
return nextTick()
|
|
5413
5330
|
}
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
columnWidthStorage[colKey] = column.renderSortNumber
|
|
5331
|
+
const storeData = type === 'reset'
|
|
5332
|
+
? {
|
|
5333
|
+
resizableData: {},
|
|
5334
|
+
sortData: {},
|
|
5335
|
+
visibleData: {},
|
|
5336
|
+
fixedData: {}
|
|
5421
5337
|
}
|
|
5338
|
+
: tableMethods.getCustomStoreData()
|
|
5339
|
+
if (updateStore) {
|
|
5340
|
+
return updateStore({
|
|
5341
|
+
id,
|
|
5342
|
+
type,
|
|
5343
|
+
storeData
|
|
5422
5344
|
})
|
|
5345
|
+
} else {
|
|
5346
|
+
setCustomStorageMap(id, type === 'reset' ? null : storeData)
|
|
5423
5347
|
}
|
|
5424
|
-
columnSortStorageMap[id] = XEUtils.isEmpty(columnWidthStorage) ? undefined : columnWidthStorage
|
|
5425
|
-
localStorage.setItem(sortStorageKey, XEUtils.toJSONString(columnSortStorageMap))
|
|
5426
|
-
}
|
|
5427
|
-
},
|
|
5428
|
-
saveCustomFixed () {
|
|
5429
|
-
const { id, customConfig } = props
|
|
5430
|
-
const { collectColumn } = internalData
|
|
5431
|
-
const customOpts = computeCustomOpts.value
|
|
5432
|
-
const { storage } = customOpts
|
|
5433
|
-
const isAllStorage = storage === true
|
|
5434
|
-
const storageOpts = isAllStorage ? {} : Object.assign({}, storage || {})
|
|
5435
|
-
const isCustomFixed = isAllStorage || storageOpts.fixed
|
|
5436
|
-
if (customConfig && isCustomFixed) {
|
|
5437
|
-
const columnFixedStorageMap = getCustomStorageMap(fixedStorageKey)
|
|
5438
|
-
const colFixeds: any[] = []
|
|
5439
|
-
if (!id) {
|
|
5440
|
-
errLog('vxe.error.reqProp', ['id'])
|
|
5441
|
-
return
|
|
5442
|
-
}
|
|
5443
|
-
XEUtils.eachTree(collectColumn, (column) => {
|
|
5444
|
-
if (column.fixed && column.fixed !== column.defaultFixed) {
|
|
5445
|
-
const colKey = column.getKey()
|
|
5446
|
-
if (colKey) {
|
|
5447
|
-
colFixeds.push(`${colKey}|${column.fixed}`)
|
|
5448
|
-
}
|
|
5449
|
-
}
|
|
5450
|
-
})
|
|
5451
|
-
columnFixedStorageMap[id] = colFixeds.join(',') || undefined
|
|
5452
|
-
localStorage.setItem(fixedStorageKey, XEUtils.toJSONString(columnFixedStorageMap))
|
|
5453
|
-
}
|
|
5454
|
-
},
|
|
5455
|
-
saveCustomVisible () {
|
|
5456
|
-
const { id, customConfig } = props
|
|
5457
|
-
const { collectColumn } = internalData
|
|
5458
|
-
const customOpts = computeCustomOpts.value
|
|
5459
|
-
const { checkMethod, storage } = customOpts
|
|
5460
|
-
const isAllStorage = storage === true
|
|
5461
|
-
const storageOpts = isAllStorage ? {} : Object.assign({}, storage || {})
|
|
5462
|
-
const isCustomVisible = isAllStorage || storageOpts.visible
|
|
5463
|
-
if (customConfig && isCustomVisible) {
|
|
5464
|
-
const columnVisibleStorageMap = getCustomStorageMap(visibleStorageKey)
|
|
5465
|
-
const colHides: any[] = []
|
|
5466
|
-
const colShows: any[] = []
|
|
5467
|
-
if (!id) {
|
|
5468
|
-
errLog('vxe.error.reqProp', ['id'])
|
|
5469
|
-
return
|
|
5470
|
-
}
|
|
5471
|
-
XEUtils.eachTree(collectColumn, (column) => {
|
|
5472
|
-
if (!checkMethod || checkMethod({ column })) {
|
|
5473
|
-
if (!column.visible && column.defaultVisible) {
|
|
5474
|
-
const colKey = column.getKey()
|
|
5475
|
-
if (colKey) {
|
|
5476
|
-
colHides.push(colKey)
|
|
5477
|
-
}
|
|
5478
|
-
} else if (column.visible && !column.defaultVisible) {
|
|
5479
|
-
const colKey = column.getKey()
|
|
5480
|
-
if (colKey) {
|
|
5481
|
-
colShows.push(colKey)
|
|
5482
|
-
}
|
|
5483
|
-
}
|
|
5484
|
-
}
|
|
5485
|
-
})
|
|
5486
|
-
columnVisibleStorageMap[id] = [colHides.join(',')].concat(colShows.length ? [colShows.join(',')] : []).join('|') || undefined
|
|
5487
|
-
localStorage.setItem(visibleStorageKey, XEUtils.toJSONString(columnVisibleStorageMap))
|
|
5488
5348
|
}
|
|
5349
|
+
return nextTick()
|
|
5489
5350
|
},
|
|
5490
5351
|
handleCustom () {
|
|
5491
5352
|
const { mouseConfig } = props
|
|
@@ -5498,8 +5359,6 @@ export default defineComponent({
|
|
|
5498
5359
|
$xeTable.clearCopyCellArea()
|
|
5499
5360
|
}
|
|
5500
5361
|
}
|
|
5501
|
-
tablePrivateMethods.saveCustomVisible()
|
|
5502
|
-
tablePrivateMethods.saveCustomSort()
|
|
5503
5362
|
tablePrivateMethods.analyColumnWidth()
|
|
5504
5363
|
return tableMethods.refreshColumn(true)
|
|
5505
5364
|
},
|