vxe-table 3.20.6 → 3.20.8

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