vxe-table 4.23.8 → 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.
Files changed (126) hide show
  1. package/dist/all.esm.js +5715 -3783
  2. package/es/components.d.ts +1 -0
  3. package/es/components.js +2 -7
  4. package/es/grid/src/emits.js +1 -15
  5. package/es/grid/src/grid.js +397 -120
  6. package/es/index.esm.js +1 -0
  7. package/es/index.js +1 -0
  8. package/es/table/module/custom/hook.js +49 -42
  9. package/es/table/module/custom/panel.js +777 -527
  10. package/es/table/module/edit/hook.js +140 -62
  11. package/es/table/module/export/export-panel.js +399 -316
  12. package/es/table/module/export/hook.js +395 -337
  13. package/es/table/module/export/import-panel.js +152 -123
  14. package/es/table/module/filter/hook.js +16 -2
  15. package/es/table/module/filter/panel.js +146 -84
  16. package/es/table/module/keyboard/hook.js +8 -4
  17. package/es/table/module/menu/panel.js +197 -126
  18. package/es/table/render/index.js +151 -98
  19. package/es/table/src/body.js +355 -233
  20. package/es/table/src/cell.js +426 -269
  21. package/es/table/src/columnInfo.js +1 -0
  22. package/es/table/src/footer.js +144 -99
  23. package/es/table/src/group.js +7 -3
  24. package/es/table/src/header.js +229 -172
  25. package/es/table/src/table.js +1503 -1030
  26. package/es/table/src/util.js +15 -19
  27. package/es/toolbar/src/toolbar.js +132 -75
  28. package/es/ui/index.js +1 -1
  29. package/es/ui/src/dom.js +9 -6
  30. package/es/ui/src/log.js +1 -1
  31. package/es/ui/src/utils.d.ts +1 -1
  32. package/lib/components.js +2 -7
  33. package/lib/grid/src/emits.js +1 -15
  34. package/lib/grid/src/grid.js +397 -120
  35. package/lib/index.common.js +1 -0
  36. package/lib/index.js +1 -0
  37. package/lib/index.umd.js +5732 -3800
  38. package/lib/index.umd.min.js +3 -3
  39. package/lib/table/module/custom/hook.js +49 -42
  40. package/lib/table/module/custom/panel.js +777 -527
  41. package/lib/table/module/edit/hook.js +140 -62
  42. package/lib/table/module/export/export-panel.js +399 -316
  43. package/lib/table/module/export/hook.js +395 -337
  44. package/lib/table/module/export/import-panel.js +152 -123
  45. package/lib/table/module/filter/hook.js +16 -2
  46. package/lib/table/module/filter/panel.js +146 -84
  47. package/lib/table/module/keyboard/hook.js +8 -4
  48. package/lib/table/module/menu/panel.js +197 -126
  49. package/lib/table/render/index.js +151 -98
  50. package/lib/table/src/body.js +355 -233
  51. package/lib/table/src/cell.js +426 -269
  52. package/lib/table/src/columnInfo.js +1 -0
  53. package/lib/table/src/footer.js +144 -99
  54. package/lib/table/src/group.js +7 -3
  55. package/lib/table/src/header.js +229 -172
  56. package/lib/table/src/table.js +1471 -1029
  57. package/lib/table/src/util.js +15 -19
  58. package/lib/toolbar/src/toolbar.js +132 -75
  59. package/lib/ui/index.js +1 -1
  60. package/lib/ui/src/dom.js +9 -6
  61. package/lib/ui/src/log.js +1 -1
  62. package/package.json +2 -2
  63. package/packages/colgroup/index.ts +22 -22
  64. package/packages/column/index.ts +22 -22
  65. package/packages/components.ts +41 -44
  66. package/packages/grid/index.ts +18 -18
  67. package/packages/grid/src/emits.ts +5 -19
  68. package/packages/grid/src/grid.ts +2229 -1925
  69. package/packages/grid/src/props.ts +22 -23
  70. package/packages/index.ts +11 -11
  71. package/packages/locale/lang/fr-FR.ts +15 -15
  72. package/packages/locale/lang/it-IT.ts +4 -4
  73. package/packages/locale/lang/uk-UA.ts +1 -1
  74. package/packages/locale/lang/uz-UZ.ts +13 -13
  75. package/packages/locale/lang/zh-CN.ts +907 -907
  76. package/packages/table/index.ts +26 -26
  77. package/packages/table/module/custom/hook.ts +510 -503
  78. package/packages/table/module/custom/panel.ts +2002 -1743
  79. package/packages/table/module/edit/hook.ts +1224 -1131
  80. package/packages/table/module/export/export-panel.ts +697 -611
  81. package/packages/table/module/export/hook.ts +2160 -2059
  82. package/packages/table/module/export/import-panel.ts +319 -279
  83. package/packages/table/module/export/util.ts +25 -24
  84. package/packages/table/module/filter/hook.ts +519 -501
  85. package/packages/table/module/filter/panel.ts +368 -304
  86. package/packages/table/module/keyboard/hook.ts +498 -494
  87. package/packages/table/module/menu/hook.ts +330 -330
  88. package/packages/table/module/menu/panel.ts +272 -201
  89. package/packages/table/module/validator/hook.ts +653 -635
  90. package/packages/table/render/index.ts +1819 -1744
  91. package/packages/table/src/body.ts +1078 -955
  92. package/packages/table/src/cell.ts +1524 -1359
  93. package/packages/table/src/column.ts +192 -192
  94. package/packages/table/src/columnInfo.ts +232 -232
  95. package/packages/table/src/emits.ts +134 -134
  96. package/packages/table/src/footer.ts +425 -380
  97. package/packages/table/src/group.ts +67 -63
  98. package/packages/table/src/header.ts +642 -581
  99. package/packages/table/src/props.ts +336 -336
  100. package/packages/table/src/store.ts +14 -14
  101. package/packages/table/src/table.ts +16011 -15454
  102. package/packages/table/src/use/cell-view.ts +41 -44
  103. package/packages/table/src/use/index.ts +1 -1
  104. package/packages/table/src/util.ts +1206 -1216
  105. package/packages/toolbar/index.ts +18 -18
  106. package/packages/toolbar/src/toolbar.ts +768 -706
  107. package/packages/ui/index.ts +519 -520
  108. package/packages/ui/src/anime.ts +51 -52
  109. package/packages/ui/src/comp.ts +3 -3
  110. package/packages/ui/src/dom.ts +466 -463
  111. package/packages/ui/src/log.ts +19 -19
  112. package/packages/ui/src/utils.ts +66 -66
  113. package/packages/ui/src/vn.ts +55 -55
  114. package/packages/v-x-e-table/index.d.ts +3 -3
  115. package/packages/v-x-e-table/index.ts +3 -3
  116. package/types/all.d.ts +76 -76
  117. package/types/index.d.ts +4 -4
  118. /package/dist/{iconfont.1793007753347.ttf → iconfont.1793009263429.ttf} +0 -0
  119. /package/dist/{iconfont.1793007753347.woff → iconfont.1793009263429.woff} +0 -0
  120. /package/dist/{iconfont.1793007753347.woff2 → iconfont.1793009263429.woff2} +0 -0
  121. /package/es/{iconfont.1793007753347.ttf → iconfont.1793009263429.ttf} +0 -0
  122. /package/es/{iconfont.1793007753347.woff → iconfont.1793009263429.woff} +0 -0
  123. /package/es/{iconfont.1793007753347.woff2 → iconfont.1793009263429.woff2} +0 -0
  124. /package/lib/{iconfont.1793007753347.ttf → iconfont.1793009263429.ttf} +0 -0
  125. /package/lib/{iconfont.1793007753347.woff → iconfont.1793009263429.woff} +0 -0
  126. /package/lib/{iconfont.1793007753347.woff2 → iconfont.1793009263429.woff2} +0 -0
