vxe-table 4.23.19 → 4.23.20

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 (124) hide show
  1. package/dist/all.esm.js +283 -251
  2. package/dist/all.esm.min.js +3 -3
  3. package/dist/style.css +4 -1
  4. package/dist/style.mini.css +1 -1
  5. package/es/components.d.ts +1 -3
  6. package/es/components.js +1 -2
  7. package/es/esm.index.d.ts +7 -0
  8. package/es/esm.index.js +8 -0
  9. package/es/style.css +4 -1
  10. package/es/style.mini.css +1 -1
  11. package/es/table/style.css +4 -1
  12. package/es/table/style.mini.css +1 -1
  13. package/es/ui/abandon.d.ts +82 -0
  14. package/es/ui/abandon.js +90 -0
  15. package/es/ui/index.d.ts +1 -83
  16. package/es/ui/index.js +2 -89
  17. package/es/ui/src/log.js +1 -1
  18. package/es/vxe-table/style.css +4 -1
  19. package/es/vxe-table/style.mini.css +1 -1
  20. package/lib/components.d.ts +1 -3
  21. package/lib/components.js +1 -2
  22. package/lib/esm.index.d.ts +7 -0
  23. package/lib/esm.index.js +39 -0
  24. package/lib/index.umd.js +248 -247
  25. package/lib/index.umd.min.js +3 -3
  26. package/lib/style.css +4 -1
  27. package/lib/style.mini.css +1 -1
  28. package/lib/table/style/style.css +4 -1
  29. package/lib/table/style/style.mini.css +1 -1
  30. package/lib/ui/abandon.d.ts +82 -0
  31. package/lib/ui/abandon.js +110 -0
  32. package/lib/ui/index.d.ts +1 -83
  33. package/lib/ui/index.js +3 -89
  34. package/lib/ui/src/log.js +1 -1
  35. package/lib/vxe-table/style/style.css +4 -1
  36. package/lib/vxe-table/style/style.mini.css +1 -1
  37. package/package.json +1 -1
  38. package/packages/colgroup/index.ts +22 -22
  39. package/packages/column/index.ts +22 -22
  40. package/packages/components.ts +42 -45
  41. package/packages/esm.index.ts +10 -0
  42. package/packages/grid/index.ts +18 -18
  43. package/packages/grid/src/emits.ts +5 -5
  44. package/packages/grid/src/grid.ts +2220 -2220
  45. package/packages/grid/src/props.ts +22 -22
  46. package/packages/index.ts +13 -13
  47. package/packages/locale/lang/ar-EG.ts +914 -914
  48. package/packages/locale/lang/de-DE.ts +914 -914
  49. package/packages/locale/lang/en-US.ts +914 -914
  50. package/packages/locale/lang/es-ES.ts +914 -914
  51. package/packages/locale/lang/fr-FR.ts +914 -914
  52. package/packages/locale/lang/hu-HU.ts +914 -914
  53. package/packages/locale/lang/hy-AM.ts +914 -914
  54. package/packages/locale/lang/id-ID.ts +914 -914
  55. package/packages/locale/lang/it-IT.ts +914 -914
  56. package/packages/locale/lang/ja-JP.ts +914 -914
  57. package/packages/locale/lang/ko-KR.ts +914 -914
  58. package/packages/locale/lang/ms-MY.ts +914 -914
  59. package/packages/locale/lang/nb-NO.ts +914 -914
  60. package/packages/locale/lang/pt-BR.ts +914 -914
  61. package/packages/locale/lang/ru-RU.ts +914 -914
  62. package/packages/locale/lang/th-TH.ts +914 -914
  63. package/packages/locale/lang/ug-CN.ts +914 -914
  64. package/packages/locale/lang/uk-UA.ts +914 -914
  65. package/packages/locale/lang/uz-UZ.ts +914 -914
  66. package/packages/locale/lang/vi-VN.ts +914 -914
  67. package/packages/locale/lang/zh-CHT.ts +914 -914
  68. package/packages/locale/lang/zh-CN.ts +914 -914
  69. package/packages/locale/lang/zh-HK.ts +914 -914
  70. package/packages/locale/lang/zh-MO.ts +914 -914
  71. package/packages/locale/lang/zh-TC.ts +914 -914
  72. package/packages/locale/lang/zh-TW.ts +914 -914
  73. package/packages/table/index.ts +26 -26
  74. package/packages/table/module/custom/hook.ts +510 -510
  75. package/packages/table/module/custom/panel.ts +2002 -2002
  76. package/packages/table/module/edit/hook.ts +1232 -1232
  77. package/packages/table/module/export/export-panel.ts +697 -697
  78. package/packages/table/module/export/hook.ts +2158 -2158
  79. package/packages/table/module/export/import-panel.ts +319 -319
  80. package/packages/table/module/export/util.ts +25 -25
  81. package/packages/table/module/filter/hook.ts +505 -505
  82. package/packages/table/module/filter/panel.ts +368 -368
  83. package/packages/table/module/keyboard/hook.ts +498 -498
  84. package/packages/table/module/menu/hook.ts +330 -330
  85. package/packages/table/module/menu/panel.ts +272 -272
  86. package/packages/table/module/validator/hook.ts +653 -653
  87. package/packages/table/render/index.ts +1819 -1819
  88. package/packages/table/src/body.ts +1078 -1078
  89. package/packages/table/src/cell.ts +1524 -1524
  90. package/packages/table/src/column.ts +192 -192
  91. package/packages/table/src/columnInfo.ts +232 -232
  92. package/packages/table/src/emits.ts +134 -134
  93. package/packages/table/src/footer.ts +425 -425
  94. package/packages/table/src/group.ts +67 -67
  95. package/packages/table/src/header.ts +661 -661
  96. package/packages/table/src/props.ts +336 -336
  97. package/packages/table/src/store.ts +14 -14
  98. package/packages/table/src/use/cell-view.ts +41 -41
  99. package/packages/table/src/use/index.ts +1 -1
  100. package/packages/table/src/util.ts +1206 -1206
  101. package/packages/toolbar/index.ts +18 -18
  102. package/packages/toolbar/src/toolbar.ts +768 -768
  103. package/packages/ui/abandon.ts +136 -0
  104. package/packages/ui/index.ts +404 -524
  105. package/packages/ui/src/anime.ts +51 -51
  106. package/packages/ui/src/comp.ts +3 -3
  107. package/packages/ui/src/dom.ts +466 -466
  108. package/packages/ui/src/log.ts +19 -19
  109. package/packages/ui/src/utils.ts +66 -66
  110. package/packages/ui/src/vn.ts +55 -55
  111. package/packages/v-x-e-table/index.d.ts +3 -3
  112. package/packages/v-x-e-table/index.ts +3 -3
  113. package/styles/components/table.scss +2 -1
  114. package/types/all.d.ts +76 -76
  115. package/types/index.d.ts +4 -4
  116. /package/dist/{iconfont.1794474448348.ttf → iconfont.1794633824975.ttf} +0 -0
  117. /package/dist/{iconfont.1794474448348.woff → iconfont.1794633824975.woff} +0 -0
  118. /package/dist/{iconfont.1794474448348.woff2 → iconfont.1794633824975.woff2} +0 -0
  119. /package/es/{iconfont.1794474448348.ttf → iconfont.1794633824975.ttf} +0 -0
  120. /package/es/{iconfont.1794474448348.woff → iconfont.1794633824975.woff} +0 -0
  121. /package/es/{iconfont.1794474448348.woff2 → iconfont.1794633824975.woff2} +0 -0
  122. /package/lib/{iconfont.1794474448348.ttf → iconfont.1794633824975.ttf} +0 -0
  123. /package/lib/{iconfont.1794474448348.woff → iconfont.1794633824975.woff} +0 -0
  124. /package/lib/{iconfont.1794474448348.woff2 → iconfont.1794633824975.woff2} +0 -0
@@ -1,2002 +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 /* define-vxe-component start */ 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
- }) /* define-vxe-component end */
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 /* define-vxe-component start */ 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
+ }) /* define-vxe-component end */