vxe-table 4.18.4 → 4.18.6
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/LICENSE +20 -20
- package/README.en.md +118 -118
- package/README.ja-JP.md +117 -117
- package/README.md +268 -268
- package/README.zh-TW.md +117 -117
- package/es/grid/style.css +4 -0
- package/es/grid/style.min.css +1 -1
- package/es/index.css +1 -1
- package/es/index.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/src/table.js +82 -22
- package/es/table/src/util.js +3 -4
- package/es/table/style.css +48 -18
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/vxe-grid/style.css +4 -0
- package/es/vxe-grid/style.min.css +1 -1
- package/es/vxe-table/style.css +48 -18
- package/lib/grid/style/style.css +4 -0
- package/lib/grid/style/style.min.css +1 -1
- package/lib/index.common.js +1 -2
- package/lib/index.css +1 -1
- package/lib/index.min.css +1 -1
- package/lib/index.umd.js +2833 -2733
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/src/table.js +7 -6
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +4 -6
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +48 -18
- package/lib/ui/index.js +1 -1
- 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/lib/v-x-e-table/index.js +1 -2
- package/lib/v-x-e-table/index.min.js +1 -1
- package/lib/vxe-colgroup/index.js +1 -2
- package/lib/vxe-colgroup/index.min.js +1 -1
- package/lib/vxe-column/index.js +1 -2
- package/lib/vxe-column/index.min.js +1 -1
- package/lib/vxe-grid/index.js +1 -2
- package/lib/vxe-grid/index.min.js +1 -1
- package/lib/vxe-grid/style/style.css +4 -0
- package/lib/vxe-grid/style/style.min.css +1 -1
- package/lib/vxe-table/index.js +1 -2
- package/lib/vxe-table/index.min.js +1 -1
- package/lib/vxe-table/style/style.css +48 -18
- package/lib/vxe-toolbar/index.js +1 -2
- package/lib/vxe-toolbar/index.min.js +1 -1
- package/lib/vxe-ui/index.js +1 -2
- package/lib/vxe-ui/index.min.js +1 -1
- package/lib/vxe-v-x-e-table/index.js +1 -2
- package/lib/vxe-v-x-e-table/index.min.js +1 -1
- package/package.json +91 -91
- package/packages/colgroup/index.ts +22 -22
- package/packages/column/index.ts +22 -22
- package/packages/components.ts +43 -43
- package/packages/grid/index.ts +18 -18
- package/packages/grid/src/emits.ts +19 -19
- package/packages/grid/src/grid.ts +1768 -1768
- package/packages/grid/src/props.ts +23 -23
- package/packages/index.ts +4 -4
- package/packages/locale/lang/ar-EG.ts +832 -832
- package/packages/locale/lang/de-DE.ts +832 -832
- package/packages/locale/lang/en-US.ts +832 -832
- package/packages/locale/lang/es-ES.ts +832 -832
- package/packages/locale/lang/fr-FR.ts +832 -832
- package/packages/locale/lang/hu-HU.ts +832 -832
- package/packages/locale/lang/hy-AM.ts +832 -832
- package/packages/locale/lang/id-ID.ts +832 -832
- package/packages/locale/lang/it-IT.ts +832 -832
- package/packages/locale/lang/ja-JP.ts +832 -832
- package/packages/locale/lang/ko-KR.ts +832 -832
- package/packages/locale/lang/ms-MY.ts +832 -832
- package/packages/locale/lang/nb-NO.ts +832 -832
- package/packages/locale/lang/pt-BR.ts +832 -832
- package/packages/locale/lang/ru-RU.ts +832 -832
- package/packages/locale/lang/th-TH.ts +832 -832
- package/packages/locale/lang/ug-CN.ts +832 -832
- package/packages/locale/lang/uk-UA.ts +832 -832
- package/packages/locale/lang/uz-UZ.ts +832 -832
- package/packages/locale/lang/vi-VN.ts +832 -832
- package/packages/locale/lang/zh-CHT.ts +832 -832
- package/packages/locale/lang/zh-CN.ts +832 -832
- package/packages/locale/lang/zh-HK.ts +3 -3
- package/packages/locale/lang/zh-MO.ts +3 -3
- package/packages/locale/lang/zh-TC.ts +3 -3
- package/packages/locale/lang/zh-TW.ts +3 -3
- package/packages/table/index.ts +26 -26
- package/packages/table/module/custom/hook.ts +359 -359
- package/packages/table/module/custom/panel.ts +1331 -1331
- package/packages/table/module/edit/hook.ts +1032 -1032
- package/packages/table/module/export/export-panel.ts +567 -567
- package/packages/table/module/export/hook.ts +1654 -1654
- package/packages/table/module/export/import-panel.ts +266 -266
- package/packages/table/module/export/util.ts +24 -24
- package/packages/table/module/filter/hook.ts +468 -468
- package/packages/table/module/filter/panel.ts +301 -301
- package/packages/table/module/keyboard/hook.ts +495 -495
- package/packages/table/module/menu/hook.ts +325 -325
- package/packages/table/module/menu/panel.ts +201 -201
- package/packages/table/module/validator/hook.ts +631 -631
- package/packages/table/render/index.ts +1440 -1440
- package/packages/table/src/body.ts +932 -932
- package/packages/table/src/cell.ts +1290 -1290
- package/packages/table/src/column.ts +190 -190
- package/packages/table/src/columnInfo.ts +225 -225
- package/packages/table/src/emits.ts +123 -123
- package/packages/table/src/footer.ts +368 -368
- package/packages/table/src/group.ts +59 -59
- package/packages/table/src/header.ts +559 -559
- package/packages/table/src/props.ts +324 -324
- package/packages/table/src/store.ts +14 -14
- package/packages/table/src/table.ts +14001 -13939
- package/packages/table/src/use/cell-view.ts +44 -44
- package/packages/table/src/use/index.ts +1 -1
- package/packages/table/src/util.ts +1064 -1064
- package/packages/toolbar/index.ts +18 -18
- package/packages/toolbar/src/toolbar.ts +701 -701
- package/packages/ui/index.ts +530 -530
- package/packages/ui/src/anime.ts +52 -52
- package/packages/ui/src/comp.ts +3 -3
- package/packages/ui/src/dom.ts +236 -236
- package/packages/ui/src/log.ts +8 -8
- package/packages/ui/src/utils.ts +56 -56
- package/packages/ui/src/vn.ts +55 -55
- package/packages/v-x-e-table/index.d.ts +4 -4
- package/packages/v-x-e-table/index.ts +4 -4
- package/styles/all.scss +7 -7
- package/styles/base.scss +16 -16
- package/styles/components/grid.scss +89 -85
- package/styles/components/icon.scss +225 -225
- package/styles/components/old-icon.scss +715 -715
- package/styles/components/table-module/all.scss +6 -6
- package/styles/components/table-module/custom.scss +527 -527
- package/styles/components/table-module/export.scss +130 -130
- package/styles/components/table-module/filter.scss +130 -130
- package/styles/components/table-module/menu.scss +81 -81
- package/styles/components/table.scss +2679 -2679
- package/styles/components/toolbar.scss +119 -119
- package/styles/default.scss +2 -2
- package/styles/helpers/baseMixin.scss +95 -95
- package/styles/index.scss +4 -4
- package/styles/modules.scss +5 -5
- package/styles/theme/base.scss +93 -93
- package/styles/theme/dark.scss +49 -49
- package/styles/theme/light.scss +44 -44
- package/styles/variable.scss +43 -43
- package/types/all.d.ts +37 -37
- package/types/index.d.ts +4 -4
- /package/es/{iconfont.1773644074946.ttf → iconfont.1773972993993.ttf} +0 -0
- /package/es/{iconfont.1773644074946.woff → iconfont.1773972993993.woff} +0 -0
- /package/es/{iconfont.1773644074946.woff2 → iconfont.1773972993993.woff2} +0 -0
- /package/lib/{iconfont.1773644074946.ttf → iconfont.1773972993993.ttf} +0 -0
- /package/lib/{iconfont.1773644074946.woff → iconfont.1773972993993.woff} +0 -0
- /package/lib/{iconfont.1773644074946.woff2 → iconfont.1773972993993.woff2} +0 -0
|
@@ -1,359 +1,359 @@
|
|
|
1
|
-
import { nextTick } from 'vue'
|
|
2
|
-
import { VxeUI } from '../../../ui'
|
|
3
|
-
import XEUtils from 'xe-utils'
|
|
4
|
-
import { getColumnList } from '../../src/util'
|
|
5
|
-
|
|
6
|
-
import type { TableCustomMethods, TableCustomPrivateMethods, VxeColumnPropTypes, VxeTableDefines } from '../../../../types'
|
|
7
|
-
|
|
8
|
-
const tableCustomMethodKeys: (keyof TableCustomMethods)[] = ['openCustom', 'closeCustom', 'getCustomVisible', 'toggleCustom', 'saveCustom', 'cancelCustom', 'resetCustom', 'toggleCustomAllCheckbox', 'setCustomAllCheckbox']
|
|
9
|
-
|
|
10
|
-
VxeUI.hooks.add('tableCustomModule', {
|
|
11
|
-
setupTable ($xeTable) {
|
|
12
|
-
const { reactData, internalData } = $xeTable
|
|
13
|
-
const { computeCustomOpts, computeRowGroupFields, computeCustomSimpleMode } = $xeTable.getComputeMaps()
|
|
14
|
-
const { refElem } = $xeTable.getRefMaps()
|
|
15
|
-
|
|
16
|
-
const $xeGrid = $xeTable.xeGrid
|
|
17
|
-
const $xeGantt = $xeTable.xeGantt
|
|
18
|
-
const $xeGGWrapper = $xeGrid || $xeGantt
|
|
19
|
-
|
|
20
|
-
const updatePopupStyle = () => {
|
|
21
|
-
const { customStore } = reactData
|
|
22
|
-
const customOpts = computeCustomOpts.value
|
|
23
|
-
const customSimpleMode = computeCustomSimpleMode.value
|
|
24
|
-
const showCustomSimpleOutside = customSimpleMode === 'outside'
|
|
25
|
-
const { popupOptions } = customOpts
|
|
26
|
-
const { maxHeight } = popupOptions || {}
|
|
27
|
-
let wrapperEl = refElem.value
|
|
28
|
-
let popupTop = 0
|
|
29
|
-
let popupMaxHeight: string | number = 0
|
|
30
|
-
if ($xeGantt) {
|
|
31
|
-
const { refGanttContainerElem } = $xeGantt.getRefMaps()
|
|
32
|
-
const ganttContainerElem = refGanttContainerElem.value
|
|
33
|
-
if (ganttContainerElem) {
|
|
34
|
-
wrapperEl = ganttContainerElem
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (showCustomSimpleOutside) {
|
|
38
|
-
if ($xeGGWrapper && wrapperEl) {
|
|
39
|
-
popupTop = wrapperEl.offsetTop
|
|
40
|
-
}
|
|
41
|
-
popupMaxHeight = XEUtils.eqNull(maxHeight) ? 360 : maxHeight
|
|
42
|
-
} else {
|
|
43
|
-
// 判断面板不能大于表格高度
|
|
44
|
-
if (wrapperEl) {
|
|
45
|
-
popupMaxHeight = wrapperEl.clientHeight - 22
|
|
46
|
-
}
|
|
47
|
-
popupMaxHeight = Math.max(88, popupMaxHeight)
|
|
48
|
-
}
|
|
49
|
-
customStore.popupTop = popupTop
|
|
50
|
-
customStore.maxHeight = XEUtils.eqNull(maxHeight) ? popupMaxHeight : maxHeight
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const openCustom = () => {
|
|
54
|
-
const { initStore, customStore } = reactData
|
|
55
|
-
customStore.visible = true
|
|
56
|
-
initStore.custom = true
|
|
57
|
-
handleUpdateCustomColumn()
|
|
58
|
-
checkCustomStatus()
|
|
59
|
-
updatePopupStyle()
|
|
60
|
-
return nextTick().then(() => updatePopupStyle())
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const handleUpdateCustomColumn = () => {
|
|
64
|
-
const { customStore } = reactData
|
|
65
|
-
const { collectColumn } = internalData
|
|
66
|
-
if (customStore.visible) {
|
|
67
|
-
const sortMaps: Record<string, number> = {}
|
|
68
|
-
const fixedMaps: Record<string, VxeColumnPropTypes.Fixed> = {}
|
|
69
|
-
const visibleMaps: Record<string, boolean> = {}
|
|
70
|
-
XEUtils.eachTree(collectColumn, column => {
|
|
71
|
-
const colid = column.getKey()
|
|
72
|
-
column.renderFixed = column.fixed
|
|
73
|
-
column.renderVisible = column.visible
|
|
74
|
-
column.renderResizeWidth = column.renderWidth
|
|
75
|
-
sortMaps[colid] = column.renderSortNumber
|
|
76
|
-
fixedMaps[colid] = column.fixed
|
|
77
|
-
visibleMaps[colid] = column.visible
|
|
78
|
-
})
|
|
79
|
-
customStore.oldSortMaps = sortMaps
|
|
80
|
-
customStore.oldFixedMaps = fixedMaps
|
|
81
|
-
customStore.oldVisibleMaps = visibleMaps
|
|
82
|
-
reactData.customColumnList = collectColumn.slice(0)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const closeCustom = () => {
|
|
87
|
-
const { customStore } = reactData
|
|
88
|
-
const customOpts = computeCustomOpts.value
|
|
89
|
-
if (customStore.visible) {
|
|
90
|
-
customStore.visible = false
|
|
91
|
-
if (!customOpts.immediate) {
|
|
92
|
-
$xeTable.handleCustom()
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return nextTick()
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const toggleCustom = () => {
|
|
99
|
-
const { customStore } = reactData
|
|
100
|
-
if (customStore.visible) {
|
|
101
|
-
return closeCustom()
|
|
102
|
-
}
|
|
103
|
-
return openCustom()
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const saveCustom = () => {
|
|
107
|
-
const { customColumnList, aggHandleFields, rowGroupList } = reactData
|
|
108
|
-
const customOpts = computeCustomOpts.value
|
|
109
|
-
const { allowVisible, allowSort, allowFixed, allowResizable, allowGroup, allowValues } = customOpts
|
|
110
|
-
XEUtils.eachTree(customColumnList, (column, index, items, path, parentColumn) => {
|
|
111
|
-
if (parentColumn) {
|
|
112
|
-
// 更新子列信息
|
|
113
|
-
column.fixed = parentColumn.fixed
|
|
114
|
-
} else {
|
|
115
|
-
if (allowSort) {
|
|
116
|
-
const sortIndex = index + 1
|
|
117
|
-
column.renderSortNumber = sortIndex
|
|
118
|
-
}
|
|
119
|
-
if (allowFixed) {
|
|
120
|
-
column.fixed = column.renderFixed
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (allowResizable) {
|
|
124
|
-
if (column.renderVisible && (!column.children || !column.children.length)) {
|
|
125
|
-
if (column.renderResizeWidth !== column.renderWidth) {
|
|
126
|
-
column.resizeWidth = column.renderResizeWidth
|
|
127
|
-
column.renderWidth = column.renderResizeWidth
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (allowVisible) {
|
|
132
|
-
column.visible = column.renderVisible
|
|
133
|
-
}
|
|
134
|
-
if (allowGroup && allowValues) {
|
|
135
|
-
column.aggFunc = column.renderAggFn
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
reactData.isCustomStatus = true
|
|
139
|
-
if (allowGroup && !!$xeTable.handlePivotTableAggregateData) {
|
|
140
|
-
if (rowGroupList.length !== aggHandleFields.length || rowGroupList.some((conf, i) => conf.field !== aggHandleFields[i])) {
|
|
141
|
-
// 更新数据分组
|
|
142
|
-
if (aggHandleFields.length) {
|
|
143
|
-
$xeTable.setRowGroups(aggHandleFields)
|
|
144
|
-
} else {
|
|
145
|
-
$xeTable.clearRowGroups()
|
|
146
|
-
}
|
|
147
|
-
} else if (allowValues) {
|
|
148
|
-
// 更新聚合函数
|
|
149
|
-
$xeTable.handleUpdateAggData()
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (allowSort) {
|
|
153
|
-
internalData.collectColumn = customColumnList
|
|
154
|
-
}
|
|
155
|
-
return $xeTable.saveCustomStore('confirm')
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const cancelCustom = () => {
|
|
159
|
-
const { customColumnList, customStore } = reactData
|
|
160
|
-
const { oldSortMaps, oldFixedMaps, oldVisibleMaps } = customStore
|
|
161
|
-
const customOpts = computeCustomOpts.value
|
|
162
|
-
const { allowVisible, allowSort, allowFixed, allowResizable } = customOpts
|
|
163
|
-
XEUtils.eachTree(customColumnList, column => {
|
|
164
|
-
const colid = column.getKey()
|
|
165
|
-
const visible = !!oldVisibleMaps[colid]
|
|
166
|
-
const fixed = oldFixedMaps[colid] || ''
|
|
167
|
-
if (allowVisible) {
|
|
168
|
-
column.renderVisible = visible
|
|
169
|
-
column.visible = visible
|
|
170
|
-
}
|
|
171
|
-
if (allowFixed) {
|
|
172
|
-
column.renderFixed = fixed
|
|
173
|
-
column.fixed = fixed
|
|
174
|
-
}
|
|
175
|
-
if (allowSort) {
|
|
176
|
-
column.renderSortNumber = oldSortMaps[colid] || 0
|
|
177
|
-
}
|
|
178
|
-
if (allowResizable) {
|
|
179
|
-
column.renderResizeWidth = column.renderWidth
|
|
180
|
-
}
|
|
181
|
-
}, { children: 'children' })
|
|
182
|
-
return nextTick()
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const setCustomAllCheckbox = (checked: boolean) => {
|
|
186
|
-
const { customStore } = reactData
|
|
187
|
-
const { customColumnList } = reactData
|
|
188
|
-
const customOpts = computeCustomOpts.value
|
|
189
|
-
const { checkMethod, visibleMethod } = customOpts
|
|
190
|
-
const isAll = !!checked
|
|
191
|
-
if (customOpts.immediate) {
|
|
192
|
-
XEUtils.eachTree(customColumnList, (column) => {
|
|
193
|
-
if (visibleMethod && !visibleMethod({ $table: $xeTable, column })) {
|
|
194
|
-
return
|
|
195
|
-
}
|
|
196
|
-
if (checkMethod && !checkMethod({ $table: $xeTable, column })) {
|
|
197
|
-
return
|
|
198
|
-
}
|
|
199
|
-
column.visible = isAll
|
|
200
|
-
column.renderVisible = isAll
|
|
201
|
-
column.halfVisible = false
|
|
202
|
-
})
|
|
203
|
-
customStore.isAll = isAll
|
|
204
|
-
reactData.isCustomStatus = true
|
|
205
|
-
$xeTable.handleCustom()
|
|
206
|
-
$xeTable.saveCustomStore('update:visible')
|
|
207
|
-
} else {
|
|
208
|
-
XEUtils.eachTree(customColumnList, (column) => {
|
|
209
|
-
if (visibleMethod && !visibleMethod({ $table: $xeTable, column })) {
|
|
210
|
-
return
|
|
211
|
-
}
|
|
212
|
-
if (checkMethod && !checkMethod({ $table: $xeTable, column })) {
|
|
213
|
-
return
|
|
214
|
-
}
|
|
215
|
-
column.renderVisible = isAll
|
|
216
|
-
column.halfVisible = false
|
|
217
|
-
})
|
|
218
|
-
customStore.isAll = isAll
|
|
219
|
-
}
|
|
220
|
-
$xeTable.checkCustomStatus()
|
|
221
|
-
return nextTick()
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const customMethods: TableCustomMethods = {
|
|
225
|
-
getCustomVisible () {
|
|
226
|
-
const { customStore } = reactData
|
|
227
|
-
return customStore.visible
|
|
228
|
-
},
|
|
229
|
-
openCustom,
|
|
230
|
-
closeCustom,
|
|
231
|
-
toggleCustom,
|
|
232
|
-
saveCustom,
|
|
233
|
-
cancelCustom,
|
|
234
|
-
resetCustom (options) {
|
|
235
|
-
const { rowGroupList } = reactData
|
|
236
|
-
const { collectColumn } = internalData
|
|
237
|
-
const customOpts = computeCustomOpts.value
|
|
238
|
-
const { checkMethod } = customOpts
|
|
239
|
-
const opts: VxeTableDefines.VxeTableCustomStorageObj = Object.assign({
|
|
240
|
-
visible: true,
|
|
241
|
-
resizable: options === true,
|
|
242
|
-
fixed: options === true,
|
|
243
|
-
sort: options === true,
|
|
244
|
-
aggFunc: options === true
|
|
245
|
-
}, options)
|
|
246
|
-
const allCols: VxeTableDefines.ColumnInfo[] = []
|
|
247
|
-
XEUtils.eachTree(collectColumn, (column) => {
|
|
248
|
-
if (opts.resizable) {
|
|
249
|
-
column.resizeWidth = 0
|
|
250
|
-
}
|
|
251
|
-
if (opts.fixed) {
|
|
252
|
-
column.fixed = column.defaultFixed
|
|
253
|
-
}
|
|
254
|
-
if (opts.sort) {
|
|
255
|
-
column.renderSortNumber = column.sortNumber
|
|
256
|
-
column.parentId = column.defaultParentId
|
|
257
|
-
}
|
|
258
|
-
if (!checkMethod || checkMethod({ $table: $xeTable, column })) {
|
|
259
|
-
column.visible = column.defaultVisible
|
|
260
|
-
}
|
|
261
|
-
if (opts.aggFunc) {
|
|
262
|
-
column.aggFunc = column.defaultAggFunc
|
|
263
|
-
column.renderAggFn = column.defaultAggFunc
|
|
264
|
-
}
|
|
265
|
-
column.renderResizeWidth = column.renderWidth
|
|
266
|
-
allCols.push(column)
|
|
267
|
-
})
|
|
268
|
-
if (opts.sort) {
|
|
269
|
-
const newCollectCols = XEUtils.toArrayTree(XEUtils.orderBy(allCols, 'renderSortNumber'), { key: 'id', parentKey: 'parentId', children: 'children' })
|
|
270
|
-
internalData.collectColumn = newCollectCols
|
|
271
|
-
internalData.tableFullColumn = getColumnList(newCollectCols)
|
|
272
|
-
}
|
|
273
|
-
reactData.isCustomStatus = false
|
|
274
|
-
return $xeTable.handleCustom().then(() => {
|
|
275
|
-
if (opts.aggFunc && ($xeTable as any).handlePivotTableAggregateData) {
|
|
276
|
-
const rowGroupFields = computeRowGroupFields.value
|
|
277
|
-
if (rowGroupFields ? rowGroupFields.length : rowGroupList.length) {
|
|
278
|
-
if (rowGroupFields && rowGroupFields.length) {
|
|
279
|
-
$xeTable.setRowGroups(rowGroupFields)
|
|
280
|
-
} else {
|
|
281
|
-
$xeTable.clearRowGroups()
|
|
282
|
-
}
|
|
283
|
-
} else {
|
|
284
|
-
$xeTable.handleUpdateAggData()
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
$xeTable.saveCustomStore('reset')
|
|
288
|
-
})
|
|
289
|
-
},
|
|
290
|
-
toggleCustomAllCheckbox () {
|
|
291
|
-
const { customStore } = reactData
|
|
292
|
-
const isAll = !customStore.isAll
|
|
293
|
-
return setCustomAllCheckbox(isAll)
|
|
294
|
-
},
|
|
295
|
-
setCustomAllCheckbox
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const checkCustomStatus = () => {
|
|
299
|
-
const { customStore } = reactData
|
|
300
|
-
const { collectColumn } = internalData
|
|
301
|
-
const customOpts = computeCustomOpts.value
|
|
302
|
-
const { checkMethod } = customOpts
|
|
303
|
-
customStore.isAll = collectColumn.every((column) => (checkMethod ? !checkMethod({ $table: $xeTable, column }) : false) || column.renderVisible)
|
|
304
|
-
customStore.isIndeterminate = !customStore.isAll && collectColumn.some((column) => (!checkMethod || checkMethod({ $table: $xeTable, column })) && (column.renderVisible || column.halfVisible))
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
const emitCustomEvent = (type: VxeTableDefines.CustomType, evnt: Event) => {
|
|
308
|
-
$xeTable.dispatchEvent('custom', { type }, evnt)
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const customPrivateMethods: TableCustomPrivateMethods = {
|
|
312
|
-
checkCustomStatus,
|
|
313
|
-
emitCustomEvent,
|
|
314
|
-
triggerCustomEvent (evnt) {
|
|
315
|
-
const reactData = $xeTable.reactData
|
|
316
|
-
|
|
317
|
-
const { customStore } = reactData
|
|
318
|
-
if (customStore.visible) {
|
|
319
|
-
closeCustom()
|
|
320
|
-
emitCustomEvent('close', evnt)
|
|
321
|
-
} else {
|
|
322
|
-
customStore.btnEl = evnt.target as HTMLDivElement
|
|
323
|
-
openCustom()
|
|
324
|
-
emitCustomEvent('open', evnt)
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
customOpenEvent (evnt) {
|
|
328
|
-
const reactData = $xeTable.reactData
|
|
329
|
-
|
|
330
|
-
const { customStore } = reactData
|
|
331
|
-
if (!customStore.visible) {
|
|
332
|
-
customStore.activeBtn = true
|
|
333
|
-
customStore.btnEl = evnt.target as HTMLDivElement
|
|
334
|
-
$xeTable.openCustom()
|
|
335
|
-
$xeTable.emitCustomEvent('open', evnt)
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
customCloseEvent (evnt) {
|
|
339
|
-
const reactData = $xeTable.reactData
|
|
340
|
-
|
|
341
|
-
const { customStore } = reactData
|
|
342
|
-
if (customStore.visible) {
|
|
343
|
-
customStore.activeBtn = false
|
|
344
|
-
$xeTable.closeCustom()
|
|
345
|
-
$xeTable.emitCustomEvent('close', evnt)
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
handleUpdateCustomColumn
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
return { ...customMethods, ...customPrivateMethods }
|
|
352
|
-
},
|
|
353
|
-
setupGrid ($xeGrid) {
|
|
354
|
-
return $xeGrid.extendTableMethods(tableCustomMethodKeys)
|
|
355
|
-
},
|
|
356
|
-
setupGantt ($xeGantt) {
|
|
357
|
-
return $xeGantt.extendTableMethods(tableCustomMethodKeys)
|
|
358
|
-
}
|
|
359
|
-
})
|
|
1
|
+
import { nextTick } from 'vue'
|
|
2
|
+
import { VxeUI } from '../../../ui'
|
|
3
|
+
import XEUtils from 'xe-utils'
|
|
4
|
+
import { getColumnList } from '../../src/util'
|
|
5
|
+
|
|
6
|
+
import type { TableCustomMethods, TableCustomPrivateMethods, VxeColumnPropTypes, VxeTableDefines } from '../../../../types'
|
|
7
|
+
|
|
8
|
+
const tableCustomMethodKeys: (keyof TableCustomMethods)[] = ['openCustom', 'closeCustom', 'getCustomVisible', 'toggleCustom', 'saveCustom', 'cancelCustom', 'resetCustom', 'toggleCustomAllCheckbox', 'setCustomAllCheckbox']
|
|
9
|
+
|
|
10
|
+
VxeUI.hooks.add('tableCustomModule', {
|
|
11
|
+
setupTable ($xeTable) {
|
|
12
|
+
const { reactData, internalData } = $xeTable
|
|
13
|
+
const { computeCustomOpts, computeRowGroupFields, computeCustomSimpleMode } = $xeTable.getComputeMaps()
|
|
14
|
+
const { refElem } = $xeTable.getRefMaps()
|
|
15
|
+
|
|
16
|
+
const $xeGrid = $xeTable.xeGrid
|
|
17
|
+
const $xeGantt = $xeTable.xeGantt
|
|
18
|
+
const $xeGGWrapper = $xeGrid || $xeGantt
|
|
19
|
+
|
|
20
|
+
const updatePopupStyle = () => {
|
|
21
|
+
const { customStore } = reactData
|
|
22
|
+
const customOpts = computeCustomOpts.value
|
|
23
|
+
const customSimpleMode = computeCustomSimpleMode.value
|
|
24
|
+
const showCustomSimpleOutside = customSimpleMode === 'outside'
|
|
25
|
+
const { popupOptions } = customOpts
|
|
26
|
+
const { maxHeight } = popupOptions || {}
|
|
27
|
+
let wrapperEl = refElem.value
|
|
28
|
+
let popupTop = 0
|
|
29
|
+
let popupMaxHeight: string | number = 0
|
|
30
|
+
if ($xeGantt) {
|
|
31
|
+
const { refGanttContainerElem } = $xeGantt.getRefMaps()
|
|
32
|
+
const ganttContainerElem = refGanttContainerElem.value
|
|
33
|
+
if (ganttContainerElem) {
|
|
34
|
+
wrapperEl = ganttContainerElem
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (showCustomSimpleOutside) {
|
|
38
|
+
if ($xeGGWrapper && wrapperEl) {
|
|
39
|
+
popupTop = wrapperEl.offsetTop
|
|
40
|
+
}
|
|
41
|
+
popupMaxHeight = XEUtils.eqNull(maxHeight) ? 360 : maxHeight
|
|
42
|
+
} else {
|
|
43
|
+
// 判断面板不能大于表格高度
|
|
44
|
+
if (wrapperEl) {
|
|
45
|
+
popupMaxHeight = wrapperEl.clientHeight - 22
|
|
46
|
+
}
|
|
47
|
+
popupMaxHeight = Math.max(88, popupMaxHeight)
|
|
48
|
+
}
|
|
49
|
+
customStore.popupTop = popupTop
|
|
50
|
+
customStore.maxHeight = XEUtils.eqNull(maxHeight) ? popupMaxHeight : maxHeight
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const openCustom = () => {
|
|
54
|
+
const { initStore, customStore } = reactData
|
|
55
|
+
customStore.visible = true
|
|
56
|
+
initStore.custom = true
|
|
57
|
+
handleUpdateCustomColumn()
|
|
58
|
+
checkCustomStatus()
|
|
59
|
+
updatePopupStyle()
|
|
60
|
+
return nextTick().then(() => updatePopupStyle())
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const handleUpdateCustomColumn = () => {
|
|
64
|
+
const { customStore } = reactData
|
|
65
|
+
const { collectColumn } = internalData
|
|
66
|
+
if (customStore.visible) {
|
|
67
|
+
const sortMaps: Record<string, number> = {}
|
|
68
|
+
const fixedMaps: Record<string, VxeColumnPropTypes.Fixed> = {}
|
|
69
|
+
const visibleMaps: Record<string, boolean> = {}
|
|
70
|
+
XEUtils.eachTree(collectColumn, column => {
|
|
71
|
+
const colid = column.getKey()
|
|
72
|
+
column.renderFixed = column.fixed
|
|
73
|
+
column.renderVisible = column.visible
|
|
74
|
+
column.renderResizeWidth = column.renderWidth
|
|
75
|
+
sortMaps[colid] = column.renderSortNumber
|
|
76
|
+
fixedMaps[colid] = column.fixed
|
|
77
|
+
visibleMaps[colid] = column.visible
|
|
78
|
+
})
|
|
79
|
+
customStore.oldSortMaps = sortMaps
|
|
80
|
+
customStore.oldFixedMaps = fixedMaps
|
|
81
|
+
customStore.oldVisibleMaps = visibleMaps
|
|
82
|
+
reactData.customColumnList = collectColumn.slice(0)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const closeCustom = () => {
|
|
87
|
+
const { customStore } = reactData
|
|
88
|
+
const customOpts = computeCustomOpts.value
|
|
89
|
+
if (customStore.visible) {
|
|
90
|
+
customStore.visible = false
|
|
91
|
+
if (!customOpts.immediate) {
|
|
92
|
+
$xeTable.handleCustom()
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return nextTick()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const toggleCustom = () => {
|
|
99
|
+
const { customStore } = reactData
|
|
100
|
+
if (customStore.visible) {
|
|
101
|
+
return closeCustom()
|
|
102
|
+
}
|
|
103
|
+
return openCustom()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const saveCustom = () => {
|
|
107
|
+
const { customColumnList, aggHandleFields, rowGroupList } = reactData
|
|
108
|
+
const customOpts = computeCustomOpts.value
|
|
109
|
+
const { allowVisible, allowSort, allowFixed, allowResizable, allowGroup, allowValues } = customOpts
|
|
110
|
+
XEUtils.eachTree(customColumnList, (column, index, items, path, parentColumn) => {
|
|
111
|
+
if (parentColumn) {
|
|
112
|
+
// 更新子列信息
|
|
113
|
+
column.fixed = parentColumn.fixed
|
|
114
|
+
} else {
|
|
115
|
+
if (allowSort) {
|
|
116
|
+
const sortIndex = index + 1
|
|
117
|
+
column.renderSortNumber = sortIndex
|
|
118
|
+
}
|
|
119
|
+
if (allowFixed) {
|
|
120
|
+
column.fixed = column.renderFixed
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (allowResizable) {
|
|
124
|
+
if (column.renderVisible && (!column.children || !column.children.length)) {
|
|
125
|
+
if (column.renderResizeWidth !== column.renderWidth) {
|
|
126
|
+
column.resizeWidth = column.renderResizeWidth
|
|
127
|
+
column.renderWidth = column.renderResizeWidth
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (allowVisible) {
|
|
132
|
+
column.visible = column.renderVisible
|
|
133
|
+
}
|
|
134
|
+
if (allowGroup && allowValues) {
|
|
135
|
+
column.aggFunc = column.renderAggFn
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
reactData.isCustomStatus = true
|
|
139
|
+
if (allowGroup && !!$xeTable.handlePivotTableAggregateData) {
|
|
140
|
+
if (rowGroupList.length !== aggHandleFields.length || rowGroupList.some((conf, i) => conf.field !== aggHandleFields[i])) {
|
|
141
|
+
// 更新数据分组
|
|
142
|
+
if (aggHandleFields.length) {
|
|
143
|
+
$xeTable.setRowGroups(aggHandleFields)
|
|
144
|
+
} else {
|
|
145
|
+
$xeTable.clearRowGroups()
|
|
146
|
+
}
|
|
147
|
+
} else if (allowValues) {
|
|
148
|
+
// 更新聚合函数
|
|
149
|
+
$xeTable.handleUpdateAggData()
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (allowSort) {
|
|
153
|
+
internalData.collectColumn = customColumnList
|
|
154
|
+
}
|
|
155
|
+
return $xeTable.saveCustomStore('confirm')
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const cancelCustom = () => {
|
|
159
|
+
const { customColumnList, customStore } = reactData
|
|
160
|
+
const { oldSortMaps, oldFixedMaps, oldVisibleMaps } = customStore
|
|
161
|
+
const customOpts = computeCustomOpts.value
|
|
162
|
+
const { allowVisible, allowSort, allowFixed, allowResizable } = customOpts
|
|
163
|
+
XEUtils.eachTree(customColumnList, column => {
|
|
164
|
+
const colid = column.getKey()
|
|
165
|
+
const visible = !!oldVisibleMaps[colid]
|
|
166
|
+
const fixed = oldFixedMaps[colid] || ''
|
|
167
|
+
if (allowVisible) {
|
|
168
|
+
column.renderVisible = visible
|
|
169
|
+
column.visible = visible
|
|
170
|
+
}
|
|
171
|
+
if (allowFixed) {
|
|
172
|
+
column.renderFixed = fixed
|
|
173
|
+
column.fixed = fixed
|
|
174
|
+
}
|
|
175
|
+
if (allowSort) {
|
|
176
|
+
column.renderSortNumber = oldSortMaps[colid] || 0
|
|
177
|
+
}
|
|
178
|
+
if (allowResizable) {
|
|
179
|
+
column.renderResizeWidth = column.renderWidth
|
|
180
|
+
}
|
|
181
|
+
}, { children: 'children' })
|
|
182
|
+
return nextTick()
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const setCustomAllCheckbox = (checked: boolean) => {
|
|
186
|
+
const { customStore } = reactData
|
|
187
|
+
const { customColumnList } = reactData
|
|
188
|
+
const customOpts = computeCustomOpts.value
|
|
189
|
+
const { checkMethod, visibleMethod } = customOpts
|
|
190
|
+
const isAll = !!checked
|
|
191
|
+
if (customOpts.immediate) {
|
|
192
|
+
XEUtils.eachTree(customColumnList, (column) => {
|
|
193
|
+
if (visibleMethod && !visibleMethod({ $table: $xeTable, column })) {
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
if (checkMethod && !checkMethod({ $table: $xeTable, column })) {
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
column.visible = isAll
|
|
200
|
+
column.renderVisible = isAll
|
|
201
|
+
column.halfVisible = false
|
|
202
|
+
})
|
|
203
|
+
customStore.isAll = isAll
|
|
204
|
+
reactData.isCustomStatus = true
|
|
205
|
+
$xeTable.handleCustom()
|
|
206
|
+
$xeTable.saveCustomStore('update:visible')
|
|
207
|
+
} else {
|
|
208
|
+
XEUtils.eachTree(customColumnList, (column) => {
|
|
209
|
+
if (visibleMethod && !visibleMethod({ $table: $xeTable, column })) {
|
|
210
|
+
return
|
|
211
|
+
}
|
|
212
|
+
if (checkMethod && !checkMethod({ $table: $xeTable, column })) {
|
|
213
|
+
return
|
|
214
|
+
}
|
|
215
|
+
column.renderVisible = isAll
|
|
216
|
+
column.halfVisible = false
|
|
217
|
+
})
|
|
218
|
+
customStore.isAll = isAll
|
|
219
|
+
}
|
|
220
|
+
$xeTable.checkCustomStatus()
|
|
221
|
+
return nextTick()
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const customMethods: TableCustomMethods = {
|
|
225
|
+
getCustomVisible () {
|
|
226
|
+
const { customStore } = reactData
|
|
227
|
+
return customStore.visible
|
|
228
|
+
},
|
|
229
|
+
openCustom,
|
|
230
|
+
closeCustom,
|
|
231
|
+
toggleCustom,
|
|
232
|
+
saveCustom,
|
|
233
|
+
cancelCustom,
|
|
234
|
+
resetCustom (options) {
|
|
235
|
+
const { rowGroupList } = reactData
|
|
236
|
+
const { collectColumn } = internalData
|
|
237
|
+
const customOpts = computeCustomOpts.value
|
|
238
|
+
const { checkMethod } = customOpts
|
|
239
|
+
const opts: VxeTableDefines.VxeTableCustomStorageObj = Object.assign({
|
|
240
|
+
visible: true,
|
|
241
|
+
resizable: options === true,
|
|
242
|
+
fixed: options === true,
|
|
243
|
+
sort: options === true,
|
|
244
|
+
aggFunc: options === true
|
|
245
|
+
}, options)
|
|
246
|
+
const allCols: VxeTableDefines.ColumnInfo[] = []
|
|
247
|
+
XEUtils.eachTree(collectColumn, (column) => {
|
|
248
|
+
if (opts.resizable) {
|
|
249
|
+
column.resizeWidth = 0
|
|
250
|
+
}
|
|
251
|
+
if (opts.fixed) {
|
|
252
|
+
column.fixed = column.defaultFixed
|
|
253
|
+
}
|
|
254
|
+
if (opts.sort) {
|
|
255
|
+
column.renderSortNumber = column.sortNumber
|
|
256
|
+
column.parentId = column.defaultParentId
|
|
257
|
+
}
|
|
258
|
+
if (!checkMethod || checkMethod({ $table: $xeTable, column })) {
|
|
259
|
+
column.visible = column.defaultVisible
|
|
260
|
+
}
|
|
261
|
+
if (opts.aggFunc) {
|
|
262
|
+
column.aggFunc = column.defaultAggFunc
|
|
263
|
+
column.renderAggFn = column.defaultAggFunc
|
|
264
|
+
}
|
|
265
|
+
column.renderResizeWidth = column.renderWidth
|
|
266
|
+
allCols.push(column)
|
|
267
|
+
})
|
|
268
|
+
if (opts.sort) {
|
|
269
|
+
const newCollectCols = XEUtils.toArrayTree(XEUtils.orderBy(allCols, 'renderSortNumber'), { key: 'id', parentKey: 'parentId', children: 'children' })
|
|
270
|
+
internalData.collectColumn = newCollectCols
|
|
271
|
+
internalData.tableFullColumn = getColumnList(newCollectCols)
|
|
272
|
+
}
|
|
273
|
+
reactData.isCustomStatus = false
|
|
274
|
+
return $xeTable.handleCustom().then(() => {
|
|
275
|
+
if (opts.aggFunc && ($xeTable as any).handlePivotTableAggregateData) {
|
|
276
|
+
const rowGroupFields = computeRowGroupFields.value
|
|
277
|
+
if (rowGroupFields ? rowGroupFields.length : rowGroupList.length) {
|
|
278
|
+
if (rowGroupFields && rowGroupFields.length) {
|
|
279
|
+
$xeTable.setRowGroups(rowGroupFields)
|
|
280
|
+
} else {
|
|
281
|
+
$xeTable.clearRowGroups()
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
$xeTable.handleUpdateAggData()
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
$xeTable.saveCustomStore('reset')
|
|
288
|
+
})
|
|
289
|
+
},
|
|
290
|
+
toggleCustomAllCheckbox () {
|
|
291
|
+
const { customStore } = reactData
|
|
292
|
+
const isAll = !customStore.isAll
|
|
293
|
+
return setCustomAllCheckbox(isAll)
|
|
294
|
+
},
|
|
295
|
+
setCustomAllCheckbox
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const checkCustomStatus = () => {
|
|
299
|
+
const { customStore } = reactData
|
|
300
|
+
const { collectColumn } = internalData
|
|
301
|
+
const customOpts = computeCustomOpts.value
|
|
302
|
+
const { checkMethod } = customOpts
|
|
303
|
+
customStore.isAll = collectColumn.every((column) => (checkMethod ? !checkMethod({ $table: $xeTable, column }) : false) || column.renderVisible)
|
|
304
|
+
customStore.isIndeterminate = !customStore.isAll && collectColumn.some((column) => (!checkMethod || checkMethod({ $table: $xeTable, column })) && (column.renderVisible || column.halfVisible))
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const emitCustomEvent = (type: VxeTableDefines.CustomType, evnt: Event) => {
|
|
308
|
+
$xeTable.dispatchEvent('custom', { type }, evnt)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const customPrivateMethods: TableCustomPrivateMethods = {
|
|
312
|
+
checkCustomStatus,
|
|
313
|
+
emitCustomEvent,
|
|
314
|
+
triggerCustomEvent (evnt) {
|
|
315
|
+
const reactData = $xeTable.reactData
|
|
316
|
+
|
|
317
|
+
const { customStore } = reactData
|
|
318
|
+
if (customStore.visible) {
|
|
319
|
+
closeCustom()
|
|
320
|
+
emitCustomEvent('close', evnt)
|
|
321
|
+
} else {
|
|
322
|
+
customStore.btnEl = evnt.target as HTMLDivElement
|
|
323
|
+
openCustom()
|
|
324
|
+
emitCustomEvent('open', evnt)
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
customOpenEvent (evnt) {
|
|
328
|
+
const reactData = $xeTable.reactData
|
|
329
|
+
|
|
330
|
+
const { customStore } = reactData
|
|
331
|
+
if (!customStore.visible) {
|
|
332
|
+
customStore.activeBtn = true
|
|
333
|
+
customStore.btnEl = evnt.target as HTMLDivElement
|
|
334
|
+
$xeTable.openCustom()
|
|
335
|
+
$xeTable.emitCustomEvent('open', evnt)
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
customCloseEvent (evnt) {
|
|
339
|
+
const reactData = $xeTable.reactData
|
|
340
|
+
|
|
341
|
+
const { customStore } = reactData
|
|
342
|
+
if (customStore.visible) {
|
|
343
|
+
customStore.activeBtn = false
|
|
344
|
+
$xeTable.closeCustom()
|
|
345
|
+
$xeTable.emitCustomEvent('close', evnt)
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
handleUpdateCustomColumn
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return { ...customMethods, ...customPrivateMethods }
|
|
352
|
+
},
|
|
353
|
+
setupGrid ($xeGrid) {
|
|
354
|
+
return $xeGrid.extendTableMethods(tableCustomMethodKeys)
|
|
355
|
+
},
|
|
356
|
+
setupGantt ($xeGantt) {
|
|
357
|
+
return $xeGantt.extendTableMethods(tableCustomMethodKeys)
|
|
358
|
+
}
|
|
359
|
+
})
|