@@ -1,1743 +1,2002 @@
1
- import { h, inject, ref, Ref, provide, VNode, PropType, nextTick, TransitionGroup, reactive, onUnmounted } from 'vue'
2
- import { defineVxeComponent } from '../../../ui/src/comp'
3
- import { VxeUI } from '@vxe-ui/core'
4
- import { formatText, hasEnableConf } from '../../../ui/src/utils'
5
- import { getTpImg, addClass, removeClass, hasControlKey } from '../../../ui/src/dom'
6
- import { createComponentLog } from '../../../ui/src/log'
7
- import XEUtils from 'xe-utils'
8
-
9
- import type { VxeButtonEvents, VxeButtonDefines } from 'vxe-pc-ui'
10
- import type { VxeTableDefines, VxeTablePrivateMethods, VxeTableConstructor, VxeTableMethods, VxeColumnPropTypes, VxeTableCustomPanelConstructor, TableCustomPanelReactData, TableCustomPanelInternalData, TableCustomPanelPrivateRef, TableCustomPanelPrivateComputed } from '../../../../types'
11
-
12
- const { errLog } = createComponentLog('table')
13
-
14
- const { getI18n, getIcon, renderEmptyElement } = VxeUI
15
-
16
- export function createInternalData (): TableCustomPanelInternalData {
17
- return {
18
- // teleportTo: undefined,
19
- // prevDragCol: undefined,
20
- // prevDragGroupField: undefined,
21
- // prevDragAggFnColid: undefined,
22
- // prevDragToChild: false,
23
- // prevDragPos: null,
24
- // customDragTime: null
25
- }
26
- }
27
-
28
- export default defineVxeComponent({
29
- name: 'TableCustomPanel',
30
- props: {
31
- customStore: {
32
- type: Object as PropType<VxeTableDefines.VxeTableCustomStoreObj>,
33
- default: () => ({} as VxeTableDefines.VxeTableCustomStoreObj)
34
- }
35
- },
36
- setup (props, context) {
37
- const xID = XEUtils.uniqueId()
38
-
39
- const VxeUIModalComponent = VxeUI.getComponent('VxeModal')
40
- const VxeUIDrawerComponent = VxeUI.getComponent('VxeDrawer')
41
- const VxeUIButtonComponent = VxeUI.getComponent('VxeButton')
42
- const VxeUINumberInputComponent = VxeUI.getComponent('VxeNumberInput')
43
- const VxeUIRadioGroupComponent = VxeUI.getComponent('VxeRadioGroup')
44
-
45
- const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods)
46
-
47
- const { props: tableProps, reactData: tableReactData, internalData: tableInternalData } = $xeTable
48
- const { computeSize, computeCustomOpts, computeMouseOpts, computeColumnDragOpts, computeColumnOpts, computeIsMaxFixedColumn, computeResizableOpts, computeAggregateOpts } = $xeTable.getComputeMaps()
49
-
50
- const refElem = ref() as Ref<HTMLDivElement>
51
- const refBodyWrapperElem = ref() as Ref<HTMLDivElement>
52
- const refCustomBodyElem = ref() as Ref<HTMLDivElement>
53
- const refDragLineElem = ref() as Ref<HTMLDivElement>
54
- const refDragTipElem = ref() as Ref<HTMLDivElement>
55
-
56
- const customPanelReactData = reactive<TableCustomPanelReactData>({
57
- dragCol: null,
58
- dragGroupField: null,
59
- dragAggFnCol: null,
60
- dragTipText: ''
61
- })
62
-
63
- let customPanelInternalData = createInternalData()
64
-
65
- const refMaps: TableCustomPanelPrivateRef = {
66
- refElem,
67
- refBodyWrapperElem,
68
- refCustomBodyElem,
69
- refDragLineElem,
70
- refDragTipElem
71
- }
72
-
73
- const computeMaps: TableCustomPanelPrivateComputed = {
74
- }
75
-
76
- const handleWrapperMouseenterEvent = (evnt: Event) => {
77
- const { customStore } = props
78
- customStore.activeWrapper = true
79
- $xeTable.customOpenEvent(evnt)
80
- }
81
-
82
- const handleWrapperMouseleaveEvent = (evnt: Event) => {
83
- const { customStore } = props
84
- customStore.activeWrapper = false
85
- setTimeout(() => {
86
- if (!customStore.activeBtn && !customStore.activeWrapper) {
87
- $xeTable.customCloseEvent(evnt)
88
- }
89
- }, 300)
90
- }
91
-
92
- const confirmCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
93
- tableReactData.isCustomStatus = true
94
- $xeTable.saveCustom()
95
- $xeTable.closeCustom()
96
- $xeTable.emitCustomEvent('confirm', $event)
97
- $xeTable.dispatchEvent('custom-confirm', {}, $event)
98
- $xeTable.emitCustomEvent('close', $event)
99
- $xeTable.dispatchEvent('custom-close', {}, $event)
100
- }
101
-
102
- const cancelCloseEvent: VxeButtonEvents.Click = ({ $event }) => {
103
- $xeTable.closeCustom()
104
- $xeTable.emitCustomEvent('close', $event)
105
- $xeTable.dispatchEvent('custom-close', {}, $event)
106
- }
107
-
108
- const cancelCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
109
- $xeTable.cancelCustom()
110
- $xeTable.closeCustom()
111
- $xeTable.emitCustomEvent('cancel', $event)
112
- $xeTable.dispatchEvent('custom-cancel', {}, $event)
113
- $xeTable.emitCustomEvent('close', $event)
114
- $xeTable.dispatchEvent('custom-close', {}, $event)
115
- }
116
-
117
- const handleResetCustomEvent = (evnt: Event) => {
118
- $xeTable.resetCustom(true)
119
- $xeTable.closeCustom()
120
- $xeTable.emitCustomEvent('reset', evnt)
121
- $xeTable.dispatchEvent('custom-reset', {}, evnt)
122
- $xeTable.emitCustomEvent('close', evnt)
123
- $xeTable.dispatchEvent('custom-close', {}, evnt)
124
- }
125
-
126
- const resetCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
127
- if (VxeUI.modal) {
128
- VxeUI.modal.confirm({
129
- content: getI18n('vxe.custom.cstmConfirmRestore'),
130
- className: 'vxe-table--ignore-clear',
131
- escClosable: true
132
- }).then(type => {
133
- if (type === 'confirm') {
134
- handleResetCustomEvent($event)
135
- }
136
- })
137
- } else {
138
- handleResetCustomEvent($event)
139
- }
140
- }
141
-
142
- const handleOptionCheck = (column: VxeTableDefines.ColumnInfo) => {
143
- const { customColumnList } = tableReactData
144
- const matchObj = XEUtils.findTree(customColumnList, item => item === column)
145
- if (matchObj && matchObj.parent) {
146
- const { parent: parentItem } = matchObj
147
- if (parentItem.children && parentItem.children.length) {
148
- parentItem.renderVisible = parentItem.children.every((column) => column.renderVisible)
149
- parentItem.halfVisible = !parentItem.renderVisible && parentItem.children.some((column) => column.renderVisible || column.halfVisible)
150
- handleOptionCheck(parentItem)
151
- }
152
- }
153
- }
154
-
155
- const changeCheckboxOption = (column: VxeTableDefines.ColumnInfo, evnt: MouseEvent) => {
156
- const isChecked = !column.renderVisible
157
- const customOpts = computeCustomOpts.value
158
- if (customOpts.immediate) {
159
- XEUtils.eachTree([column], (item) => {
160
- item.visible = isChecked
161
- item.renderVisible = isChecked
162
- item.halfVisible = false
163
- })
164
- tableReactData.isCustomStatus = true
165
- $xeTable.handleCustom()
166
- $xeTable.saveCustomStore('update:visible')
167
- } else {
168
- XEUtils.eachTree([column], (item) => {
169
- item.renderVisible = isChecked
170
- item.halfVisible = false
171
- })
172
- }
173
- handleOptionCheck(column)
174
- $xeTable.checkCustomStatus()
175
- $xeTable.dispatchEvent('custom-visible-change', { column, checked: isChecked }, evnt)
176
- }
177
-
178
- const changeColumnWidth = (column: VxeTableDefines.ColumnInfo) => {
179
- const customOpts = computeCustomOpts.value
180
- if (customOpts.immediate) {
181
- if (column.renderResizeWidth !== column.renderWidth) {
182
- column.resizeWidth = column.renderResizeWidth
183
- column.renderWidth = column.renderResizeWidth
184
- tableReactData.isCustomStatus = true
185
- $xeTable.handleCustom()
186
- $xeTable.saveCustomStore('update:width')
187
- }
188
- }
189
- }
190
-
191
- const changeFixedOption = (column: VxeTableDefines.ColumnInfo, colFixed: VxeColumnPropTypes.Fixed, evnt: Event) => {
192
- const isMaxFixedColumn = computeIsMaxFixedColumn.value
193
- const customOpts = computeCustomOpts.value
194
- let targetFixed: VxeColumnPropTypes.Fixed = null
195
- if (customOpts.immediate) {
196
- if (column.renderFixed === colFixed) {
197
- targetFixed = ''
198
- XEUtils.eachTree([column], col => {
199
- col.fixed = ''
200
- col.renderFixed = ''
201
- })
202
- } else {
203
- if (!isMaxFixedColumn || column.renderFixed) {
204
- targetFixed = colFixed
205
- XEUtils.eachTree([column], col => {
206
- col.fixed = colFixed
207
- col.renderFixed = colFixed
208
- })
209
- }
210
- }
211
- tableReactData.isCustomStatus = true
212
- $xeTable.handleCustom()
213
- $xeTable.saveCustomStore('update:fixed')
214
- } else {
215
- if (column.renderFixed === colFixed) {
216
- targetFixed = ''
217
- XEUtils.eachTree([column], col => {
218
- col.renderFixed = ''
219
- })
220
- } else {
221
- if (!isMaxFixedColumn || column.renderFixed) {
222
- targetFixed = colFixed
223
- XEUtils.eachTree([column], col => {
224
- col.renderFixed = colFixed
225
- })
226
- }
227
- }
228
- }
229
- if (targetFixed !== null) {
230
- $xeTable.dispatchEvent('custom-fixed-change', { column, fixed: targetFixed }, evnt)
231
- }
232
- }
233
-
234
- const changeAlignOption = (column: VxeTableDefines.ColumnInfo, targetAlign: VxeColumnPropTypes.Align, colProperty: 'align' | 'headerAlign' | 'footerAlign', renderProperty: 'renderAlign' | 'renderHeaderAlign' | 'renderFooterAlign', eName: 'custom-align-change' | 'custom-header-align-change' | 'custom-footer-align-change', evnt: Event) => {
235
- const customOpts = computeCustomOpts.value
236
- if (customOpts.immediate) {
237
- column[colProperty] = targetAlign
238
- column[renderProperty] = targetAlign
239
- tableReactData.isCustomStatus = true
240
- $xeTable.handleCustom()
241
- $xeTable.saveCustomStore(`update:${colProperty}`)
242
- } else {
243
- column[renderProperty] = targetAlign
244
- }
245
- $xeTable.dispatchEvent(eName, { column, [colProperty]: targetAlign }, evnt)
246
- }
247
-
248
- const allOptionEvent = (evnt: MouseEvent) => {
249
- const { customStore } = tableReactData
250
- const isAll = !customStore.isAll
251
- $xeTable.toggleCustomAllCheckbox()
252
- $xeTable.dispatchEvent('custom-visible-all', { checked: isAll }, evnt)
253
- }
254
-
255
- const showDropTip = (evnt: DragEvent | MouseEvent, optEl: HTMLElement | null, showLine: boolean, dragPos: string) => {
256
- const bodyWrapperElem = refBodyWrapperElem.value
257
- if (!bodyWrapperElem) {
258
- return
259
- }
260
- const customBodyElem = refCustomBodyElem.value
261
- if (!customBodyElem) {
262
- return
263
- }
264
- const { prevDragToChild } = customPanelInternalData
265
- const bodyWrapperRect = bodyWrapperElem.getBoundingClientRect()
266
- const customBodyRect = customBodyElem.getBoundingClientRect()
267
- const dragLineEl = refDragLineElem.value
268
- if (optEl) {
269
- if (dragLineEl) {
270
- if (showLine) {
271
- const optRect = optEl.getBoundingClientRect()
272
- dragLineEl.style.display = 'block'
273
- dragLineEl.style.left = `${Math.max(0, customBodyRect.x - bodyWrapperRect.x)}px`
274
- dragLineEl.style.top = `${Math.max(1, optRect.y + bodyWrapperElem.scrollTop - bodyWrapperRect.y)}px`
275
- dragLineEl.style.height = `${optRect.height}px`
276
- dragLineEl.style.width = `${optRect.width}px`
277
- dragLineEl.setAttribute('drag-pos', dragPos)
278
- dragLineEl.setAttribute('drag-to-child', prevDragToChild ? 'y' : 'n')
279
- } else {
280
- dragLineEl.style.display = ''
281
- }
282
- }
283
- } else {
284
- if (dragLineEl) {
285
- dragLineEl.style.display = 'node'
286
- }
287
- }
288
- const dragTipEl = refDragTipElem.value
289
- if (dragTipEl) {
290
- dragTipEl.style.display = 'block'
291
- dragTipEl.style.top = `${Math.min(bodyWrapperElem.clientHeight + bodyWrapperElem.scrollTop - dragTipEl.clientHeight, evnt.clientY + bodyWrapperElem.scrollTop - bodyWrapperRect.y)}px`
292
- dragTipEl.style.left = `${Math.min(bodyWrapperElem.clientWidth + bodyWrapperElem.scrollLeft - dragTipEl.clientWidth, evnt.clientX + bodyWrapperElem.scrollLeft - bodyWrapperRect.x)}px`
293
- dragTipEl.setAttribute('drag-status', showLine ? (prevDragToChild ? 'sub' : 'normal') : 'disabled')
294
- }
295
- }
296
-
297
- const updateColDropTipContent = () => {
298
- const { dragCol } = customPanelReactData
299
- const columnDragOpts = computeColumnDragOpts.value
300
- const { tooltipMethod } = columnDragOpts
301
- let tipContent = ''
302
- if (tooltipMethod) {
303
- const dtParams = {
304
- $table: $xeTable,
305
- column: dragCol as VxeTableDefines.ColumnInfo
306
- }
307
- tipContent = `${tooltipMethod(dtParams) || ''}`
308
- } else {
309
- tipContent = getI18n('vxe.custom.cstmDragTarget', [dragCol && dragCol.type !== 'html' ? dragCol.getTitle() : ''])
310
- }
311
- customPanelReactData.dragTipText = tipContent
312
- }
313
-
314
- const hideDropTip = () => {
315
- const dragTipEl = refDragTipElem.value
316
- const dragLineEl = refDragLineElem.value
317
- if (dragTipEl) {
318
- dragTipEl.style.display = ''
319
- }
320
- if (dragLineEl) {
321
- dragLineEl.style.display = ''
322
- }
323
- }
324
-
325
- const sortMousedownEvent = (evnt: DragEvent) => {
326
- const btnEl = evnt.currentTarget as HTMLElement
327
- const cellEl = btnEl.parentElement as HTMLElement
328
- const tdEl = cellEl.parentElement as HTMLElement
329
- const trEl = tdEl.parentElement as HTMLElement
330
- const colid = trEl.getAttribute('colid')
331
- const column = $xeTable.getColumnById(colid)
332
- trEl.draggable = true
333
- customPanelReactData.dragCol = column
334
- customPanelReactData.dragGroupField = null
335
- customPanelReactData.dragAggFnCol = null
336
- updateColDropTipContent()
337
- addClass(trEl, 'active--drag-origin')
338
- }
339
-
340
- const sortMouseupEvent = (evnt: MouseEvent) => {
341
- const btnEl = evnt.currentTarget as HTMLElement
342
- const cellEl = btnEl.parentElement as HTMLElement
343
- const tdEl = cellEl.parentElement as HTMLElement
344
- const trEl = tdEl.parentElement as HTMLElement
345
- hideDropTip()
346
- trEl.draggable = false
347
- customPanelReactData.dragCol = null
348
- customPanelReactData.dragGroupField = null
349
- customPanelReactData.dragAggFnCol = null
350
- removeClass(trEl, 'active--drag-origin')
351
- }
352
-
353
- const sortDragstartEvent = (evnt: DragEvent) => {
354
- const { customDragTime } = customPanelInternalData
355
- if (evnt.dataTransfer) {
356
- evnt.dataTransfer.setDragImage(getTpImg(), 0, 0)
357
- }
358
- if (customDragTime) {
359
- clearTimeout(customDragTime)
360
- }
361
- tableReactData.isCustomDragStatus = true
362
- customPanelInternalData.prevDragGroupField = null
363
- customPanelInternalData.prevDragAggFnColid = null
364
- }
365
-
366
- const sortDragendEvent = (evnt: DragEvent) => {
367
- const { mouseConfig } = tableProps
368
- const { customColumnList } = tableReactData
369
- const { collectColumn } = tableInternalData
370
- const customOpts = computeCustomOpts.value
371
- const mouseOpts = computeMouseOpts.value
372
- const { immediate } = customOpts
373
- const trEl = evnt.currentTarget as HTMLElement
374
- const columnDragOpts = computeColumnDragOpts.value
375
- const { isCrossDrag, isPeerDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod } = columnDragOpts
376
- const { dragCol } = customPanelReactData
377
- const { prevDragCol, prevDragGroupField, prevDragAggFnColid, prevDragPos, prevDragToChild } = customPanelInternalData
378
- const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
379
-
380
- if (prevDragGroupField || prevDragAggFnColid) {
381
- if ($xeTable.handlePivotTableAggPanelDragendEvent) {
382
- $xeTable.handlePivotTableAggPanelDragendEvent(evnt)
383
- }
384
- } else if (prevDragCol && dragCol) {
385
- // 判断是否有拖动
386
- if (prevDragCol !== dragCol) {
387
- const dragColumn = dragCol
388
- const newColumn = prevDragCol
389
- Promise.resolve(
390
- dragEndMethod
391
- ? dragEndMethod({
392
- oldColumn: dragColumn,
393
- newColumn,
394
- dragColumn,
395
- dragPos: prevDragPos as any,
396
- dragToChild: !!prevDragToChild,
397
- offsetIndex: dragOffsetIndex
398
- })
399
- : true
400
- ).then((status) => {
401
- if (!status) {
402
- return
403
- }
404
-
405
- let oafIndex = -1
406
- let nafIndex = -1
407
-
408
- const oldAllMaps: Record<string, any> = {}
409
- XEUtils.eachTree([dragColumn], column => {
410
- oldAllMaps[column.id] = column
411
- })
412
-
413
- let isSelfToChildStatus = false
414
-
415
- // 只有实时拖拽支持跨层级
416
- if (immediate) {
417
- if (dragColumn.parentId && newColumn.parentId) {
418
- // 子到子
419
-
420
- if (isPeerDrag && !isCrossDrag) {
421
- if (dragColumn.parentId !== newColumn.parentId) {
422
- // 非同级
423
- return
424
- }
425
- } else {
426
- if (!isCrossDrag) {
427
- return
428
- }
429
-
430
- if (oldAllMaps[newColumn.id]) {
431
- isSelfToChildStatus = true
432
- if (!(isCrossDrag && isSelfToChildDrag)) {
433
- if (VxeUI.modal) {
434
- VxeUI.modal.message({
435
- status: 'error',
436
- content: getI18n('vxe.error.treeDragChild')
437
- })
438
- }
439
- return
440
- }
441
- }
442
- }
443
- } else if (dragColumn.parentId) {
444
- // 子到根
445
-
446
- if (!isCrossDrag) {
447
- return
448
- }
449
- } else if (newColumn.parentId) {
450
- // 根到子
451
-
452
- if (!isCrossDrag) {
453
- return
454
- }
455
- if (oldAllMaps[newColumn.id]) {
456
- isSelfToChildStatus = true
457
- if (!(isCrossDrag && isSelfToChildDrag)) {
458
- if (VxeUI.modal) {
459
- VxeUI.modal.message({
460
- status: 'error',
461
- content: getI18n('vxe.error.treeDragChild')
462
- })
463
- }
464
- return
465
- }
466
- }
467
- } else {
468
- // 根到根
469
- }
470
-
471
- const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id)
472
-
473
- // 改变层级
474
- if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
475
- if (oldewMatchRest) {
476
- const { items: oCols, index: oIndex } = oldewMatchRest
477
- const childList = dragColumn.children || []
478
- childList.forEach(column => {
479
- column.parentId = dragColumn.parentId
480
- })
481
- oCols.splice(oIndex, 1, ...childList)
482
- dragColumn.children = []
483
- }
484
- } else {
485
- if (oldewMatchRest) {
486
- const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest
487
- oCols.splice(oIndex, 1)
488
- if (!oParent) {
489
- oafIndex = oIndex
490
- }
491
- }
492
- }
493
-
494
- const newMatchRest = XEUtils.findTree(collectColumn, item => item.id === newColumn.id)
495
- if (newMatchRest) {
496
- const { items: nCols, index: nIndex, parent: nParent } = newMatchRest
497
- // 转子级
498
- if ((isCrossDrag && isToChildDrag) && prevDragToChild) {
499
- dragColumn.parentId = newColumn.id
500
- newColumn.children = (newColumn.children || []).concat([dragColumn])
501
- } else {
502
- dragColumn.parentId = newColumn.parentId
503
- nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn)
504
- }
505
- if (!nParent) {
506
- nafIndex = nIndex
507
- }
508
- }
509
-
510
- XEUtils.eachTree(collectColumn, (column, index, items, path, parentItem) => {
511
- if (!parentItem) {
512
- const sortIndex = index + 1
513
- column.renderSortNumber = sortIndex
514
- }
515
- })
516
- } else {
517
- oafIndex = XEUtils.findIndexOf(customColumnList, item => item.id === dragColumn.id)
518
- customColumnList.splice(oafIndex, 1)
519
-
520
- nafIndex = XEUtils.findIndexOf(customColumnList, item => item.id === newColumn.id)
521
- customColumnList.splice(nafIndex + dragOffsetIndex, 0, dragColumn)
522
- }
523
-
524
- if (hasEnableConf(mouseConfig, mouseOpts)) {
525
- if ($xeTable.clearSelected) {
526
- $xeTable.clearSelected()
527
- }
528
- if ($xeTable.clearCellAreas) {
529
- $xeTable.clearCellAreas()
530
- $xeTable.clearCopyCellArea()
531
- }
532
- }
533
-
534
- const csParams = {
535
- oldColumn: dragColumn,
536
- newColumn,
537
- dragColumn,
538
- dragPos: prevDragPos,
539
- offsetIndex: dragOffsetIndex,
540
- _index: {
541
- newIndex: nafIndex,
542
- oldIndex: oafIndex
543
- }
544
- }
545
- $xeTable.dispatchEvent('custom-sort-change', csParams, evnt)
546
- $xeTable.dispatchEvent('column-dragend', csParams, evnt)
547
-
548
- if (immediate) {
549
- tableReactData.customColumnList = collectColumn.slice(0)
550
- $xeTable.handleColDragSwapColumn()
551
- }
552
- clearDragAnimateStatus()
553
- }).catch(() => {
554
- })
555
- }
556
- }
557
-
558
- hideDropTip()
559
- customPanelReactData.dragCol = null
560
- customPanelReactData.dragGroupField = null
561
- customPanelReactData.dragAggFnCol = null
562
- customPanelInternalData.prevDragGroupField = null
563
- customPanelInternalData.prevDragAggFnColid = null
564
- trEl.draggable = false
565
- trEl.removeAttribute('drag-pos')
566
- removeClass(trEl, 'active--drag-target')
567
- removeClass(trEl, 'active--drag-origin')
568
- }
569
-
570
- const sortDragoverEvent = (evnt: DragEvent) => {
571
- const customOpts = computeCustomOpts.value
572
- const { showSortDragButton, allowSort, immediate } = customOpts
573
- const columnDragOpts = computeColumnDragOpts.value
574
- const { isCrossDrag, isPeerDrag, isToChildDrag } = columnDragOpts
575
- const optEl = evnt.currentTarget as HTMLElement
576
- const isControlKey = hasControlKey(evnt)
577
- const colid = optEl.getAttribute('colid')
578
- const column = $xeTable.getColumnById(colid)
579
- const { dragCol } = customPanelReactData
580
- customPanelInternalData.prevDragGroupField = null
581
- customPanelInternalData.prevDragAggFnColid = null
582
- // 是否移入有效列
583
- if (column && (isCrossDrag || isPeerDrag || column.level === 1)) {
584
- evnt.preventDefault()
585
- const offsetY = evnt.clientY - optEl.getBoundingClientRect().y
586
- const dragPos = offsetY < optEl.clientHeight / 2 ? 'top' : 'bottom'
587
- if (
588
- !dragCol ||
589
- !(showSortDragButton && allowSort) ||
590
- (dragCol && dragCol.id === column.id) ||
591
- (!isCrossDrag && (isPeerDrag ? dragCol.parentId !== column.parentId : column.level > 1)) ||
592
- (!immediate && column.level > 1) ||
593
- (!isCrossDrag && (isPeerDrag ? dragCol.parentId !== column.parentId : dragCol.level > 1)) ||
594
- (!immediate && dragCol.level > 1)
595
- ) {
596
- showDropTip(evnt, optEl, false, dragPos)
597
- return
598
- }
599
- customPanelInternalData.prevDragToChild = !!((isCrossDrag && isToChildDrag) && isControlKey && immediate)
600
- customPanelInternalData.prevDragCol = column
601
- customPanelInternalData.prevDragPos = dragPos
602
- showDropTip(evnt, optEl, true, dragPos)
603
- }
604
- }
605
-
606
- const clearDragAnimateStatus = () => {
607
- customPanelInternalData.customDragTime = setTimeout(() => {
608
- tableReactData.isCustomDragStatus = false
609
- customPanelInternalData.customDragTime = undefined
610
- }, 350)
611
- }
612
-
613
- const sortMoveUpEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
614
- const { customColumnList } = tableReactData
615
- const matchObj = XEUtils.findTree(customColumnList, item => item === column)
616
- if (matchObj) {
617
- const { item, items, index } = matchObj
618
- if (index > 0) {
619
- tableReactData.isCustomDragStatus = true
620
- nextTick(() => {
621
- items.splice(index, 1)
622
- items.splice(index - 1, 0, item)
623
- clearDragAnimateStatus()
624
- })
625
- }
626
- }
627
- }
628
-
629
- const sortMoveDnEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
630
- const { customColumnList } = tableReactData
631
- const matchObj = XEUtils.findTree(customColumnList, item => item === column)
632
- if (matchObj) {
633
- const { item, items, index } = matchObj
634
- if (index < items.length - 1) {
635
- tableReactData.isCustomDragStatus = true
636
- nextTick(() => {
637
- items.splice(index, 1)
638
- items.splice(index + 1, 0, item)
639
- clearDragAnimateStatus()
640
- })
641
- }
642
- }
643
- }
644
-
645
- const sortMoveTopEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
646
- const { customColumnList } = tableReactData
647
- const matchObj = XEUtils.findTree(customColumnList, item => item === column)
648
- if (matchObj) {
649
- const { item, items, index, parent: parentItem } = matchObj
650
- if (parentItem || index > 0) {
651
- tableReactData.isCustomDragStatus = true
652
- nextTick(() => {
653
- item.parentId = null
654
- items.splice(index, 1)
655
- customColumnList.unshift(item)
656
- clearDragAnimateStatus()
657
- })
658
- }
659
- }
660
- }
661
-
662
- const sortMoveBottomEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
663
- const { customColumnList } = tableReactData
664
- const matchObj = XEUtils.findTree(customColumnList, item => item === column)
665
- if (matchObj) {
666
- const { item, items, index, parent: parentItem } = matchObj
667
- if (parentItem || index < items.length - 1) {
668
- tableReactData.isCustomDragStatus = true
669
- nextTick(() => {
670
- item.parentId = null
671
- items.splice(index, 1)
672
- customColumnList.push(item)
673
- clearDragAnimateStatus()
674
- })
675
- }
676
- }
677
- }
678
-
679
- const renderDragTip = () => {
680
- const { dragTipText } = customPanelReactData
681
- const columnDragOpts = computeColumnDragOpts.value
682
- return h('div', {}, [
683
- h('div', {
684
- ref: refDragLineElem,
685
- class: ['vxe-table-custom-popup--drag-line', {
686
- 'is--guides': columnDragOpts.showGuidesStatus
687
- }]
688
- }),
689
- h('div', {
690
- ref: refDragTipElem,
691
- class: 'vxe-table-custom-popup--drag-tip'
692
- }, [
693
- h('div', {
694
- class: 'vxe-table-custom-popup--drag-tip-wrapper'
695
- }, [
696
- h('div', {
697
- class: 'vxe-table-custom-popup--drag-tip-status'
698
- }, [
699
- h('span', {
700
- class: ['vxe-table-custom-popup--drag-tip-normal-status', getIcon().TABLE_DRAG_STATUS_ROW]
701
- }),
702
- h('span', {
703
- class: ['vxe-table-custom-popup--drag-tip-sub-status', getIcon().TABLE_DRAG_STATUS_SUB_ROW]
704
- }),
705
- h('span', {
706
- class: ['vxe-table-custom-popup--drag-tip-group-status', getIcon().TABLE_DRAG_STATUS_AGG_GROUP]
707
- }),
708
- h('span', {
709
- class: ['vxe-table-custom-popup--drag-tip-values-status', getIcon().TABLE_DRAG_STATUS_AGG_VALUES]
710
- }),
711
- h('span', {
712
- class: ['vxe-table-custom-popup--drag-tip-disabled-status', getIcon().TABLE_DRAG_DISABLED]
713
- })
714
- ]),
715
- h('div', {
716
- class: 'vxe-table-custom-popup--drag-tip-content'
717
- }, `${dragTipText || ''}`)
718
- ])
719
- ])
720
- ])
721
- }
722
-
723
- const renderSimplePanel = () => {
724
- const $xeGrid = $xeTable.xeGrid
725
- const $xeGantt = $xeTable.xeGantt
726
- const tableProps = $xeTable.props
727
-
728
- const { customStore } = props
729
- const { treeConfig, rowGroupConfig, aggregateConfig } = tableProps
730
- const { isCustomStatus, customColumnList, isCustomDragStatus } = tableReactData
731
- const customOpts = computeCustomOpts.value
732
- const columnDragOpts = computeColumnDragOpts.value
733
- const { defPopupStyle } = customStore
734
- const { immediate, checkMethod, visibleMethod, allowVisible, allowSort, allowFixed, allowGroup, allowValues, trigger, placement, showSortDragButton, showSortMoveButton, showSortPutButton } = customOpts
735
- const isMaxFixedColumn = computeIsMaxFixedColumn.value
736
- const vSize = computeSize.value
737
- const { isCrossDrag, isPeerDrag } = columnDragOpts
738
- const slots = customOpts.slots || {}
739
- const headerSlot = slots.header
740
- const topSlot = slots.top
741
- const bottomSlot = slots.bottom
742
- const defaultSlot = slots.default
743
- const footerSlot = slots.footer
744
- const colVNs: VNode[] = []
745
- const customWrapperOns: any = {}
746
- const isAllChecked = customStore.isAll
747
- const isAllIndeterminate = customStore.isIndeterminate
748
- // hover 触发
749
- if (trigger === 'hover') {
750
- customWrapperOns.onMouseenter = handleWrapperMouseenterEvent
751
- customWrapperOns.onMouseleave = handleWrapperMouseleaveEvent
752
- }
753
- const params = {
754
- $table: $xeTable,
755
- $grid: $xeGrid,
756
- $gantt: $xeGantt,
757
- columns: customColumnList,
758
- isAllChecked,
759
- isAllIndeterminate,
760
- isCustomStatus
761
- }
762
- XEUtils.eachTree(customColumnList, (column, index, items, path, parentItem) => {
763
- const isVisible = visibleMethod ? visibleMethod({ $table: $xeTable, column }) : true
764
- if (isVisible) {
765
- const isChecked = column.renderVisible
766
- const isIndeterminate = column.halfVisible
767
- const isColGroup = column.children && column.children.length
768
- const colTitle = formatText(column.getTitle(), 1)
769
- const isDisabled = checkMethod ? !checkMethod({ $table: $xeTable, column }) : false
770
- const isHidden = !isChecked
771
- const showSortBtn = (isCrossDrag || isPeerDrag ? immediate : false) || column.level === 1
772
- colVNs.push(
773
- h('li', {
774
- key: column.id,
775
- colid: column.id,
776
- class: ['vxe-table-custom--option', `level--${column.level}`, {
777
- 'is--hidden': isDisabled || isHidden,
778
- 'is--group': isColGroup
779
- }],
780
- onDragstart: sortDragstartEvent,
781
- onDragend: sortDragendEvent,
782
- onDragover: sortDragoverEvent
783
- }, [
784
- allowVisible
785
- ? h('div', {
786
- class: ['vxe-table-custom--checkbox-option', {
787
- 'is--checked': isChecked,
788
- 'is--indeterminate': isIndeterminate,
789
- 'is--disabled': isDisabled
790
- }],
791
- title: getI18n('vxe.custom.setting.colVisible'),
792
- onClick: (evnt: MouseEvent) => {
793
- if (!isDisabled) {
794
- changeCheckboxOption(column, evnt)
795
- }
796
- }
797
- }, [
798
- h('span', {
799
- class: ['vxe-checkbox--icon', isIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
800
- })
801
- ])
802
- : renderEmptyElement($xeTable),
803
- h('div', {
804
- class: 'vxe-table-custom--name-option'
805
- }, [
806
- (allowSort && showSortDragButton) || (allowGroup || allowValues)
807
- ? (
808
- showSortBtn || ((allowGroup || allowValues) && !isColGroup)
809
- ? h('div', {
810
- class: 'vxe-table-custom--sort-option'
811
- }, [
812
- h('span', {
813
- class: ['vxe-table-custom--sort-btn', {
814
- 'is--disabled': isHidden
815
- }],
816
- title: getI18n('vxe.custom.setting.sortHelpTip'),
817
- ...(isHidden
818
- ? {}
819
- : {
820
- onMousedown: sortMousedownEvent,
821
- onMouseup: sortMouseupEvent
822
- })
823
- }, [
824
- h('i', {
825
- class: getIcon().TABLE_CUSTOM_SORT
826
- })
827
- ])
828
- ])
829
- : renderEmptyElement($xeTable)
830
- )
831
- : renderEmptyElement($xeTable),
832
- column.type === 'html'
833
- ? h('div', {
834
- key: '1',
835
- class: 'vxe-table-custom--checkbox-label',
836
- innerHTML: colTitle
837
- })
838
- : h('div', {
839
- key: '0',
840
- class: 'vxe-table-custom--checkbox-label'
841
- }, colTitle)
842
- ]),
843
- showSortBtn && (showSortMoveButton || showSortPutButton)
844
- ? h('div', {
845
- class: 'vxe-table-custom--move-btn-option'
846
- }, VxeUIButtonComponent
847
- ? [
848
- showSortMoveButton
849
- ? h(VxeUIButtonComponent, {
850
- mode: 'text',
851
- icon: 'vxe-icon-arrows-up',
852
- title: getI18n('vxe.custom.setting.moveUpTitle'),
853
- disabled: index <= 0,
854
- onClick (evntParame) {
855
- sortMoveUpEvent(evntParame, column)
856
- }
857
- })
858
- : renderEmptyElement($xeTable),
859
- showSortMoveButton
860
- ? h(VxeUIButtonComponent, {
861
- mode: 'text',
862
- icon: 'vxe-icon-arrows-down',
863
- title: getI18n('vxe.custom.setting.moveDnTitle'),
864
- disabled: index >= items.length - 1,
865
- onClick (evntParame) {
866
- sortMoveDnEvent(evntParame, column)
867
- }
868
- })
869
- : renderEmptyElement($xeTable),
870
- showSortPutButton && !parentItem
871
- ? h(VxeUIButtonComponent, {
872
- mode: 'text',
873
- icon: 'vxe-icon-top',
874
- title: getI18n('vxe.custom.setting.putTopTitle'),
875
- disabled: index <= 0,
876
- onClick (evntParame) {
877
- sortMoveTopEvent(evntParame, column)
878
- }
879
- })
880
- : renderEmptyElement($xeTable),
881
- showSortPutButton && !parentItem
882
- ? h(VxeUIButtonComponent, {
883
- mode: 'text',
884
- icon: 'vxe-icon-bottom',
885
- title: getI18n('vxe.custom.setting.putBottomTitle'),
886
- disabled: index >= items.length - 1,
887
- onClick (evntParame) {
888
- sortMoveBottomEvent(evntParame, column)
889
- }
890
- })
891
- : renderEmptyElement($xeTable)
892
- ]
893
- : [])
894
- : renderEmptyElement($xeTable),
895
- !parentItem && allowFixed
896
- ? h('div', {
897
- class: 'vxe-table-custom--fixed-option'
898
- }, VxeUIButtonComponent
899
- ? [
900
- h(VxeUIButtonComponent, {
901
- mode: 'text',
902
- icon: column.renderFixed === 'left' ? getIcon().TOOLBAR_TOOLS_FIXED_LEFT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_LEFT,
903
- status: column.renderFixed === 'left' ? 'primary' : '',
904
- disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
905
- title: getI18n(column.renderFixed === 'left' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedLeft'),
906
- onClick: ({ $event }) => {
907
- changeFixedOption(column, 'left', $event)
908
- }
909
- }),
910
- h(VxeUIButtonComponent, {
911
- mode: 'text',
912
- icon: column.renderFixed === 'right' ? getIcon().TOOLBAR_TOOLS_FIXED_RIGHT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_RIGHT,
913
- status: column.renderFixed === 'right' ? 'primary' : '',
914
- disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
915
- title: getI18n(column.renderFixed === 'right' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedRight'),
916
- onClick: ({ $event }) => {
917
- changeFixedOption(column, 'right', $event)
918
- }
919
- })
920
- ]
921
- : [])
922
- : renderEmptyElement($xeTable)
923
- ])
924
- )
925
- }
926
- })
927
- return h('div', {
928
- ref: refElem,
929
- key: 'simple',
930
- class: ['vxe-table-custom-wrapper', `placement--${placement}`, {
931
- [`size--${vSize}`]: vSize,
932
- 'is--active': customStore.visible
933
- }],
934
- style: defPopupStyle
935
- }, customStore.visible
936
- ? [
937
- h('div', {
938
- ref: refBodyWrapperElem,
939
- class: 'vxe-table-custom-simple--body-wrapper'
940
- }, [
941
- !treeConfig && (aggregateConfig || rowGroupConfig) && $xeTable.getPivotTableAggregateSimplePanel
942
- ? h($xeTable.getPivotTableAggregateSimplePanel(), {
943
- customStore
944
- })
945
- : renderEmptyElement($xeTable),
946
- h('div', {
947
- ref: refCustomBodyElem,
948
- class: 'vxe-table-custom--handle-wrapper'
949
- }, [
950
- h('div', {
951
- class: 'vxe-table-custom--header'
952
- }, headerSlot
953
- ? $xeTable.callSlot(headerSlot, params)
954
- : [
955
- h('ul', {
956
- class: 'vxe-table-custom--panel-list'
957
- }, [
958
- h('li', {
959
- class: 'vxe-table-custom--option'
960
- }, [
961
- allowVisible
962
- ? h('div', {
963
- class: ['vxe-table-custom--checkbox-option', {
964
- 'is--checked': isAllChecked,
965
- 'is--indeterminate': isAllIndeterminate
966
- }],
967
- title: getI18n('vxe.table.allTitle'),
968
- onClick: allOptionEvent
969
- }, [
970
- h('span', {
971
- class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
972
- }),
973
- h('span', {
974
- class: 'vxe-checkbox--label'
975
- }, getI18n('vxe.toolbar.customAll'))
976
- ])
977
- : h('span', {
978
- class: 'vxe-checkbox--label'
979
- }, getI18n('vxe.table.customTitle'))
980
- ])
981
- ])
982
- ]),
983
- h('div', {
984
- class: 'vxe-table-custom--body'
985
- }, [
986
- topSlot
987
- ? h('div', {
988
- class: 'vxe-table-custom--panel-top'
989
- }, $xeTable.callSlot(topSlot, params))
990
- : renderEmptyElement($xeTable),
991
- defaultSlot
992
- ? h('div', {
993
- class: 'vxe-table-custom--panel-body'
994
- }, $xeTable.callSlot(defaultSlot, params))
995
- : h(TransitionGroup, {
996
- class: 'vxe-table-custom--panel-list',
997
- name: isCustomDragStatus ? 'vxe-table-custom--list' : '',
998
- tag: 'ul',
999
- ...customWrapperOns
1000
- }, {
1001
- default: () => colVNs
1002
- }),
1003
- bottomSlot
1004
- ? h('div', {
1005
- class: 'vxe-table-custom--panel-bottom'
1006
- }, $xeTable.callSlot(bottomSlot, params))
1007
- : renderEmptyElement($xeTable)
1008
- ]),
1009
- customOpts.showFooter
1010
- ? h('div', {
1011
- class: 'vxe-table-custom--footer'
1012
- }, footerSlot
1013
- ? $xeTable.callSlot(footerSlot, params)
1014
- : [
1015
- h('div', {
1016
- class: 'vxe-table-custom--footer-buttons'
1017
- }, [
1018
- VxeUIButtonComponent
1019
- ? h(VxeUIButtonComponent, {
1020
- mode: 'text',
1021
- content: customOpts.resetButtonText || getI18n('vxe.table.customRestore'),
1022
- disabled: !isCustomStatus,
1023
- onClick: resetCustomEvent
1024
- })
1025
- : renderEmptyElement($xeTable),
1026
- immediate
1027
- ? (VxeUIButtonComponent
1028
- ? h(VxeUIButtonComponent, {
1029
- mode: 'text',
1030
- content: customOpts.closeButtonText || getI18n('vxe.table.customClose'),
1031
- onClick: cancelCloseEvent
1032
- })
1033
- : renderEmptyElement($xeTable))
1034
- : (VxeUIButtonComponent
1035
- ? h(VxeUIButtonComponent, {
1036
- mode: 'text',
1037
- content: customOpts.cancelButtonText || getI18n('vxe.table.customCancel'),
1038
- onClick: cancelCustomEvent
1039
- })
1040
- : renderEmptyElement($xeTable)),
1041
- immediate
1042
- ? renderEmptyElement($xeTable)
1043
- : (VxeUIButtonComponent
1044
- ? h(VxeUIButtonComponent, {
1045
- mode: 'text',
1046
- status: 'primary',
1047
- content: customOpts.confirmButtonText || getI18n('vxe.table.customConfirm'),
1048
- onClick: confirmCustomEvent
1049
- })
1050
- : renderEmptyElement($xeTable))
1051
- ])
1052
- ])
1053
- : null
1054
- ]),
1055
- renderDragTip()
1056
- ])
1057
- ]
1058
- : [])
1059
- }
1060
-
1061
- const renderPopupBodys = () => {
1062
- const { resizable: allResizable } = tableProps
1063
- const { customColumnList } = tableReactData
1064
- const customOpts = computeCustomOpts.value
1065
- const columnDragOpts = computeColumnDragOpts.value
1066
- const { immediate, showSortDragButton, showSortMoveButton, showSortPutButton, allowVisible, allowSort, allowFixed, allowAlign, allowHeaderAlign, allowFooterAlign, allowResizable, allowGroup, allowValues, checkMethod, visibleMethod } = customOpts
1067
- const columnOpts = computeColumnOpts.value
1068
- const resizableOpts = computeResizableOpts.value
1069
- const { minWidth: reMinWidth, maxWidth: reMaxWidth } = resizableOpts
1070
- const isMaxFixedColumn = computeIsMaxFixedColumn.value
1071
- const { isCrossDrag, isPeerDrag } = columnDragOpts
1072
-
1073
- const trVNs: VNode[] = []
1074
- XEUtils.eachTree(customColumnList, (column, index, items, path, parentItem) => {
1075
- const isVisible = visibleMethod ? visibleMethod({ $table: $xeTable, column }) : true
1076
- if (isVisible) {
1077
- // 默认继承调整宽度
1078
- let customMinWidth = 0
1079
- let customMaxWidth = 0
1080
- if (allowResizable) {
1081
- const resizeParams = {
1082
- $table: $xeTable,
1083
- column,
1084
- columnIndex: $xeTable.getColumnIndex(column),
1085
- $columnIndex: $xeTable.getVMColumnIndex(column),
1086
- _columnIndex: $xeTable.getVTColumnIndex(column),
1087
- rowIndex: -1,
1088
- _rowIndex: -1,
1089
- $rowIndex: -1
1090
- }
1091
- if (reMinWidth) {
1092
- customMinWidth = XEUtils.toNumber(XEUtils.isFunction(reMinWidth) ? reMinWidth(resizeParams) : reMinWidth)
1093
- }
1094
- if (reMaxWidth) {
1095
- customMaxWidth = XEUtils.toNumber(XEUtils.isFunction(reMaxWidth) ? reMaxWidth(resizeParams) : reMaxWidth)
1096
- }
1097
- }
1098
-
1099
- const isChecked = column.renderVisible
1100
- const isIndeterminate = column.halfVisible
1101
- const colTitle = formatText(column.getTitle(), 1)
1102
- const isColGroup = column.children && column.children.length
1103
- const isDisabled = checkMethod ? !checkMethod({ $table: $xeTable, column }) : false
1104
- const isHidden = !isChecked
1105
- const showSortBtn = (isCrossDrag || isPeerDrag ? immediate : false) || column.level === 1
1106
-
1107
- const alignList = [
1108
- { icon: getIcon().TABLE_CUSTOM_ALIGN_LEFT, value: 'left', title: getI18n('vxe.custom.setting.anLeftTitle'), disabled: isHidden },
1109
- { icon: getIcon().TABLE_CUSTOM_ALIGN_CENTER, value: 'center', title: getI18n('vxe.custom.setting.anCenterTitle'), disabled: isHidden },
1110
- { icon: getIcon().TABLE_CUSTOM_ALIGN_RIGHT, value: 'right', title: getI18n('vxe.custom.setting.anRightTitle'), disabled: isHidden }
1111
- ]
1112
-
1113
- const tdVNs: VNode[] = []
1114
- if (allowVisible) {
1115
- tdVNs.push(
1116
- h('td', {
1117
- key: 'av',
1118
- class: 'vxe-table-custom-popup--column-td col--visible'
1119
- }, [
1120
- h('div', {
1121
- class: ['vxe-table-custom--checkbox-option', {
1122
- 'is--checked': isChecked,
1123
- 'is--indeterminate': isIndeterminate,
1124
- 'is--disabled': isDisabled
1125
- }],
1126
- title: getI18n('vxe.custom.setting.colVisible'),
1127
- onClick: (evnt: MouseEvent) => {
1128
- if (!isDisabled) {
1129
- changeCheckboxOption(column, evnt)
1130
- }
1131
- }
1132
- }, [
1133
- h('span', {
1134
- class: ['vxe-checkbox--icon', isIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
1135
- })
1136
- ])
1137
- ])
1138
- )
1139
- }
1140
- tdVNs.push(
1141
- h('td', {
1142
- key: 'at',
1143
- class: 'vxe-table-custom-popup--column-td col--name'
1144
- }, [
1145
- h('div', {
1146
- class: 'vxe-table-custom-popup--name'
1147
- }, [
1148
- (allowSort && showSortDragButton) || (allowGroup || allowValues)
1149
- ? (
1150
- showSortBtn || ((allowGroup || allowValues) && !isColGroup)
1151
- ? h('div', {
1152
- class: ['vxe-table-custom-popup--column-sort-btn', {
1153
- 'is--disabled': isHidden
1154
- }],
1155
- title: getI18n('vxe.custom.setting.sortHelpTip'),
1156
- ...(isHidden
1157
- ? {}
1158
- : {
1159
- onMousedown: sortMousedownEvent,
1160
- onMouseup: sortMouseupEvent
1161
- })
1162
- }, [
1163
- h('i', {
1164
- class: getIcon().TABLE_CUSTOM_SORT
1165
- })
1166
- ])
1167
- : h('div', {
1168
- class: 'vxe-table-custom-popup--column-sort-placeholder'
1169
- })
1170
- )
1171
- : renderEmptyElement($xeTable),
1172
- column.type === 'html'
1173
- ? h('div', {
1174
- key: '1',
1175
- class: 'vxe-table-custom-popup--title',
1176
- innerHTML: colTitle
1177
- })
1178
- : h('div', {
1179
- key: '0',
1180
- class: 'vxe-table-custom-popup--title',
1181
- title: colTitle
1182
- }, colTitle),
1183
- showSortBtn && (showSortMoveButton || showSortPutButton)
1184
- ? h('div', {
1185
- class: 'vxe-table-custom-popup--move-btn'
1186
- }, VxeUIButtonComponent
1187
- ? [
1188
- showSortMoveButton
1189
- ? h(VxeUIButtonComponent, {
1190
- mode: 'text',
1191
- icon: 'vxe-icon-arrows-up',
1192
- title: getI18n('vxe.custom.setting.moveUpTitle'),
1193
- disabled: index <= 0,
1194
- onClick (evntParame) {
1195
- sortMoveUpEvent(evntParame, column)
1196
- }
1197
- })
1198
- : renderEmptyElement($xeTable),
1199
- showSortMoveButton
1200
- ? h(VxeUIButtonComponent, {
1201
- mode: 'text',
1202
- icon: 'vxe-icon-arrows-down',
1203
- title: getI18n('vxe.custom.setting.moveDnTitle'),
1204
- disabled: index >= items.length - 1,
1205
- onClick (evntParame) {
1206
- sortMoveDnEvent(evntParame, column)
1207
- }
1208
- })
1209
- : renderEmptyElement($xeTable),
1210
- showSortPutButton && !parentItem
1211
- ? h(VxeUIButtonComponent, {
1212
- mode: 'text',
1213
- icon: 'vxe-icon-top',
1214
- title: getI18n('vxe.custom.setting.putTopTitle'),
1215
- disabled: index <= 0,
1216
- onClick (evntParame) {
1217
- sortMoveTopEvent(evntParame, column)
1218
- }
1219
- })
1220
- : renderEmptyElement($xeTable),
1221
- showSortPutButton && !parentItem
1222
- ? h(VxeUIButtonComponent, {
1223
- mode: 'text',
1224
- icon: 'vxe-icon-bottom',
1225
- title: getI18n('vxe.custom.setting.putBottomTitle'),
1226
- disabled: index >= items.length - 1,
1227
- onClick (evntParame) {
1228
- sortMoveBottomEvent(evntParame, column)
1229
- }
1230
- })
1231
- : renderEmptyElement($xeTable)
1232
- ]
1233
- : [])
1234
- : renderEmptyElement($xeTable)
1235
- ])
1236
- ])
1237
- )
1238
- if (allowResizable) {
1239
- tdVNs.push(
1240
- h('td', {
1241
- key: 'aw',
1242
- class: 'vxe-table-custom-popup--column-td col--resizable'
1243
- }, [
1244
- (
1245
- (column.children && column.children.length) ||
1246
- !(XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
1247
- )
1248
- ? h('span', '-')
1249
- : (
1250
- VxeUINumberInputComponent
1251
- ? h(VxeUINumberInputComponent, {
1252
- type: 'integer',
1253
- immediate: false,
1254
- disabled: isHidden,
1255
- modelValue: column.renderResizeWidth,
1256
- min: customMinWidth || 0,
1257
- max: customMaxWidth || 9999,
1258
- 'onUpdate:modelValue' (value: any) {
1259
- const width = Math.max(0, Number(value))
1260
- column.renderResizeWidth = width
1261
- },
1262
- onChange () {
1263
- changeColumnWidth(column)
1264
- }
1265
- })
1266
- : renderEmptyElement($xeTable)
1267
- )
1268
- ])
1269
- )
1270
- }
1271
- if (allowFixed) {
1272
- tdVNs.push(
1273
- h('td', {
1274
- key: 'af',
1275
- class: 'vxe-table-custom-popup--column-td col--fixed'
1276
- }, parentItem
1277
- ? [h('span', '-')]
1278
- : (VxeUIRadioGroupComponent
1279
- ? [
1280
- h(VxeUIButtonComponent, {
1281
- icon: column.renderFixed === 'left' ? getIcon().TOOLBAR_TOOLS_FIXED_LEFT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_LEFT,
1282
- status: column.renderFixed === 'left' ? 'primary' : '',
1283
- disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
1284
- title: getI18n(column.renderFixed === 'left' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedLeft'),
1285
- onClick: ({ $event }) => {
1286
- changeFixedOption(column, 'left', $event)
1287
- }
1288
- }),
1289
- h(VxeUIButtonComponent, {
1290
- icon: column.renderFixed === 'right' ? getIcon().TOOLBAR_TOOLS_FIXED_RIGHT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_RIGHT,
1291
- status: column.renderFixed === 'right' ? 'primary' : '',
1292
- disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
1293
- title: getI18n(column.renderFixed === 'right' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedRight'),
1294
- onClick: ({ $event }) => {
1295
- changeFixedOption(column, 'right', $event)
1296
- }
1297
- })
1298
- ]
1299
- : []
1300
- )
1301
- )
1302
- )
1303
- }
1304
- if (allowAlign) {
1305
- tdVNs.push(
1306
- h('td', {
1307
- key: 'aa',
1308
- class: 'vxe-table-custom-popup--column-td col--align'
1309
- }, VxeUIRadioGroupComponent
1310
- ? [
1311
- h(VxeUIRadioGroupComponent, {
1312
- modelValue: column.renderAlign || 'left',
1313
- type: 'button',
1314
- strict: false,
1315
- disabled: isHidden,
1316
- options: alignList,
1317
- onChange ({ value, $event }) {
1318
- changeAlignOption(column, value, 'align', 'renderAlign', 'custom-align-change', $event)
1319
- }
1320
- })
1321
- ]
1322
- : []
1323
- )
1324
- )
1325
- }
1326
- if (allowHeaderAlign) {
1327
- tdVNs.push(
1328
- h('td', {
1329
- key: 'aha',
1330
- class: 'vxe-table-custom-popup--column-td col--header-align'
1331
- }, isColGroup
1332
- ? [h('span', '-')]
1333
- : (VxeUIRadioGroupComponent
1334
- ? [
1335
- h(VxeUIRadioGroupComponent, {
1336
- modelValue: column.renderHeaderAlign || 'left',
1337
- type: 'button',
1338
- strict: false,
1339
- disabled: isHidden,
1340
- options: alignList,
1341
- onChange ({ value, $event }) {
1342
- changeAlignOption(column, value, 'headerAlign', 'renderHeaderAlign', 'custom-header-align-change', $event)
1343
- }
1344
- })
1345
- ]
1346
- : []
1347
- )
1348
- )
1349
- )
1350
- }
1351
- if (allowFooterAlign) {
1352
- tdVNs.push(
1353
- h('td', {
1354
- key: 'afa',
1355
- class: 'vxe-table-custom-popup--column-td col--footer-align'
1356
- }, isColGroup
1357
- ? [h('span', '-')]
1358
- : (VxeUIRadioGroupComponent
1359
- ? [
1360
- h(VxeUIRadioGroupComponent, {
1361
- modelValue: column.renderFooterAlign || 'left',
1362
- type: 'button',
1363
- strict: false,
1364
- disabled: isHidden,
1365
- options: alignList,
1366
- onChange ({ value, $event }) {
1367
- changeAlignOption(column, value, 'footerAlign', 'renderFooterAlign', 'custom-footer-align-change', $event)
1368
- }
1369
- })
1370
- ]
1371
- : []
1372
- )
1373
- )
1374
- )
1375
- }
1376
-
1377
- trVNs.push(
1378
- h('tr', {
1379
- key: column.id,
1380
- colid: column.id,
1381
- class: [`vxe-table-custom-popup--row level--${column.level}`, {
1382
- 'is--group': isColGroup
1383
- }],
1384
- onDragstart: sortDragstartEvent,
1385
- onDragend: sortDragendEvent,
1386
- onDragover: sortDragoverEvent
1387
- }, tdVNs)
1388
- )
1389
- }
1390
- })
1391
- return trVNs
1392
- }
1393
-
1394
- const renderPopupPanel = () => {
1395
- const $xeGrid = $xeTable.xeGrid
1396
- const $xeGantt = $xeTable.xeGantt
1397
-
1398
- const { customStore } = props
1399
- const { treeConfig, rowGroupConfig, aggregateConfig } = tableProps
1400
- const { isCustomStatus, customColumnList } = tableReactData
1401
- const vSize = computeSize.value
1402
- const customOpts = computeCustomOpts.value
1403
- const aggregateOpts = computeAggregateOpts.value
1404
- const { panePopupStyle } = customStore
1405
- const { placement: aggPlacement } = aggregateOpts
1406
- const { mode, immediate, modalOptions, drawerOptions, allowVisible, allowFixed, allowAlign, allowHeaderAlign, allowFooterAlign, allowResizable } = customOpts
1407
- const columnOpts = computeColumnOpts.value
1408
- const { maxFixedSize } = columnOpts
1409
- const modalOpts = Object.assign({}, modalOptions)
1410
- const drawerOpts = Object.assign({}, drawerOptions)
1411
- const slots = customOpts.slots || {}
1412
- const headerSlot = slots.header
1413
- const topSlot = slots.top
1414
- const bottomSlot = slots.bottom
1415
- const defaultSlot = slots.default
1416
- const footerSlot = slots.footer
1417
- const isAllChecked = customStore.isAll
1418
- const isAllIndeterminate = customStore.isIndeterminate
1419
- const isAggRtBmLayout = aggPlacement === 'right' || aggPlacement === 'bottom'
1420
- const params = {
1421
- $table: $xeTable,
1422
- $grid: $xeGrid,
1423
- $gantt: $xeGantt,
1424
- columns: customColumnList,
1425
- isAllChecked,
1426
- isAllIndeterminate,
1427
- isCustomStatus
1428
- }
1429
-
1430
- const colVNs: VNode[] = []
1431
- const headVNs: VNode[] = []
1432
- if (allowVisible) {
1433
- colVNs.push(
1434
- h('col', {
1435
- key: 'av',
1436
- class: 'vxe-table-custom-popup--column-col col--checkbox'
1437
- })
1438
- )
1439
- headVNs.push(
1440
- h('th', {
1441
- key: 'av',
1442
- class: 'vxe-table-custom-popup--column-th col--checkbox'
1443
- }, [
1444
- h('div', {
1445
- class: ['vxe-table-custom--checkbox-option', {
1446
- 'is--checked': isAllChecked,
1447
- 'is--indeterminate': isAllIndeterminate
1448
- }],
1449
- title: getI18n('vxe.table.allTitle'),
1450
- onClick: allOptionEvent
1451
- }, [
1452
- h('span', {
1453
- class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
1454
- })
1455
- // h('span', {
1456
- // class: 'vxe-checkbox--label'
1457
- // }, getI18n('vxe.toolbar.customAll'))
1458
- ])
1459
- ])
1460
- )
1461
- }
1462
- colVNs.push(
1463
- h('col', {
1464
- key: 'at',
1465
- class: 'vxe-table-custom-popup--column-col col--title'
1466
- })
1467
- )
1468
- headVNs.push(
1469
- h('th', {
1470
- key: 'at',
1471
- class: 'vxe-table-custom-popup--column-th col--title'
1472
- }, getI18n('vxe.custom.setting.colTitle'))
1473
- )
1474
- if (allowResizable) {
1475
- colVNs.push(
1476
- h('col', {
1477
- key: 'aw',
1478
- class: 'vxe-table-custom-popup--column-col col--width'
1479
- })
1480
- )
1481
- headVNs.push(
1482
- h('th', {
1483
- key: 'aw',
1484
- class: 'vxe-table-custom-popup--column-th col--width'
1485
- }, getI18n('vxe.custom.setting.colResizable'))
1486
- )
1487
- }
1488
- if (allowFixed) {
1489
- colVNs.push(
1490
- h('col', {
1491
- key: 'af',
1492
- class: 'vxe-table-custom-popup--column-col col--fixed'
1493
- })
1494
- )
1495
- headVNs.push(
1496
- h('th', {
1497
- key: 'af',
1498
- class: 'vxe-table-custom-popup--column-th col--fixed'
1499
- }, getI18n(`vxe.custom.setting.${maxFixedSize ? 'colFixedMax' : 'colFixed'}`, [maxFixedSize]))
1500
- )
1501
- }
1502
- if (allowAlign) {
1503
- colVNs.push(
1504
- h('col', {
1505
- key: 'aa',
1506
- class: 'vxe-table-custom-popup--column-col col--align'
1507
- })
1508
- )
1509
- headVNs.push(
1510
- h('th', {
1511
- key: 'aa',
1512
- class: 'vxe-table-custom-popup--column-th col--align'
1513
- }, getI18n('vxe.custom.setting.colAlign'))
1514
- )
1515
- }
1516
- if (allowHeaderAlign) {
1517
- colVNs.push(
1518
- h('col', {
1519
- key: 'aha',
1520
- class: 'vxe-table-custom-popup--column-col col--header-align'
1521
- })
1522
- )
1523
- headVNs.push(
1524
- h('th', {
1525
- key: 'aha',
1526
- class: 'vxe-table-custom-popup--column-th col--header-align'
1527
- }, getI18n('vxe.custom.setting.colHeadAlign'))
1528
- )
1529
- }
1530
- if (allowFooterAlign) {
1531
- colVNs.push(
1532
- h('col', {
1533
- key: 'afa',
1534
- class: 'vxe-table-custom-popup--column-col col--footer-align'
1535
- })
1536
- )
1537
- headVNs.push(
1538
- h('th', {
1539
- key: 'afa',
1540
- class: 'vxe-table-custom-popup--column-th col--footer-align'
1541
- }, getI18n('vxe.custom.setting.colFootAlign'))
1542
- )
1543
- }
1544
-
1545
- const scopedSlots: Record<string, any> = {
1546
- default: () => {
1547
- return h('div', {
1548
- ref: refBodyWrapperElem,
1549
- class: ['vxe-table-custom-popup--body-wrapper', `agg-layout--${aggPlacement}`, {
1550
- [`size--${vSize}`]: vSize
1551
- }],
1552
- style: panePopupStyle
1553
- }, defaultSlot
1554
- ? $xeTable.callSlot(defaultSlot, params)
1555
- : [
1556
- !isAggRtBmLayout && !treeConfig && (aggregateConfig || rowGroupConfig) && $xeTable.getPivotTableAggregatePopupPanel
1557
- ? h($xeTable.getPivotTableAggregatePopupPanel(), {
1558
- customStore
1559
- })
1560
- : renderEmptyElement($xeTable),
1561
- h('div', {
1562
- ref: refCustomBodyElem,
1563
- class: 'vxe-table-custom-popup--handle-wrapper'
1564
- }, [
1565
- topSlot
1566
- ? h('div', {
1567
- class: 'vxe-table-custom-popup--table-top'
1568
- }, $xeTable.callSlot(topSlot, params))
1569
- : renderEmptyElement($xeTable),
1570
- h('div', {
1571
- class: 'vxe-table-custom-popup--table-wrapper'
1572
- }, [
1573
- h('table', {}, [
1574
- h('colgroup', {}, colVNs),
1575
- h('thead', {}, [
1576
- h('tr', {}, headVNs)
1577
- ]),
1578
- h(TransitionGroup, {
1579
- class: 'vxe-table-custom--panel-list',
1580
- tag: 'tbody',
1581
- name: 'vxe-table-custom--list'
1582
- }, {
1583
- default: () => renderPopupBodys()
1584
- })
1585
- ])
1586
- ]),
1587
- bottomSlot
1588
- ? h('div', {
1589
- class: 'vxe-table-custom-popup--table-bottom'
1590
- }, $xeTable.callSlot(bottomSlot, params))
1591
- : renderEmptyElement($xeTable),
1592
- renderDragTip()
1593
- ]),
1594
- isAggRtBmLayout && !treeConfig && (aggregateConfig || rowGroupConfig) && $xeTable.getPivotTableAggregatePopupPanel
1595
- ? h($xeTable.getPivotTableAggregatePopupPanel(), {
1596
- customStore
1597
- })
1598
- : renderEmptyElement($xeTable)
1599
- ])
1600
- },
1601
- footer: () => {
1602
- if (footerSlot) {
1603
- return $xeTable.callSlot(footerSlot, params)
1604
- }
1605
- return h('div', {
1606
- class: 'vxe-table-custom-popup--footer'
1607
- }, [
1608
- VxeUIButtonComponent
1609
- ? h(VxeUIButtonComponent, {
1610
- content: customOpts.resetButtonText || getI18n('vxe.custom.cstmRestore'),
1611
- disabled: !isCustomStatus,
1612
- onClick: resetCustomEvent
1613
- })
1614
- : renderEmptyElement($xeTable),
1615
- immediate
1616
- ? (VxeUIButtonComponent
1617
- ? h(VxeUIButtonComponent, {
1618
- status: 'primary',
1619
- content: customOpts.closeButtonText || getI18n('vxe.table.customClose'),
1620
- onClick: cancelCloseEvent
1621
- })
1622
- : renderEmptyElement($xeTable))
1623
- : (VxeUIButtonComponent
1624
- ? h(VxeUIButtonComponent, {
1625
- content: customOpts.cancelButtonText || getI18n('vxe.table.customCancel'),
1626
- onClick: cancelCustomEvent
1627
- })
1628
- : renderEmptyElement($xeTable)),
1629
- immediate
1630
- ? renderEmptyElement($xeTable)
1631
- : (VxeUIButtonComponent
1632
- ? h(VxeUIButtonComponent, {
1633
- status: 'primary',
1634
- content: customOpts.confirmButtonText || getI18n('vxe.custom.cstmConfirm'),
1635
- onClick: confirmCustomEvent
1636
- })
1637
- : renderEmptyElement($xeTable))
1638
- ])
1639
- }
1640
- }
1641
- if (headerSlot) {
1642
- scopedSlots.header = () => $xeTable.callSlot(headerSlot, params)
1643
- }
1644
- if (mode === 'drawer') {
1645
- return VxeUIDrawerComponent
1646
- ? h(VxeUIDrawerComponent, {
1647
- key: 'drawer',
1648
- className: ['vxe-table-custom-drawer-wrapper', 'vxe-table--ignore-clear', drawerOpts.className || ''].join(' '),
1649
- modelValue: customStore.visible,
1650
- title: drawerOpts.title || getI18n('vxe.custom.cstmTitle'),
1651
- width: drawerOpts.width || Math.min(880, Math.floor(document.documentElement.clientWidth * 0.6)),
1652
- position: drawerOpts.position,
1653
- resize: !!drawerOpts.resize,
1654
- escClosable: !!drawerOpts.escClosable,
1655
- maskClosable: !!drawerOpts.maskClosable,
1656
- destroyOnClose: true,
1657
- showFooter: true,
1658
- 'onUpdate:modelValue' (value: any) {
1659
- customStore.visible = value
1660
- }
1661
- }, scopedSlots)
1662
- : renderEmptyElement($xeTable)
1663
- }
1664
- return VxeUIModalComponent
1665
- ? h(VxeUIModalComponent, {
1666
- key: 'modal',
1667
- className: ['vxe-table-custom-modal-wrapper', 'vxe-table--ignore-clear', modalOpts.className || ''].join(' '),
1668
- modelValue: customStore.visible,
1669
- title: modalOpts.title || getI18n('vxe.custom.cstmTitle'),
1670
- width: modalOpts.width || Math.min(1000, document.documentElement.clientWidth),
1671
- minWidth: modalOpts.minWidth || 800,
1672
- height: modalOpts.height || Math.min(680, document.documentElement.clientHeight),
1673
- minHeight: modalOpts.minHeight || 400,
1674
- showZoom: modalOpts.showZoom,
1675
- showMaximize: modalOpts.showMaximize,
1676
- showMinimize: modalOpts.showMinimize,
1677
- mask: modalOpts.mask,
1678
- lockView: modalOpts.lockView,
1679
- resize: modalOpts.resize,
1680
- transfer: modalOpts.transfer,
1681
- escClosable: !!modalOpts.escClosable,
1682
- maskClosable: !!modalOpts.maskClosable,
1683
- destroyOnClose: true,
1684
- showFooter: true,
1685
- 'onUpdate:modelValue' (value: any) {
1686
- customStore.visible = value
1687
- }
1688
- }, scopedSlots)
1689
- : renderEmptyElement($xeTable)
1690
- }
1691
-
1692
- const renderVN = () => {
1693
- const customOpts = computeCustomOpts.value
1694
- if (['modal', 'drawer', 'popup'].includes(`${customOpts.mode}`)) {
1695
- return renderPopupPanel()
1696
- }
1697
- return renderSimplePanel()
1698
- }
1699
-
1700
- nextTick(() => {
1701
- const customOpts = computeCustomOpts.value
1702
- const { mode } = customOpts
1703
- if (!VxeUIModalComponent && (mode === 'modal')) {
1704
- errLog('vxe.error.reqComp', ['vxe-modal'])
1705
- }
1706
- if (!VxeUIDrawerComponent && (mode === 'drawer')) {
1707
- errLog('vxe.error.reqComp', ['vxe-drawer'])
1708
- }
1709
- if (!VxeUIButtonComponent) {
1710
- errLog('vxe.error.reqComp', ['vxe-button'])
1711
- }
1712
- if (!VxeUINumberInputComponent) {
1713
- errLog('vxe.error.reqComp', ['vxe-number-input'])
1714
- }
1715
- if (!VxeUIRadioGroupComponent) {
1716
- errLog('vxe.error.reqComp', ['vxe-radio-group'])
1717
- }
1718
- })
1719
-
1720
- const $xeTableCustomPanel: VxeTableCustomPanelConstructor = {
1721
- xID,
1722
- props,
1723
- context,
1724
- reactData: customPanelReactData,
1725
- internalData: customPanelInternalData,
1726
- xeTable: $xeTable,
1727
- getRefMaps: () => refMaps,
1728
- getComputeMaps: () => computeMaps,
1729
- renderVN
1730
- }
1731
-
1732
- onUnmounted(() => {
1733
- customPanelInternalData = createInternalData()
1734
- })
1735
-
1736
- provide('$xeTableCustomPanel', $xeTableCustomPanel)
1737
-
1738
- return $xeTableCustomPanel
1739
- },
1740
- render () {
1741
- return this.renderVN()
1742
- }
1743
- })
1
+ import { h, inject, ref, Ref, provide, VNode, PropType, nextTick, TransitionGroup, reactive, onUnmounted } from 'vue'
2
+ import { defineVxeComponent } from '../../../ui/src/comp'
3
+ import { VxeUI } from '@vxe-ui/core'
4
+ import { formatText, hasEnableConf } from '../../../ui/src/utils'
5
+ import { getTpImg, addClass, removeClass, hasControlKey } from '../../../ui/src/dom'
6
+ import { createComponentLog } from '../../../ui/src/log'
7
+ import XEUtils from 'xe-utils'
8
+
9
+ import type { VxeButtonEvents, VxeButtonDefines } from 'vxe-pc-ui'
10
+ import type { VxeTableDefines, VxeTablePrivateMethods, VxeTableConstructor, VxeTableMethods, VxeColumnPropTypes, VxeTableCustomPanelConstructor, TableCustomPanelReactData, TableCustomPanelInternalData, TableCustomPanelPrivateRef, TableCustomPanelPrivateComputed } from '../../../../types'
11
+
12
+ const { errLog } = createComponentLog('table')
13
+
14
+ const { getI18n, getIcon, renderEmptyElement } = VxeUI
15
+
16
+ export function createInternalData(): TableCustomPanelInternalData {
17
+ return {
18
+ // teleportTo: undefined,
19
+ // prevDragCol: undefined,
20
+ // prevDragGroupField: undefined,
21
+ // prevDragAggFnColid: undefined,
22
+ // prevDragToChild: false,
23
+ // prevDragPos: null,
24
+ // customDragTime: null
25
+ }
26
+ }
27
+
28
+ export default defineVxeComponent({
29
+ name: 'TableCustomPanel',
30
+ props: {
31
+ customStore: {
32
+ type: Object as PropType<VxeTableDefines.VxeTableCustomStoreObj>,
33
+ default: () => ({}) as VxeTableDefines.VxeTableCustomStoreObj
34
+ }
35
+ },
36
+ setup(props, context) {
37
+ const xID = XEUtils.uniqueId()
38
+
39
+ const VxeUIModalComponent = VxeUI.getComponent('VxeModal')
40
+ const VxeUIDrawerComponent = VxeUI.getComponent('VxeDrawer')
41
+ const VxeUIButtonComponent = VxeUI.getComponent('VxeButton')
42
+ const VxeUINumberInputComponent = VxeUI.getComponent('VxeNumberInput')
43
+ const VxeUIRadioGroupComponent = VxeUI.getComponent('VxeRadioGroup')
44
+
45
+ const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods)
46
+
47
+ const { props: tableProps, reactData: tableReactData, internalData: tableInternalData } = $xeTable
48
+ const { computeSize, computeCustomOpts, computeMouseOpts, computeColumnDragOpts, computeColumnOpts, computeIsMaxFixedColumn, computeResizableOpts, computeAggregateOpts } = $xeTable.getComputeMaps()
49
+
50
+ const refElem = ref() as Ref<HTMLDivElement>
51
+ const refBodyWrapperElem = ref() as Ref<HTMLDivElement>
52
+ const refCustomBodyElem = ref() as Ref<HTMLDivElement>
53
+ const refDragLineElem = ref() as Ref<HTMLDivElement>
54
+ const refDragTipElem = ref() as Ref<HTMLDivElement>
55
+
56
+ const customPanelReactData = reactive<TableCustomPanelReactData>({
57
+ dragCol: null,
58
+ dragGroupField: null,
59
+ dragAggFnCol: null,
60
+ dragTipText: ''
61
+ })
62
+
63
+ let customPanelInternalData = createInternalData()
64
+
65
+ const refMaps: TableCustomPanelPrivateRef = {
66
+ refElem,
67
+ refBodyWrapperElem,
68
+ refCustomBodyElem,
69
+ refDragLineElem,
70
+ refDragTipElem
71
+ }
72
+
73
+ const computeMaps: TableCustomPanelPrivateComputed = {}
74
+
75
+ const handleWrapperMouseenterEvent = (evnt: Event) => {
76
+ const { customStore } = props
77
+ customStore.activeWrapper = true
78
+ $xeTable.customOpenEvent(evnt)
79
+ }
80
+
81
+ const handleWrapperMouseleaveEvent = (evnt: Event) => {
82
+ const { customStore } = props
83
+ customStore.activeWrapper = false
84
+ setTimeout(() => {
85
+ if (!customStore.activeBtn && !customStore.activeWrapper) {
86
+ $xeTable.customCloseEvent(evnt)
87
+ }
88
+ }, 300)
89
+ }
90
+
91
+ const confirmCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
92
+ tableReactData.isCustomStatus = true
93
+ $xeTable.saveCustom()
94
+ $xeTable.closeCustom()
95
+ $xeTable.emitCustomEvent('confirm', $event)
96
+ $xeTable.dispatchEvent('custom-confirm', {}, $event)
97
+ $xeTable.emitCustomEvent('close', $event)
98
+ $xeTable.dispatchEvent('custom-close', {}, $event)
99
+ }
100
+
101
+ const cancelCloseEvent: VxeButtonEvents.Click = ({ $event }) => {
102
+ $xeTable.closeCustom()
103
+ $xeTable.emitCustomEvent('close', $event)
104
+ $xeTable.dispatchEvent('custom-close', {}, $event)
105
+ }
106
+
107
+ const cancelCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
108
+ $xeTable.cancelCustom()
109
+ $xeTable.closeCustom()
110
+ $xeTable.emitCustomEvent('cancel', $event)
111
+ $xeTable.dispatchEvent('custom-cancel', {}, $event)
112
+ $xeTable.emitCustomEvent('close', $event)
113
+ $xeTable.dispatchEvent('custom-close', {}, $event)
114
+ }
115
+
116
+ const handleResetCustomEvent = (evnt: Event) => {
117
+ $xeTable.resetCustom(true)
118
+ $xeTable.closeCustom()
119
+ $xeTable.emitCustomEvent('reset', evnt)
120
+ $xeTable.dispatchEvent('custom-reset', {}, evnt)
121
+ $xeTable.emitCustomEvent('close', evnt)
122
+ $xeTable.dispatchEvent('custom-close', {}, evnt)
123
+ }
124
+
125
+ const resetCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
126
+ if (VxeUI.modal) {
127
+ VxeUI.modal
128
+ .confirm({
129
+ content: getI18n('vxe.custom.cstmConfirmRestore'),
130
+ className: 'vxe-table--ignore-clear',
131
+ escClosable: true
132
+ })
133
+ .then((type) => {
134
+ if (type === 'confirm') {
135
+ handleResetCustomEvent($event)
136
+ }
137
+ })
138
+ } else {
139
+ handleResetCustomEvent($event)
140
+ }
141
+ }
142
+
143
+ const handleOptionCheck = (column: VxeTableDefines.ColumnInfo) => {
144
+ const { customColumnList } = tableReactData
145
+ const matchObj = XEUtils.findTree(customColumnList, (item) => item === column)
146
+ if (matchObj && matchObj.parent) {
147
+ const { parent: parentItem } = matchObj
148
+ if (parentItem.children && parentItem.children.length) {
149
+ parentItem.renderVisible = parentItem.children.every((column) => column.renderVisible)
150
+ parentItem.halfVisible = !parentItem.renderVisible && parentItem.children.some((column) => column.renderVisible || column.halfVisible)
151
+ handleOptionCheck(parentItem)
152
+ }
153
+ }
154
+ }
155
+
156
+ const changeCheckboxOption = (column: VxeTableDefines.ColumnInfo, evnt: MouseEvent) => {
157
+ const isChecked = !column.renderVisible
158
+ const customOpts = computeCustomOpts.value
159
+ if (customOpts.immediate) {
160
+ XEUtils.eachTree([column], (item) => {
161
+ item.visible = isChecked
162
+ item.renderVisible = isChecked
163
+ item.halfVisible = false
164
+ })
165
+ tableReactData.isCustomStatus = true
166
+ $xeTable.handleCustom()
167
+ $xeTable.saveCustomStore('update:visible')
168
+ } else {
169
+ XEUtils.eachTree([column], (item) => {
170
+ item.renderVisible = isChecked
171
+ item.halfVisible = false
172
+ })
173
+ }
174
+ handleOptionCheck(column)
175
+ $xeTable.checkCustomStatus()
176
+ $xeTable.dispatchEvent('custom-visible-change', { column, checked: isChecked }, evnt)
177
+ }
178
+
179
+ const changeColumnWidth = (column: VxeTableDefines.ColumnInfo) => {
180
+ const customOpts = computeCustomOpts.value
181
+ if (customOpts.immediate) {
182
+ if (column.renderResizeWidth !== column.renderWidth) {
183
+ column.resizeWidth = column.renderResizeWidth
184
+ column.renderWidth = column.renderResizeWidth
185
+ tableReactData.isCustomStatus = true
186
+ $xeTable.handleCustom()
187
+ $xeTable.saveCustomStore('update:width')
188
+ }
189
+ }
190
+ }
191
+
192
+ const changeFixedOption = (column: VxeTableDefines.ColumnInfo, colFixed: VxeColumnPropTypes.Fixed, evnt: Event) => {
193
+ const isMaxFixedColumn = computeIsMaxFixedColumn.value
194
+ const customOpts = computeCustomOpts.value
195
+ let targetFixed: VxeColumnPropTypes.Fixed = null
196
+ if (customOpts.immediate) {
197
+ if (column.renderFixed === colFixed) {
198
+ targetFixed = ''
199
+ XEUtils.eachTree([column], (col) => {
200
+ col.fixed = ''
201
+ col.renderFixed = ''
202
+ })
203
+ } else {
204
+ if (!isMaxFixedColumn || column.renderFixed) {
205
+ targetFixed = colFixed
206
+ XEUtils.eachTree([column], (col) => {
207
+ col.fixed = colFixed
208
+ col.renderFixed = colFixed
209
+ })
210
+ }
211
+ }
212
+ tableReactData.isCustomStatus = true
213
+ $xeTable.handleCustom()
214
+ $xeTable.saveCustomStore('update:fixed')
215
+ } else {
216
+ if (column.renderFixed === colFixed) {
217
+ targetFixed = ''
218
+ XEUtils.eachTree([column], (col) => {
219
+ col.renderFixed = ''
220
+ })
221
+ } else {
222
+ if (!isMaxFixedColumn || column.renderFixed) {
223
+ targetFixed = colFixed
224
+ XEUtils.eachTree([column], (col) => {
225
+ col.renderFixed = colFixed
226
+ })
227
+ }
228
+ }
229
+ }
230
+ if (targetFixed !== null) {
231
+ $xeTable.dispatchEvent('custom-fixed-change', { column, fixed: targetFixed }, evnt)
232
+ }
233
+ }
234
+
235
+ const changeAlignOption = (
236
+ column: VxeTableDefines.ColumnInfo,
237
+ targetAlign: VxeColumnPropTypes.Align,
238
+ colProperty: 'align' | 'headerAlign' | 'footerAlign',
239
+ renderProperty: 'renderAlign' | 'renderHeaderAlign' | 'renderFooterAlign',
240
+ eName: 'custom-align-change' | 'custom-header-align-change' | 'custom-footer-align-change',
241
+ evnt: Event
242
+ ) => {
243
+ const customOpts = computeCustomOpts.value
244
+ if (customOpts.immediate) {
245
+ column[colProperty] = targetAlign
246
+ column[renderProperty] = targetAlign
247
+ tableReactData.isCustomStatus = true
248
+ $xeTable.handleCustom()
249
+ $xeTable.saveCustomStore(`update:${colProperty}`)
250
+ } else {
251
+ column[renderProperty] = targetAlign
252
+ }
253
+ $xeTable.dispatchEvent(eName, { column, [colProperty]: targetAlign }, evnt)
254
+ }
255
+
256
+ const allOptionEvent = (evnt: MouseEvent) => {
257
+ const { customStore } = tableReactData
258
+ const isAll = !customStore.isAll
259
+ $xeTable.toggleCustomAllCheckbox()
260
+ $xeTable.dispatchEvent('custom-visible-all', { checked: isAll }, evnt)
261
+ }
262
+
263
+ const showDropTip = (evnt: DragEvent | MouseEvent, optEl: HTMLElement | null, showLine: boolean, dragPos: string) => {
264
+ const bodyWrapperElem = refBodyWrapperElem.value
265
+ if (!bodyWrapperElem) {
266
+ return
267
+ }
268
+ const customBodyElem = refCustomBodyElem.value
269
+ if (!customBodyElem) {
270
+ return
271
+ }
272
+ const { prevDragToChild } = customPanelInternalData
273
+ const bodyWrapperRect = bodyWrapperElem.getBoundingClientRect()
274
+ const customBodyRect = customBodyElem.getBoundingClientRect()
275
+ const dragLineEl = refDragLineElem.value
276
+ if (optEl) {
277
+ if (dragLineEl) {
278
+ if (showLine) {
279
+ const optRect = optEl.getBoundingClientRect()
280
+ dragLineEl.style.display = 'block'
281
+ dragLineEl.style.left = `${Math.max(0, customBodyRect.x - bodyWrapperRect.x)}px`
282
+ dragLineEl.style.top = `${Math.max(1, optRect.y + bodyWrapperElem.scrollTop - bodyWrapperRect.y)}px`
283
+ dragLineEl.style.height = `${optRect.height}px`
284
+ dragLineEl.style.width = `${optRect.width}px`
285
+ dragLineEl.setAttribute('drag-pos', dragPos)
286
+ dragLineEl.setAttribute('drag-to-child', prevDragToChild ? 'y' : 'n')
287
+ } else {
288
+ dragLineEl.style.display = ''
289
+ }
290
+ }
291
+ } else {
292
+ if (dragLineEl) {
293
+ dragLineEl.style.display = 'node'
294
+ }
295
+ }
296
+ const dragTipEl = refDragTipElem.value
297
+ if (dragTipEl) {
298
+ dragTipEl.style.display = 'block'
299
+ dragTipEl.style.top = `${Math.min(bodyWrapperElem.clientHeight + bodyWrapperElem.scrollTop - dragTipEl.clientHeight, evnt.clientY + bodyWrapperElem.scrollTop - bodyWrapperRect.y)}px`
300
+ dragTipEl.style.left = `${Math.min(bodyWrapperElem.clientWidth + bodyWrapperElem.scrollLeft - dragTipEl.clientWidth, evnt.clientX + bodyWrapperElem.scrollLeft - bodyWrapperRect.x)}px`
301
+ dragTipEl.setAttribute('drag-status', showLine ? (prevDragToChild ? 'sub' : 'normal') : 'disabled')
302
+ }
303
+ }
304
+
305
+ const updateColDropTipContent = () => {
306
+ const { dragCol } = customPanelReactData
307
+ const columnDragOpts = computeColumnDragOpts.value
308
+ const { tooltipMethod } = columnDragOpts
309
+ let tipContent = ''
310
+ if (tooltipMethod) {
311
+ const dtParams = {
312
+ $table: $xeTable,
313
+ column: dragCol as VxeTableDefines.ColumnInfo
314
+ }
315
+ tipContent = `${tooltipMethod(dtParams) || ''}`
316
+ } else {
317
+ tipContent = getI18n('vxe.custom.cstmDragTarget', [dragCol && dragCol.type !== 'html' ? dragCol.getTitle() : ''])
318
+ }
319
+ customPanelReactData.dragTipText = tipContent
320
+ }
321
+
322
+ const hideDropTip = () => {
323
+ const dragTipEl = refDragTipElem.value
324
+ const dragLineEl = refDragLineElem.value
325
+ if (dragTipEl) {
326
+ dragTipEl.style.display = ''
327
+ }
328
+ if (dragLineEl) {
329
+ dragLineEl.style.display = ''
330
+ }
331
+ }
332
+
333
+ const sortMousedownEvent = (evnt: DragEvent) => {
334
+ const btnEl = evnt.currentTarget as HTMLElement
335
+ const cellEl = btnEl.parentElement as HTMLElement
336
+ const tdEl = cellEl.parentElement as HTMLElement
337
+ const trEl = tdEl.parentElement as HTMLElement
338
+ const colid = trEl.getAttribute('colid')
339
+ const column = $xeTable.getColumnById(colid)
340
+ trEl.draggable = true
341
+ customPanelReactData.dragCol = column
342
+ customPanelReactData.dragGroupField = null
343
+ customPanelReactData.dragAggFnCol = null
344
+ updateColDropTipContent()
345
+ addClass(trEl, 'active--drag-origin')
346
+ }
347
+
348
+ const sortMouseupEvent = (evnt: MouseEvent) => {
349
+ const btnEl = evnt.currentTarget as HTMLElement
350
+ const cellEl = btnEl.parentElement as HTMLElement
351
+ const tdEl = cellEl.parentElement as HTMLElement
352
+ const trEl = tdEl.parentElement as HTMLElement
353
+ hideDropTip()
354
+ trEl.draggable = false
355
+ customPanelReactData.dragCol = null
356
+ customPanelReactData.dragGroupField = null
357
+ customPanelReactData.dragAggFnCol = null
358
+ removeClass(trEl, 'active--drag-origin')
359
+ }
360
+
361
+ const sortDragstartEvent = (evnt: DragEvent) => {
362
+ const { customDragTime } = customPanelInternalData
363
+ if (evnt.dataTransfer) {
364
+ evnt.dataTransfer.setDragImage(getTpImg(), 0, 0)
365
+ }
366
+ if (customDragTime) {
367
+ clearTimeout(customDragTime)
368
+ }
369
+ tableReactData.isCustomDragStatus = true
370
+ customPanelInternalData.prevDragGroupField = null
371
+ customPanelInternalData.prevDragAggFnColid = null
372
+ }
373
+
374
+ const sortDragendEvent = (evnt: DragEvent) => {
375
+ const { mouseConfig } = tableProps
376
+ const { customColumnList } = tableReactData
377
+ const { collectColumn } = tableInternalData
378
+ const customOpts = computeCustomOpts.value
379
+ const mouseOpts = computeMouseOpts.value
380
+ const { immediate } = customOpts
381
+ const trEl = evnt.currentTarget as HTMLElement
382
+ const columnDragOpts = computeColumnDragOpts.value
383
+ const { isCrossDrag, isPeerDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod } = columnDragOpts
384
+ const { dragCol } = customPanelReactData
385
+ const { prevDragCol, prevDragGroupField, prevDragAggFnColid, prevDragPos, prevDragToChild } = customPanelInternalData
386
+ const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
387
+
388
+ if (prevDragGroupField || prevDragAggFnColid) {
389
+ if ($xeTable.handlePivotTableAggPanelDragendEvent) {
390
+ $xeTable.handlePivotTableAggPanelDragendEvent(evnt)
391
+ }
392
+ } else if (prevDragCol && dragCol) {
393
+ // 判断是否有拖动
394
+ if (prevDragCol !== dragCol) {
395
+ const dragColumn = dragCol
396
+ const newColumn = prevDragCol
397
+ Promise.resolve(
398
+ dragEndMethod
399
+ ? dragEndMethod({
400
+ oldColumn: dragColumn,
401
+ newColumn,
402
+ dragColumn,
403
+ dragPos: prevDragPos as any,
404
+ dragToChild: !!prevDragToChild,
405
+ offsetIndex: dragOffsetIndex
406
+ })
407
+ : true
408
+ )
409
+ .then((status) => {
410
+ if (!status) {
411
+ return
412
+ }
413
+
414
+ let oafIndex = -1
415
+ let nafIndex = -1
416
+
417
+ const oldAllMaps: Record<string, any> = {}
418
+ XEUtils.eachTree([dragColumn], (column) => {
419
+ oldAllMaps[column.id] = column
420
+ })
421
+
422
+ let isSelfToChildStatus = false
423
+
424
+ // 只有实时拖拽支持跨层级
425
+ if (immediate) {
426
+ if (dragColumn.parentId && newColumn.parentId) {
427
+ // 子到子
428
+
429
+ if (isPeerDrag && !isCrossDrag) {
430
+ if (dragColumn.parentId !== newColumn.parentId) {
431
+ // 非同级
432
+ return
433
+ }
434
+ } else {
435
+ if (!isCrossDrag) {
436
+ return
437
+ }
438
+
439
+ if (oldAllMaps[newColumn.id]) {
440
+ isSelfToChildStatus = true
441
+ if (!(isCrossDrag && isSelfToChildDrag)) {
442
+ if (VxeUI.modal) {
443
+ VxeUI.modal.message({
444
+ status: 'error',
445
+ content: getI18n('vxe.error.treeDragChild')
446
+ })
447
+ }
448
+ return
449
+ }
450
+ }
451
+ }
452
+ } else if (dragColumn.parentId) {
453
+ // 子到根
454
+
455
+ if (!isCrossDrag) {
456
+ return
457
+ }
458
+ } else if (newColumn.parentId) {
459
+ // 根到子
460
+
461
+ if (!isCrossDrag) {
462
+ return
463
+ }
464
+ if (oldAllMaps[newColumn.id]) {
465
+ isSelfToChildStatus = true
466
+ if (!(isCrossDrag && isSelfToChildDrag)) {
467
+ if (VxeUI.modal) {
468
+ VxeUI.modal.message({
469
+ status: 'error',
470
+ content: getI18n('vxe.error.treeDragChild')
471
+ })
472
+ }
473
+ return
474
+ }
475
+ }
476
+ } else {
477
+ // 根到根
478
+ }
479
+
480
+ const oldewMatchRest = XEUtils.findTree(collectColumn, (item) => item.id === dragColumn.id)
481
+
482
+ // 改变层级
483
+ if (isSelfToChildStatus && isCrossDrag && isSelfToChildDrag) {
484
+ if (oldewMatchRest) {
485
+ const { items: oCols, index: oIndex } = oldewMatchRest
486
+ const childList = dragColumn.children || []
487
+ childList.forEach((column) => {
488
+ column.parentId = dragColumn.parentId
489
+ })
490
+ oCols.splice(oIndex, 1, ...childList)
491
+ dragColumn.children = []
492
+ }
493
+ } else {
494
+ if (oldewMatchRest) {
495
+ const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest
496
+ oCols.splice(oIndex, 1)
497
+ if (!oParent) {
498
+ oafIndex = oIndex
499
+ }
500
+ }
501
+ }
502
+
503
+ const newMatchRest = XEUtils.findTree(collectColumn, (item) => item.id === newColumn.id)
504
+ if (newMatchRest) {
505
+ const { items: nCols, index: nIndex, parent: nParent } = newMatchRest
506
+ // 转子级
507
+ if (isCrossDrag && isToChildDrag && prevDragToChild) {
508
+ dragColumn.parentId = newColumn.id
509
+ newColumn.children = (newColumn.children || []).concat([dragColumn])
510
+ } else {
511
+ dragColumn.parentId = newColumn.parentId
512
+ nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn)
513
+ }
514
+ if (!nParent) {
515
+ nafIndex = nIndex
516
+ }
517
+ }
518
+
519
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentItem) => {
520
+ if (!parentItem) {
521
+ const sortIndex = index + 1
522
+ column.renderSortNumber = sortIndex
523
+ }
524
+ })
525
+ } else {
526
+ oafIndex = XEUtils.findIndexOf(customColumnList, (item) => item.id === dragColumn.id)
527
+ customColumnList.splice(oafIndex, 1)
528
+
529
+ nafIndex = XEUtils.findIndexOf(customColumnList, (item) => item.id === newColumn.id)
530
+ customColumnList.splice(nafIndex + dragOffsetIndex, 0, dragColumn)
531
+ }
532
+
533
+ if (hasEnableConf(mouseConfig, mouseOpts)) {
534
+ if ($xeTable.clearSelected) {
535
+ $xeTable.clearSelected()
536
+ }
537
+ if ($xeTable.clearCellAreas) {
538
+ $xeTable.clearCellAreas()
539
+ $xeTable.clearCopyCellArea()
540
+ }
541
+ }
542
+
543
+ const csParams = {
544
+ oldColumn: dragColumn,
545
+ newColumn,
546
+ dragColumn,
547
+ dragPos: prevDragPos,
548
+ offsetIndex: dragOffsetIndex,
549
+ _index: {
550
+ newIndex: nafIndex,
551
+ oldIndex: oafIndex
552
+ }
553
+ }
554
+ $xeTable.dispatchEvent('custom-sort-change', csParams, evnt)
555
+ $xeTable.dispatchEvent('column-dragend', csParams, evnt)
556
+
557
+ if (immediate) {
558
+ tableReactData.customColumnList = collectColumn.slice(0)
559
+ $xeTable.handleColDragSwapColumn()
560
+ }
561
+ clearDragAnimateStatus()
562
+ })
563
+ .catch(() => {})
564
+ }
565
+ }
566
+
567
+ hideDropTip()
568
+ customPanelReactData.dragCol = null
569
+ customPanelReactData.dragGroupField = null
570
+ customPanelReactData.dragAggFnCol = null
571
+ customPanelInternalData.prevDragGroupField = null
572
+ customPanelInternalData.prevDragAggFnColid = null
573
+ trEl.draggable = false
574
+ trEl.removeAttribute('drag-pos')
575
+ removeClass(trEl, 'active--drag-target')
576
+ removeClass(trEl, 'active--drag-origin')
577
+ }
578
+
579
+ const sortDragoverEvent = (evnt: DragEvent) => {
580
+ const customOpts = computeCustomOpts.value
581
+ const { showSortDragButton, allowSort, immediate } = customOpts
582
+ const columnDragOpts = computeColumnDragOpts.value
583
+ const { isCrossDrag, isPeerDrag, isToChildDrag } = columnDragOpts
584
+ const optEl = evnt.currentTarget as HTMLElement
585
+ const isControlKey = hasControlKey(evnt)
586
+ const colid = optEl.getAttribute('colid')
587
+ const column = $xeTable.getColumnById(colid)
588
+ const { dragCol } = customPanelReactData
589
+ customPanelInternalData.prevDragGroupField = null
590
+ customPanelInternalData.prevDragAggFnColid = null
591
+ // 是否移入有效列
592
+ if (column && (isCrossDrag || isPeerDrag || column.level === 1)) {
593
+ evnt.preventDefault()
594
+ const offsetY = evnt.clientY - optEl.getBoundingClientRect().y
595
+ const dragPos = offsetY < optEl.clientHeight / 2 ? 'top' : 'bottom'
596
+ if (
597
+ !dragCol ||
598
+ !(showSortDragButton && allowSort) ||
599
+ (dragCol && dragCol.id === column.id) ||
600
+ (!isCrossDrag && (isPeerDrag ? dragCol.parentId !== column.parentId : column.level > 1)) ||
601
+ (!immediate && column.level > 1) ||
602
+ (!isCrossDrag && (isPeerDrag ? dragCol.parentId !== column.parentId : dragCol.level > 1)) ||
603
+ (!immediate && dragCol.level > 1)
604
+ ) {
605
+ showDropTip(evnt, optEl, false, dragPos)
606
+ return
607
+ }
608
+ customPanelInternalData.prevDragToChild = !!(isCrossDrag && isToChildDrag && isControlKey && immediate)
609
+ customPanelInternalData.prevDragCol = column
610
+ customPanelInternalData.prevDragPos = dragPos
611
+ showDropTip(evnt, optEl, true, dragPos)
612
+ }
613
+ }
614
+
615
+ const clearDragAnimateStatus = () => {
616
+ customPanelInternalData.customDragTime = setTimeout(() => {
617
+ tableReactData.isCustomDragStatus = false
618
+ customPanelInternalData.customDragTime = undefined
619
+ }, 350)
620
+ }
621
+
622
+ const sortMoveUpEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
623
+ const { customColumnList } = tableReactData
624
+ const matchObj = XEUtils.findTree(customColumnList, (item) => item === column)
625
+ if (matchObj) {
626
+ const { item, items, index } = matchObj
627
+ if (index > 0) {
628
+ tableReactData.isCustomDragStatus = true
629
+ nextTick(() => {
630
+ items.splice(index, 1)
631
+ items.splice(index - 1, 0, item)
632
+ clearDragAnimateStatus()
633
+ })
634
+ }
635
+ }
636
+ }
637
+
638
+ const sortMoveDnEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
639
+ const { customColumnList } = tableReactData
640
+ const matchObj = XEUtils.findTree(customColumnList, (item) => item === column)
641
+ if (matchObj) {
642
+ const { item, items, index } = matchObj
643
+ if (index < items.length - 1) {
644
+ tableReactData.isCustomDragStatus = true
645
+ nextTick(() => {
646
+ items.splice(index, 1)
647
+ items.splice(index + 1, 0, item)
648
+ clearDragAnimateStatus()
649
+ })
650
+ }
651
+ }
652
+ }
653
+
654
+ const sortMoveTopEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
655
+ const { customColumnList } = tableReactData
656
+ const matchObj = XEUtils.findTree(customColumnList, (item) => item === column)
657
+ if (matchObj) {
658
+ const { item, items, index, parent: parentItem } = matchObj
659
+ if (parentItem || index > 0) {
660
+ tableReactData.isCustomDragStatus = true
661
+ nextTick(() => {
662
+ item.parentId = null
663
+ items.splice(index, 1)
664
+ customColumnList.unshift(item)
665
+ clearDragAnimateStatus()
666
+ })
667
+ }
668
+ }
669
+ }
670
+
671
+ const sortMoveBottomEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
672
+ const { customColumnList } = tableReactData
673
+ const matchObj = XEUtils.findTree(customColumnList, (item) => item === column)
674
+ if (matchObj) {
675
+ const { item, items, index, parent: parentItem } = matchObj
676
+ if (parentItem || index < items.length - 1) {
677
+ tableReactData.isCustomDragStatus = true
678
+ nextTick(() => {
679
+ item.parentId = null
680
+ items.splice(index, 1)
681
+ customColumnList.push(item)
682
+ clearDragAnimateStatus()
683
+ })
684
+ }
685
+ }
686
+ }
687
+
688
+ const renderDragTip = () => {
689
+ const { dragTipText } = customPanelReactData
690
+ const columnDragOpts = computeColumnDragOpts.value
691
+ return h('div', {}, [
692
+ h('div', {
693
+ ref: refDragLineElem,
694
+ class: [
695
+ 'vxe-table-custom-popup--drag-line',
696
+ {
697
+ 'is--guides': columnDragOpts.showGuidesStatus
698
+ }
699
+ ]
700
+ }),
701
+ h(
702
+ 'div',
703
+ {
704
+ ref: refDragTipElem,
705
+ class: 'vxe-table-custom-popup--drag-tip'
706
+ },
707
+ [
708
+ h(
709
+ 'div',
710
+ {
711
+ class: 'vxe-table-custom-popup--drag-tip-wrapper'
712
+ },
713
+ [
714
+ h(
715
+ 'div',
716
+ {
717
+ class: 'vxe-table-custom-popup--drag-tip-status'
718
+ },
719
+ [
720
+ h('span', {
721
+ class: ['vxe-table-custom-popup--drag-tip-normal-status', getIcon().TABLE_DRAG_STATUS_ROW]
722
+ }),
723
+ h('span', {
724
+ class: ['vxe-table-custom-popup--drag-tip-sub-status', getIcon().TABLE_DRAG_STATUS_SUB_ROW]
725
+ }),
726
+ h('span', {
727
+ class: ['vxe-table-custom-popup--drag-tip-group-status', getIcon().TABLE_DRAG_STATUS_AGG_GROUP]
728
+ }),
729
+ h('span', {
730
+ class: ['vxe-table-custom-popup--drag-tip-values-status', getIcon().TABLE_DRAG_STATUS_AGG_VALUES]
731
+ }),
732
+ h('span', {
733
+ class: ['vxe-table-custom-popup--drag-tip-disabled-status', getIcon().TABLE_DRAG_DISABLED]
734
+ })
735
+ ]
736
+ ),
737
+ h(
738
+ 'div',
739
+ {
740
+ class: 'vxe-table-custom-popup--drag-tip-content'
741
+ },
742
+ `${dragTipText || ''}`
743
+ )
744
+ ]
745
+ )
746
+ ]
747
+ )
748
+ ])
749
+ }
750
+
751
+ const renderSimplePanel = () => {
752
+ const $xeGrid = $xeTable.xeGrid
753
+ const $xeGantt = $xeTable.xeGantt
754
+ const tableProps = $xeTable.props
755
+
756
+ const { customStore } = props
757
+ const { treeConfig, rowGroupConfig, aggregateConfig } = tableProps
758
+ const { isCustomStatus, customColumnList, isCustomDragStatus } = tableReactData
759
+ const customOpts = computeCustomOpts.value
760
+ const columnDragOpts = computeColumnDragOpts.value
761
+ const { defPopupStyle } = customStore
762
+ const { immediate, checkMethod, visibleMethod, allowVisible, allowSort, allowFixed, allowGroup, allowValues, trigger, placement, showSortDragButton, showSortMoveButton, showSortPutButton } = customOpts
763
+ const isMaxFixedColumn = computeIsMaxFixedColumn.value
764
+ const vSize = computeSize.value
765
+ const { isCrossDrag, isPeerDrag } = columnDragOpts
766
+ const slots = customOpts.slots || {}
767
+ const headerSlot = slots.header
768
+ const topSlot = slots.top
769
+ const bottomSlot = slots.bottom
770
+ const defaultSlot = slots.default
771
+ const footerSlot = slots.footer
772
+ const colVNs: VNode[] = []
773
+ const customWrapperOns: any = {}
774
+ const isAllChecked = customStore.isAll
775
+ const isAllIndeterminate = customStore.isIndeterminate
776
+ // hover 触发
777
+ if (trigger === 'hover') {
778
+ customWrapperOns.onMouseenter = handleWrapperMouseenterEvent
779
+ customWrapperOns.onMouseleave = handleWrapperMouseleaveEvent
780
+ }
781
+ const params = {
782
+ $table: $xeTable,
783
+ $grid: $xeGrid,
784
+ $gantt: $xeGantt,
785
+ columns: customColumnList,
786
+ isAllChecked,
787
+ isAllIndeterminate,
788
+ isCustomStatus
789
+ }
790
+ XEUtils.eachTree(customColumnList, (column, index, items, path, parentItem) => {
791
+ const isVisible = visibleMethod ? visibleMethod({ $table: $xeTable, column }) : true
792
+ if (isVisible) {
793
+ const isChecked = column.renderVisible
794
+ const isIndeterminate = column.halfVisible
795
+ const isColGroup = column.children && column.children.length
796
+ const colTitle = formatText(column.getTitle(), 1)
797
+ const isDisabled = checkMethod ? !checkMethod({ $table: $xeTable, column }) : false
798
+ const isHidden = !isChecked
799
+ const showSortBtn = (isCrossDrag || isPeerDrag ? immediate : false) || column.level === 1
800
+ colVNs.push(
801
+ h(
802
+ 'li',
803
+ {
804
+ key: column.id,
805
+ colid: column.id,
806
+ class: [
807
+ 'vxe-table-custom--option',
808
+ `level--${column.level}`,
809
+ {
810
+ 'is--hidden': isDisabled || isHidden,
811
+ 'is--group': isColGroup
812
+ }
813
+ ],
814
+ onDragstart: sortDragstartEvent,
815
+ onDragend: sortDragendEvent,
816
+ onDragover: sortDragoverEvent
817
+ },
818
+ [
819
+ allowVisible
820
+ ? h(
821
+ 'div',
822
+ {
823
+ class: [
824
+ 'vxe-table-custom--checkbox-option',
825
+ {
826
+ 'is--checked': isChecked,
827
+ 'is--indeterminate': isIndeterminate,
828
+ 'is--disabled': isDisabled
829
+ }
830
+ ],
831
+ title: getI18n('vxe.custom.setting.colVisible'),
832
+ onClick: (evnt: MouseEvent) => {
833
+ if (!isDisabled) {
834
+ changeCheckboxOption(column, evnt)
835
+ }
836
+ }
837
+ },
838
+ [
839
+ h('span', {
840
+ class: ['vxe-checkbox--icon', isIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED]
841
+ })
842
+ ]
843
+ )
844
+ : renderEmptyElement($xeTable),
845
+ h(
846
+ 'div',
847
+ {
848
+ class: 'vxe-table-custom--name-option'
849
+ },
850
+ [
851
+ (allowSort && showSortDragButton) || allowGroup || allowValues
852
+ ? showSortBtn || ((allowGroup || allowValues) && !isColGroup)
853
+ ? h(
854
+ 'div',
855
+ {
856
+ class: 'vxe-table-custom--sort-option'
857
+ },
858
+ [
859
+ h(
860
+ 'span',
861
+ {
862
+ class: [
863
+ 'vxe-table-custom--sort-btn',
864
+ {
865
+ 'is--disabled': isHidden
866
+ }
867
+ ],
868
+ title: getI18n('vxe.custom.setting.sortHelpTip'),
869
+ ...(isHidden
870
+ ? {}
871
+ : {
872
+ onMousedown: sortMousedownEvent,
873
+ onMouseup: sortMouseupEvent
874
+ })
875
+ },
876
+ [
877
+ h('i', {
878
+ class: getIcon().TABLE_CUSTOM_SORT
879
+ })
880
+ ]
881
+ )
882
+ ]
883
+ )
884
+ : renderEmptyElement($xeTable)
885
+ : renderEmptyElement($xeTable),
886
+ column.type === 'html'
887
+ ? h('div', {
888
+ key: '1',
889
+ class: 'vxe-table-custom--checkbox-label',
890
+ innerHTML: colTitle
891
+ })
892
+ : h(
893
+ 'div',
894
+ {
895
+ key: '0',
896
+ class: 'vxe-table-custom--checkbox-label'
897
+ },
898
+ colTitle
899
+ )
900
+ ]
901
+ ),
902
+ showSortBtn && (showSortMoveButton || showSortPutButton)
903
+ ? h(
904
+ 'div',
905
+ {
906
+ class: 'vxe-table-custom--move-btn-option'
907
+ },
908
+ VxeUIButtonComponent
909
+ ? [
910
+ showSortMoveButton
911
+ ? h(VxeUIButtonComponent, {
912
+ mode: 'text',
913
+ icon: 'vxe-icon-arrows-up',
914
+ title: getI18n('vxe.custom.setting.moveUpTitle'),
915
+ disabled: index <= 0,
916
+ onClick(evntParame) {
917
+ sortMoveUpEvent(evntParame, column)
918
+ }
919
+ })
920
+ : renderEmptyElement($xeTable),
921
+ showSortMoveButton
922
+ ? h(VxeUIButtonComponent, {
923
+ mode: 'text',
924
+ icon: 'vxe-icon-arrows-down',
925
+ title: getI18n('vxe.custom.setting.moveDnTitle'),
926
+ disabled: index >= items.length - 1,
927
+ onClick(evntParame) {
928
+ sortMoveDnEvent(evntParame, column)
929
+ }
930
+ })
931
+ : renderEmptyElement($xeTable),
932
+ showSortPutButton && !parentItem
933
+ ? h(VxeUIButtonComponent, {
934
+ mode: 'text',
935
+ icon: 'vxe-icon-top',
936
+ title: getI18n('vxe.custom.setting.putTopTitle'),
937
+ disabled: index <= 0,
938
+ onClick(evntParame) {
939
+ sortMoveTopEvent(evntParame, column)
940
+ }
941
+ })
942
+ : renderEmptyElement($xeTable),
943
+ showSortPutButton && !parentItem
944
+ ? h(VxeUIButtonComponent, {
945
+ mode: 'text',
946
+ icon: 'vxe-icon-bottom',
947
+ title: getI18n('vxe.custom.setting.putBottomTitle'),
948
+ disabled: index >= items.length - 1,
949
+ onClick(evntParame) {
950
+ sortMoveBottomEvent(evntParame, column)
951
+ }
952
+ })
953
+ : renderEmptyElement($xeTable)
954
+ ]
955
+ : []
956
+ )
957
+ : renderEmptyElement($xeTable),
958
+ !parentItem && allowFixed
959
+ ? h(
960
+ 'div',
961
+ {
962
+ class: 'vxe-table-custom--fixed-option'
963
+ },
964
+ VxeUIButtonComponent
965
+ ? [
966
+ h(VxeUIButtonComponent, {
967
+ mode: 'text',
968
+ icon: column.renderFixed === 'left' ? getIcon().TOOLBAR_TOOLS_FIXED_LEFT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_LEFT,
969
+ status: column.renderFixed === 'left' ? 'primary' : '',
970
+ disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
971
+ title: getI18n(column.renderFixed === 'left' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedLeft'),
972
+ onClick: ({ $event }) => {
973
+ changeFixedOption(column, 'left', $event)
974
+ }
975
+ }),
976
+ h(VxeUIButtonComponent, {
977
+ mode: 'text',
978
+ icon: column.renderFixed === 'right' ? getIcon().TOOLBAR_TOOLS_FIXED_RIGHT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_RIGHT,
979
+ status: column.renderFixed === 'right' ? 'primary' : '',
980
+ disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
981
+ title: getI18n(column.renderFixed === 'right' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedRight'),
982
+ onClick: ({ $event }) => {
983
+ changeFixedOption(column, 'right', $event)
984
+ }
985
+ })
986
+ ]
987
+ : []
988
+ )
989
+ : renderEmptyElement($xeTable)
990
+ ]
991
+ )
992
+ )
993
+ }
994
+ })
995
+ return h(
996
+ 'div',
997
+ {
998
+ ref: refElem,
999
+ key: 'simple',
1000
+ class: [
1001
+ 'vxe-table-custom-wrapper',
1002
+ `placement--${placement}`,
1003
+ {
1004
+ [`size--${vSize}`]: vSize,
1005
+ 'is--active': customStore.visible
1006
+ }
1007
+ ],
1008
+ style: defPopupStyle
1009
+ },
1010
+ customStore.visible
1011
+ ? [
1012
+ h(
1013
+ 'div',
1014
+ {
1015
+ ref: refBodyWrapperElem,
1016
+ class: 'vxe-table-custom-simple--body-wrapper'
1017
+ },
1018
+ [
1019
+ !treeConfig && (aggregateConfig || rowGroupConfig) && $xeTable.getPivotTableAggregateSimplePanel
1020
+ ? h($xeTable.getPivotTableAggregateSimplePanel(), {
1021
+ customStore
1022
+ })
1023
+ : renderEmptyElement($xeTable),
1024
+ h(
1025
+ 'div',
1026
+ {
1027
+ ref: refCustomBodyElem,
1028
+ class: 'vxe-table-custom--handle-wrapper'
1029
+ },
1030
+ [
1031
+ h(
1032
+ 'div',
1033
+ {
1034
+ class: 'vxe-table-custom--header'
1035
+ },
1036
+ headerSlot
1037
+ ? $xeTable.callSlot(headerSlot, params)
1038
+ : [
1039
+ h(
1040
+ 'ul',
1041
+ {
1042
+ class: 'vxe-table-custom--panel-list'
1043
+ },
1044
+ [
1045
+ h(
1046
+ 'li',
1047
+ {
1048
+ class: 'vxe-table-custom--option'
1049
+ },
1050
+ [
1051
+ allowVisible
1052
+ ? h(
1053
+ 'div',
1054
+ {
1055
+ class: [
1056
+ 'vxe-table-custom--checkbox-option',
1057
+ {
1058
+ 'is--checked': isAllChecked,
1059
+ 'is--indeterminate': isAllIndeterminate
1060
+ }
1061
+ ],
1062
+ title: getI18n('vxe.table.allTitle'),
1063
+ onClick: allOptionEvent
1064
+ },
1065
+ [
1066
+ h('span', {
1067
+ class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED]
1068
+ }),
1069
+ h(
1070
+ 'span',
1071
+ {
1072
+ class: 'vxe-checkbox--label'
1073
+ },
1074
+ getI18n('vxe.toolbar.customAll')
1075
+ )
1076
+ ]
1077
+ )
1078
+ : h(
1079
+ 'span',
1080
+ {
1081
+ class: 'vxe-checkbox--label'
1082
+ },
1083
+ getI18n('vxe.table.customTitle')
1084
+ )
1085
+ ]
1086
+ )
1087
+ ]
1088
+ )
1089
+ ]
1090
+ ),
1091
+ h(
1092
+ 'div',
1093
+ {
1094
+ class: 'vxe-table-custom--body'
1095
+ },
1096
+ [
1097
+ topSlot
1098
+ ? h(
1099
+ 'div',
1100
+ {
1101
+ class: 'vxe-table-custom--panel-top'
1102
+ },
1103
+ $xeTable.callSlot(topSlot, params)
1104
+ )
1105
+ : renderEmptyElement($xeTable),
1106
+ defaultSlot
1107
+ ? h(
1108
+ 'div',
1109
+ {
1110
+ class: 'vxe-table-custom--panel-body'
1111
+ },
1112
+ $xeTable.callSlot(defaultSlot, params)
1113
+ )
1114
+ : h(
1115
+ TransitionGroup,
1116
+ {
1117
+ class: 'vxe-table-custom--panel-list',
1118
+ name: isCustomDragStatus ? 'vxe-table-custom--list' : '',
1119
+ tag: 'ul',
1120
+ ...customWrapperOns
1121
+ },
1122
+ {
1123
+ default: () => colVNs
1124
+ }
1125
+ ),
1126
+ bottomSlot
1127
+ ? h(
1128
+ 'div',
1129
+ {
1130
+ class: 'vxe-table-custom--panel-bottom'
1131
+ },
1132
+ $xeTable.callSlot(bottomSlot, params)
1133
+ )
1134
+ : renderEmptyElement($xeTable)
1135
+ ]
1136
+ ),
1137
+ customOpts.showFooter
1138
+ ? h(
1139
+ 'div',
1140
+ {
1141
+ class: 'vxe-table-custom--footer'
1142
+ },
1143
+ footerSlot
1144
+ ? $xeTable.callSlot(footerSlot, params)
1145
+ : [
1146
+ h(
1147
+ 'div',
1148
+ {
1149
+ class: 'vxe-table-custom--footer-buttons'
1150
+ },
1151
+ [
1152
+ VxeUIButtonComponent
1153
+ ? h(VxeUIButtonComponent, {
1154
+ mode: 'text',
1155
+ content: customOpts.resetButtonText || getI18n('vxe.table.customRestore'),
1156
+ disabled: !isCustomStatus,
1157
+ onClick: resetCustomEvent
1158
+ })
1159
+ : renderEmptyElement($xeTable),
1160
+ immediate
1161
+ ? VxeUIButtonComponent
1162
+ ? h(VxeUIButtonComponent, {
1163
+ mode: 'text',
1164
+ content: customOpts.closeButtonText || getI18n('vxe.table.customClose'),
1165
+ onClick: cancelCloseEvent
1166
+ })
1167
+ : renderEmptyElement($xeTable)
1168
+ : VxeUIButtonComponent
1169
+ ? h(VxeUIButtonComponent, {
1170
+ mode: 'text',
1171
+ content: customOpts.cancelButtonText || getI18n('vxe.table.customCancel'),
1172
+ onClick: cancelCustomEvent
1173
+ })
1174
+ : renderEmptyElement($xeTable),
1175
+ immediate
1176
+ ? renderEmptyElement($xeTable)
1177
+ : VxeUIButtonComponent
1178
+ ? h(VxeUIButtonComponent, {
1179
+ mode: 'text',
1180
+ status: 'primary',
1181
+ content: customOpts.confirmButtonText || getI18n('vxe.table.customConfirm'),
1182
+ onClick: confirmCustomEvent
1183
+ })
1184
+ : renderEmptyElement($xeTable)
1185
+ ]
1186
+ )
1187
+ ]
1188
+ )
1189
+ : null
1190
+ ]
1191
+ ),
1192
+ renderDragTip()
1193
+ ]
1194
+ )
1195
+ ]
1196
+ : []
1197
+ )
1198
+ }
1199
+
1200
+ const renderPopupBodys = () => {
1201
+ const { resizable: allResizable } = tableProps
1202
+ const { customColumnList } = tableReactData
1203
+ const customOpts = computeCustomOpts.value
1204
+ const columnDragOpts = computeColumnDragOpts.value
1205
+ const { immediate, showSortDragButton, showSortMoveButton, showSortPutButton, allowVisible, allowSort, allowFixed, allowAlign, allowHeaderAlign, allowFooterAlign, allowResizable, allowGroup, allowValues, checkMethod, visibleMethod } = customOpts
1206
+ const columnOpts = computeColumnOpts.value
1207
+ const resizableOpts = computeResizableOpts.value
1208
+ const { minWidth: reMinWidth, maxWidth: reMaxWidth } = resizableOpts
1209
+ const isMaxFixedColumn = computeIsMaxFixedColumn.value
1210
+ const { isCrossDrag, isPeerDrag } = columnDragOpts
1211
+
1212
+ const trVNs: VNode[] = []
1213
+ XEUtils.eachTree(customColumnList, (column, index, items, path, parentItem) => {
1214
+ const isVisible = visibleMethod ? visibleMethod({ $table: $xeTable, column }) : true
1215
+ if (isVisible) {
1216
+ // 默认继承调整宽度
1217
+ let customMinWidth = 0
1218
+ let customMaxWidth = 0
1219
+ if (allowResizable) {
1220
+ const resizeParams = {
1221
+ $table: $xeTable,
1222
+ column,
1223
+ columnIndex: $xeTable.getColumnIndex(column),
1224
+ $columnIndex: $xeTable.getVMColumnIndex(column),
1225
+ _columnIndex: $xeTable.getVTColumnIndex(column),
1226
+ rowIndex: -1,
1227
+ _rowIndex: -1,
1228
+ $rowIndex: -1
1229
+ }
1230
+ if (reMinWidth) {
1231
+ customMinWidth = XEUtils.toNumber(XEUtils.isFunction(reMinWidth) ? reMinWidth(resizeParams) : reMinWidth)
1232
+ }
1233
+ if (reMaxWidth) {
1234
+ customMaxWidth = XEUtils.toNumber(XEUtils.isFunction(reMaxWidth) ? reMaxWidth(resizeParams) : reMaxWidth)
1235
+ }
1236
+ }
1237
+
1238
+ const isChecked = column.renderVisible
1239
+ const isIndeterminate = column.halfVisible
1240
+ const colTitle = formatText(column.getTitle(), 1)
1241
+ const isColGroup = column.children && column.children.length
1242
+ const isDisabled = checkMethod ? !checkMethod({ $table: $xeTable, column }) : false
1243
+ const isHidden = !isChecked
1244
+ const showSortBtn = (isCrossDrag || isPeerDrag ? immediate : false) || column.level === 1
1245
+
1246
+ const alignList = [
1247
+ { icon: getIcon().TABLE_CUSTOM_ALIGN_LEFT, value: 'left', title: getI18n('vxe.custom.setting.anLeftTitle'), disabled: isHidden },
1248
+ { icon: getIcon().TABLE_CUSTOM_ALIGN_CENTER, value: 'center', title: getI18n('vxe.custom.setting.anCenterTitle'), disabled: isHidden },
1249
+ { icon: getIcon().TABLE_CUSTOM_ALIGN_RIGHT, value: 'right', title: getI18n('vxe.custom.setting.anRightTitle'), disabled: isHidden }
1250
+ ]
1251
+
1252
+ const tdVNs: VNode[] = []
1253
+ if (allowVisible) {
1254
+ tdVNs.push(
1255
+ h(
1256
+ 'td',
1257
+ {
1258
+ key: 'av',
1259
+ class: 'vxe-table-custom-popup--column-td col--visible'
1260
+ },
1261
+ [
1262
+ h(
1263
+ 'div',
1264
+ {
1265
+ class: [
1266
+ 'vxe-table-custom--checkbox-option',
1267
+ {
1268
+ 'is--checked': isChecked,
1269
+ 'is--indeterminate': isIndeterminate,
1270
+ 'is--disabled': isDisabled
1271
+ }
1272
+ ],
1273
+ title: getI18n('vxe.custom.setting.colVisible'),
1274
+ onClick: (evnt: MouseEvent) => {
1275
+ if (!isDisabled) {
1276
+ changeCheckboxOption(column, evnt)
1277
+ }
1278
+ }
1279
+ },
1280
+ [
1281
+ h('span', {
1282
+ class: ['vxe-checkbox--icon', isIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED]
1283
+ })
1284
+ ]
1285
+ )
1286
+ ]
1287
+ )
1288
+ )
1289
+ }
1290
+ tdVNs.push(
1291
+ h(
1292
+ 'td',
1293
+ {
1294
+ key: 'at',
1295
+ class: 'vxe-table-custom-popup--column-td col--name'
1296
+ },
1297
+ [
1298
+ h(
1299
+ 'div',
1300
+ {
1301
+ class: 'vxe-table-custom-popup--name'
1302
+ },
1303
+ [
1304
+ (allowSort && showSortDragButton) || allowGroup || allowValues
1305
+ ? showSortBtn || ((allowGroup || allowValues) && !isColGroup)
1306
+ ? h(
1307
+ 'div',
1308
+ {
1309
+ class: [
1310
+ 'vxe-table-custom-popup--column-sort-btn',
1311
+ {
1312
+ 'is--disabled': isHidden
1313
+ }
1314
+ ],
1315
+ title: getI18n('vxe.custom.setting.sortHelpTip'),
1316
+ ...(isHidden
1317
+ ? {}
1318
+ : {
1319
+ onMousedown: sortMousedownEvent,
1320
+ onMouseup: sortMouseupEvent
1321
+ })
1322
+ },
1323
+ [
1324
+ h('i', {
1325
+ class: getIcon().TABLE_CUSTOM_SORT
1326
+ })
1327
+ ]
1328
+ )
1329
+ : h('div', {
1330
+ class: 'vxe-table-custom-popup--column-sort-placeholder'
1331
+ })
1332
+ : renderEmptyElement($xeTable),
1333
+ column.type === 'html'
1334
+ ? h('div', {
1335
+ key: '1',
1336
+ class: 'vxe-table-custom-popup--title',
1337
+ innerHTML: colTitle
1338
+ })
1339
+ : h(
1340
+ 'div',
1341
+ {
1342
+ key: '0',
1343
+ class: 'vxe-table-custom-popup--title',
1344
+ title: colTitle
1345
+ },
1346
+ colTitle
1347
+ ),
1348
+ showSortBtn && (showSortMoveButton || showSortPutButton)
1349
+ ? h(
1350
+ 'div',
1351
+ {
1352
+ class: 'vxe-table-custom-popup--move-btn'
1353
+ },
1354
+ VxeUIButtonComponent
1355
+ ? [
1356
+ showSortMoveButton
1357
+ ? h(VxeUIButtonComponent, {
1358
+ mode: 'text',
1359
+ icon: 'vxe-icon-arrows-up',
1360
+ title: getI18n('vxe.custom.setting.moveUpTitle'),
1361
+ disabled: index <= 0,
1362
+ onClick(evntParame) {
1363
+ sortMoveUpEvent(evntParame, column)
1364
+ }
1365
+ })
1366
+ : renderEmptyElement($xeTable),
1367
+ showSortMoveButton
1368
+ ? h(VxeUIButtonComponent, {
1369
+ mode: 'text',
1370
+ icon: 'vxe-icon-arrows-down',
1371
+ title: getI18n('vxe.custom.setting.moveDnTitle'),
1372
+ disabled: index >= items.length - 1,
1373
+ onClick(evntParame) {
1374
+ sortMoveDnEvent(evntParame, column)
1375
+ }
1376
+ })
1377
+ : renderEmptyElement($xeTable),
1378
+ showSortPutButton && !parentItem
1379
+ ? h(VxeUIButtonComponent, {
1380
+ mode: 'text',
1381
+ icon: 'vxe-icon-top',
1382
+ title: getI18n('vxe.custom.setting.putTopTitle'),
1383
+ disabled: index <= 0,
1384
+ onClick(evntParame) {
1385
+ sortMoveTopEvent(evntParame, column)
1386
+ }
1387
+ })
1388
+ : renderEmptyElement($xeTable),
1389
+ showSortPutButton && !parentItem
1390
+ ? h(VxeUIButtonComponent, {
1391
+ mode: 'text',
1392
+ icon: 'vxe-icon-bottom',
1393
+ title: getI18n('vxe.custom.setting.putBottomTitle'),
1394
+ disabled: index >= items.length - 1,
1395
+ onClick(evntParame) {
1396
+ sortMoveBottomEvent(evntParame, column)
1397
+ }
1398
+ })
1399
+ : renderEmptyElement($xeTable)
1400
+ ]
1401
+ : []
1402
+ )
1403
+ : renderEmptyElement($xeTable)
1404
+ ]
1405
+ )
1406
+ ]
1407
+ )
1408
+ )
1409
+ if (allowResizable) {
1410
+ tdVNs.push(
1411
+ h(
1412
+ 'td',
1413
+ {
1414
+ key: 'aw',
1415
+ class: 'vxe-table-custom-popup--column-td col--resizable'
1416
+ },
1417
+ [
1418
+ (column.children && column.children.length) || !(XEUtils.isBoolean(column.resizable) ? column.resizable : columnOpts.resizable || allResizable)
1419
+ ? h('span', '-')
1420
+ : VxeUINumberInputComponent
1421
+ ? h(VxeUINumberInputComponent, {
1422
+ type: 'integer',
1423
+ immediate: false,
1424
+ disabled: isHidden,
1425
+ modelValue: column.renderResizeWidth,
1426
+ min: customMinWidth || 0,
1427
+ max: customMaxWidth || 9999,
1428
+ 'onUpdate:modelValue'(value: any) {
1429
+ const width = Math.max(0, Number(value))
1430
+ column.renderResizeWidth = width
1431
+ },
1432
+ onChange() {
1433
+ changeColumnWidth(column)
1434
+ }
1435
+ })
1436
+ : renderEmptyElement($xeTable)
1437
+ ]
1438
+ )
1439
+ )
1440
+ }
1441
+ if (allowFixed) {
1442
+ tdVNs.push(
1443
+ h(
1444
+ 'td',
1445
+ {
1446
+ key: 'af',
1447
+ class: 'vxe-table-custom-popup--column-td col--fixed'
1448
+ },
1449
+ parentItem
1450
+ ? [h('span', '-')]
1451
+ : VxeUIRadioGroupComponent
1452
+ ? [
1453
+ h(VxeUIButtonComponent, {
1454
+ icon: column.renderFixed === 'left' ? getIcon().TOOLBAR_TOOLS_FIXED_LEFT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_LEFT,
1455
+ status: column.renderFixed === 'left' ? 'primary' : '',
1456
+ disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
1457
+ title: getI18n(column.renderFixed === 'left' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedLeft'),
1458
+ onClick: ({ $event }) => {
1459
+ changeFixedOption(column, 'left', $event)
1460
+ }
1461
+ }),
1462
+ h(VxeUIButtonComponent, {
1463
+ icon: column.renderFixed === 'right' ? getIcon().TOOLBAR_TOOLS_FIXED_RIGHT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_RIGHT,
1464
+ status: column.renderFixed === 'right' ? 'primary' : '',
1465
+ disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
1466
+ title: getI18n(column.renderFixed === 'right' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedRight'),
1467
+ onClick: ({ $event }) => {
1468
+ changeFixedOption(column, 'right', $event)
1469
+ }
1470
+ })
1471
+ ]
1472
+ : []
1473
+ )
1474
+ )
1475
+ }
1476
+ if (allowAlign) {
1477
+ tdVNs.push(
1478
+ h(
1479
+ 'td',
1480
+ {
1481
+ key: 'aa',
1482
+ class: 'vxe-table-custom-popup--column-td col--align'
1483
+ },
1484
+ VxeUIRadioGroupComponent
1485
+ ? [
1486
+ h(VxeUIRadioGroupComponent, {
1487
+ modelValue: column.renderAlign || 'left',
1488
+ type: 'button',
1489
+ strict: false,
1490
+ disabled: isHidden,
1491
+ options: alignList,
1492
+ onChange({ value, $event }) {
1493
+ changeAlignOption(column, value, 'align', 'renderAlign', 'custom-align-change', $event)
1494
+ }
1495
+ })
1496
+ ]
1497
+ : []
1498
+ )
1499
+ )
1500
+ }
1501
+ if (allowHeaderAlign) {
1502
+ tdVNs.push(
1503
+ h(
1504
+ 'td',
1505
+ {
1506
+ key: 'aha',
1507
+ class: 'vxe-table-custom-popup--column-td col--header-align'
1508
+ },
1509
+ isColGroup
1510
+ ? [h('span', '-')]
1511
+ : VxeUIRadioGroupComponent
1512
+ ? [
1513
+ h(VxeUIRadioGroupComponent, {
1514
+ modelValue: column.renderHeaderAlign || 'left',
1515
+ type: 'button',
1516
+ strict: false,
1517
+ disabled: isHidden,
1518
+ options: alignList,
1519
+ onChange({ value, $event }) {
1520
+ changeAlignOption(column, value, 'headerAlign', 'renderHeaderAlign', 'custom-header-align-change', $event)
1521
+ }
1522
+ })
1523
+ ]
1524
+ : []
1525
+ )
1526
+ )
1527
+ }
1528
+ if (allowFooterAlign) {
1529
+ tdVNs.push(
1530
+ h(
1531
+ 'td',
1532
+ {
1533
+ key: 'afa',
1534
+ class: 'vxe-table-custom-popup--column-td col--footer-align'
1535
+ },
1536
+ isColGroup
1537
+ ? [h('span', '-')]
1538
+ : VxeUIRadioGroupComponent
1539
+ ? [
1540
+ h(VxeUIRadioGroupComponent, {
1541
+ modelValue: column.renderFooterAlign || 'left',
1542
+ type: 'button',
1543
+ strict: false,
1544
+ disabled: isHidden,
1545
+ options: alignList,
1546
+ onChange({ value, $event }) {
1547
+ changeAlignOption(column, value, 'footerAlign', 'renderFooterAlign', 'custom-footer-align-change', $event)
1548
+ }
1549
+ })
1550
+ ]
1551
+ : []
1552
+ )
1553
+ )
1554
+ }
1555
+
1556
+ trVNs.push(
1557
+ h(
1558
+ 'tr',
1559
+ {
1560
+ key: column.id,
1561
+ colid: column.id,
1562
+ class: [
1563
+ `vxe-table-custom-popup--row level--${column.level}`,
1564
+ {
1565
+ 'is--group': isColGroup
1566
+ }
1567
+ ],
1568
+ onDragstart: sortDragstartEvent,
1569
+ onDragend: sortDragendEvent,
1570
+ onDragover: sortDragoverEvent
1571
+ },
1572
+ tdVNs
1573
+ )
1574
+ )
1575
+ }
1576
+ })
1577
+ return trVNs
1578
+ }
1579
+
1580
+ const renderPopupPanel = () => {
1581
+ const $xeGrid = $xeTable.xeGrid
1582
+ const $xeGantt = $xeTable.xeGantt
1583
+
1584
+ const { customStore } = props
1585
+ const { treeConfig, rowGroupConfig, aggregateConfig } = tableProps
1586
+ const { isCustomStatus, customColumnList } = tableReactData
1587
+ const vSize = computeSize.value
1588
+ const customOpts = computeCustomOpts.value
1589
+ const aggregateOpts = computeAggregateOpts.value
1590
+ const { panePopupStyle } = customStore
1591
+ const { placement: aggPlacement } = aggregateOpts
1592
+ const { mode, immediate, modalOptions, drawerOptions, allowVisible, allowFixed, allowAlign, allowHeaderAlign, allowFooterAlign, allowResizable } = customOpts
1593
+ const columnOpts = computeColumnOpts.value
1594
+ const { maxFixedSize } = columnOpts
1595
+ const modalOpts = Object.assign({}, modalOptions)
1596
+ const drawerOpts = Object.assign({}, drawerOptions)
1597
+ const slots = customOpts.slots || {}
1598
+ const headerSlot = slots.header
1599
+ const topSlot = slots.top
1600
+ const bottomSlot = slots.bottom
1601
+ const defaultSlot = slots.default
1602
+ const footerSlot = slots.footer
1603
+ const isAllChecked = customStore.isAll
1604
+ const isAllIndeterminate = customStore.isIndeterminate
1605
+ const isAggRtBmLayout = aggPlacement === 'right' || aggPlacement === 'bottom'
1606
+ const params = {
1607
+ $table: $xeTable,
1608
+ $grid: $xeGrid,
1609
+ $gantt: $xeGantt,
1610
+ columns: customColumnList,
1611
+ isAllChecked,
1612
+ isAllIndeterminate,
1613
+ isCustomStatus
1614
+ }
1615
+
1616
+ const colVNs: VNode[] = []
1617
+ const headVNs: VNode[] = []
1618
+ if (allowVisible) {
1619
+ colVNs.push(
1620
+ h('col', {
1621
+ key: 'av',
1622
+ class: 'vxe-table-custom-popup--column-col col--checkbox'
1623
+ })
1624
+ )
1625
+ headVNs.push(
1626
+ h(
1627
+ 'th',
1628
+ {
1629
+ key: 'av',
1630
+ class: 'vxe-table-custom-popup--column-th col--checkbox'
1631
+ },
1632
+ [
1633
+ h(
1634
+ 'div',
1635
+ {
1636
+ class: [
1637
+ 'vxe-table-custom--checkbox-option',
1638
+ {
1639
+ 'is--checked': isAllChecked,
1640
+ 'is--indeterminate': isAllIndeterminate
1641
+ }
1642
+ ],
1643
+ title: getI18n('vxe.table.allTitle'),
1644
+ onClick: allOptionEvent
1645
+ },
1646
+ [
1647
+ h('span', {
1648
+ class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED]
1649
+ })
1650
+ // h('span', {
1651
+ // class: 'vxe-checkbox--label'
1652
+ // }, getI18n('vxe.toolbar.customAll'))
1653
+ ]
1654
+ )
1655
+ ]
1656
+ )
1657
+ )
1658
+ }
1659
+ colVNs.push(
1660
+ h('col', {
1661
+ key: 'at',
1662
+ class: 'vxe-table-custom-popup--column-col col--title'
1663
+ })
1664
+ )
1665
+ headVNs.push(
1666
+ h(
1667
+ 'th',
1668
+ {
1669
+ key: 'at',
1670
+ class: 'vxe-table-custom-popup--column-th col--title'
1671
+ },
1672
+ getI18n('vxe.custom.setting.colTitle')
1673
+ )
1674
+ )
1675
+ if (allowResizable) {
1676
+ colVNs.push(
1677
+ h('col', {
1678
+ key: 'aw',
1679
+ class: 'vxe-table-custom-popup--column-col col--width'
1680
+ })
1681
+ )
1682
+ headVNs.push(
1683
+ h(
1684
+ 'th',
1685
+ {
1686
+ key: 'aw',
1687
+ class: 'vxe-table-custom-popup--column-th col--width'
1688
+ },
1689
+ getI18n('vxe.custom.setting.colResizable')
1690
+ )
1691
+ )
1692
+ }
1693
+ if (allowFixed) {
1694
+ colVNs.push(
1695
+ h('col', {
1696
+ key: 'af',
1697
+ class: 'vxe-table-custom-popup--column-col col--fixed'
1698
+ })
1699
+ )
1700
+ headVNs.push(
1701
+ h(
1702
+ 'th',
1703
+ {
1704
+ key: 'af',
1705
+ class: 'vxe-table-custom-popup--column-th col--fixed'
1706
+ },
1707
+ getI18n(`vxe.custom.setting.${maxFixedSize ? 'colFixedMax' : 'colFixed'}`, [maxFixedSize])
1708
+ )
1709
+ )
1710
+ }
1711
+ if (allowAlign) {
1712
+ colVNs.push(
1713
+ h('col', {
1714
+ key: 'aa',
1715
+ class: 'vxe-table-custom-popup--column-col col--align'
1716
+ })
1717
+ )
1718
+ headVNs.push(
1719
+ h(
1720
+ 'th',
1721
+ {
1722
+ key: 'aa',
1723
+ class: 'vxe-table-custom-popup--column-th col--align'
1724
+ },
1725
+ getI18n('vxe.custom.setting.colAlign')
1726
+ )
1727
+ )
1728
+ }
1729
+ if (allowHeaderAlign) {
1730
+ colVNs.push(
1731
+ h('col', {
1732
+ key: 'aha',
1733
+ class: 'vxe-table-custom-popup--column-col col--header-align'
1734
+ })
1735
+ )
1736
+ headVNs.push(
1737
+ h(
1738
+ 'th',
1739
+ {
1740
+ key: 'aha',
1741
+ class: 'vxe-table-custom-popup--column-th col--header-align'
1742
+ },
1743
+ getI18n('vxe.custom.setting.colHeadAlign')
1744
+ )
1745
+ )
1746
+ }
1747
+ if (allowFooterAlign) {
1748
+ colVNs.push(
1749
+ h('col', {
1750
+ key: 'afa',
1751
+ class: 'vxe-table-custom-popup--column-col col--footer-align'
1752
+ })
1753
+ )
1754
+ headVNs.push(
1755
+ h(
1756
+ 'th',
1757
+ {
1758
+ key: 'afa',
1759
+ class: 'vxe-table-custom-popup--column-th col--footer-align'
1760
+ },
1761
+ getI18n('vxe.custom.setting.colFootAlign')
1762
+ )
1763
+ )
1764
+ }
1765
+
1766
+ const scopedSlots: Record<string, any> = {
1767
+ default: () => {
1768
+ return h(
1769
+ 'div',
1770
+ {
1771
+ ref: refBodyWrapperElem,
1772
+ class: [
1773
+ 'vxe-table-custom-popup--body-wrapper',
1774
+ `agg-layout--${aggPlacement}`,
1775
+ {
1776
+ [`size--${vSize}`]: vSize
1777
+ }
1778
+ ],
1779
+ style: panePopupStyle
1780
+ },
1781
+ defaultSlot
1782
+ ? $xeTable.callSlot(defaultSlot, params)
1783
+ : [
1784
+ !isAggRtBmLayout && !treeConfig && (aggregateConfig || rowGroupConfig) && $xeTable.getPivotTableAggregatePopupPanel
1785
+ ? h($xeTable.getPivotTableAggregatePopupPanel(), {
1786
+ customStore
1787
+ })
1788
+ : renderEmptyElement($xeTable),
1789
+ h(
1790
+ 'div',
1791
+ {
1792
+ ref: refCustomBodyElem,
1793
+ class: 'vxe-table-custom-popup--handle-wrapper'
1794
+ },
1795
+ [
1796
+ topSlot
1797
+ ? h(
1798
+ 'div',
1799
+ {
1800
+ class: 'vxe-table-custom-popup--table-top'
1801
+ },
1802
+ $xeTable.callSlot(topSlot, params)
1803
+ )
1804
+ : renderEmptyElement($xeTable),
1805
+ h(
1806
+ 'div',
1807
+ {
1808
+ class: 'vxe-table-custom-popup--table-wrapper'
1809
+ },
1810
+ [
1811
+ h('table', {}, [
1812
+ h('colgroup', {}, colVNs),
1813
+ h('thead', {}, [h('tr', {}, headVNs)]),
1814
+ h(
1815
+ TransitionGroup,
1816
+ {
1817
+ class: 'vxe-table-custom--panel-list',
1818
+ tag: 'tbody',
1819
+ name: 'vxe-table-custom--list'
1820
+ },
1821
+ {
1822
+ default: () => renderPopupBodys()
1823
+ }
1824
+ )
1825
+ ])
1826
+ ]
1827
+ ),
1828
+ bottomSlot
1829
+ ? h(
1830
+ 'div',
1831
+ {
1832
+ class: 'vxe-table-custom-popup--table-bottom'
1833
+ },
1834
+ $xeTable.callSlot(bottomSlot, params)
1835
+ )
1836
+ : renderEmptyElement($xeTable),
1837
+ renderDragTip()
1838
+ ]
1839
+ ),
1840
+ isAggRtBmLayout && !treeConfig && (aggregateConfig || rowGroupConfig) && $xeTable.getPivotTableAggregatePopupPanel
1841
+ ? h($xeTable.getPivotTableAggregatePopupPanel(), {
1842
+ customStore
1843
+ })
1844
+ : renderEmptyElement($xeTable)
1845
+ ]
1846
+ )
1847
+ },
1848
+ footer: () => {
1849
+ if (footerSlot) {
1850
+ return $xeTable.callSlot(footerSlot, params)
1851
+ }
1852
+ return h(
1853
+ 'div',
1854
+ {
1855
+ class: 'vxe-table-custom-popup--footer'
1856
+ },
1857
+ [
1858
+ VxeUIButtonComponent
1859
+ ? h(VxeUIButtonComponent, {
1860
+ content: customOpts.resetButtonText || getI18n('vxe.custom.cstmRestore'),
1861
+ disabled: !isCustomStatus,
1862
+ onClick: resetCustomEvent
1863
+ })
1864
+ : renderEmptyElement($xeTable),
1865
+ immediate
1866
+ ? VxeUIButtonComponent
1867
+ ? h(VxeUIButtonComponent, {
1868
+ status: 'primary',
1869
+ content: customOpts.closeButtonText || getI18n('vxe.table.customClose'),
1870
+ onClick: cancelCloseEvent
1871
+ })
1872
+ : renderEmptyElement($xeTable)
1873
+ : VxeUIButtonComponent
1874
+ ? h(VxeUIButtonComponent, {
1875
+ content: customOpts.cancelButtonText || getI18n('vxe.table.customCancel'),
1876
+ onClick: cancelCustomEvent
1877
+ })
1878
+ : renderEmptyElement($xeTable),
1879
+ immediate
1880
+ ? renderEmptyElement($xeTable)
1881
+ : VxeUIButtonComponent
1882
+ ? h(VxeUIButtonComponent, {
1883
+ status: 'primary',
1884
+ content: customOpts.confirmButtonText || getI18n('vxe.custom.cstmConfirm'),
1885
+ onClick: confirmCustomEvent
1886
+ })
1887
+ : renderEmptyElement($xeTable)
1888
+ ]
1889
+ )
1890
+ }
1891
+ }
1892
+ if (headerSlot) {
1893
+ scopedSlots.header = () => $xeTable.callSlot(headerSlot, params)
1894
+ }
1895
+ if (mode === 'drawer') {
1896
+ return VxeUIDrawerComponent
1897
+ ? h(
1898
+ VxeUIDrawerComponent,
1899
+ {
1900
+ key: 'drawer',
1901
+ className: ['vxe-table-custom-drawer-wrapper', 'vxe-table--ignore-clear', drawerOpts.className || ''].join(' '),
1902
+ modelValue: customStore.visible,
1903
+ title: drawerOpts.title || getI18n('vxe.custom.cstmTitle'),
1904
+ width: drawerOpts.width || Math.min(880, Math.floor(document.documentElement.clientWidth * 0.6)),
1905
+ position: drawerOpts.position,
1906
+ resize: !!drawerOpts.resize,
1907
+ escClosable: !!drawerOpts.escClosable,
1908
+ maskClosable: !!drawerOpts.maskClosable,
1909
+ destroyOnClose: true,
1910
+ showFooter: true,
1911
+ 'onUpdate:modelValue'(value: any) {
1912
+ customStore.visible = value
1913
+ }
1914
+ },
1915
+ scopedSlots
1916
+ )
1917
+ : renderEmptyElement($xeTable)
1918
+ }
1919
+ return VxeUIModalComponent
1920
+ ? h(
1921
+ VxeUIModalComponent,
1922
+ {
1923
+ key: 'modal',
1924
+ className: ['vxe-table-custom-modal-wrapper', 'vxe-table--ignore-clear', modalOpts.className || ''].join(' '),
1925
+ modelValue: customStore.visible,
1926
+ title: modalOpts.title || getI18n('vxe.custom.cstmTitle'),
1927
+ width: modalOpts.width || Math.min(1000, document.documentElement.clientWidth),
1928
+ minWidth: modalOpts.minWidth || 800,
1929
+ height: modalOpts.height || Math.min(680, document.documentElement.clientHeight),
1930
+ minHeight: modalOpts.minHeight || 400,
1931
+ showZoom: modalOpts.showZoom,
1932
+ showMaximize: modalOpts.showMaximize,
1933
+ showMinimize: modalOpts.showMinimize,
1934
+ mask: modalOpts.mask,
1935
+ lockView: modalOpts.lockView,
1936
+ resize: modalOpts.resize,
1937
+ transfer: modalOpts.transfer,
1938
+ escClosable: !!modalOpts.escClosable,
1939
+ maskClosable: !!modalOpts.maskClosable,
1940
+ destroyOnClose: true,
1941
+ showFooter: true,
1942
+ 'onUpdate:modelValue'(value: any) {
1943
+ customStore.visible = value
1944
+ }
1945
+ },
1946
+ scopedSlots
1947
+ )
1948
+ : renderEmptyElement($xeTable)
1949
+ }
1950
+
1951
+ const renderVN = () => {
1952
+ const customOpts = computeCustomOpts.value
1953
+ if (['modal', 'drawer', 'popup'].includes(`${customOpts.mode}`)) {
1954
+ return renderPopupPanel()
1955
+ }
1956
+ return renderSimplePanel()
1957
+ }
1958
+
1959
+ nextTick(() => {
1960
+ const customOpts = computeCustomOpts.value
1961
+ const { mode } = customOpts
1962
+ if (!VxeUIModalComponent && mode === 'modal') {
1963
+ errLog('vxe.error.reqComp', ['vxe-modal'])
1964
+ }
1965
+ if (!VxeUIDrawerComponent && mode === 'drawer') {
1966
+ errLog('vxe.error.reqComp', ['vxe-drawer'])
1967
+ }
1968
+ if (!VxeUIButtonComponent) {
1969
+ errLog('vxe.error.reqComp', ['vxe-button'])
1970
+ }
1971
+ if (!VxeUINumberInputComponent) {
1972
+ errLog('vxe.error.reqComp', ['vxe-number-input'])
1973
+ }
1974
+ if (!VxeUIRadioGroupComponent) {
1975
+ errLog('vxe.error.reqComp', ['vxe-radio-group'])
1976
+ }
1977
+ })
1978
+
1979
+ const $xeTableCustomPanel: VxeTableCustomPanelConstructor = {
1980
+ xID,
1981
+ props,
1982
+ context,
1983
+ reactData: customPanelReactData,
1984
+ internalData: customPanelInternalData,
1985
+ xeTable: $xeTable,
1986
+ getRefMaps: () => refMaps,
1987
+ getComputeMaps: () => computeMaps,
1988
+ renderVN
1989
+ }
1990
+
1991
+ onUnmounted(() => {
1992
+ customPanelInternalData = createInternalData()
1993
+ })
1994
+
1995
+ provide('$xeTableCustomPanel', $xeTableCustomPanel)
1996
+
1997
+ return $xeTableCustomPanel
1998
+ },
1999
+ render() {
2000
+ return this.renderVN()
2001
+ }
2002
+ })