vxe-table 4.23.7 → 4.23.9
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/dist/all.esm.js +5859 -4018
- package/es/colgroup/index.js +1 -1
- package/es/column/index.js +1 -1
- package/es/components.d.ts +3 -0
- package/es/components.js +4 -8
- package/es/grid/index.js +1 -1
- package/es/grid/src/emits.js +1 -15
- package/es/grid/src/grid.js +398 -121
- package/es/grid/src/props.js +1 -1
- package/es/index.esm.js +6 -0
- package/es/index.js +6 -0
- package/es/table/index.js +1 -1
- package/es/table/module/custom/hook.js +50 -43
- package/es/table/module/custom/panel.js +778 -528
- package/es/table/module/edit/hook.js +141 -63
- package/es/table/module/export/export-panel.js +400 -317
- package/es/table/module/export/hook.js +396 -338
- package/es/table/module/export/import-panel.js +153 -124
- package/es/table/module/filter/hook.js +17 -3
- package/es/table/module/filter/panel.js +147 -85
- package/es/table/module/keyboard/hook.js +9 -5
- package/es/table/module/menu/hook.js +1 -1
- package/es/table/module/menu/panel.js +198 -127
- package/es/table/module/validator/hook.js +1 -1
- package/es/table/render/index.js +152 -99
- package/es/table/src/body.js +356 -234
- package/es/table/src/cell.js +427 -270
- package/es/table/src/columnInfo.js +2 -1
- package/es/table/src/footer.js +145 -100
- package/es/table/src/group.js +7 -3
- package/es/table/src/header.js +230 -173
- package/es/table/src/props.js +1 -1
- package/es/table/src/table.js +1504 -1031
- package/es/table/src/util.js +15 -19
- package/es/toolbar/index.js +1 -1
- package/es/toolbar/src/toolbar.js +133 -76
- package/es/ui/index.d.ts +0 -1
- package/es/ui/index.js +1 -2
- package/es/ui/src/dom.js +9 -6
- package/es/ui/src/log.js +1 -1
- package/es/ui/src/utils.d.ts +1 -1
- package/es/v-x-e-table/index.d.ts +0 -1
- package/es/v-x-e-table/index.js +0 -1
- package/lib/colgroup/index.js +5 -5
- package/lib/column/index.js +5 -5
- package/lib/components.js +8 -12
- package/lib/grid/index.js +4 -4
- package/lib/grid/src/emits.js +1 -15
- package/lib/grid/src/grid.js +419 -142
- package/lib/grid/src/props.js +2 -2
- package/lib/index.common.js +6 -0
- package/lib/index.js +6 -0
- package/lib/index.umd.js +5825 -3945
- package/lib/index.umd.min.js +3 -3
- package/lib/table/index.js +5 -5
- package/lib/table/module/custom/hook.js +51 -44
- package/lib/table/module/custom/panel.js +790 -540
- package/lib/table/module/edit/hook.js +142 -64
- package/lib/table/module/export/export-panel.js +406 -323
- package/lib/table/module/export/hook.js +419 -361
- package/lib/table/module/export/import-panel.js +157 -128
- package/lib/table/module/filter/hook.js +18 -4
- package/lib/table/module/filter/panel.js +149 -87
- package/lib/table/module/keyboard/hook.js +10 -6
- package/lib/table/module/menu/hook.js +2 -2
- package/lib/table/module/menu/panel.js +199 -128
- package/lib/table/module/validator/hook.js +2 -2
- package/lib/table/render/index.js +153 -100
- package/lib/table/src/body.js +357 -235
- package/lib/table/src/cell.js +428 -271
- package/lib/table/src/columnInfo.js +3 -2
- package/lib/table/src/footer.js +146 -101
- package/lib/table/src/group.js +7 -3
- package/lib/table/src/header.js +231 -174
- package/lib/table/src/props.js +2 -2
- package/lib/table/src/table.js +1487 -1045
- package/lib/table/src/util.js +15 -19
- package/lib/toolbar/index.js +4 -4
- package/lib/toolbar/src/toolbar.js +135 -78
- package/lib/ui/index.js +1 -3
- package/lib/ui/src/dom.js +9 -6
- package/lib/ui/src/log.js +1 -1
- package/lib/v-x-e-table/index.js +0 -2
- package/package.json +8 -3
- package/packages/colgroup/index.ts +22 -22
- package/packages/column/index.ts +22 -22
- package/packages/components.ts +41 -43
- package/packages/grid/index.ts +18 -18
- package/packages/grid/src/emits.ts +5 -19
- package/packages/grid/src/grid.ts +2229 -1925
- package/packages/grid/src/props.ts +22 -23
- package/packages/index.ts +11 -4
- package/packages/locale/lang/fr-FR.ts +15 -15
- package/packages/locale/lang/it-IT.ts +4 -4
- package/packages/locale/lang/uk-UA.ts +1 -1
- package/packages/locale/lang/uz-UZ.ts +13 -13
- package/packages/locale/lang/zh-CN.ts +907 -907
- package/packages/table/index.ts +26 -26
- package/packages/table/module/custom/hook.ts +510 -503
- package/packages/table/module/custom/panel.ts +2002 -1743
- package/packages/table/module/edit/hook.ts +1224 -1131
- package/packages/table/module/export/export-panel.ts +697 -611
- package/packages/table/module/export/hook.ts +2160 -2059
- package/packages/table/module/export/import-panel.ts +319 -279
- package/packages/table/module/export/util.ts +25 -24
- package/packages/table/module/filter/hook.ts +519 -501
- package/packages/table/module/filter/panel.ts +368 -304
- package/packages/table/module/keyboard/hook.ts +498 -494
- package/packages/table/module/menu/hook.ts +330 -330
- package/packages/table/module/menu/panel.ts +272 -201
- package/packages/table/module/validator/hook.ts +653 -635
- package/packages/table/render/index.ts +1819 -1744
- package/packages/table/src/body.ts +1078 -955
- package/packages/table/src/cell.ts +1524 -1359
- package/packages/table/src/column.ts +192 -192
- package/packages/table/src/columnInfo.ts +232 -232
- package/packages/table/src/emits.ts +134 -134
- package/packages/table/src/footer.ts +425 -380
- package/packages/table/src/group.ts +67 -63
- package/packages/table/src/header.ts +642 -581
- package/packages/table/src/props.ts +336 -336
- package/packages/table/src/store.ts +14 -14
- package/packages/table/src/table.ts +16011 -15454
- package/packages/table/src/use/cell-view.ts +41 -44
- package/packages/table/src/use/index.ts +1 -1
- package/packages/table/src/util.ts +1206 -1216
- package/packages/toolbar/index.ts +18 -18
- package/packages/toolbar/src/toolbar.ts +768 -706
- package/packages/ui/index.ts +519 -521
- package/packages/ui/src/anime.ts +51 -52
- package/packages/ui/src/comp.ts +3 -3
- package/packages/ui/src/dom.ts +466 -463
- package/packages/ui/src/log.ts +19 -19
- package/packages/ui/src/utils.ts +66 -66
- package/packages/ui/src/vn.ts +55 -55
- package/packages/v-x-e-table/index.d.ts +3 -4
- package/packages/v-x-e-table/index.ts +3 -4
- package/types/all.d.ts +76 -76
- package/types/index.d.ts +4 -4
- /package/dist/{iconfont.1792979665397.ttf → iconfont.1793009263429.ttf} +0 -0
- /package/dist/{iconfont.1792979665397.woff → iconfont.1793009263429.woff} +0 -0
- /package/dist/{iconfont.1792979665397.woff2 → iconfont.1793009263429.woff2} +0 -0
- /package/es/{iconfont.1792979665397.ttf → iconfont.1793009263429.ttf} +0 -0
- /package/es/{iconfont.1792979665397.woff → iconfont.1793009263429.woff} +0 -0
- /package/es/{iconfont.1792979665397.woff2 → iconfont.1793009263429.woff2} +0 -0
- /package/lib/{iconfont.1792979665397.ttf → iconfont.1793009263429.ttf} +0 -0
- /package/lib/{iconfont.1792979665397.woff → iconfont.1793009263429.woff} +0 -0
- /package/lib/{iconfont.1792979665397.woff2 → iconfont.1793009263429.woff2} +0 -0
|
@@ -1,503 +1,510 @@
|
|
|
1
|
-
import { nextTick } from 'vue'
|
|
2
|
-
import { VxeUI } from '
|
|
3
|
-
import XEUtils from 'xe-utils'
|
|
4
|
-
import { getColumnList } from '../../src/util'
|
|
5
|
-
import { toCssUnit } from '../../../ui/src/dom'
|
|
6
|
-
|
|
7
|
-
import type { TableCustomMethods, TableCustomPrivateMethods, VxeColumnPropTypes, VxeTableDefines, VxeComponentStyleType } from '../../../../types'
|
|
8
|
-
|
|
9
|
-
const tableCustomMethodKeys: (keyof TableCustomMethods)[] = ['openCustom', 'closeCustom', 'getCustomVisible', 'toggleCustom', 'saveCustom', 'cancelCustom', 'resetCustom', 'toggleCustomAllCheckbox', 'setCustomAllCheckbox']
|
|
10
|
-
|
|
11
|
-
const customColumnCssKeys = ['checkbox', 'sort', 'title', 'width', 'fixed', 'align', 'header-align', 'footer-align']
|
|
12
|
-
|
|
13
|
-
VxeUI.hooks.add('tableCustomModule', {
|
|
14
|
-
setupTable
|
|
15
|
-
const { reactData, internalData } = $xeTable
|
|
16
|
-
const { computeCustomOpts, computeRowGroupFields, computeCustomSimpleMode } = $xeTable.getComputeMaps()
|
|
17
|
-
const { refElem } = $xeTable.getRefMaps()
|
|
18
|
-
|
|
19
|
-
const $xeGrid = $xeTable.xeGrid
|
|
20
|
-
const $xeGantt = $xeTable.xeGantt
|
|
21
|
-
const $xeGGWrapper = $xeGrid || $xeGantt
|
|
22
|
-
|
|
23
|
-
const updatePopupStyle = () => {
|
|
24
|
-
const { customStore } = reactData
|
|
25
|
-
const customOpts = computeCustomOpts.value
|
|
26
|
-
const { mode, placement, popupOptions } = customOpts
|
|
27
|
-
const showSimple = !(mode === 'modal' || mode === 'drawer')
|
|
28
|
-
const { transfer, minWidth, maxWidth, maxHeight } = popupOptions || {}
|
|
29
|
-
const customSimpleMode = computeCustomSimpleMode.value
|
|
30
|
-
const showCustomSimpleOutside = customSimpleMode === 'outside'
|
|
31
|
-
const bodyEl = document.documentElement
|
|
32
|
-
let wrapperEl = refElem.value
|
|
33
|
-
let popupTop = 0
|
|
34
|
-
let popupMaxHeight: string | number = 0
|
|
35
|
-
const defPupStys: VxeComponentStyleType = {}
|
|
36
|
-
const panePupStys: VxeComponentStyleType = {}
|
|
37
|
-
if ($xeGantt) {
|
|
38
|
-
const { refGanttContainerElem } = $xeGantt.getRefMaps()
|
|
39
|
-
const ganttContainerElem = refGanttContainerElem.value
|
|
40
|
-
if (ganttContainerElem) {
|
|
41
|
-
wrapperEl = ganttContainerElem
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const tableRect = wrapperEl.getBoundingClientRect()
|
|
45
|
-
// 多种模式,指定元素插入
|
|
46
|
-
if (showSimple && transfer) {
|
|
47
|
-
popupTop = tableRect.top + bodyEl.scrollTop
|
|
48
|
-
popupMaxHeight = XEUtils.eqNull(maxHeight) ? 360 : maxHeight
|
|
49
|
-
} else if (showCustomSimpleOutside) {
|
|
50
|
-
if ($xeGGWrapper && wrapperEl) {
|
|
51
|
-
popupTop = wrapperEl.offsetTop
|
|
52
|
-
}
|
|
53
|
-
popupMaxHeight = XEUtils.eqNull(maxHeight) ? 360 : maxHeight
|
|
54
|
-
} else {
|
|
55
|
-
// 判断面板不能大于表格高度
|
|
56
|
-
if (wrapperEl) {
|
|
57
|
-
popupMaxHeight = wrapperEl.clientHeight - 22
|
|
58
|
-
}
|
|
59
|
-
popupMaxHeight = Math.max(88, popupMaxHeight)
|
|
60
|
-
}
|
|
61
|
-
let popupMxHeight: string | number = 0
|
|
62
|
-
if (!(placement === 'left' || placement === 'right')) {
|
|
63
|
-
popupMxHeight = XEUtils.eqNull(maxHeight) ? popupMaxHeight : maxHeight
|
|
64
|
-
}
|
|
65
|
-
if (!placement || !
|
|
66
|
-
if (popupTop) {
|
|
67
|
-
defPupStys.top = toCssUnit(popupTop)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (showSimple && transfer) {
|
|
72
|
-
if (placement === 'bottom-left' || placement === 'bottom-right') {
|
|
73
|
-
defPupStys.bottom = toCssUnit(bodyEl.scrollHeight - tableRect.top - tableRect.height + 1)
|
|
74
|
-
}
|
|
75
|
-
if (placement === 'top-left' || placement === 'bottom-left') {
|
|
76
|
-
defPupStys.left = toCssUnit(tableRect.left)
|
|
77
|
-
} else if (!placement || placement === 'top-right' || placement === 'bottom-right') {
|
|
78
|
-
defPupStys.right = toCssUnit(bodyEl.scrollWidth - tableRect.left - tableRect.width + 1)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// 同步表格的css变量到弹窗中
|
|
83
|
-
const bodyComputeStyle = getComputedStyle(bodyEl)
|
|
84
|
-
const tableComputeStyle = getComputedStyle(wrapperEl)
|
|
85
|
-
customColumnCssKeys.forEach(key => {
|
|
86
|
-
const currCssKey = `--vxe-ui-vxe-table-custom-column-${key}-${key === 'title' ? 'min-' : ''}width`
|
|
87
|
-
const currCssVal = tableComputeStyle.getPropertyValue(currCssKey)
|
|
88
|
-
if (currCssVal && currCssVal !== bodyComputeStyle.getPropertyValue(currCssKey)) {
|
|
89
|
-
panePupStys[currCssKey] = currCssVal
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
if (minWidth) {
|
|
93
|
-
defPupStys['--vxe-ui-vxe-table-custom-default-min-width'] = toCssUnit(minWidth)
|
|
94
|
-
}
|
|
95
|
-
if (maxWidth) {
|
|
96
|
-
defPupStys['--vxe-ui-vxe-table-custom-default-max-width'] = toCssUnit(maxWidth)
|
|
97
|
-
}
|
|
98
|
-
if (popupMxHeight) {
|
|
99
|
-
defPupStys.maxHeight = toCssUnit(popupMxHeight)
|
|
100
|
-
}
|
|
101
|
-
customStore.defPopupStyle = defPupStys
|
|
102
|
-
customStore.panePopupStyle = panePupStys
|
|
103
|
-
customStore.maxHeight = popupMxHeight
|
|
104
|
-
return nextTick()
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const openCustom = () => {
|
|
108
|
-
const { initStore, customStore } = reactData
|
|
109
|
-
const customOpts = computeCustomOpts.value
|
|
110
|
-
const { mode, popupOptions } = customOpts
|
|
111
|
-
const showSimple = !(mode === 'modal' || mode === 'drawer')
|
|
112
|
-
const { transfer } = popupOptions || {}
|
|
113
|
-
const customSimpleMode = computeCustomSimpleMode.value
|
|
114
|
-
const showCustomSimpleOutside = customSimpleMode === 'outside'
|
|
115
|
-
let cpToElem = null
|
|
116
|
-
// 多种模式,指定元素插入
|
|
117
|
-
if (showSimple && transfer) {
|
|
118
|
-
cpToElem = document.body
|
|
119
|
-
} else {
|
|
120
|
-
if (showCustomSimpleOutside && $xeGGWrapper) {
|
|
121
|
-
const { refPopupContainerElem } = $xeGGWrapper.getRefMaps()
|
|
122
|
-
const popupContainerElem = refPopupContainerElem.value
|
|
123
|
-
if (popupContainerElem) {
|
|
124
|
-
cpToElem = popupContainerElem
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
if (internalData.customPopupToElem !== cpToElem) {
|
|
129
|
-
reactData.ctPopupFlag++
|
|
130
|
-
}
|
|
131
|
-
internalData.customPopupToElem = cpToElem
|
|
132
|
-
customStore.visible = true
|
|
133
|
-
initStore.custom = true
|
|
134
|
-
handleUpdateCustomColumn()
|
|
135
|
-
checkCustomStatus()
|
|
136
|
-
updatePopupStyle()
|
|
137
|
-
return nextTick().then(() => updatePopupStyle())
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const handleUpdateCustomColumn = () => {
|
|
141
|
-
const { customStore } = reactData
|
|
142
|
-
const { collectColumn } = internalData
|
|
143
|
-
if (customStore.visible) {
|
|
144
|
-
const sortMaps: Record<string, number> = {}
|
|
145
|
-
const fixedMaps: Record<string, VxeColumnPropTypes.Fixed> = {}
|
|
146
|
-
const visibleMaps: Record<string, boolean> = {}
|
|
147
|
-
XEUtils.eachTree(collectColumn, column => {
|
|
148
|
-
const colid = column.getKey()
|
|
149
|
-
column.renderFixed = column.fixed
|
|
150
|
-
column.renderVisible = column.visible
|
|
151
|
-
column.renderResizeWidth = column.renderWidth
|
|
152
|
-
column.renderAlign = column.align
|
|
153
|
-
column.renderHeaderAlign = column.headerAlign
|
|
154
|
-
column.renderFooterAlign = column.footerAlign
|
|
155
|
-
sortMaps[colid] = column.renderSortNumber
|
|
156
|
-
fixedMaps[colid] = column.fixed
|
|
157
|
-
visibleMaps[colid] = column.visible
|
|
158
|
-
})
|
|
159
|
-
customStore.oldSortMaps = sortMaps
|
|
160
|
-
customStore.oldFixedMaps = fixedMaps
|
|
161
|
-
customStore.oldVisibleMaps = visibleMaps
|
|
162
|
-
reactData.customColumnList = collectColumn.slice(0)
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const closeCustom = () => {
|
|
167
|
-
const { customStore } = reactData
|
|
168
|
-
const customOpts = computeCustomOpts.value
|
|
169
|
-
if (customStore.visible) {
|
|
170
|
-
customStore.visible = false
|
|
171
|
-
if (!customOpts.immediate) {
|
|
172
|
-
$xeTable.handleCustom()
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return nextTick()
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const toggleCustom = () => {
|
|
179
|
-
const { customStore } = reactData
|
|
180
|
-
if (customStore.visible) {
|
|
181
|
-
return closeCustom()
|
|
182
|
-
}
|
|
183
|
-
return openCustom()
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const saveCustom = (isDirectly?: boolean) => {
|
|
187
|
-
const { customColumnList, aggHandleFields, rowGroupList } = reactData
|
|
188
|
-
const customOpts = computeCustomOpts.value
|
|
189
|
-
const { allowVisible, allowSort, allowFixed, allowResizable, allowAlign, allowHeaderAlign, allowFooterAlign, allowGroup, allowValues } = customOpts
|
|
190
|
-
if (isDirectly) {
|
|
191
|
-
XEUtils.eachTree(customColumnList, (column) => {
|
|
192
|
-
if (allowResizable) {
|
|
193
|
-
if (column.renderVisible && (!column.children || !column.children.length)) {
|
|
194
|
-
column.resizeWidth = Math.max(0, XEUtils.toNumber(column.renderWidth))
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
})
|
|
198
|
-
} else {
|
|
199
|
-
XEUtils.eachTree(customColumnList, (column, index, items, path, parentColumn) => {
|
|
200
|
-
if (parentColumn) {
|
|
201
|
-
|
|
202
|
-
column.fixed = parentColumn.fixed
|
|
203
|
-
} else {
|
|
204
|
-
if (allowSort) {
|
|
205
|
-
const sortIndex = index + 1
|
|
206
|
-
column.renderSortNumber = sortIndex
|
|
207
|
-
}
|
|
208
|
-
if (allowFixed) {
|
|
209
|
-
column.fixed = column.renderFixed
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
if (allowResizable) {
|
|
213
|
-
if (column.renderVisible && (!column.children || !column.children.length)) {
|
|
214
|
-
if (column.renderResizeWidth !== column.renderWidth) {
|
|
215
|
-
column.resizeWidth = column.renderResizeWidth
|
|
216
|
-
column.renderWidth = column.renderResizeWidth
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
if (allowVisible) {
|
|
221
|
-
column.visible = column.renderVisible
|
|
222
|
-
}
|
|
223
|
-
if (allowAlign) {
|
|
224
|
-
column.align = column.renderAlign
|
|
225
|
-
}
|
|
226
|
-
if (allowHeaderAlign) {
|
|
227
|
-
column.headerAlign = column.renderHeaderAlign
|
|
228
|
-
}
|
|
229
|
-
if (allowFooterAlign) {
|
|
230
|
-
column.footerAlign = column.renderFooterAlign
|
|
231
|
-
}
|
|
232
|
-
if (allowGroup && allowValues) {
|
|
233
|
-
column.aggFunc = column.renderAggFn
|
|
234
|
-
}
|
|
235
|
-
})
|
|
236
|
-
}
|
|
237
|
-
reactData.isCustomStatus = true
|
|
238
|
-
if (allowGroup && !!$xeTable.handlePivotTableAggData) {
|
|
239
|
-
if (rowGroupList.length !== aggHandleFields.length || rowGroupList.some((conf, i) => conf.field !== aggHandleFields[i])) {
|
|
240
|
-
// 更新数据分组
|
|
241
|
-
if (aggHandleFields.length) {
|
|
242
|
-
$xeTable.setRowGroups(aggHandleFields)
|
|
243
|
-
} else {
|
|
244
|
-
$xeTable.clearRowGroups()
|
|
245
|
-
}
|
|
246
|
-
} else if (allowValues) {
|
|
247
|
-
// 更新聚合函数
|
|
248
|
-
$xeTable.handleUpdateAggData()
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
if (allowSort) {
|
|
252
|
-
internalData.collectColumn = customColumnList
|
|
253
|
-
}
|
|
254
|
-
return $xeTable.saveCustomStore('confirm')
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
const cancelCustom = () => {
|
|
258
|
-
const { customColumnList, customStore } = reactData
|
|
259
|
-
const { oldSortMaps, oldFixedMaps, oldVisibleMaps } = customStore
|
|
260
|
-
const customOpts = computeCustomOpts.value
|
|
261
|
-
const { allowVisible, allowSort, allowFixed, allowAlign, allowHeaderAlign, allowFooterAlign, allowResizable, allowGroup, allowValues } = customOpts
|
|
262
|
-
XEUtils.eachTree(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
column
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
column
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
if (opts.
|
|
373
|
-
column.
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
column.
|
|
378
|
-
}
|
|
379
|
-
if (opts.
|
|
380
|
-
column.
|
|
381
|
-
column.
|
|
382
|
-
}
|
|
383
|
-
if (
|
|
384
|
-
column.
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
column.
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
column.
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}
|
|
1
|
+
import { nextTick } from 'vue'
|
|
2
|
+
import { VxeUI } from '@vxe-ui/core'
|
|
3
|
+
import XEUtils from 'xe-utils'
|
|
4
|
+
import { getColumnList } from '../../src/util'
|
|
5
|
+
import { toCssUnit } from '../../../ui/src/dom'
|
|
6
|
+
|
|
7
|
+
import type { TableCustomMethods, TableCustomPrivateMethods, VxeColumnPropTypes, VxeTableDefines, VxeComponentStyleType } from '../../../../types'
|
|
8
|
+
|
|
9
|
+
const tableCustomMethodKeys: (keyof TableCustomMethods)[] = ['openCustom', 'closeCustom', 'getCustomVisible', 'toggleCustom', 'saveCustom', 'cancelCustom', 'resetCustom', 'toggleCustomAllCheckbox', 'setCustomAllCheckbox']
|
|
10
|
+
|
|
11
|
+
const customColumnCssKeys = ['checkbox', 'sort', 'title', 'width', 'fixed', 'align', 'header-align', 'footer-align']
|
|
12
|
+
|
|
13
|
+
VxeUI.hooks.add('tableCustomModule', {
|
|
14
|
+
setupTable($xeTable) {
|
|
15
|
+
const { reactData, internalData } = $xeTable
|
|
16
|
+
const { computeCustomOpts, computeRowGroupFields, computeCustomSimpleMode } = $xeTable.getComputeMaps()
|
|
17
|
+
const { refElem } = $xeTable.getRefMaps()
|
|
18
|
+
|
|
19
|
+
const $xeGrid = $xeTable.xeGrid
|
|
20
|
+
const $xeGantt = $xeTable.xeGantt
|
|
21
|
+
const $xeGGWrapper = $xeGrid || $xeGantt
|
|
22
|
+
|
|
23
|
+
const updatePopupStyle = () => {
|
|
24
|
+
const { customStore } = reactData
|
|
25
|
+
const customOpts = computeCustomOpts.value
|
|
26
|
+
const { mode, placement, popupOptions } = customOpts
|
|
27
|
+
const showSimple = !(mode === 'modal' || mode === 'drawer')
|
|
28
|
+
const { transfer, minWidth, maxWidth, maxHeight } = popupOptions || {}
|
|
29
|
+
const customSimpleMode = computeCustomSimpleMode.value
|
|
30
|
+
const showCustomSimpleOutside = customSimpleMode === 'outside'
|
|
31
|
+
const bodyEl = document.documentElement
|
|
32
|
+
let wrapperEl = refElem.value
|
|
33
|
+
let popupTop = 0
|
|
34
|
+
let popupMaxHeight: string | number = 0
|
|
35
|
+
const defPupStys: VxeComponentStyleType = {}
|
|
36
|
+
const panePupStys: VxeComponentStyleType = {}
|
|
37
|
+
if ($xeGantt) {
|
|
38
|
+
const { refGanttContainerElem } = $xeGantt.getRefMaps()
|
|
39
|
+
const ganttContainerElem = refGanttContainerElem.value
|
|
40
|
+
if (ganttContainerElem) {
|
|
41
|
+
wrapperEl = ganttContainerElem
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const tableRect = wrapperEl.getBoundingClientRect()
|
|
45
|
+
// 多种模式,指定元素插入
|
|
46
|
+
if (showSimple && transfer) {
|
|
47
|
+
popupTop = tableRect.top + bodyEl.scrollTop
|
|
48
|
+
popupMaxHeight = XEUtils.eqNull(maxHeight) ? 360 : maxHeight
|
|
49
|
+
} else if (showCustomSimpleOutside) {
|
|
50
|
+
if ($xeGGWrapper && wrapperEl) {
|
|
51
|
+
popupTop = wrapperEl.offsetTop
|
|
52
|
+
}
|
|
53
|
+
popupMaxHeight = XEUtils.eqNull(maxHeight) ? 360 : maxHeight
|
|
54
|
+
} else {
|
|
55
|
+
// 判断面板不能大于表格高度
|
|
56
|
+
if (wrapperEl) {
|
|
57
|
+
popupMaxHeight = wrapperEl.clientHeight - 22
|
|
58
|
+
}
|
|
59
|
+
popupMaxHeight = Math.max(88, popupMaxHeight)
|
|
60
|
+
}
|
|
61
|
+
let popupMxHeight: string | number = 0
|
|
62
|
+
if (!(placement === 'left' || placement === 'right')) {
|
|
63
|
+
popupMxHeight = XEUtils.eqNull(maxHeight) ? popupMaxHeight : maxHeight
|
|
64
|
+
}
|
|
65
|
+
if (!placement || !['left', 'right', 'bottom-left', 'bottom-right'].includes(placement)) {
|
|
66
|
+
if (popupTop) {
|
|
67
|
+
defPupStys.top = toCssUnit(popupTop)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (showSimple && transfer) {
|
|
72
|
+
if (placement === 'bottom-left' || placement === 'bottom-right') {
|
|
73
|
+
defPupStys.bottom = toCssUnit(bodyEl.scrollHeight - tableRect.top - tableRect.height + 1)
|
|
74
|
+
}
|
|
75
|
+
if (placement === 'top-left' || placement === 'bottom-left') {
|
|
76
|
+
defPupStys.left = toCssUnit(tableRect.left)
|
|
77
|
+
} else if (!placement || placement === 'top-right' || placement === 'bottom-right') {
|
|
78
|
+
defPupStys.right = toCssUnit(bodyEl.scrollWidth - tableRect.left - tableRect.width + 1)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 同步表格的css变量到弹窗中
|
|
83
|
+
const bodyComputeStyle = getComputedStyle(bodyEl)
|
|
84
|
+
const tableComputeStyle = getComputedStyle(wrapperEl)
|
|
85
|
+
customColumnCssKeys.forEach((key) => {
|
|
86
|
+
const currCssKey = `--vxe-ui-vxe-table-custom-column-${key}-${key === 'title' ? 'min-' : ''}width`
|
|
87
|
+
const currCssVal = tableComputeStyle.getPropertyValue(currCssKey)
|
|
88
|
+
if (currCssVal && currCssVal !== bodyComputeStyle.getPropertyValue(currCssKey)) {
|
|
89
|
+
panePupStys[currCssKey] = currCssVal
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
if (minWidth) {
|
|
93
|
+
defPupStys['--vxe-ui-vxe-table-custom-default-min-width'] = toCssUnit(minWidth)
|
|
94
|
+
}
|
|
95
|
+
if (maxWidth) {
|
|
96
|
+
defPupStys['--vxe-ui-vxe-table-custom-default-max-width'] = toCssUnit(maxWidth)
|
|
97
|
+
}
|
|
98
|
+
if (popupMxHeight) {
|
|
99
|
+
defPupStys.maxHeight = toCssUnit(popupMxHeight)
|
|
100
|
+
}
|
|
101
|
+
customStore.defPopupStyle = defPupStys
|
|
102
|
+
customStore.panePopupStyle = panePupStys
|
|
103
|
+
customStore.maxHeight = popupMxHeight
|
|
104
|
+
return nextTick()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const openCustom = () => {
|
|
108
|
+
const { initStore, customStore } = reactData
|
|
109
|
+
const customOpts = computeCustomOpts.value
|
|
110
|
+
const { mode, popupOptions } = customOpts
|
|
111
|
+
const showSimple = !(mode === 'modal' || mode === 'drawer')
|
|
112
|
+
const { transfer } = popupOptions || {}
|
|
113
|
+
const customSimpleMode = computeCustomSimpleMode.value
|
|
114
|
+
const showCustomSimpleOutside = customSimpleMode === 'outside'
|
|
115
|
+
let cpToElem = null
|
|
116
|
+
// 多种模式,指定元素插入
|
|
117
|
+
if (showSimple && transfer) {
|
|
118
|
+
cpToElem = document.body
|
|
119
|
+
} else {
|
|
120
|
+
if (showCustomSimpleOutside && $xeGGWrapper) {
|
|
121
|
+
const { refPopupContainerElem } = $xeGGWrapper.getRefMaps()
|
|
122
|
+
const popupContainerElem = refPopupContainerElem.value
|
|
123
|
+
if (popupContainerElem) {
|
|
124
|
+
cpToElem = popupContainerElem
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (internalData.customPopupToElem !== cpToElem) {
|
|
129
|
+
reactData.ctPopupFlag++
|
|
130
|
+
}
|
|
131
|
+
internalData.customPopupToElem = cpToElem
|
|
132
|
+
customStore.visible = true
|
|
133
|
+
initStore.custom = true
|
|
134
|
+
handleUpdateCustomColumn()
|
|
135
|
+
checkCustomStatus()
|
|
136
|
+
updatePopupStyle()
|
|
137
|
+
return nextTick().then(() => updatePopupStyle())
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const handleUpdateCustomColumn = () => {
|
|
141
|
+
const { customStore } = reactData
|
|
142
|
+
const { collectColumn } = internalData
|
|
143
|
+
if (customStore.visible) {
|
|
144
|
+
const sortMaps: Record<string, number> = {}
|
|
145
|
+
const fixedMaps: Record<string, VxeColumnPropTypes.Fixed> = {}
|
|
146
|
+
const visibleMaps: Record<string, boolean> = {}
|
|
147
|
+
XEUtils.eachTree(collectColumn, (column) => {
|
|
148
|
+
const colid = column.getKey()
|
|
149
|
+
column.renderFixed = column.fixed
|
|
150
|
+
column.renderVisible = column.visible
|
|
151
|
+
column.renderResizeWidth = column.renderWidth
|
|
152
|
+
column.renderAlign = column.align
|
|
153
|
+
column.renderHeaderAlign = column.headerAlign
|
|
154
|
+
column.renderFooterAlign = column.footerAlign
|
|
155
|
+
sortMaps[colid] = column.renderSortNumber
|
|
156
|
+
fixedMaps[colid] = column.fixed
|
|
157
|
+
visibleMaps[colid] = column.visible
|
|
158
|
+
})
|
|
159
|
+
customStore.oldSortMaps = sortMaps
|
|
160
|
+
customStore.oldFixedMaps = fixedMaps
|
|
161
|
+
customStore.oldVisibleMaps = visibleMaps
|
|
162
|
+
reactData.customColumnList = collectColumn.slice(0)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const closeCustom = () => {
|
|
167
|
+
const { customStore } = reactData
|
|
168
|
+
const customOpts = computeCustomOpts.value
|
|
169
|
+
if (customStore.visible) {
|
|
170
|
+
customStore.visible = false
|
|
171
|
+
if (!customOpts.immediate) {
|
|
172
|
+
$xeTable.handleCustom()
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return nextTick()
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const toggleCustom = () => {
|
|
179
|
+
const { customStore } = reactData
|
|
180
|
+
if (customStore.visible) {
|
|
181
|
+
return closeCustom()
|
|
182
|
+
}
|
|
183
|
+
return openCustom()
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const saveCustom = (isDirectly?: boolean) => {
|
|
187
|
+
const { customColumnList, aggHandleFields, rowGroupList } = reactData
|
|
188
|
+
const customOpts = computeCustomOpts.value
|
|
189
|
+
const { allowVisible, allowSort, allowFixed, allowResizable, allowAlign, allowHeaderAlign, allowFooterAlign, allowGroup, allowValues } = customOpts
|
|
190
|
+
if (isDirectly) {
|
|
191
|
+
XEUtils.eachTree(customColumnList, (column) => {
|
|
192
|
+
if (allowResizable) {
|
|
193
|
+
if (column.renderVisible && (!column.children || !column.children.length)) {
|
|
194
|
+
column.resizeWidth = Math.max(0, XEUtils.toNumber(column.renderWidth))
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
} else {
|
|
199
|
+
XEUtils.eachTree(customColumnList, (column, index, items, path, parentColumn) => {
|
|
200
|
+
if (parentColumn) {
|
|
201
|
+
// 更新子列信息
|
|
202
|
+
column.fixed = parentColumn.fixed
|
|
203
|
+
} else {
|
|
204
|
+
if (allowSort) {
|
|
205
|
+
const sortIndex = index + 1
|
|
206
|
+
column.renderSortNumber = sortIndex
|
|
207
|
+
}
|
|
208
|
+
if (allowFixed) {
|
|
209
|
+
column.fixed = column.renderFixed
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (allowResizable) {
|
|
213
|
+
if (column.renderVisible && (!column.children || !column.children.length)) {
|
|
214
|
+
if (column.renderResizeWidth !== column.renderWidth) {
|
|
215
|
+
column.resizeWidth = column.renderResizeWidth
|
|
216
|
+
column.renderWidth = column.renderResizeWidth
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (allowVisible) {
|
|
221
|
+
column.visible = column.renderVisible
|
|
222
|
+
}
|
|
223
|
+
if (allowAlign) {
|
|
224
|
+
column.align = column.renderAlign
|
|
225
|
+
}
|
|
226
|
+
if (allowHeaderAlign) {
|
|
227
|
+
column.headerAlign = column.renderHeaderAlign
|
|
228
|
+
}
|
|
229
|
+
if (allowFooterAlign) {
|
|
230
|
+
column.footerAlign = column.renderFooterAlign
|
|
231
|
+
}
|
|
232
|
+
if (allowGroup && allowValues) {
|
|
233
|
+
column.aggFunc = column.renderAggFn
|
|
234
|
+
}
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
reactData.isCustomStatus = true
|
|
238
|
+
if (allowGroup && !!$xeTable.handlePivotTableAggData) {
|
|
239
|
+
if (rowGroupList.length !== aggHandleFields.length || rowGroupList.some((conf, i) => conf.field !== aggHandleFields[i])) {
|
|
240
|
+
// 更新数据分组
|
|
241
|
+
if (aggHandleFields.length) {
|
|
242
|
+
$xeTable.setRowGroups(aggHandleFields)
|
|
243
|
+
} else {
|
|
244
|
+
$xeTable.clearRowGroups()
|
|
245
|
+
}
|
|
246
|
+
} else if (allowValues) {
|
|
247
|
+
// 更新聚合函数
|
|
248
|
+
$xeTable.handleUpdateAggData()
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (allowSort) {
|
|
252
|
+
internalData.collectColumn = customColumnList
|
|
253
|
+
}
|
|
254
|
+
return $xeTable.saveCustomStore('confirm')
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const cancelCustom = () => {
|
|
258
|
+
const { customColumnList, customStore } = reactData
|
|
259
|
+
const { oldSortMaps, oldFixedMaps, oldVisibleMaps } = customStore
|
|
260
|
+
const customOpts = computeCustomOpts.value
|
|
261
|
+
const { allowVisible, allowSort, allowFixed, allowAlign, allowHeaderAlign, allowFooterAlign, allowResizable, allowGroup, allowValues } = customOpts
|
|
262
|
+
XEUtils.eachTree(
|
|
263
|
+
customColumnList,
|
|
264
|
+
(column) => {
|
|
265
|
+
const colid = column.getKey()
|
|
266
|
+
const visible = !!oldVisibleMaps[colid]
|
|
267
|
+
const fixed = oldFixedMaps[colid] || ''
|
|
268
|
+
if (allowVisible) {
|
|
269
|
+
column.renderVisible = visible
|
|
270
|
+
column.visible = visible
|
|
271
|
+
}
|
|
272
|
+
if (allowFixed) {
|
|
273
|
+
column.renderFixed = fixed
|
|
274
|
+
column.fixed = fixed
|
|
275
|
+
}
|
|
276
|
+
if (allowSort) {
|
|
277
|
+
column.renderSortNumber = oldSortMaps[colid] || 0
|
|
278
|
+
}
|
|
279
|
+
if (allowResizable) {
|
|
280
|
+
column.renderResizeWidth = column.renderWidth
|
|
281
|
+
}
|
|
282
|
+
if (allowAlign) {
|
|
283
|
+
column.align = column.renderAlign
|
|
284
|
+
}
|
|
285
|
+
if (allowHeaderAlign) {
|
|
286
|
+
column.headerAlign = column.renderHeaderAlign
|
|
287
|
+
}
|
|
288
|
+
if (allowFooterAlign) {
|
|
289
|
+
column.footerAlign = column.renderFooterAlign
|
|
290
|
+
}
|
|
291
|
+
if (allowGroup) {
|
|
292
|
+
// 无
|
|
293
|
+
}
|
|
294
|
+
if (allowValues) {
|
|
295
|
+
// 无
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
{ children: 'children' }
|
|
299
|
+
)
|
|
300
|
+
return nextTick()
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const setCustomAllCheckbox = (checked: boolean) => {
|
|
304
|
+
const { customStore } = reactData
|
|
305
|
+
const { customColumnList } = reactData
|
|
306
|
+
const customOpts = computeCustomOpts.value
|
|
307
|
+
const { checkMethod, visibleMethod } = customOpts
|
|
308
|
+
const isAll = !!checked
|
|
309
|
+
if (customOpts.immediate) {
|
|
310
|
+
XEUtils.eachTree(customColumnList, (column) => {
|
|
311
|
+
if (visibleMethod && !visibleMethod({ $table: $xeTable, column })) {
|
|
312
|
+
return
|
|
313
|
+
}
|
|
314
|
+
if (checkMethod && !checkMethod({ $table: $xeTable, column })) {
|
|
315
|
+
return
|
|
316
|
+
}
|
|
317
|
+
column.visible = isAll
|
|
318
|
+
column.renderVisible = isAll
|
|
319
|
+
column.halfVisible = false
|
|
320
|
+
})
|
|
321
|
+
customStore.isAll = isAll
|
|
322
|
+
reactData.isCustomStatus = true
|
|
323
|
+
$xeTable.handleCustom()
|
|
324
|
+
$xeTable.saveCustomStore('update:visible')
|
|
325
|
+
} else {
|
|
326
|
+
XEUtils.eachTree(customColumnList, (column) => {
|
|
327
|
+
if (visibleMethod && !visibleMethod({ $table: $xeTable, column })) {
|
|
328
|
+
return
|
|
329
|
+
}
|
|
330
|
+
if (checkMethod && !checkMethod({ $table: $xeTable, column })) {
|
|
331
|
+
return
|
|
332
|
+
}
|
|
333
|
+
column.renderVisible = isAll
|
|
334
|
+
column.halfVisible = false
|
|
335
|
+
})
|
|
336
|
+
customStore.isAll = isAll
|
|
337
|
+
}
|
|
338
|
+
$xeTable.checkCustomStatus()
|
|
339
|
+
return nextTick()
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const customMethods: TableCustomMethods = {
|
|
343
|
+
getCustomVisible() {
|
|
344
|
+
const { customStore } = reactData
|
|
345
|
+
return customStore.visible
|
|
346
|
+
},
|
|
347
|
+
openCustom,
|
|
348
|
+
closeCustom,
|
|
349
|
+
toggleCustom,
|
|
350
|
+
saveCustom,
|
|
351
|
+
cancelCustom,
|
|
352
|
+
resetCustom(options) {
|
|
353
|
+
const { rowGroupList } = reactData
|
|
354
|
+
const { collectColumn } = internalData
|
|
355
|
+
const customOpts = computeCustomOpts.value
|
|
356
|
+
const { checkMethod } = customOpts
|
|
357
|
+
const opts: VxeTableDefines.VxeTableCustomStorageObj = Object.assign(
|
|
358
|
+
{
|
|
359
|
+
visible: true,
|
|
360
|
+
resizable: options === true,
|
|
361
|
+
fixed: options === true,
|
|
362
|
+
sort: options === true,
|
|
363
|
+
aggFunc: options === true,
|
|
364
|
+
align: options === true,
|
|
365
|
+
headerAlign: options === true,
|
|
366
|
+
footerAlign: options === true
|
|
367
|
+
},
|
|
368
|
+
options
|
|
369
|
+
)
|
|
370
|
+
const allCols: VxeTableDefines.ColumnInfo[] = []
|
|
371
|
+
XEUtils.eachTree(collectColumn, (column) => {
|
|
372
|
+
if (opts.resizable) {
|
|
373
|
+
column.resizeWidth = 0
|
|
374
|
+
}
|
|
375
|
+
if (opts.fixed) {
|
|
376
|
+
column.fixed = column.defaultFixed
|
|
377
|
+
column.renderFixed = column.defaultFixed
|
|
378
|
+
}
|
|
379
|
+
if (opts.sort) {
|
|
380
|
+
column.renderSortNumber = column.sortNumber
|
|
381
|
+
column.parentId = column.defaultParentId
|
|
382
|
+
}
|
|
383
|
+
if (!checkMethod || checkMethod({ $table: $xeTable, column })) {
|
|
384
|
+
column.visible = column.defaultVisible
|
|
385
|
+
}
|
|
386
|
+
if (opts.align) {
|
|
387
|
+
column.align = column.defaultAlign
|
|
388
|
+
column.renderAlign = column.defaultAlign
|
|
389
|
+
}
|
|
390
|
+
if (opts.headerAlign) {
|
|
391
|
+
column.headerAlign = column.defaultHeaderAlign
|
|
392
|
+
column.renderHeaderAlign = column.defaultHeaderAlign
|
|
393
|
+
}
|
|
394
|
+
if (opts.footerAlign) {
|
|
395
|
+
column.footerAlign = column.defaultFooterAlign
|
|
396
|
+
column.renderFooterAlign = column.defaultFooterAlign
|
|
397
|
+
}
|
|
398
|
+
if (opts.aggFunc) {
|
|
399
|
+
column.aggFunc = column.defaultAggFunc
|
|
400
|
+
column.renderAggFn = column.defaultAggFunc
|
|
401
|
+
}
|
|
402
|
+
column.renderResizeWidth = column.renderWidth
|
|
403
|
+
allCols.push(column)
|
|
404
|
+
})
|
|
405
|
+
if (opts.sort) {
|
|
406
|
+
const newCollectCols = XEUtils.toArrayTree(XEUtils.orderBy(allCols, 'renderSortNumber'), { key: 'id', parentKey: 'parentId', children: 'children' })
|
|
407
|
+
internalData.collectColumn = newCollectCols
|
|
408
|
+
internalData.tableFullColumn = getColumnList(newCollectCols)
|
|
409
|
+
}
|
|
410
|
+
reactData.isCustomStatus = false
|
|
411
|
+
return $xeTable.handleCustom().then(() => {
|
|
412
|
+
if (opts.aggFunc && !!$xeTable.handlePivotTableAggData) {
|
|
413
|
+
const rowGroupFields = computeRowGroupFields.value
|
|
414
|
+
if (rowGroupFields ? rowGroupFields.length : rowGroupList.length) {
|
|
415
|
+
if (rowGroupFields && rowGroupFields.length) {
|
|
416
|
+
$xeTable.setRowGroups(rowGroupFields)
|
|
417
|
+
} else {
|
|
418
|
+
$xeTable.clearRowGroups()
|
|
419
|
+
}
|
|
420
|
+
} else {
|
|
421
|
+
$xeTable.handleUpdateAggData()
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
$xeTable.saveCustomStore('reset')
|
|
425
|
+
})
|
|
426
|
+
},
|
|
427
|
+
toggleCustomAllCheckbox() {
|
|
428
|
+
const { customStore } = reactData
|
|
429
|
+
const isAll = !customStore.isAll
|
|
430
|
+
return setCustomAllCheckbox(isAll)
|
|
431
|
+
},
|
|
432
|
+
setCustomAllCheckbox
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const checkCustomStatus = () => {
|
|
436
|
+
const { customStore } = reactData
|
|
437
|
+
const { collectColumn } = internalData
|
|
438
|
+
const customOpts = computeCustomOpts.value
|
|
439
|
+
const { checkMethod } = customOpts
|
|
440
|
+
customStore.isAll = collectColumn.every((column) => (checkMethod ? !checkMethod({ $table: $xeTable, column }) : false) || column.renderVisible)
|
|
441
|
+
customStore.isIndeterminate = !customStore.isAll && collectColumn.some((column) => (!checkMethod || checkMethod({ $table: $xeTable, column })) && (column.renderVisible || column.halfVisible))
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const emitCustomEvent = (type: VxeTableDefines.CustomType, evnt: Event) => {
|
|
445
|
+
$xeTable.dispatchEvent('custom', { type }, evnt)
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const customPrivateMethods: TableCustomPrivateMethods = {
|
|
449
|
+
checkCustomStatus,
|
|
450
|
+
emitCustomEvent,
|
|
451
|
+
triggerCustomEvent(evnt) {
|
|
452
|
+
const reactData = $xeTable.reactData
|
|
453
|
+
|
|
454
|
+
const { customStore } = reactData
|
|
455
|
+
if (customStore.visible) {
|
|
456
|
+
closeCustom()
|
|
457
|
+
emitCustomEvent('close', evnt)
|
|
458
|
+
$xeTable.dispatchEvent('custom-close', {}, evnt)
|
|
459
|
+
} else {
|
|
460
|
+
customStore.btnEl = evnt.target as HTMLDivElement
|
|
461
|
+
openCustom()
|
|
462
|
+
emitCustomEvent('open', evnt)
|
|
463
|
+
$xeTable.dispatchEvent('custom-open', {}, evnt)
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
customOpenEvent(evnt) {
|
|
467
|
+
const reactData = $xeTable.reactData
|
|
468
|
+
|
|
469
|
+
const { customStore } = reactData
|
|
470
|
+
if (!customStore.visible) {
|
|
471
|
+
customStore.activeBtn = true
|
|
472
|
+
customStore.btnEl = evnt.target as HTMLDivElement
|
|
473
|
+
$xeTable.openCustom()
|
|
474
|
+
$xeTable.emitCustomEvent('open', evnt)
|
|
475
|
+
$xeTable.dispatchEvent('custom-open', {}, evnt)
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
customCloseEvent(evnt) {
|
|
479
|
+
const reactData = $xeTable.reactData
|
|
480
|
+
|
|
481
|
+
const { customStore } = reactData
|
|
482
|
+
if (customStore.visible) {
|
|
483
|
+
customStore.activeBtn = false
|
|
484
|
+
$xeTable.closeCustom()
|
|
485
|
+
$xeTable.emitCustomEvent('close', evnt)
|
|
486
|
+
$xeTable.dispatchEvent('custom-close', {}, evnt)
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
handleUpdateCustomColumn,
|
|
490
|
+
handleCustomStyle() {
|
|
491
|
+
const reactData = $xeTable.reactData
|
|
492
|
+
|
|
493
|
+
const { customStore } = reactData
|
|
494
|
+
if (!customStore.visible) {
|
|
495
|
+
return nextTick()
|
|
496
|
+
}
|
|
497
|
+
reactData.isCustomDragStatus = false
|
|
498
|
+
return updatePopupStyle()
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return { ...customMethods, ...customPrivateMethods }
|
|
503
|
+
},
|
|
504
|
+
setupGrid($xeGrid) {
|
|
505
|
+
return $xeGrid.extendTableMethods(tableCustomMethodKeys)
|
|
506
|
+
},
|
|
507
|
+
setupGantt($xeGantt) {
|
|
508
|
+
return $xeGantt.extendTableMethods(tableCustomMethodKeys)
|
|
509
|
+
}
|
|
510
|
+
})
|