vxe-table 4.19.0-beta.2 → 4.19.0-beta.3

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 (121) hide show
  1. package/LICENSE +20 -20
  2. package/README.en.md +118 -118
  3. package/README.ja-JP.md +117 -117
  4. package/README.md +268 -268
  5. package/README.zh-TW.md +117 -117
  6. package/es/style.css +1 -1
  7. package/es/table/render/index.js +1 -1
  8. package/es/ui/index.js +1 -1
  9. package/es/ui/src/log.js +1 -1
  10. package/lib/index.umd.js +2767 -2851
  11. package/lib/index.umd.min.js +1 -1
  12. package/lib/style.css +1 -1
  13. package/lib/table/render/index.js +1 -1
  14. package/lib/table/render/index.min.js +1 -1
  15. package/lib/ui/index.js +1 -1
  16. package/lib/ui/index.min.js +1 -1
  17. package/lib/ui/src/log.js +1 -1
  18. package/lib/ui/src/log.min.js +1 -1
  19. package/package.json +92 -92
  20. package/packages/colgroup/index.ts +22 -22
  21. package/packages/column/index.ts +22 -22
  22. package/packages/components.ts +43 -43
  23. package/packages/grid/index.ts +18 -18
  24. package/packages/grid/src/emits.ts +19 -19
  25. package/packages/grid/src/grid.ts +1768 -1768
  26. package/packages/grid/src/props.ts +23 -23
  27. package/packages/index.ts +4 -4
  28. package/packages/locale/lang/ar-EG.ts +840 -840
  29. package/packages/locale/lang/de-DE.ts +840 -840
  30. package/packages/locale/lang/en-US.ts +840 -840
  31. package/packages/locale/lang/es-ES.ts +840 -840
  32. package/packages/locale/lang/fr-FR.ts +840 -840
  33. package/packages/locale/lang/hu-HU.ts +840 -840
  34. package/packages/locale/lang/hy-AM.ts +840 -840
  35. package/packages/locale/lang/id-ID.ts +840 -840
  36. package/packages/locale/lang/it-IT.ts +840 -840
  37. package/packages/locale/lang/ja-JP.ts +840 -840
  38. package/packages/locale/lang/ko-KR.ts +840 -840
  39. package/packages/locale/lang/ms-MY.ts +840 -840
  40. package/packages/locale/lang/nb-NO.ts +840 -840
  41. package/packages/locale/lang/pt-BR.ts +840 -840
  42. package/packages/locale/lang/ru-RU.ts +840 -840
  43. package/packages/locale/lang/th-TH.ts +840 -840
  44. package/packages/locale/lang/ug-CN.ts +840 -840
  45. package/packages/locale/lang/uk-UA.ts +840 -840
  46. package/packages/locale/lang/uz-UZ.ts +840 -840
  47. package/packages/locale/lang/vi-VN.ts +840 -840
  48. package/packages/locale/lang/zh-CHT.ts +840 -840
  49. package/packages/locale/lang/zh-CN.ts +840 -840
  50. package/packages/locale/lang/zh-HK.ts +3 -3
  51. package/packages/locale/lang/zh-MO.ts +3 -3
  52. package/packages/locale/lang/zh-TC.ts +3 -3
  53. package/packages/locale/lang/zh-TW.ts +3 -3
  54. package/packages/table/index.ts +26 -26
  55. package/packages/table/module/custom/hook.ts +422 -422
  56. package/packages/table/module/custom/panel.ts +1512 -1512
  57. package/packages/table/module/edit/hook.ts +1064 -1064
  58. package/packages/table/module/export/export-panel.ts +567 -567
  59. package/packages/table/module/export/hook.ts +1654 -1654
  60. package/packages/table/module/export/import-panel.ts +266 -266
  61. package/packages/table/module/export/util.ts +24 -24
  62. package/packages/table/module/filter/hook.ts +468 -468
  63. package/packages/table/module/filter/panel.ts +301 -301
  64. package/packages/table/module/keyboard/hook.ts +494 -494
  65. package/packages/table/module/menu/hook.ts +325 -325
  66. package/packages/table/module/menu/panel.ts +201 -201
  67. package/packages/table/module/validator/hook.ts +631 -631
  68. package/packages/table/render/index.ts +1440 -1440
  69. package/packages/table/src/body.ts +935 -935
  70. package/packages/table/src/cell.ts +1290 -1290
  71. package/packages/table/src/column.ts +190 -190
  72. package/packages/table/src/columnInfo.ts +225 -225
  73. package/packages/table/src/emits.ts +125 -125
  74. package/packages/table/src/footer.ts +368 -368
  75. package/packages/table/src/group.ts +59 -59
  76. package/packages/table/src/header.ts +561 -561
  77. package/packages/table/src/props.ts +324 -324
  78. package/packages/table/src/store.ts +14 -14
  79. package/packages/table/src/table.ts +14274 -14274
  80. package/packages/table/src/use/cell-view.ts +44 -44
  81. package/packages/table/src/use/index.ts +1 -1
  82. package/packages/table/src/util.ts +1086 -1086
  83. package/packages/toolbar/index.ts +18 -18
  84. package/packages/toolbar/src/toolbar.ts +701 -701
  85. package/packages/ui/index.ts +532 -532
  86. package/packages/ui/src/anime.ts +52 -52
  87. package/packages/ui/src/comp.ts +3 -3
  88. package/packages/ui/src/dom.ts +264 -264
  89. package/packages/ui/src/log.ts +8 -8
  90. package/packages/ui/src/utils.ts +56 -56
  91. package/packages/ui/src/vn.ts +55 -55
  92. package/packages/v-x-e-table/index.d.ts +4 -4
  93. package/packages/v-x-e-table/index.ts +4 -4
  94. package/styles/all.scss +7 -7
  95. package/styles/base.scss +16 -16
  96. package/styles/components/grid.scss +89 -89
  97. package/styles/components/icon.scss +225 -225
  98. package/styles/components/old-icon.scss +715 -715
  99. package/styles/components/table-module/all.scss +6 -6
  100. package/styles/components/table-module/custom.scss +550 -550
  101. package/styles/components/table-module/export.scss +130 -130
  102. package/styles/components/table-module/filter.scss +130 -130
  103. package/styles/components/table-module/menu.scss +81 -81
  104. package/styles/components/table.scss +2679 -2679
  105. package/styles/components/toolbar.scss +119 -119
  106. package/styles/default.scss +2 -2
  107. package/styles/helpers/baseMixin.scss +95 -95
  108. package/styles/index.scss +4 -4
  109. package/styles/modules.scss +5 -5
  110. package/styles/theme/base.scss +93 -93
  111. package/styles/theme/dark.scss +49 -49
  112. package/styles/theme/light.scss +44 -44
  113. package/styles/variable.scss +43 -43
  114. package/types/all.d.ts +37 -37
  115. package/types/index.d.ts +4 -4
  116. /package/es/{iconfont.1778157083004.ttf → iconfont.1778318183872.ttf} +0 -0
  117. /package/es/{iconfont.1778157083004.woff → iconfont.1778318183872.woff} +0 -0
  118. /package/es/{iconfont.1778157083004.woff2 → iconfont.1778318183872.woff2} +0 -0
  119. /package/lib/{iconfont.1778157083004.ttf → iconfont.1778318183872.ttf} +0 -0
  120. /package/lib/{iconfont.1778157083004.woff → iconfont.1778318183872.woff} +0 -0
  121. /package/lib/{iconfont.1778157083004.woff2 → iconfont.1778318183872.woff2} +0 -0
@@ -1,1512 +1,1512 @@
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 '../../../ui'
4
- import { formatText } from '../../../ui/src/utils'
5
- import { getTpImg, addClass, removeClass, hasControlKey } from '../../../ui/src/dom'
6
- import { errLog } 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 { getI18n, getIcon, renderEmptyElement } = VxeUI
13
-
14
- export function createInternalData (): TableCustomPanelInternalData {
15
- return {
16
- // teleportTo: undefined,
17
- // prevDragCol: undefined,
18
- // prevDragGroupField: undefined,
19
- // prevDragAggFnColid: undefined,
20
- // prevDragToChild: false,
21
- // prevDragPos: null,
22
- // customDragTime: null
23
- }
24
- }
25
-
26
- export default defineVxeComponent({
27
- name: 'TableCustomPanel',
28
- props: {
29
- customStore: {
30
- type: Object as PropType<VxeTableDefines.VxeTableCustomStoreObj>,
31
- default: () => ({} as VxeTableDefines.VxeTableCustomStoreObj)
32
- }
33
- },
34
- setup (props, context) {
35
- const xID = XEUtils.uniqueId()
36
-
37
- const VxeUIModalComponent = VxeUI.getComponent('VxeModal')
38
- const VxeUIDrawerComponent = VxeUI.getComponent('VxeDrawer')
39
- const VxeUIButtonComponent = VxeUI.getComponent('VxeButton')
40
- const VxeUINumberInputComponent = VxeUI.getComponent('VxeNumberInput')
41
- const VxeUIRadioGroupComponent = VxeUI.getComponent('VxeRadioGroup')
42
-
43
- const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods)
44
-
45
- const { props: tableProps, reactData: tableReactData, internalData: tableInternalData } = $xeTable
46
- const { computeSize, computeCustomOpts, computeColumnDragOpts, computeColumnOpts, computeIsMaxFixedColumn, computeResizableOpts } = $xeTable.getComputeMaps()
47
-
48
- const refElem = ref() as Ref<HTMLDivElement>
49
- const refBodyWrapperElem = ref() as Ref<HTMLDivElement>
50
- const refCustomBodyElem = ref() as Ref<HTMLDivElement>
51
- const refDragLineElem = ref() as Ref<HTMLDivElement>
52
- const refDragTipElem = ref() as Ref<HTMLDivElement>
53
-
54
- const customPanelReactData = reactive<TableCustomPanelReactData>({
55
- dragCol: null,
56
- dragGroupField: null,
57
- dragAggFnCol: null,
58
- dragTipText: ''
59
- })
60
-
61
- let customPanelInternalData = createInternalData()
62
-
63
- const refMaps: TableCustomPanelPrivateRef = {
64
- refElem,
65
- refBodyWrapperElem,
66
- refCustomBodyElem,
67
- refDragLineElem,
68
- refDragTipElem
69
- }
70
-
71
- const computeMaps: TableCustomPanelPrivateComputed = {
72
- }
73
-
74
- const handleWrapperMouseenterEvent = (evnt: Event) => {
75
- const { customStore } = props
76
- customStore.activeWrapper = true
77
- $xeTable.customOpenEvent(evnt)
78
- }
79
-
80
- const handleWrapperMouseleaveEvent = (evnt: Event) => {
81
- const { customStore } = props
82
- customStore.activeWrapper = false
83
- setTimeout(() => {
84
- if (!customStore.activeBtn && !customStore.activeWrapper) {
85
- $xeTable.customCloseEvent(evnt)
86
- }
87
- }, 300)
88
- }
89
-
90
- const confirmCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
91
- tableReactData.isCustomStatus = true
92
- $xeTable.saveCustom()
93
- $xeTable.closeCustom()
94
- $xeTable.emitCustomEvent('confirm', $event)
95
- $xeTable.emitCustomEvent('close', $event)
96
- }
97
-
98
- const cancelCloseEvent: VxeButtonEvents.Click = ({ $event }) => {
99
- $xeTable.closeCustom()
100
- $xeTable.emitCustomEvent('close', $event)
101
- }
102
-
103
- const cancelCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
104
- $xeTable.cancelCustom()
105
- $xeTable.closeCustom()
106
- $xeTable.emitCustomEvent('cancel', $event)
107
- $xeTable.emitCustomEvent('close', $event)
108
- }
109
-
110
- const handleResetCustomEvent = (evnt: Event) => {
111
- $xeTable.resetCustom(true)
112
- $xeTable.closeCustom()
113
- $xeTable.emitCustomEvent('reset', evnt)
114
- $xeTable.emitCustomEvent('close', evnt)
115
- }
116
-
117
- const resetCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
118
- if (VxeUI.modal) {
119
- VxeUI.modal.confirm({
120
- content: getI18n('vxe.custom.cstmConfirmRestore'),
121
- className: 'vxe-table--ignore-clear',
122
- escClosable: true
123
- }).then(type => {
124
- if (type === 'confirm') {
125
- handleResetCustomEvent($event)
126
- }
127
- })
128
- } else {
129
- handleResetCustomEvent($event)
130
- }
131
- }
132
-
133
- const handleOptionCheck = (column: VxeTableDefines.ColumnInfo) => {
134
- const { customColumnList } = tableReactData
135
- const matchObj = XEUtils.findTree(customColumnList, item => item === column)
136
- if (matchObj && matchObj.parent) {
137
- const { parent: parentItem } = matchObj
138
- if (parentItem.children && parentItem.children.length) {
139
- parentItem.renderVisible = parentItem.children.every((column) => column.renderVisible)
140
- parentItem.halfVisible = !parentItem.renderVisible && parentItem.children.some((column) => column.renderVisible || column.halfVisible)
141
- handleOptionCheck(parentItem)
142
- }
143
- }
144
- }
145
-
146
- const changeCheckboxOption = (column: VxeTableDefines.ColumnInfo, evnt: MouseEvent) => {
147
- const isChecked = !column.renderVisible
148
- const customOpts = computeCustomOpts.value
149
- if (customOpts.immediate) {
150
- XEUtils.eachTree([column], (item) => {
151
- item.visible = isChecked
152
- item.renderVisible = isChecked
153
- item.halfVisible = false
154
- })
155
- tableReactData.isCustomStatus = true
156
- $xeTable.handleCustom()
157
- $xeTable.saveCustomStore('update:visible')
158
- } else {
159
- XEUtils.eachTree([column], (item) => {
160
- item.renderVisible = isChecked
161
- item.halfVisible = false
162
- })
163
- }
164
- handleOptionCheck(column)
165
- $xeTable.checkCustomStatus()
166
- $xeTable.dispatchEvent('custom-visible-change', { column, checked: isChecked }, evnt)
167
- }
168
-
169
- const changeColumnWidth = (column: VxeTableDefines.ColumnInfo) => {
170
- const customOpts = computeCustomOpts.value
171
- if (customOpts.immediate) {
172
- if (column.renderResizeWidth !== column.renderWidth) {
173
- column.resizeWidth = column.renderResizeWidth
174
- column.renderWidth = column.renderResizeWidth
175
- tableReactData.isCustomStatus = true
176
- $xeTable.handleCustom()
177
- $xeTable.saveCustomStore('update:width')
178
- }
179
- }
180
- }
181
-
182
- const changeFixedOption = (column: VxeTableDefines.ColumnInfo, colFixed: VxeColumnPropTypes.Fixed, evnt: Event) => {
183
- const isMaxFixedColumn = computeIsMaxFixedColumn.value
184
- const customOpts = computeCustomOpts.value
185
- let targetFixed: VxeColumnPropTypes.Fixed = null
186
- if (customOpts.immediate) {
187
- if (column.renderFixed === colFixed) {
188
- targetFixed = ''
189
- XEUtils.eachTree([column], col => {
190
- col.fixed = ''
191
- col.renderFixed = ''
192
- })
193
- } else {
194
- if (!isMaxFixedColumn || column.renderFixed) {
195
- targetFixed = colFixed
196
- XEUtils.eachTree([column], col => {
197
- col.fixed = colFixed
198
- col.renderFixed = colFixed
199
- })
200
- }
201
- }
202
- tableReactData.isCustomStatus = true
203
- $xeTable.handleCustom()
204
- $xeTable.saveCustomStore('update:fixed')
205
- } else {
206
- if (column.renderFixed === colFixed) {
207
- targetFixed = ''
208
- XEUtils.eachTree([column], col => {
209
- col.renderFixed = ''
210
- })
211
- } else {
212
- if (!isMaxFixedColumn || column.renderFixed) {
213
- targetFixed = colFixed
214
- XEUtils.eachTree([column], col => {
215
- col.renderFixed = colFixed
216
- })
217
- }
218
- }
219
- }
220
- if (targetFixed !== null) {
221
- $xeTable.dispatchEvent('custom-fixed-change', { column, fixed: targetFixed }, evnt)
222
- }
223
- }
224
-
225
- const allOptionEvent = (evnt: MouseEvent) => {
226
- const { customStore } = tableReactData
227
- const isAll = !customStore.isAll
228
- $xeTable.toggleCustomAllCheckbox()
229
- $xeTable.dispatchEvent('custom-visible-all', { checked: isAll }, evnt)
230
- }
231
-
232
- const showDropTip = (evnt: DragEvent | MouseEvent, optEl: HTMLElement | null, showLine: boolean, dragPos: string) => {
233
- const bodyWrapperElem = refBodyWrapperElem.value
234
- if (!bodyWrapperElem) {
235
- return
236
- }
237
- const customBodyElem = refCustomBodyElem.value
238
- if (!customBodyElem) {
239
- return
240
- }
241
- const { prevDragToChild } = customPanelInternalData
242
- const bodyWrapperRect = bodyWrapperElem.getBoundingClientRect()
243
- const customBodyRect = customBodyElem.getBoundingClientRect()
244
- const dragLineEl = refDragLineElem.value
245
- if (optEl) {
246
- if (dragLineEl) {
247
- if (showLine) {
248
- const optRect = optEl.getBoundingClientRect()
249
- dragLineEl.style.display = 'block'
250
- dragLineEl.style.left = `${Math.max(0, customBodyRect.x - bodyWrapperRect.x)}px`
251
- dragLineEl.style.top = `${Math.max(1, optRect.y + bodyWrapperElem.scrollTop - bodyWrapperRect.y)}px`
252
- dragLineEl.style.height = `${optRect.height}px`
253
- dragLineEl.style.width = `${optRect.width}px`
254
- dragLineEl.setAttribute('drag-pos', dragPos)
255
- dragLineEl.setAttribute('drag-to-child', prevDragToChild ? 'y' : 'n')
256
- } else {
257
- dragLineEl.style.display = ''
258
- }
259
- }
260
- } else {
261
- if (dragLineEl) {
262
- dragLineEl.style.display = 'node'
263
- }
264
- }
265
- const dragTipEl = refDragTipElem.value
266
- if (dragTipEl) {
267
- dragTipEl.style.display = 'block'
268
- dragTipEl.style.top = `${Math.min(bodyWrapperElem.clientHeight + bodyWrapperElem.scrollTop - dragTipEl.clientHeight, evnt.clientY + bodyWrapperElem.scrollTop - bodyWrapperRect.y)}px`
269
- dragTipEl.style.left = `${Math.min(bodyWrapperElem.clientWidth + bodyWrapperElem.scrollLeft - dragTipEl.clientWidth, evnt.clientX + bodyWrapperElem.scrollLeft - bodyWrapperRect.x)}px`
270
- dragTipEl.setAttribute('drag-status', showLine ? (prevDragToChild ? 'sub' : 'normal') : 'disabled')
271
- }
272
- }
273
-
274
- const updateColDropTipContent = () => {
275
- const { dragCol } = customPanelReactData
276
- const columnDragOpts = computeColumnDragOpts.value
277
- const { tooltipMethod } = columnDragOpts
278
- let tipContent = ''
279
- if (tooltipMethod) {
280
- const dtParams = {
281
- $table: $xeTable,
282
- column: dragCol as VxeTableDefines.ColumnInfo
283
- }
284
- tipContent = `${tooltipMethod(dtParams) || ''}`
285
- } else {
286
- tipContent = getI18n('vxe.custom.cstmDragTarget', [dragCol && dragCol.type !== 'html' ? dragCol.getTitle() : ''])
287
- }
288
- customPanelReactData.dragTipText = tipContent
289
- }
290
-
291
- const hideDropTip = () => {
292
- const dragTipEl = refDragTipElem.value
293
- const dragLineEl = refDragLineElem.value
294
- if (dragTipEl) {
295
- dragTipEl.style.display = ''
296
- }
297
- if (dragLineEl) {
298
- dragLineEl.style.display = ''
299
- }
300
- }
301
-
302
- const sortMousedownEvent = (evnt: DragEvent) => {
303
- const btnEl = evnt.currentTarget as HTMLElement
304
- const cellEl = btnEl.parentElement as HTMLElement
305
- const tdEl = cellEl.parentElement as HTMLElement
306
- const trEl = tdEl.parentElement as HTMLElement
307
- const colid = trEl.getAttribute('colid')
308
- const column = $xeTable.getColumnById(colid)
309
- trEl.draggable = true
310
- customPanelReactData.dragCol = column
311
- customPanelReactData.dragGroupField = null
312
- customPanelReactData.dragAggFnCol = null
313
- updateColDropTipContent()
314
- addClass(trEl, 'active--drag-origin')
315
- }
316
-
317
- const sortMouseupEvent = (evnt: MouseEvent) => {
318
- const btnEl = evnt.currentTarget as HTMLElement
319
- const cellEl = btnEl.parentElement as HTMLElement
320
- const tdEl = cellEl.parentElement as HTMLElement
321
- const trEl = tdEl.parentElement as HTMLElement
322
- hideDropTip()
323
- trEl.draggable = false
324
- customPanelReactData.dragCol = null
325
- customPanelReactData.dragGroupField = null
326
- customPanelReactData.dragAggFnCol = null
327
- removeClass(trEl, 'active--drag-origin')
328
- }
329
-
330
- const sortDragstartEvent = (evnt: DragEvent) => {
331
- const { customDragTime } = customPanelInternalData
332
- if (evnt.dataTransfer) {
333
- evnt.dataTransfer.setDragImage(getTpImg(), 0, 0)
334
- }
335
- if (customDragTime) {
336
- clearTimeout(customDragTime)
337
- }
338
- tableReactData.isCustomDragStatus = true
339
- customPanelInternalData.prevDragGroupField = null
340
- customPanelInternalData.prevDragAggFnColid = null
341
- }
342
-
343
- const sortDragendEvent = (evnt: DragEvent) => {
344
- const { mouseConfig } = tableProps
345
- const { customColumnList } = tableReactData
346
- const { collectColumn } = tableInternalData
347
- const customOpts = computeCustomOpts.value
348
- const { immediate } = customOpts
349
- const trEl = evnt.currentTarget as HTMLElement
350
- const columnDragOpts = computeColumnDragOpts.value
351
- const { isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod } = columnDragOpts
352
- const { dragCol } = customPanelReactData
353
- const { prevDragCol, prevDragGroupField, prevDragAggFnColid, prevDragPos, prevDragToChild } = customPanelInternalData
354
- const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
355
-
356
- if (prevDragGroupField || prevDragAggFnColid) {
357
- if ($xeTable.handlePivotTableAggregatePanelDragendEvent) {
358
- $xeTable.handlePivotTableAggregatePanelDragendEvent(evnt)
359
- }
360
- } else if (prevDragCol && dragCol) {
361
- // 判断是否有拖动
362
- if (prevDragCol !== dragCol) {
363
- const dragColumn = dragCol
364
- const newColumn = prevDragCol
365
- Promise.resolve(
366
- dragEndMethod
367
- ? dragEndMethod({
368
- oldColumn: dragColumn,
369
- newColumn,
370
- dragColumn,
371
- dragPos: prevDragPos as any,
372
- dragToChild: !!prevDragToChild,
373
- offsetIndex: dragOffsetIndex
374
- })
375
- : true
376
- ).then((status) => {
377
- if (!status) {
378
- return
379
- }
380
-
381
- let oafIndex = -1
382
- let nafIndex = -1
383
-
384
- const oldAllMaps: Record<string, any> = {}
385
- XEUtils.eachTree([dragColumn], column => {
386
- oldAllMaps[column.id] = column
387
- })
388
-
389
- let isSelfToChildStatus = false
390
-
391
- // 只有实时拖拽支持跨层级
392
- if (immediate) {
393
- if (dragColumn.parentId && newColumn.parentId) {
394
- // 子到子
395
-
396
- if (!isCrossDrag) {
397
- return
398
- }
399
- if (oldAllMaps[newColumn.id]) {
400
- isSelfToChildStatus = true
401
- if (!(isCrossDrag && isSelfToChildDrag)) {
402
- if (VxeUI.modal) {
403
- VxeUI.modal.message({
404
- status: 'error',
405
- content: getI18n('vxe.error.treeDragChild')
406
- })
407
- }
408
- return
409
- }
410
- }
411
- } else if (dragColumn.parentId) {
412
- // 子到根
413
-
414
- if (!isCrossDrag) {
415
- return
416
- }
417
- } else if (newColumn.parentId) {
418
- // 根到子
419
-
420
- if (!isCrossDrag) {
421
- return
422
- }
423
- if (oldAllMaps[newColumn.id]) {
424
- isSelfToChildStatus = true
425
- if (!(isCrossDrag && isSelfToChildDrag)) {
426
- if (VxeUI.modal) {
427
- VxeUI.modal.message({
428
- status: 'error',
429
- content: getI18n('vxe.error.treeDragChild')
430
- })
431
- }
432
- return
433
- }
434
- }
435
- } else {
436
- // 根到根
437
- }
438
-
439
- const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id)
440
-
441
- // 改变层级
442
- if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
443
- if (oldewMatchRest) {
444
- const { items: oCols, index: oIndex } = oldewMatchRest
445
- const childList = dragColumn.children || []
446
- childList.forEach(column => {
447
- column.parentId = dragColumn.parentId
448
- })
449
- oCols.splice(oIndex, 1, ...childList)
450
- dragColumn.children = []
451
- }
452
- } else {
453
- if (oldewMatchRest) {
454
- const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest
455
- oCols.splice(oIndex, 1)
456
- if (!oParent) {
457
- oafIndex = oIndex
458
- }
459
- }
460
- }
461
-
462
- const newMatchRest = XEUtils.findTree(collectColumn, item => item.id === newColumn.id)
463
- if (newMatchRest) {
464
- const { items: nCols, index: nIndex, parent: nParent } = newMatchRest
465
- // 转子级
466
- if ((isCrossDrag && isToChildDrag) && prevDragToChild) {
467
- dragColumn.parentId = newColumn.id
468
- newColumn.children = (newColumn.children || []).concat([dragColumn])
469
- } else {
470
- dragColumn.parentId = newColumn.parentId
471
- nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn)
472
- }
473
- if (!nParent) {
474
- nafIndex = nIndex
475
- }
476
- }
477
-
478
- XEUtils.eachTree(collectColumn, (column, index, items, path, parentItem) => {
479
- if (!parentItem) {
480
- const sortIndex = index + 1
481
- column.renderSortNumber = sortIndex
482
- }
483
- })
484
- } else {
485
- oafIndex = XEUtils.findIndexOf(customColumnList, item => item.id === dragColumn.id)
486
- customColumnList.splice(oafIndex, 1)
487
-
488
- nafIndex = XEUtils.findIndexOf(customColumnList, item => item.id === newColumn.id)
489
- customColumnList.splice(nafIndex + dragOffsetIndex, 0, dragColumn)
490
- }
491
-
492
- if (mouseConfig) {
493
- if ($xeTable.clearSelected) {
494
- $xeTable.clearSelected()
495
- }
496
- if ($xeTable.clearCellAreas) {
497
- $xeTable.clearCellAreas()
498
- $xeTable.clearCopyCellArea()
499
- }
500
- }
501
-
502
- const csParams = {
503
- oldColumn: dragColumn,
504
- newColumn,
505
- dragColumn,
506
- dragPos: prevDragPos,
507
- offsetIndex: dragOffsetIndex,
508
- _index: {
509
- newIndex: nafIndex,
510
- oldIndex: oafIndex
511
- }
512
- }
513
- $xeTable.dispatchEvent('custom-sort-change', csParams, evnt)
514
- $xeTable.dispatchEvent('column-dragend', csParams, evnt)
515
-
516
- if (immediate) {
517
- tableReactData.customColumnList = collectColumn.slice(0)
518
- $xeTable.handleColDragSwapColumn()
519
- }
520
- clearDragAnimateStatus()
521
- }).catch(() => {
522
- })
523
- }
524
- }
525
-
526
- hideDropTip()
527
- customPanelReactData.dragCol = null
528
- customPanelReactData.dragGroupField = null
529
- customPanelReactData.dragAggFnCol = null
530
- customPanelInternalData.prevDragGroupField = null
531
- customPanelInternalData.prevDragAggFnColid = null
532
- trEl.draggable = false
533
- trEl.removeAttribute('drag-pos')
534
- removeClass(trEl, 'active--drag-target')
535
- removeClass(trEl, 'active--drag-origin')
536
- }
537
-
538
- const sortDragoverEvent = (evnt: DragEvent) => {
539
- const customOpts = computeCustomOpts.value
540
- const { immediate } = customOpts
541
- const columnDragOpts = computeColumnDragOpts.value
542
- const { isCrossDrag, isToChildDrag } = columnDragOpts
543
- const optEl = evnt.currentTarget as HTMLElement
544
- const isControlKey = hasControlKey(evnt)
545
- const colid = optEl.getAttribute('colid')
546
- const column = $xeTable.getColumnById(colid)
547
- const { dragCol } = customPanelReactData
548
- customPanelInternalData.prevDragGroupField = null
549
- customPanelInternalData.prevDragAggFnColid = null
550
- // 是否移入有效列
551
- if (column && (isCrossDrag || column.level === 1)) {
552
- evnt.preventDefault()
553
- const offsetY = evnt.clientY - optEl.getBoundingClientRect().y
554
- const dragPos = offsetY < optEl.clientHeight / 2 ? 'top' : 'bottom'
555
- if (
556
- !dragCol ||
557
- (dragCol && dragCol.id === column.id) ||
558
- (!isCrossDrag && column.level > 1) ||
559
- (!immediate && column.level > 1)
560
- ) {
561
- showDropTip(evnt, optEl, false, dragPos)
562
- return
563
- }
564
- customPanelInternalData.prevDragToChild = !!((isCrossDrag && isToChildDrag) && isControlKey && immediate)
565
- customPanelInternalData.prevDragCol = column
566
- customPanelInternalData.prevDragPos = dragPos
567
- showDropTip(evnt, optEl, true, dragPos)
568
- }
569
- }
570
-
571
- const clearDragAnimateStatus = () => {
572
- customPanelInternalData.customDragTime = setTimeout(() => {
573
- tableReactData.isCustomDragStatus = false
574
- customPanelInternalData.customDragTime = undefined
575
- }, 350)
576
- }
577
-
578
- const sortMoveUpEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
579
- const { customColumnList } = tableReactData
580
- const matchObj = XEUtils.findTree(customColumnList, item => item === column)
581
- if (matchObj) {
582
- const { item, items, index } = matchObj
583
- if (index > 0) {
584
- tableReactData.isCustomDragStatus = true
585
- nextTick(() => {
586
- items.splice(index, 1)
587
- items.splice(index - 1, 0, item)
588
- clearDragAnimateStatus()
589
- })
590
- }
591
- }
592
- }
593
-
594
- const sortMoveDnEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
595
- const { customColumnList } = tableReactData
596
- const matchObj = XEUtils.findTree(customColumnList, item => item === column)
597
- if (matchObj) {
598
- const { item, items, index } = matchObj
599
- if (index < items.length - 1) {
600
- tableReactData.isCustomDragStatus = true
601
- nextTick(() => {
602
- items.splice(index, 1)
603
- items.splice(index + 1, 0, item)
604
- clearDragAnimateStatus()
605
- })
606
- }
607
- }
608
- }
609
-
610
- const sortMoveTopEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
611
- const { customColumnList } = tableReactData
612
- const matchObj = XEUtils.findTree(customColumnList, item => item === column)
613
- if (matchObj) {
614
- const { item, items, index, parent: parentItem } = matchObj
615
- if (parentItem || index > 0) {
616
- tableReactData.isCustomDragStatus = true
617
- nextTick(() => {
618
- item.parentId = null
619
- items.splice(index, 1)
620
- customColumnList.unshift(item)
621
- clearDragAnimateStatus()
622
- })
623
- }
624
- }
625
- }
626
-
627
- const sortMoveBottomEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
628
- const { customColumnList } = tableReactData
629
- const matchObj = XEUtils.findTree(customColumnList, item => item === column)
630
- if (matchObj) {
631
- const { item, items, index, parent: parentItem } = matchObj
632
- if (parentItem || index < items.length - 1) {
633
- tableReactData.isCustomDragStatus = true
634
- nextTick(() => {
635
- item.parentId = null
636
- items.splice(index, 1)
637
- customColumnList.push(item)
638
- clearDragAnimateStatus()
639
- })
640
- }
641
- }
642
- }
643
-
644
- const renderDragTip = () => {
645
- const { dragTipText } = customPanelReactData
646
- const columnDragOpts = computeColumnDragOpts.value
647
- return h('div', {}, [
648
- h('div', {
649
- ref: refDragLineElem,
650
- class: ['vxe-table-custom-popup--drag-line', {
651
- 'is--guides': columnDragOpts.showGuidesStatus
652
- }]
653
- }),
654
- h('div', {
655
- ref: refDragTipElem,
656
- class: 'vxe-table-custom-popup--drag-tip'
657
- }, [
658
- h('div', {
659
- class: 'vxe-table-custom-popup--drag-tip-wrapper'
660
- }, [
661
- h('div', {
662
- class: 'vxe-table-custom-popup--drag-tip-status'
663
- }, [
664
- h('span', {
665
- class: ['vxe-table-custom-popup--drag-tip-normal-status', getIcon().TABLE_DRAG_STATUS_ROW]
666
- }),
667
- h('span', {
668
- class: ['vxe-table-custom-popup--drag-tip-sub-status', getIcon().TABLE_DRAG_STATUS_SUB_ROW]
669
- }),
670
- h('span', {
671
- class: ['vxe-table-custom-popup--drag-tip-group-status', getIcon().TABLE_DRAG_STATUS_AGG_GROUP]
672
- }),
673
- h('span', {
674
- class: ['vxe-table-custom-popup--drag-tip-values-status', getIcon().TABLE_DRAG_STATUS_AGG_VALUES]
675
- }),
676
- h('span', {
677
- class: ['vxe-table-custom-popup--drag-tip-disabled-status', getIcon().TABLE_DRAG_DISABLED]
678
- })
679
- ]),
680
- h('div', {
681
- class: 'vxe-table-custom-popup--drag-tip-content'
682
- }, `${dragTipText || ''}`)
683
- ])
684
- ])
685
- ])
686
- }
687
-
688
- const renderSimplePanel = () => {
689
- const $xeGrid = $xeTable.xeGrid
690
- const $xeGantt = $xeTable.xeGantt
691
- const tableProps = $xeTable.props
692
-
693
- const { customStore } = props
694
- const { treeConfig, rowGroupConfig, aggregateConfig } = tableProps
695
- const { isCustomStatus, customColumnList, isCustomDragStatus } = tableReactData
696
- const customOpts = computeCustomOpts.value
697
- const { immediate } = customOpts
698
- const columnDragOpts = computeColumnDragOpts.value
699
- const { popupStyle } = customStore
700
- const { checkMethod, visibleMethod, allowVisible, allowSort, allowFixed, trigger, placement, showSortDragButton, showSortMoveButton, showSortPutButton } = customOpts
701
- const isMaxFixedColumn = computeIsMaxFixedColumn.value
702
- const vSize = computeSize.value
703
- const { isCrossDrag } = columnDragOpts
704
- const slots = customOpts.slots || {}
705
- const headerSlot = slots.header
706
- const topSlot = slots.top
707
- const bottomSlot = slots.bottom
708
- const defaultSlot = slots.default
709
- const footerSlot = slots.footer
710
- const colVNs: VNode[] = []
711
- const customWrapperOns: any = {}
712
- const isAllChecked = customStore.isAll
713
- const isAllIndeterminate = customStore.isIndeterminate
714
- // hover 触发
715
- if (trigger === 'hover') {
716
- customWrapperOns.onMouseenter = handleWrapperMouseenterEvent
717
- customWrapperOns.onMouseleave = handleWrapperMouseleaveEvent
718
- }
719
- const params = {
720
- $table: $xeTable,
721
- $grid: $xeGrid,
722
- $gantt: $xeGantt,
723
- columns: customColumnList,
724
- isAllChecked,
725
- isAllIndeterminate,
726
- isCustomStatus
727
- }
728
- XEUtils.eachTree(customColumnList, (column, index, items, path, parentItem) => {
729
- const isVisible = visibleMethod ? visibleMethod({ $table: $xeTable, column }) : true
730
- if (isVisible) {
731
- const isChecked = column.renderVisible
732
- const isIndeterminate = column.halfVisible
733
- const isColGroup = column.children && column.children.length
734
- const colTitle = formatText(column.getTitle(), 1)
735
- const isDisabled = checkMethod ? !checkMethod({ $table: $xeTable, column }) : false
736
- const isHidden = !isChecked
737
- const showSortBtn = ((isCrossDrag ? immediate : false) || column.level === 1)
738
- colVNs.push(
739
- h('li', {
740
- key: column.id,
741
- colid: column.id,
742
- class: ['vxe-table-custom--option', `level--${column.level}`, {
743
- 'is--hidden': isDisabled || isHidden,
744
- 'is--group': isColGroup
745
- }],
746
- onDragstart: sortDragstartEvent,
747
- onDragend: sortDragendEvent,
748
- onDragover: sortDragoverEvent
749
- }, [
750
- allowVisible
751
- ? h('div', {
752
- class: ['vxe-table-custom--checkbox-option', {
753
- 'is--checked': isChecked,
754
- 'is--indeterminate': isIndeterminate,
755
- 'is--disabled': isDisabled
756
- }],
757
- title: getI18n('vxe.custom.setting.colVisible'),
758
- onClick: (evnt: MouseEvent) => {
759
- if (!isDisabled) {
760
- changeCheckboxOption(column, evnt)
761
- }
762
- }
763
- }, [
764
- h('span', {
765
- class: ['vxe-checkbox--icon', isIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
766
- })
767
- ])
768
- : renderEmptyElement($xeTable),
769
- h('div', {
770
- class: 'vxe-table-custom--name-option'
771
- }, [
772
- allowSort && showSortDragButton && showSortBtn
773
- ? h('div', {
774
- class: 'vxe-table-custom--sort-option'
775
- }, [
776
- h('span', {
777
- class: ['vxe-table-custom--sort-btn', {
778
- 'is--disabled': isHidden
779
- }],
780
- title: getI18n('vxe.custom.setting.sortHelpTip'),
781
- ...(isHidden
782
- ? {}
783
- : {
784
- onMousedown: sortMousedownEvent,
785
- onMouseup: sortMouseupEvent
786
- })
787
- }, [
788
- h('i', {
789
- class: getIcon().TABLE_CUSTOM_SORT
790
- })
791
- ])
792
- ])
793
- : renderEmptyElement($xeTable),
794
- column.type === 'html'
795
- ? h('div', {
796
- key: '1',
797
- class: 'vxe-table-custom--checkbox-label',
798
- innerHTML: colTitle
799
- })
800
- : h('div', {
801
- key: '0',
802
- class: 'vxe-table-custom--checkbox-label'
803
- }, colTitle)
804
- ]),
805
- showSortBtn && (showSortMoveButton || showSortPutButton)
806
- ? h('div', {
807
- class: 'vxe-table-custom--move-btn-option'
808
- }, VxeUIButtonComponent
809
- ? [
810
- showSortMoveButton
811
- ? h(VxeUIButtonComponent, {
812
- mode: 'text',
813
- icon: 'vxe-icon-arrows-up',
814
- title: getI18n('vxe.custom.setting.moveUpTitle'),
815
- disabled: index <= 0,
816
- onClick (evntParame) {
817
- sortMoveUpEvent(evntParame, column)
818
- }
819
- })
820
- : renderEmptyElement($xeTable),
821
- showSortMoveButton
822
- ? h(VxeUIButtonComponent, {
823
- mode: 'text',
824
- icon: 'vxe-icon-arrows-down',
825
- title: getI18n('vxe.custom.setting.moveDnTitle'),
826
- disabled: index >= items.length - 1,
827
- onClick (evntParame) {
828
- sortMoveDnEvent(evntParame, column)
829
- }
830
- })
831
- : renderEmptyElement($xeTable),
832
- showSortPutButton && !parentItem
833
- ? h(VxeUIButtonComponent, {
834
- mode: 'text',
835
- icon: 'vxe-icon-top',
836
- title: getI18n('vxe.custom.setting.putTopTitle'),
837
- disabled: index <= 0,
838
- onClick (evntParame) {
839
- sortMoveTopEvent(evntParame, column)
840
- }
841
- })
842
- : renderEmptyElement($xeTable),
843
- showSortPutButton && !parentItem
844
- ? h(VxeUIButtonComponent, {
845
- mode: 'text',
846
- icon: 'vxe-icon-bottom',
847
- title: getI18n('vxe.custom.setting.putBottomTitle'),
848
- disabled: index >= items.length - 1,
849
- onClick (evntParame) {
850
- sortMoveBottomEvent(evntParame, column)
851
- }
852
- })
853
- : renderEmptyElement($xeTable)
854
- ]
855
- : [])
856
- : renderEmptyElement($xeTable),
857
- !parentItem && allowFixed
858
- ? h('div', {
859
- class: 'vxe-table-custom--fixed-option'
860
- }, [
861
- VxeUIButtonComponent
862
- ? h(VxeUIButtonComponent, {
863
- mode: 'text',
864
- icon: column.renderFixed === 'left' ? getIcon().TOOLBAR_TOOLS_FIXED_LEFT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_LEFT,
865
- status: column.renderFixed === 'left' ? 'primary' : '',
866
- disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
867
- title: getI18n(column.renderFixed === 'left' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedLeft'),
868
- onClick: ({ $event }) => {
869
- changeFixedOption(column, 'left', $event)
870
- }
871
- })
872
- : renderEmptyElement($xeTable),
873
- VxeUIButtonComponent
874
- ? h(VxeUIButtonComponent, {
875
- mode: 'text',
876
- icon: column.renderFixed === 'right' ? getIcon().TOOLBAR_TOOLS_FIXED_RIGHT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_RIGHT,
877
- status: column.renderFixed === 'right' ? 'primary' : '',
878
- disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
879
- title: getI18n(column.renderFixed === 'right' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedRight'),
880
- onClick: ({ $event }) => {
881
- changeFixedOption(column, 'right', $event)
882
- }
883
- })
884
- : renderEmptyElement($xeTable)
885
- ])
886
- : renderEmptyElement($xeTable)
887
- ])
888
- )
889
- }
890
- })
891
- return h('div', {
892
- ref: refElem,
893
- key: 'simple',
894
- class: ['vxe-table-custom-wrapper', `placement--${placement}`, {
895
- [`size--${vSize}`]: vSize,
896
- 'is--active': customStore.visible
897
- }],
898
- style: popupStyle
899
- }, customStore.visible
900
- ? [
901
- h('div', {
902
- ref: refBodyWrapperElem,
903
- class: 'vxe-table-custom-simple--body-wrapper'
904
- }, [
905
- !treeConfig && (aggregateConfig || rowGroupConfig) && $xeTable.getPivotTableAggregateSimplePanel
906
- ? h($xeTable.getPivotTableAggregateSimplePanel(), {
907
- customStore
908
- })
909
- : renderEmptyElement($xeTable),
910
- h('div', {
911
- ref: refCustomBodyElem,
912
- class: 'vxe-table-custom--handle-wrapper'
913
- }, [
914
- h('div', {
915
- class: 'vxe-table-custom--header'
916
- }, headerSlot
917
- ? $xeTable.callSlot(headerSlot, params)
918
- : [
919
- h('ul', {
920
- class: 'vxe-table-custom--panel-list'
921
- }, [
922
- h('li', {
923
- class: 'vxe-table-custom--option'
924
- }, [
925
- allowVisible
926
- ? h('div', {
927
- class: ['vxe-table-custom--checkbox-option', {
928
- 'is--checked': isAllChecked,
929
- 'is--indeterminate': isAllIndeterminate
930
- }],
931
- title: getI18n('vxe.table.allTitle'),
932
- onClick: allOptionEvent
933
- }, [
934
- h('span', {
935
- class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
936
- }),
937
- h('span', {
938
- class: 'vxe-checkbox--label'
939
- }, getI18n('vxe.toolbar.customAll'))
940
- ])
941
- : h('span', {
942
- class: 'vxe-checkbox--label'
943
- }, getI18n('vxe.table.customTitle'))
944
- ])
945
- ])
946
- ]),
947
- h('div', {
948
- class: 'vxe-table-custom--body'
949
- }, [
950
- topSlot
951
- ? h('div', {
952
- class: 'vxe-table-custom--panel-top'
953
- }, $xeTable.callSlot(topSlot, params))
954
- : renderEmptyElement($xeTable),
955
- defaultSlot
956
- ? h('div', {
957
- class: 'vxe-table-custom--panel-body'
958
- }, $xeTable.callSlot(defaultSlot, params))
959
- : h(TransitionGroup, {
960
- class: 'vxe-table-custom--panel-list',
961
- name: isCustomDragStatus ? 'vxe-table-custom--list' : '',
962
- tag: 'ul',
963
- ...customWrapperOns
964
- }, {
965
- default: () => colVNs
966
- }),
967
- bottomSlot
968
- ? h('div', {
969
- class: 'vxe-table-custom--panel-bottom'
970
- }, $xeTable.callSlot(bottomSlot, params))
971
- : renderEmptyElement($xeTable)
972
- ]),
973
- customOpts.showFooter
974
- ? h('div', {
975
- class: 'vxe-table-custom--footer'
976
- }, footerSlot
977
- ? $xeTable.callSlot(footerSlot, params)
978
- : [
979
- h('div', {
980
- class: 'vxe-table-custom--footer-buttons'
981
- }, [
982
- VxeUIButtonComponent
983
- ? h(VxeUIButtonComponent, {
984
- mode: 'text',
985
- content: customOpts.resetButtonText || getI18n('vxe.table.customRestore'),
986
- disabled: !isCustomStatus,
987
- onClick: resetCustomEvent
988
- })
989
- : renderEmptyElement($xeTable),
990
- immediate
991
- ? (VxeUIButtonComponent
992
- ? h(VxeUIButtonComponent, {
993
- mode: 'text',
994
- content: customOpts.closeButtonText || getI18n('vxe.table.customClose'),
995
- onClick: cancelCloseEvent
996
- })
997
- : renderEmptyElement($xeTable))
998
- : (VxeUIButtonComponent
999
- ? h(VxeUIButtonComponent, {
1000
- mode: 'text',
1001
- content: customOpts.cancelButtonText || getI18n('vxe.table.customCancel'),
1002
- onClick: cancelCustomEvent
1003
- })
1004
- : renderEmptyElement($xeTable)),
1005
- immediate
1006
- ? renderEmptyElement($xeTable)
1007
- : (VxeUIButtonComponent
1008
- ? h(VxeUIButtonComponent, {
1009
- mode: 'text',
1010
- status: 'primary',
1011
- content: customOpts.confirmButtonText || getI18n('vxe.table.customConfirm'),
1012
- onClick: confirmCustomEvent
1013
- })
1014
- : renderEmptyElement($xeTable))
1015
- ])
1016
- ])
1017
- : null
1018
- ]),
1019
- renderDragTip()
1020
- ])
1021
- ]
1022
- : [])
1023
- }
1024
-
1025
- const renderPopupPanel = () => {
1026
- const $xeGrid = $xeTable.xeGrid
1027
- const $xeGantt = $xeTable.xeGantt
1028
-
1029
- const { customStore } = props
1030
- const { treeConfig, rowGroupConfig, aggregateConfig, resizable: allResizable } = tableProps
1031
- const { isCustomStatus, customColumnList } = tableReactData
1032
- const customOpts = computeCustomOpts.value
1033
- const { immediate, showSortDragButton, showSortMoveButton, showSortPutButton } = customOpts
1034
- const columnDragOpts = computeColumnDragOpts.value
1035
- const { mode, modalOptions, drawerOptions, allowVisible, allowSort, allowFixed, allowResizable, checkMethod, visibleMethod } = customOpts
1036
- const columnOpts = computeColumnOpts.value
1037
- const { maxFixedSize } = columnOpts
1038
- const resizableOpts = computeResizableOpts.value
1039
- const { minWidth: reMinWidth, maxWidth: reMaxWidth } = resizableOpts
1040
- const modalOpts = Object.assign({}, modalOptions)
1041
- const drawerOpts = Object.assign({}, drawerOptions)
1042
- const isMaxFixedColumn = computeIsMaxFixedColumn.value
1043
- const { isCrossDrag } = columnDragOpts
1044
- const slots = customOpts.slots || {}
1045
- const headerSlot = slots.header
1046
- const topSlot = slots.top
1047
- const bottomSlot = slots.bottom
1048
- const defaultSlot = slots.default
1049
- const footerSlot = slots.footer
1050
- const trVNs: VNode[] = []
1051
- const isAllChecked = customStore.isAll
1052
- const isAllIndeterminate = customStore.isIndeterminate
1053
- const params = {
1054
- $table: $xeTable,
1055
- $grid: $xeGrid,
1056
- $gantt: $xeGantt,
1057
- columns: customColumnList,
1058
- isAllChecked,
1059
- isAllIndeterminate,
1060
- isCustomStatus
1061
- }
1062
- XEUtils.eachTree(customColumnList, (column, index, items, path, parentItem) => {
1063
- const isVisible = visibleMethod ? visibleMethod({ $table: $xeTable, column }) : true
1064
- if (isVisible) {
1065
- // 默认继承调整宽度
1066
- let customMinWidth = 0
1067
- let customMaxWidth = 0
1068
- if (allowResizable) {
1069
- const resizeParams = {
1070
- $table: $xeTable,
1071
- column,
1072
- columnIndex: index,
1073
- $columnIndex: index,
1074
- $rowIndex: -1
1075
- }
1076
- if (reMinWidth) {
1077
- customMinWidth = XEUtils.toNumber(XEUtils.isFunction(reMinWidth) ? reMinWidth(resizeParams) : reMinWidth)
1078
- }
1079
- if (reMaxWidth) {
1080
- customMaxWidth = XEUtils.toNumber(XEUtils.isFunction(reMaxWidth) ? reMaxWidth(resizeParams) : reMaxWidth)
1081
- }
1082
- }
1083
-
1084
- const isChecked = column.renderVisible
1085
- const isIndeterminate = column.halfVisible
1086
- const colTitle = formatText(column.getTitle(), 1)
1087
- const isColGroup = column.children && column.children.length
1088
- const isDisabled = checkMethod ? !checkMethod({ $table: $xeTable, column }) : false
1089
- const isHidden = !isChecked
1090
- const showSortBtn = ((isCrossDrag ? immediate : false) || column.level === 1)
1091
- trVNs.push(
1092
- h('tr', {
1093
- key: column.id,
1094
- colid: column.id,
1095
- class: [`vxe-table-custom-popup--row level--${column.level}`, {
1096
- 'is--group': isColGroup
1097
- }],
1098
- onDragstart: sortDragstartEvent,
1099
- onDragend: sortDragendEvent,
1100
- onDragover: sortDragoverEvent
1101
- }, [
1102
- allowVisible
1103
- ? h('td', {
1104
- class: 'vxe-table-custom-popup--column-item col--visible'
1105
- }, [
1106
- h('div', {
1107
- class: ['vxe-table-custom--checkbox-option', {
1108
- 'is--checked': isChecked,
1109
- 'is--indeterminate': isIndeterminate,
1110
- 'is--disabled': isDisabled
1111
- }],
1112
- title: getI18n('vxe.custom.setting.colVisible'),
1113
- onClick: (evnt: MouseEvent) => {
1114
- if (!isDisabled) {
1115
- changeCheckboxOption(column, evnt)
1116
- }
1117
- }
1118
- }, [
1119
- h('span', {
1120
- class: ['vxe-checkbox--icon', isIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
1121
- })
1122
- ])
1123
- ])
1124
- : renderEmptyElement($xeTable),
1125
- h('td', {
1126
- class: 'vxe-table-custom-popup--column-item col--name'
1127
- }, [
1128
- h('div', {
1129
- class: 'vxe-table-custom-popup--name'
1130
- }, [
1131
- allowSort
1132
- ? showSortDragButton && (showSortBtn
1133
- ? h('div', {
1134
- class: ['vxe-table-custom-popup--column-sort-btn', {
1135
- 'is--disabled': isHidden
1136
- }],
1137
- title: getI18n('vxe.custom.setting.sortHelpTip'),
1138
- ...(isHidden
1139
- ? {}
1140
- : {
1141
- onMousedown: sortMousedownEvent,
1142
- onMouseup: sortMouseupEvent
1143
- })
1144
- }, [
1145
- h('i', {
1146
- class: getIcon().TABLE_CUSTOM_SORT
1147
- })
1148
- ])
1149
- : h('div', {
1150
- class: 'vxe-table-custom-popup--column-sort-placeholder'
1151
- }))
1152
- : renderEmptyElement($xeTable),
1153
- column.type === 'html'
1154
- ? h('div', {
1155
- key: '1',
1156
- class: 'vxe-table-custom-popup--title',
1157
- innerHTML: colTitle
1158
- })
1159
- : h('div', {
1160
- key: '0',
1161
- class: 'vxe-table-custom-popup--title',
1162
- title: colTitle
1163
- }, colTitle),
1164
- showSortBtn && (showSortMoveButton || showSortPutButton)
1165
- ? h('div', {
1166
- class: 'vxe-table-custom-popup--move-btn'
1167
- }, VxeUIButtonComponent
1168
- ? [
1169
- showSortMoveButton
1170
- ? h(VxeUIButtonComponent, {
1171
- mode: 'text',
1172
- content: getI18n('vxe.custom.setting.moveUp'),
1173
- title: getI18n('vxe.custom.setting.moveUpTitle'),
1174
- disabled: index <= 0,
1175
- onClick (evntParame) {
1176
- sortMoveUpEvent(evntParame, column)
1177
- }
1178
- })
1179
- : renderEmptyElement($xeTable),
1180
- showSortMoveButton
1181
- ? h(VxeUIButtonComponent, {
1182
- mode: 'text',
1183
- content: getI18n('vxe.custom.setting.moveDn'),
1184
- title: getI18n('vxe.custom.setting.moveDnTitle'),
1185
- disabled: index >= items.length - 1,
1186
- onClick (evntParame) {
1187
- sortMoveDnEvent(evntParame, column)
1188
- }
1189
- })
1190
- : renderEmptyElement($xeTable),
1191
- showSortPutButton && !parentItem
1192
- ? h(VxeUIButtonComponent, {
1193
- mode: 'text',
1194
- content: getI18n('vxe.custom.setting.putTop'),
1195
- title: getI18n('vxe.custom.setting.putTopTitle'),
1196
- disabled: index <= 0,
1197
- onClick (evntParame) {
1198
- sortMoveTopEvent(evntParame, column)
1199
- }
1200
- })
1201
- : renderEmptyElement($xeTable),
1202
- showSortPutButton && !parentItem
1203
- ? h(VxeUIButtonComponent, {
1204
- mode: 'text',
1205
- content: getI18n('vxe.custom.setting.putBottom'),
1206
- title: getI18n('vxe.custom.setting.putBottomTitle'),
1207
- disabled: index >= items.length - 1,
1208
- onClick (evntParame) {
1209
- sortMoveBottomEvent(evntParame, column)
1210
- }
1211
- })
1212
- : renderEmptyElement($xeTable)
1213
- ]
1214
- : [])
1215
- : renderEmptyElement($xeTable)
1216
- ])
1217
- ]),
1218
- allowResizable
1219
- ? h('td', {
1220
- class: 'vxe-table-custom-popup--column-item col--resizable'
1221
- }, [
1222
- (
1223
- (column.children && column.children.length) ||
1224
- !(XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
1225
- )
1226
- ? h('span', '-')
1227
- : (
1228
- VxeUINumberInputComponent
1229
- ? h(VxeUINumberInputComponent, {
1230
- type: 'integer',
1231
- immediate: false,
1232
- disabled: isHidden,
1233
- modelValue: column.renderResizeWidth,
1234
- min: customMinWidth || undefined,
1235
- max: customMaxWidth || undefined,
1236
- 'onUpdate:modelValue' (value: any) {
1237
- const width = Math.max(0, Number(value))
1238
- column.renderResizeWidth = width
1239
- },
1240
- onChange () {
1241
- changeColumnWidth(column)
1242
- }
1243
- })
1244
- : renderEmptyElement($xeTable)
1245
- )
1246
- ])
1247
- : renderEmptyElement($xeTable),
1248
- allowFixed
1249
- ? h('td', {
1250
- class: 'vxe-table-custom-popup--column-item col--fixed'
1251
- }, [
1252
- parentItem
1253
- ? h('span', '-')
1254
- : (
1255
- VxeUIRadioGroupComponent
1256
- ? h(VxeUIRadioGroupComponent, {
1257
- modelValue: column.renderFixed || '',
1258
- type: 'button',
1259
- size: 'mini',
1260
- disabled: isHidden,
1261
- options: [
1262
- { label: getI18n('vxe.custom.setting.fixedLeft'), value: 'left', disabled: isHidden || isMaxFixedColumn },
1263
- { label: getI18n('vxe.custom.setting.fixedUnset'), value: '', disabled: isHidden },
1264
- { label: getI18n('vxe.custom.setting.fixedRight'), value: 'right', disabled: isHidden || isMaxFixedColumn }
1265
- ],
1266
- onChange ({ label, $event }) {
1267
- changeFixedOption(column, label, $event)
1268
- }
1269
- })
1270
- : renderEmptyElement($xeTable)
1271
- )
1272
- ])
1273
- : renderEmptyElement($xeTable)
1274
- ])
1275
- )
1276
- }
1277
- })
1278
- const scopedSlots: Record<string, any> = {
1279
- default: () => {
1280
- return h('div', {
1281
- ref: refBodyWrapperElem,
1282
- class: 'vxe-table-custom-popup--body-wrapper'
1283
- }, defaultSlot
1284
- ? $xeTable.callSlot(defaultSlot, params)
1285
- : [
1286
- !treeConfig && (aggregateConfig || rowGroupConfig) && $xeTable.getPivotTableAggregatePopupPanel
1287
- ? h($xeTable.getPivotTableAggregatePopupPanel(), {
1288
- customStore
1289
- })
1290
- : renderEmptyElement($xeTable),
1291
- h('div', {
1292
- ref: refCustomBodyElem,
1293
- class: 'vxe-table-custom-popup--handle-wrapper'
1294
- }, [
1295
- topSlot
1296
- ? h('div', {
1297
- class: 'vxe-table-custom-popup--table-top'
1298
- }, $xeTable.callSlot(topSlot, params))
1299
- : renderEmptyElement($xeTable),
1300
- h('div', {
1301
- class: 'vxe-table-custom-popup--table-wrapper'
1302
- }, [
1303
- h('table', {}, [
1304
- h('colgroup', {}, [
1305
- allowVisible
1306
- ? h('col', {
1307
- class: 'vxe-table-custom-popup--table-col-seq'
1308
- })
1309
- : renderEmptyElement($xeTable),
1310
- h('col', {
1311
- class: 'vxe-table-custom-popup--table-col-title'
1312
- }),
1313
- allowResizable
1314
- ? h('col', {
1315
- class: 'vxe-table-custom-popup--table-col-width'
1316
- })
1317
- : renderEmptyElement($xeTable),
1318
- allowFixed
1319
- ? h('col', {
1320
- class: 'vxe-table-custom-popup--table-col-fixed'
1321
- })
1322
- : renderEmptyElement($xeTable)
1323
- ]),
1324
- h('thead', {}, [
1325
- h('tr', {}, [
1326
- allowVisible
1327
- ? h('th', {}, [
1328
- h('div', {
1329
- class: ['vxe-table-custom--checkbox-option', {
1330
- 'is--checked': isAllChecked,
1331
- 'is--indeterminate': isAllIndeterminate
1332
- }],
1333
- title: getI18n('vxe.table.allTitle'),
1334
- onClick: allOptionEvent
1335
- }, [
1336
- h('span', {
1337
- class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
1338
- }),
1339
- h('span', {
1340
- class: 'vxe-checkbox--label'
1341
- }, getI18n('vxe.toolbar.customAll'))
1342
- ])
1343
- ])
1344
- : renderEmptyElement($xeTable),
1345
- h('th', {}, getI18n('vxe.custom.setting.colTitle')),
1346
- allowResizable
1347
- ? h('th', {}, getI18n('vxe.custom.setting.colResizable'))
1348
- : renderEmptyElement($xeTable),
1349
- allowFixed
1350
- ? h('th', {}, getI18n(`vxe.custom.setting.${maxFixedSize ? 'colFixedMax' : 'colFixed'}`, [maxFixedSize]))
1351
- : renderEmptyElement($xeTable)
1352
- ])
1353
- ]),
1354
- h(TransitionGroup, {
1355
- class: 'vxe-table-custom--panel-list',
1356
- tag: 'tbody',
1357
- name: 'vxe-table-custom--list'
1358
- }, {
1359
- default: () => trVNs
1360
- })
1361
- ])
1362
- ]),
1363
- bottomSlot
1364
- ? h('div', {
1365
- class: 'vxe-table-custom-popup--table-bottom'
1366
- }, $xeTable.callSlot(bottomSlot, params))
1367
- : renderEmptyElement($xeTable),
1368
- renderDragTip()
1369
- ])
1370
- ])
1371
- },
1372
- footer: () => {
1373
- if (footerSlot) {
1374
- return $xeTable.callSlot(footerSlot, params)
1375
- }
1376
- return h('div', {
1377
- class: 'vxe-table-custom-popup--footer'
1378
- }, [
1379
- VxeUIButtonComponent
1380
- ? h(VxeUIButtonComponent, {
1381
- content: customOpts.resetButtonText || getI18n('vxe.custom.cstmRestore'),
1382
- disabled: !isCustomStatus,
1383
- onClick: resetCustomEvent
1384
- })
1385
- : renderEmptyElement($xeTable),
1386
- immediate
1387
- ? (VxeUIButtonComponent
1388
- ? h(VxeUIButtonComponent, {
1389
- content: customOpts.closeButtonText || getI18n('vxe.table.customClose'),
1390
- onClick: cancelCloseEvent
1391
- })
1392
- : renderEmptyElement($xeTable))
1393
- : (VxeUIButtonComponent
1394
- ? h(VxeUIButtonComponent, {
1395
- content: customOpts.cancelButtonText || getI18n('vxe.table.customCancel'),
1396
- onClick: cancelCustomEvent
1397
- })
1398
- : renderEmptyElement($xeTable)),
1399
- immediate
1400
- ? renderEmptyElement($xeTable)
1401
- : (VxeUIButtonComponent
1402
- ? h(VxeUIButtonComponent, {
1403
- status: 'primary',
1404
- content: customOpts.confirmButtonText || getI18n('vxe.custom.cstmConfirm'),
1405
- onClick: confirmCustomEvent
1406
- })
1407
- : renderEmptyElement($xeTable))
1408
- ])
1409
- }
1410
- }
1411
- if (headerSlot) {
1412
- scopedSlots.header = () => $xeTable.callSlot(headerSlot, params)
1413
- }
1414
- if (mode === 'drawer') {
1415
- return VxeUIDrawerComponent
1416
- ? h(VxeUIDrawerComponent, {
1417
- key: 'drawer',
1418
- className: ['vxe-table-custom-drawer-wrapper', 'vxe-table--ignore-clear', drawerOpts.className || ''].join(' '),
1419
- modelValue: customStore.visible,
1420
- title: drawerOpts.title || getI18n('vxe.custom.cstmTitle'),
1421
- width: drawerOpts.width || Math.min(880, Math.floor(document.documentElement.clientWidth * 0.6)),
1422
- position: drawerOpts.position,
1423
- resize: !!drawerOpts.resize,
1424
- escClosable: !!drawerOpts.escClosable,
1425
- maskClosable: !!drawerOpts.maskClosable,
1426
- destroyOnClose: true,
1427
- showFooter: true,
1428
- 'onUpdate:modelValue' (value: any) {
1429
- customStore.visible = value
1430
- }
1431
- }, scopedSlots)
1432
- : renderEmptyElement($xeTable)
1433
- }
1434
- return VxeUIModalComponent
1435
- ? h(VxeUIModalComponent, {
1436
- key: 'modal',
1437
- className: ['vxe-table-custom-modal-wrapper', 'vxe-table--ignore-clear', modalOpts.className || ''].join(' '),
1438
- modelValue: customStore.visible,
1439
- title: modalOpts.title || getI18n('vxe.custom.cstmTitle'),
1440
- width: modalOpts.width || Math.min(880, document.documentElement.clientWidth),
1441
- minWidth: modalOpts.minWidth || 700,
1442
- height: modalOpts.height || Math.min(680, document.documentElement.clientHeight),
1443
- minHeight: modalOpts.minHeight || 400,
1444
- showZoom: modalOpts.showZoom,
1445
- showMaximize: modalOpts.showMaximize,
1446
- showMinimize: modalOpts.showMinimize,
1447
- mask: modalOpts.mask,
1448
- lockView: modalOpts.lockView,
1449
- resize: modalOpts.resize,
1450
- escClosable: !!modalOpts.escClosable,
1451
- maskClosable: !!modalOpts.maskClosable,
1452
- destroyOnClose: true,
1453
- showFooter: true,
1454
- 'onUpdate:modelValue' (value: any) {
1455
- customStore.visible = value
1456
- }
1457
- }, scopedSlots)
1458
- : renderEmptyElement($xeTable)
1459
- }
1460
-
1461
- const renderVN = () => {
1462
- const customOpts = computeCustomOpts.value
1463
- if (['modal', 'drawer', 'popup'].includes(`${customOpts.mode}`)) {
1464
- return renderPopupPanel()
1465
- }
1466
- return renderSimplePanel()
1467
- }
1468
-
1469
- nextTick(() => {
1470
- const customOpts = computeCustomOpts.value
1471
- const { mode } = customOpts
1472
- if (!VxeUIModalComponent && (mode === 'modal')) {
1473
- errLog('vxe.error.reqComp', ['vxe-modal'])
1474
- }
1475
- if (!VxeUIDrawerComponent && (mode === 'drawer')) {
1476
- errLog('vxe.error.reqComp', ['vxe-drawer'])
1477
- }
1478
- if (!VxeUIButtonComponent) {
1479
- errLog('vxe.error.reqComp', ['vxe-button'])
1480
- }
1481
- if (!VxeUINumberInputComponent) {
1482
- errLog('vxe.error.reqComp', ['vxe-number-input'])
1483
- }
1484
- if (!VxeUIRadioGroupComponent) {
1485
- errLog('vxe.error.reqComp', ['vxe-radio-group'])
1486
- }
1487
- })
1488
-
1489
- const $xeTableCustomPanel: VxeTableCustomPanelConstructor = {
1490
- xID,
1491
- props,
1492
- context,
1493
- reactData: customPanelReactData,
1494
- internalData: customPanelInternalData,
1495
- xeTable: $xeTable,
1496
- getRefMaps: () => refMaps,
1497
- getComputeMaps: () => computeMaps,
1498
- renderVN
1499
- }
1500
-
1501
- onUnmounted(() => {
1502
- customPanelInternalData = createInternalData()
1503
- })
1504
-
1505
- provide('$xeTableCustomPanel', $xeTableCustomPanel)
1506
-
1507
- return $xeTableCustomPanel
1508
- },
1509
- render () {
1510
- return this.renderVN()
1511
- }
1512
- })
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 '../../../ui'
4
+ import { formatText } from '../../../ui/src/utils'
5
+ import { getTpImg, addClass, removeClass, hasControlKey } from '../../../ui/src/dom'
6
+ import { errLog } 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 { getI18n, getIcon, renderEmptyElement } = VxeUI
13
+
14
+ export function createInternalData (): TableCustomPanelInternalData {
15
+ return {
16
+ // teleportTo: undefined,
17
+ // prevDragCol: undefined,
18
+ // prevDragGroupField: undefined,
19
+ // prevDragAggFnColid: undefined,
20
+ // prevDragToChild: false,
21
+ // prevDragPos: null,
22
+ // customDragTime: null
23
+ }
24
+ }
25
+
26
+ export default defineVxeComponent({
27
+ name: 'TableCustomPanel',
28
+ props: {
29
+ customStore: {
30
+ type: Object as PropType<VxeTableDefines.VxeTableCustomStoreObj>,
31
+ default: () => ({} as VxeTableDefines.VxeTableCustomStoreObj)
32
+ }
33
+ },
34
+ setup (props, context) {
35
+ const xID = XEUtils.uniqueId()
36
+
37
+ const VxeUIModalComponent = VxeUI.getComponent('VxeModal')
38
+ const VxeUIDrawerComponent = VxeUI.getComponent('VxeDrawer')
39
+ const VxeUIButtonComponent = VxeUI.getComponent('VxeButton')
40
+ const VxeUINumberInputComponent = VxeUI.getComponent('VxeNumberInput')
41
+ const VxeUIRadioGroupComponent = VxeUI.getComponent('VxeRadioGroup')
42
+
43
+ const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods)
44
+
45
+ const { props: tableProps, reactData: tableReactData, internalData: tableInternalData } = $xeTable
46
+ const { computeSize, computeCustomOpts, computeColumnDragOpts, computeColumnOpts, computeIsMaxFixedColumn, computeResizableOpts } = $xeTable.getComputeMaps()
47
+
48
+ const refElem = ref() as Ref<HTMLDivElement>
49
+ const refBodyWrapperElem = ref() as Ref<HTMLDivElement>
50
+ const refCustomBodyElem = ref() as Ref<HTMLDivElement>
51
+ const refDragLineElem = ref() as Ref<HTMLDivElement>
52
+ const refDragTipElem = ref() as Ref<HTMLDivElement>
53
+
54
+ const customPanelReactData = reactive<TableCustomPanelReactData>({
55
+ dragCol: null,
56
+ dragGroupField: null,
57
+ dragAggFnCol: null,
58
+ dragTipText: ''
59
+ })
60
+
61
+ let customPanelInternalData = createInternalData()
62
+
63
+ const refMaps: TableCustomPanelPrivateRef = {
64
+ refElem,
65
+ refBodyWrapperElem,
66
+ refCustomBodyElem,
67
+ refDragLineElem,
68
+ refDragTipElem
69
+ }
70
+
71
+ const computeMaps: TableCustomPanelPrivateComputed = {
72
+ }
73
+
74
+ const handleWrapperMouseenterEvent = (evnt: Event) => {
75
+ const { customStore } = props
76
+ customStore.activeWrapper = true
77
+ $xeTable.customOpenEvent(evnt)
78
+ }
79
+
80
+ const handleWrapperMouseleaveEvent = (evnt: Event) => {
81
+ const { customStore } = props
82
+ customStore.activeWrapper = false
83
+ setTimeout(() => {
84
+ if (!customStore.activeBtn && !customStore.activeWrapper) {
85
+ $xeTable.customCloseEvent(evnt)
86
+ }
87
+ }, 300)
88
+ }
89
+
90
+ const confirmCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
91
+ tableReactData.isCustomStatus = true
92
+ $xeTable.saveCustom()
93
+ $xeTable.closeCustom()
94
+ $xeTable.emitCustomEvent('confirm', $event)
95
+ $xeTable.emitCustomEvent('close', $event)
96
+ }
97
+
98
+ const cancelCloseEvent: VxeButtonEvents.Click = ({ $event }) => {
99
+ $xeTable.closeCustom()
100
+ $xeTable.emitCustomEvent('close', $event)
101
+ }
102
+
103
+ const cancelCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
104
+ $xeTable.cancelCustom()
105
+ $xeTable.closeCustom()
106
+ $xeTable.emitCustomEvent('cancel', $event)
107
+ $xeTable.emitCustomEvent('close', $event)
108
+ }
109
+
110
+ const handleResetCustomEvent = (evnt: Event) => {
111
+ $xeTable.resetCustom(true)
112
+ $xeTable.closeCustom()
113
+ $xeTable.emitCustomEvent('reset', evnt)
114
+ $xeTable.emitCustomEvent('close', evnt)
115
+ }
116
+
117
+ const resetCustomEvent: VxeButtonEvents.Click = ({ $event }) => {
118
+ if (VxeUI.modal) {
119
+ VxeUI.modal.confirm({
120
+ content: getI18n('vxe.custom.cstmConfirmRestore'),
121
+ className: 'vxe-table--ignore-clear',
122
+ escClosable: true
123
+ }).then(type => {
124
+ if (type === 'confirm') {
125
+ handleResetCustomEvent($event)
126
+ }
127
+ })
128
+ } else {
129
+ handleResetCustomEvent($event)
130
+ }
131
+ }
132
+
133
+ const handleOptionCheck = (column: VxeTableDefines.ColumnInfo) => {
134
+ const { customColumnList } = tableReactData
135
+ const matchObj = XEUtils.findTree(customColumnList, item => item === column)
136
+ if (matchObj && matchObj.parent) {
137
+ const { parent: parentItem } = matchObj
138
+ if (parentItem.children && parentItem.children.length) {
139
+ parentItem.renderVisible = parentItem.children.every((column) => column.renderVisible)
140
+ parentItem.halfVisible = !parentItem.renderVisible && parentItem.children.some((column) => column.renderVisible || column.halfVisible)
141
+ handleOptionCheck(parentItem)
142
+ }
143
+ }
144
+ }
145
+
146
+ const changeCheckboxOption = (column: VxeTableDefines.ColumnInfo, evnt: MouseEvent) => {
147
+ const isChecked = !column.renderVisible
148
+ const customOpts = computeCustomOpts.value
149
+ if (customOpts.immediate) {
150
+ XEUtils.eachTree([column], (item) => {
151
+ item.visible = isChecked
152
+ item.renderVisible = isChecked
153
+ item.halfVisible = false
154
+ })
155
+ tableReactData.isCustomStatus = true
156
+ $xeTable.handleCustom()
157
+ $xeTable.saveCustomStore('update:visible')
158
+ } else {
159
+ XEUtils.eachTree([column], (item) => {
160
+ item.renderVisible = isChecked
161
+ item.halfVisible = false
162
+ })
163
+ }
164
+ handleOptionCheck(column)
165
+ $xeTable.checkCustomStatus()
166
+ $xeTable.dispatchEvent('custom-visible-change', { column, checked: isChecked }, evnt)
167
+ }
168
+
169
+ const changeColumnWidth = (column: VxeTableDefines.ColumnInfo) => {
170
+ const customOpts = computeCustomOpts.value
171
+ if (customOpts.immediate) {
172
+ if (column.renderResizeWidth !== column.renderWidth) {
173
+ column.resizeWidth = column.renderResizeWidth
174
+ column.renderWidth = column.renderResizeWidth
175
+ tableReactData.isCustomStatus = true
176
+ $xeTable.handleCustom()
177
+ $xeTable.saveCustomStore('update:width')
178
+ }
179
+ }
180
+ }
181
+
182
+ const changeFixedOption = (column: VxeTableDefines.ColumnInfo, colFixed: VxeColumnPropTypes.Fixed, evnt: Event) => {
183
+ const isMaxFixedColumn = computeIsMaxFixedColumn.value
184
+ const customOpts = computeCustomOpts.value
185
+ let targetFixed: VxeColumnPropTypes.Fixed = null
186
+ if (customOpts.immediate) {
187
+ if (column.renderFixed === colFixed) {
188
+ targetFixed = ''
189
+ XEUtils.eachTree([column], col => {
190
+ col.fixed = ''
191
+ col.renderFixed = ''
192
+ })
193
+ } else {
194
+ if (!isMaxFixedColumn || column.renderFixed) {
195
+ targetFixed = colFixed
196
+ XEUtils.eachTree([column], col => {
197
+ col.fixed = colFixed
198
+ col.renderFixed = colFixed
199
+ })
200
+ }
201
+ }
202
+ tableReactData.isCustomStatus = true
203
+ $xeTable.handleCustom()
204
+ $xeTable.saveCustomStore('update:fixed')
205
+ } else {
206
+ if (column.renderFixed === colFixed) {
207
+ targetFixed = ''
208
+ XEUtils.eachTree([column], col => {
209
+ col.renderFixed = ''
210
+ })
211
+ } else {
212
+ if (!isMaxFixedColumn || column.renderFixed) {
213
+ targetFixed = colFixed
214
+ XEUtils.eachTree([column], col => {
215
+ col.renderFixed = colFixed
216
+ })
217
+ }
218
+ }
219
+ }
220
+ if (targetFixed !== null) {
221
+ $xeTable.dispatchEvent('custom-fixed-change', { column, fixed: targetFixed }, evnt)
222
+ }
223
+ }
224
+
225
+ const allOptionEvent = (evnt: MouseEvent) => {
226
+ const { customStore } = tableReactData
227
+ const isAll = !customStore.isAll
228
+ $xeTable.toggleCustomAllCheckbox()
229
+ $xeTable.dispatchEvent('custom-visible-all', { checked: isAll }, evnt)
230
+ }
231
+
232
+ const showDropTip = (evnt: DragEvent | MouseEvent, optEl: HTMLElement | null, showLine: boolean, dragPos: string) => {
233
+ const bodyWrapperElem = refBodyWrapperElem.value
234
+ if (!bodyWrapperElem) {
235
+ return
236
+ }
237
+ const customBodyElem = refCustomBodyElem.value
238
+ if (!customBodyElem) {
239
+ return
240
+ }
241
+ const { prevDragToChild } = customPanelInternalData
242
+ const bodyWrapperRect = bodyWrapperElem.getBoundingClientRect()
243
+ const customBodyRect = customBodyElem.getBoundingClientRect()
244
+ const dragLineEl = refDragLineElem.value
245
+ if (optEl) {
246
+ if (dragLineEl) {
247
+ if (showLine) {
248
+ const optRect = optEl.getBoundingClientRect()
249
+ dragLineEl.style.display = 'block'
250
+ dragLineEl.style.left = `${Math.max(0, customBodyRect.x - bodyWrapperRect.x)}px`
251
+ dragLineEl.style.top = `${Math.max(1, optRect.y + bodyWrapperElem.scrollTop - bodyWrapperRect.y)}px`
252
+ dragLineEl.style.height = `${optRect.height}px`
253
+ dragLineEl.style.width = `${optRect.width}px`
254
+ dragLineEl.setAttribute('drag-pos', dragPos)
255
+ dragLineEl.setAttribute('drag-to-child', prevDragToChild ? 'y' : 'n')
256
+ } else {
257
+ dragLineEl.style.display = ''
258
+ }
259
+ }
260
+ } else {
261
+ if (dragLineEl) {
262
+ dragLineEl.style.display = 'node'
263
+ }
264
+ }
265
+ const dragTipEl = refDragTipElem.value
266
+ if (dragTipEl) {
267
+ dragTipEl.style.display = 'block'
268
+ dragTipEl.style.top = `${Math.min(bodyWrapperElem.clientHeight + bodyWrapperElem.scrollTop - dragTipEl.clientHeight, evnt.clientY + bodyWrapperElem.scrollTop - bodyWrapperRect.y)}px`
269
+ dragTipEl.style.left = `${Math.min(bodyWrapperElem.clientWidth + bodyWrapperElem.scrollLeft - dragTipEl.clientWidth, evnt.clientX + bodyWrapperElem.scrollLeft - bodyWrapperRect.x)}px`
270
+ dragTipEl.setAttribute('drag-status', showLine ? (prevDragToChild ? 'sub' : 'normal') : 'disabled')
271
+ }
272
+ }
273
+
274
+ const updateColDropTipContent = () => {
275
+ const { dragCol } = customPanelReactData
276
+ const columnDragOpts = computeColumnDragOpts.value
277
+ const { tooltipMethod } = columnDragOpts
278
+ let tipContent = ''
279
+ if (tooltipMethod) {
280
+ const dtParams = {
281
+ $table: $xeTable,
282
+ column: dragCol as VxeTableDefines.ColumnInfo
283
+ }
284
+ tipContent = `${tooltipMethod(dtParams) || ''}`
285
+ } else {
286
+ tipContent = getI18n('vxe.custom.cstmDragTarget', [dragCol && dragCol.type !== 'html' ? dragCol.getTitle() : ''])
287
+ }
288
+ customPanelReactData.dragTipText = tipContent
289
+ }
290
+
291
+ const hideDropTip = () => {
292
+ const dragTipEl = refDragTipElem.value
293
+ const dragLineEl = refDragLineElem.value
294
+ if (dragTipEl) {
295
+ dragTipEl.style.display = ''
296
+ }
297
+ if (dragLineEl) {
298
+ dragLineEl.style.display = ''
299
+ }
300
+ }
301
+
302
+ const sortMousedownEvent = (evnt: DragEvent) => {
303
+ const btnEl = evnt.currentTarget as HTMLElement
304
+ const cellEl = btnEl.parentElement as HTMLElement
305
+ const tdEl = cellEl.parentElement as HTMLElement
306
+ const trEl = tdEl.parentElement as HTMLElement
307
+ const colid = trEl.getAttribute('colid')
308
+ const column = $xeTable.getColumnById(colid)
309
+ trEl.draggable = true
310
+ customPanelReactData.dragCol = column
311
+ customPanelReactData.dragGroupField = null
312
+ customPanelReactData.dragAggFnCol = null
313
+ updateColDropTipContent()
314
+ addClass(trEl, 'active--drag-origin')
315
+ }
316
+
317
+ const sortMouseupEvent = (evnt: MouseEvent) => {
318
+ const btnEl = evnt.currentTarget as HTMLElement
319
+ const cellEl = btnEl.parentElement as HTMLElement
320
+ const tdEl = cellEl.parentElement as HTMLElement
321
+ const trEl = tdEl.parentElement as HTMLElement
322
+ hideDropTip()
323
+ trEl.draggable = false
324
+ customPanelReactData.dragCol = null
325
+ customPanelReactData.dragGroupField = null
326
+ customPanelReactData.dragAggFnCol = null
327
+ removeClass(trEl, 'active--drag-origin')
328
+ }
329
+
330
+ const sortDragstartEvent = (evnt: DragEvent) => {
331
+ const { customDragTime } = customPanelInternalData
332
+ if (evnt.dataTransfer) {
333
+ evnt.dataTransfer.setDragImage(getTpImg(), 0, 0)
334
+ }
335
+ if (customDragTime) {
336
+ clearTimeout(customDragTime)
337
+ }
338
+ tableReactData.isCustomDragStatus = true
339
+ customPanelInternalData.prevDragGroupField = null
340
+ customPanelInternalData.prevDragAggFnColid = null
341
+ }
342
+
343
+ const sortDragendEvent = (evnt: DragEvent) => {
344
+ const { mouseConfig } = tableProps
345
+ const { customColumnList } = tableReactData
346
+ const { collectColumn } = tableInternalData
347
+ const customOpts = computeCustomOpts.value
348
+ const { immediate } = customOpts
349
+ const trEl = evnt.currentTarget as HTMLElement
350
+ const columnDragOpts = computeColumnDragOpts.value
351
+ const { isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod } = columnDragOpts
352
+ const { dragCol } = customPanelReactData
353
+ const { prevDragCol, prevDragGroupField, prevDragAggFnColid, prevDragPos, prevDragToChild } = customPanelInternalData
354
+ const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
355
+
356
+ if (prevDragGroupField || prevDragAggFnColid) {
357
+ if ($xeTable.handlePivotTableAggregatePanelDragendEvent) {
358
+ $xeTable.handlePivotTableAggregatePanelDragendEvent(evnt)
359
+ }
360
+ } else if (prevDragCol && dragCol) {
361
+ // 判断是否有拖动
362
+ if (prevDragCol !== dragCol) {
363
+ const dragColumn = dragCol
364
+ const newColumn = prevDragCol
365
+ Promise.resolve(
366
+ dragEndMethod
367
+ ? dragEndMethod({
368
+ oldColumn: dragColumn,
369
+ newColumn,
370
+ dragColumn,
371
+ dragPos: prevDragPos as any,
372
+ dragToChild: !!prevDragToChild,
373
+ offsetIndex: dragOffsetIndex
374
+ })
375
+ : true
376
+ ).then((status) => {
377
+ if (!status) {
378
+ return
379
+ }
380
+
381
+ let oafIndex = -1
382
+ let nafIndex = -1
383
+
384
+ const oldAllMaps: Record<string, any> = {}
385
+ XEUtils.eachTree([dragColumn], column => {
386
+ oldAllMaps[column.id] = column
387
+ })
388
+
389
+ let isSelfToChildStatus = false
390
+
391
+ // 只有实时拖拽支持跨层级
392
+ if (immediate) {
393
+ if (dragColumn.parentId && newColumn.parentId) {
394
+ // 子到子
395
+
396
+ if (!isCrossDrag) {
397
+ return
398
+ }
399
+ if (oldAllMaps[newColumn.id]) {
400
+ isSelfToChildStatus = true
401
+ if (!(isCrossDrag && isSelfToChildDrag)) {
402
+ if (VxeUI.modal) {
403
+ VxeUI.modal.message({
404
+ status: 'error',
405
+ content: getI18n('vxe.error.treeDragChild')
406
+ })
407
+ }
408
+ return
409
+ }
410
+ }
411
+ } else if (dragColumn.parentId) {
412
+ // 子到根
413
+
414
+ if (!isCrossDrag) {
415
+ return
416
+ }
417
+ } else if (newColumn.parentId) {
418
+ // 根到子
419
+
420
+ if (!isCrossDrag) {
421
+ return
422
+ }
423
+ if (oldAllMaps[newColumn.id]) {
424
+ isSelfToChildStatus = true
425
+ if (!(isCrossDrag && isSelfToChildDrag)) {
426
+ if (VxeUI.modal) {
427
+ VxeUI.modal.message({
428
+ status: 'error',
429
+ content: getI18n('vxe.error.treeDragChild')
430
+ })
431
+ }
432
+ return
433
+ }
434
+ }
435
+ } else {
436
+ // 根到根
437
+ }
438
+
439
+ const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id)
440
+
441
+ // 改变层级
442
+ if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
443
+ if (oldewMatchRest) {
444
+ const { items: oCols, index: oIndex } = oldewMatchRest
445
+ const childList = dragColumn.children || []
446
+ childList.forEach(column => {
447
+ column.parentId = dragColumn.parentId
448
+ })
449
+ oCols.splice(oIndex, 1, ...childList)
450
+ dragColumn.children = []
451
+ }
452
+ } else {
453
+ if (oldewMatchRest) {
454
+ const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest
455
+ oCols.splice(oIndex, 1)
456
+ if (!oParent) {
457
+ oafIndex = oIndex
458
+ }
459
+ }
460
+ }
461
+
462
+ const newMatchRest = XEUtils.findTree(collectColumn, item => item.id === newColumn.id)
463
+ if (newMatchRest) {
464
+ const { items: nCols, index: nIndex, parent: nParent } = newMatchRest
465
+ // 转子级
466
+ if ((isCrossDrag && isToChildDrag) && prevDragToChild) {
467
+ dragColumn.parentId = newColumn.id
468
+ newColumn.children = (newColumn.children || []).concat([dragColumn])
469
+ } else {
470
+ dragColumn.parentId = newColumn.parentId
471
+ nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn)
472
+ }
473
+ if (!nParent) {
474
+ nafIndex = nIndex
475
+ }
476
+ }
477
+
478
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentItem) => {
479
+ if (!parentItem) {
480
+ const sortIndex = index + 1
481
+ column.renderSortNumber = sortIndex
482
+ }
483
+ })
484
+ } else {
485
+ oafIndex = XEUtils.findIndexOf(customColumnList, item => item.id === dragColumn.id)
486
+ customColumnList.splice(oafIndex, 1)
487
+
488
+ nafIndex = XEUtils.findIndexOf(customColumnList, item => item.id === newColumn.id)
489
+ customColumnList.splice(nafIndex + dragOffsetIndex, 0, dragColumn)
490
+ }
491
+
492
+ if (mouseConfig) {
493
+ if ($xeTable.clearSelected) {
494
+ $xeTable.clearSelected()
495
+ }
496
+ if ($xeTable.clearCellAreas) {
497
+ $xeTable.clearCellAreas()
498
+ $xeTable.clearCopyCellArea()
499
+ }
500
+ }
501
+
502
+ const csParams = {
503
+ oldColumn: dragColumn,
504
+ newColumn,
505
+ dragColumn,
506
+ dragPos: prevDragPos,
507
+ offsetIndex: dragOffsetIndex,
508
+ _index: {
509
+ newIndex: nafIndex,
510
+ oldIndex: oafIndex
511
+ }
512
+ }
513
+ $xeTable.dispatchEvent('custom-sort-change', csParams, evnt)
514
+ $xeTable.dispatchEvent('column-dragend', csParams, evnt)
515
+
516
+ if (immediate) {
517
+ tableReactData.customColumnList = collectColumn.slice(0)
518
+ $xeTable.handleColDragSwapColumn()
519
+ }
520
+ clearDragAnimateStatus()
521
+ }).catch(() => {
522
+ })
523
+ }
524
+ }
525
+
526
+ hideDropTip()
527
+ customPanelReactData.dragCol = null
528
+ customPanelReactData.dragGroupField = null
529
+ customPanelReactData.dragAggFnCol = null
530
+ customPanelInternalData.prevDragGroupField = null
531
+ customPanelInternalData.prevDragAggFnColid = null
532
+ trEl.draggable = false
533
+ trEl.removeAttribute('drag-pos')
534
+ removeClass(trEl, 'active--drag-target')
535
+ removeClass(trEl, 'active--drag-origin')
536
+ }
537
+
538
+ const sortDragoverEvent = (evnt: DragEvent) => {
539
+ const customOpts = computeCustomOpts.value
540
+ const { immediate } = customOpts
541
+ const columnDragOpts = computeColumnDragOpts.value
542
+ const { isCrossDrag, isToChildDrag } = columnDragOpts
543
+ const optEl = evnt.currentTarget as HTMLElement
544
+ const isControlKey = hasControlKey(evnt)
545
+ const colid = optEl.getAttribute('colid')
546
+ const column = $xeTable.getColumnById(colid)
547
+ const { dragCol } = customPanelReactData
548
+ customPanelInternalData.prevDragGroupField = null
549
+ customPanelInternalData.prevDragAggFnColid = null
550
+ // 是否移入有效列
551
+ if (column && (isCrossDrag || column.level === 1)) {
552
+ evnt.preventDefault()
553
+ const offsetY = evnt.clientY - optEl.getBoundingClientRect().y
554
+ const dragPos = offsetY < optEl.clientHeight / 2 ? 'top' : 'bottom'
555
+ if (
556
+ !dragCol ||
557
+ (dragCol && dragCol.id === column.id) ||
558
+ (!isCrossDrag && column.level > 1) ||
559
+ (!immediate && column.level > 1)
560
+ ) {
561
+ showDropTip(evnt, optEl, false, dragPos)
562
+ return
563
+ }
564
+ customPanelInternalData.prevDragToChild = !!((isCrossDrag && isToChildDrag) && isControlKey && immediate)
565
+ customPanelInternalData.prevDragCol = column
566
+ customPanelInternalData.prevDragPos = dragPos
567
+ showDropTip(evnt, optEl, true, dragPos)
568
+ }
569
+ }
570
+
571
+ const clearDragAnimateStatus = () => {
572
+ customPanelInternalData.customDragTime = setTimeout(() => {
573
+ tableReactData.isCustomDragStatus = false
574
+ customPanelInternalData.customDragTime = undefined
575
+ }, 350)
576
+ }
577
+
578
+ const sortMoveUpEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
579
+ const { customColumnList } = tableReactData
580
+ const matchObj = XEUtils.findTree(customColumnList, item => item === column)
581
+ if (matchObj) {
582
+ const { item, items, index } = matchObj
583
+ if (index > 0) {
584
+ tableReactData.isCustomDragStatus = true
585
+ nextTick(() => {
586
+ items.splice(index, 1)
587
+ items.splice(index - 1, 0, item)
588
+ clearDragAnimateStatus()
589
+ })
590
+ }
591
+ }
592
+ }
593
+
594
+ const sortMoveDnEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
595
+ const { customColumnList } = tableReactData
596
+ const matchObj = XEUtils.findTree(customColumnList, item => item === column)
597
+ if (matchObj) {
598
+ const { item, items, index } = matchObj
599
+ if (index < items.length - 1) {
600
+ tableReactData.isCustomDragStatus = true
601
+ nextTick(() => {
602
+ items.splice(index, 1)
603
+ items.splice(index + 1, 0, item)
604
+ clearDragAnimateStatus()
605
+ })
606
+ }
607
+ }
608
+ }
609
+
610
+ const sortMoveTopEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
611
+ const { customColumnList } = tableReactData
612
+ const matchObj = XEUtils.findTree(customColumnList, item => item === column)
613
+ if (matchObj) {
614
+ const { item, items, index, parent: parentItem } = matchObj
615
+ if (parentItem || index > 0) {
616
+ tableReactData.isCustomDragStatus = true
617
+ nextTick(() => {
618
+ item.parentId = null
619
+ items.splice(index, 1)
620
+ customColumnList.unshift(item)
621
+ clearDragAnimateStatus()
622
+ })
623
+ }
624
+ }
625
+ }
626
+
627
+ const sortMoveBottomEvent = (evntParame: VxeButtonDefines.ClickEventParams, column: VxeTableDefines.ColumnInfo) => {
628
+ const { customColumnList } = tableReactData
629
+ const matchObj = XEUtils.findTree(customColumnList, item => item === column)
630
+ if (matchObj) {
631
+ const { item, items, index, parent: parentItem } = matchObj
632
+ if (parentItem || index < items.length - 1) {
633
+ tableReactData.isCustomDragStatus = true
634
+ nextTick(() => {
635
+ item.parentId = null
636
+ items.splice(index, 1)
637
+ customColumnList.push(item)
638
+ clearDragAnimateStatus()
639
+ })
640
+ }
641
+ }
642
+ }
643
+
644
+ const renderDragTip = () => {
645
+ const { dragTipText } = customPanelReactData
646
+ const columnDragOpts = computeColumnDragOpts.value
647
+ return h('div', {}, [
648
+ h('div', {
649
+ ref: refDragLineElem,
650
+ class: ['vxe-table-custom-popup--drag-line', {
651
+ 'is--guides': columnDragOpts.showGuidesStatus
652
+ }]
653
+ }),
654
+ h('div', {
655
+ ref: refDragTipElem,
656
+ class: 'vxe-table-custom-popup--drag-tip'
657
+ }, [
658
+ h('div', {
659
+ class: 'vxe-table-custom-popup--drag-tip-wrapper'
660
+ }, [
661
+ h('div', {
662
+ class: 'vxe-table-custom-popup--drag-tip-status'
663
+ }, [
664
+ h('span', {
665
+ class: ['vxe-table-custom-popup--drag-tip-normal-status', getIcon().TABLE_DRAG_STATUS_ROW]
666
+ }),
667
+ h('span', {
668
+ class: ['vxe-table-custom-popup--drag-tip-sub-status', getIcon().TABLE_DRAG_STATUS_SUB_ROW]
669
+ }),
670
+ h('span', {
671
+ class: ['vxe-table-custom-popup--drag-tip-group-status', getIcon().TABLE_DRAG_STATUS_AGG_GROUP]
672
+ }),
673
+ h('span', {
674
+ class: ['vxe-table-custom-popup--drag-tip-values-status', getIcon().TABLE_DRAG_STATUS_AGG_VALUES]
675
+ }),
676
+ h('span', {
677
+ class: ['vxe-table-custom-popup--drag-tip-disabled-status', getIcon().TABLE_DRAG_DISABLED]
678
+ })
679
+ ]),
680
+ h('div', {
681
+ class: 'vxe-table-custom-popup--drag-tip-content'
682
+ }, `${dragTipText || ''}`)
683
+ ])
684
+ ])
685
+ ])
686
+ }
687
+
688
+ const renderSimplePanel = () => {
689
+ const $xeGrid = $xeTable.xeGrid
690
+ const $xeGantt = $xeTable.xeGantt
691
+ const tableProps = $xeTable.props
692
+
693
+ const { customStore } = props
694
+ const { treeConfig, rowGroupConfig, aggregateConfig } = tableProps
695
+ const { isCustomStatus, customColumnList, isCustomDragStatus } = tableReactData
696
+ const customOpts = computeCustomOpts.value
697
+ const { immediate } = customOpts
698
+ const columnDragOpts = computeColumnDragOpts.value
699
+ const { popupStyle } = customStore
700
+ const { checkMethod, visibleMethod, allowVisible, allowSort, allowFixed, trigger, placement, showSortDragButton, showSortMoveButton, showSortPutButton } = customOpts
701
+ const isMaxFixedColumn = computeIsMaxFixedColumn.value
702
+ const vSize = computeSize.value
703
+ const { isCrossDrag } = columnDragOpts
704
+ const slots = customOpts.slots || {}
705
+ const headerSlot = slots.header
706
+ const topSlot = slots.top
707
+ const bottomSlot = slots.bottom
708
+ const defaultSlot = slots.default
709
+ const footerSlot = slots.footer
710
+ const colVNs: VNode[] = []
711
+ const customWrapperOns: any = {}
712
+ const isAllChecked = customStore.isAll
713
+ const isAllIndeterminate = customStore.isIndeterminate
714
+ // hover 触发
715
+ if (trigger === 'hover') {
716
+ customWrapperOns.onMouseenter = handleWrapperMouseenterEvent
717
+ customWrapperOns.onMouseleave = handleWrapperMouseleaveEvent
718
+ }
719
+ const params = {
720
+ $table: $xeTable,
721
+ $grid: $xeGrid,
722
+ $gantt: $xeGantt,
723
+ columns: customColumnList,
724
+ isAllChecked,
725
+ isAllIndeterminate,
726
+ isCustomStatus
727
+ }
728
+ XEUtils.eachTree(customColumnList, (column, index, items, path, parentItem) => {
729
+ const isVisible = visibleMethod ? visibleMethod({ $table: $xeTable, column }) : true
730
+ if (isVisible) {
731
+ const isChecked = column.renderVisible
732
+ const isIndeterminate = column.halfVisible
733
+ const isColGroup = column.children && column.children.length
734
+ const colTitle = formatText(column.getTitle(), 1)
735
+ const isDisabled = checkMethod ? !checkMethod({ $table: $xeTable, column }) : false
736
+ const isHidden = !isChecked
737
+ const showSortBtn = ((isCrossDrag ? immediate : false) || column.level === 1)
738
+ colVNs.push(
739
+ h('li', {
740
+ key: column.id,
741
+ colid: column.id,
742
+ class: ['vxe-table-custom--option', `level--${column.level}`, {
743
+ 'is--hidden': isDisabled || isHidden,
744
+ 'is--group': isColGroup
745
+ }],
746
+ onDragstart: sortDragstartEvent,
747
+ onDragend: sortDragendEvent,
748
+ onDragover: sortDragoverEvent
749
+ }, [
750
+ allowVisible
751
+ ? h('div', {
752
+ class: ['vxe-table-custom--checkbox-option', {
753
+ 'is--checked': isChecked,
754
+ 'is--indeterminate': isIndeterminate,
755
+ 'is--disabled': isDisabled
756
+ }],
757
+ title: getI18n('vxe.custom.setting.colVisible'),
758
+ onClick: (evnt: MouseEvent) => {
759
+ if (!isDisabled) {
760
+ changeCheckboxOption(column, evnt)
761
+ }
762
+ }
763
+ }, [
764
+ h('span', {
765
+ class: ['vxe-checkbox--icon', isIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
766
+ })
767
+ ])
768
+ : renderEmptyElement($xeTable),
769
+ h('div', {
770
+ class: 'vxe-table-custom--name-option'
771
+ }, [
772
+ allowSort && showSortDragButton && showSortBtn
773
+ ? h('div', {
774
+ class: 'vxe-table-custom--sort-option'
775
+ }, [
776
+ h('span', {
777
+ class: ['vxe-table-custom--sort-btn', {
778
+ 'is--disabled': isHidden
779
+ }],
780
+ title: getI18n('vxe.custom.setting.sortHelpTip'),
781
+ ...(isHidden
782
+ ? {}
783
+ : {
784
+ onMousedown: sortMousedownEvent,
785
+ onMouseup: sortMouseupEvent
786
+ })
787
+ }, [
788
+ h('i', {
789
+ class: getIcon().TABLE_CUSTOM_SORT
790
+ })
791
+ ])
792
+ ])
793
+ : renderEmptyElement($xeTable),
794
+ column.type === 'html'
795
+ ? h('div', {
796
+ key: '1',
797
+ class: 'vxe-table-custom--checkbox-label',
798
+ innerHTML: colTitle
799
+ })
800
+ : h('div', {
801
+ key: '0',
802
+ class: 'vxe-table-custom--checkbox-label'
803
+ }, colTitle)
804
+ ]),
805
+ showSortBtn && (showSortMoveButton || showSortPutButton)
806
+ ? h('div', {
807
+ class: 'vxe-table-custom--move-btn-option'
808
+ }, VxeUIButtonComponent
809
+ ? [
810
+ showSortMoveButton
811
+ ? h(VxeUIButtonComponent, {
812
+ mode: 'text',
813
+ icon: 'vxe-icon-arrows-up',
814
+ title: getI18n('vxe.custom.setting.moveUpTitle'),
815
+ disabled: index <= 0,
816
+ onClick (evntParame) {
817
+ sortMoveUpEvent(evntParame, column)
818
+ }
819
+ })
820
+ : renderEmptyElement($xeTable),
821
+ showSortMoveButton
822
+ ? h(VxeUIButtonComponent, {
823
+ mode: 'text',
824
+ icon: 'vxe-icon-arrows-down',
825
+ title: getI18n('vxe.custom.setting.moveDnTitle'),
826
+ disabled: index >= items.length - 1,
827
+ onClick (evntParame) {
828
+ sortMoveDnEvent(evntParame, column)
829
+ }
830
+ })
831
+ : renderEmptyElement($xeTable),
832
+ showSortPutButton && !parentItem
833
+ ? h(VxeUIButtonComponent, {
834
+ mode: 'text',
835
+ icon: 'vxe-icon-top',
836
+ title: getI18n('vxe.custom.setting.putTopTitle'),
837
+ disabled: index <= 0,
838
+ onClick (evntParame) {
839
+ sortMoveTopEvent(evntParame, column)
840
+ }
841
+ })
842
+ : renderEmptyElement($xeTable),
843
+ showSortPutButton && !parentItem
844
+ ? h(VxeUIButtonComponent, {
845
+ mode: 'text',
846
+ icon: 'vxe-icon-bottom',
847
+ title: getI18n('vxe.custom.setting.putBottomTitle'),
848
+ disabled: index >= items.length - 1,
849
+ onClick (evntParame) {
850
+ sortMoveBottomEvent(evntParame, column)
851
+ }
852
+ })
853
+ : renderEmptyElement($xeTable)
854
+ ]
855
+ : [])
856
+ : renderEmptyElement($xeTable),
857
+ !parentItem && allowFixed
858
+ ? h('div', {
859
+ class: 'vxe-table-custom--fixed-option'
860
+ }, [
861
+ VxeUIButtonComponent
862
+ ? h(VxeUIButtonComponent, {
863
+ mode: 'text',
864
+ icon: column.renderFixed === 'left' ? getIcon().TOOLBAR_TOOLS_FIXED_LEFT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_LEFT,
865
+ status: column.renderFixed === 'left' ? 'primary' : '',
866
+ disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
867
+ title: getI18n(column.renderFixed === 'left' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedLeft'),
868
+ onClick: ({ $event }) => {
869
+ changeFixedOption(column, 'left', $event)
870
+ }
871
+ })
872
+ : renderEmptyElement($xeTable),
873
+ VxeUIButtonComponent
874
+ ? h(VxeUIButtonComponent, {
875
+ mode: 'text',
876
+ icon: column.renderFixed === 'right' ? getIcon().TOOLBAR_TOOLS_FIXED_RIGHT_ACTIVE : getIcon().TOOLBAR_TOOLS_FIXED_RIGHT,
877
+ status: column.renderFixed === 'right' ? 'primary' : '',
878
+ disabled: isHidden || (isMaxFixedColumn && !column.renderFixed),
879
+ title: getI18n(column.renderFixed === 'right' ? 'vxe.toolbar.cancelFixed' : 'vxe.toolbar.fixedRight'),
880
+ onClick: ({ $event }) => {
881
+ changeFixedOption(column, 'right', $event)
882
+ }
883
+ })
884
+ : renderEmptyElement($xeTable)
885
+ ])
886
+ : renderEmptyElement($xeTable)
887
+ ])
888
+ )
889
+ }
890
+ })
891
+ return h('div', {
892
+ ref: refElem,
893
+ key: 'simple',
894
+ class: ['vxe-table-custom-wrapper', `placement--${placement}`, {
895
+ [`size--${vSize}`]: vSize,
896
+ 'is--active': customStore.visible
897
+ }],
898
+ style: popupStyle
899
+ }, customStore.visible
900
+ ? [
901
+ h('div', {
902
+ ref: refBodyWrapperElem,
903
+ class: 'vxe-table-custom-simple--body-wrapper'
904
+ }, [
905
+ !treeConfig && (aggregateConfig || rowGroupConfig) && $xeTable.getPivotTableAggregateSimplePanel
906
+ ? h($xeTable.getPivotTableAggregateSimplePanel(), {
907
+ customStore
908
+ })
909
+ : renderEmptyElement($xeTable),
910
+ h('div', {
911
+ ref: refCustomBodyElem,
912
+ class: 'vxe-table-custom--handle-wrapper'
913
+ }, [
914
+ h('div', {
915
+ class: 'vxe-table-custom--header'
916
+ }, headerSlot
917
+ ? $xeTable.callSlot(headerSlot, params)
918
+ : [
919
+ h('ul', {
920
+ class: 'vxe-table-custom--panel-list'
921
+ }, [
922
+ h('li', {
923
+ class: 'vxe-table-custom--option'
924
+ }, [
925
+ allowVisible
926
+ ? h('div', {
927
+ class: ['vxe-table-custom--checkbox-option', {
928
+ 'is--checked': isAllChecked,
929
+ 'is--indeterminate': isAllIndeterminate
930
+ }],
931
+ title: getI18n('vxe.table.allTitle'),
932
+ onClick: allOptionEvent
933
+ }, [
934
+ h('span', {
935
+ class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
936
+ }),
937
+ h('span', {
938
+ class: 'vxe-checkbox--label'
939
+ }, getI18n('vxe.toolbar.customAll'))
940
+ ])
941
+ : h('span', {
942
+ class: 'vxe-checkbox--label'
943
+ }, getI18n('vxe.table.customTitle'))
944
+ ])
945
+ ])
946
+ ]),
947
+ h('div', {
948
+ class: 'vxe-table-custom--body'
949
+ }, [
950
+ topSlot
951
+ ? h('div', {
952
+ class: 'vxe-table-custom--panel-top'
953
+ }, $xeTable.callSlot(topSlot, params))
954
+ : renderEmptyElement($xeTable),
955
+ defaultSlot
956
+ ? h('div', {
957
+ class: 'vxe-table-custom--panel-body'
958
+ }, $xeTable.callSlot(defaultSlot, params))
959
+ : h(TransitionGroup, {
960
+ class: 'vxe-table-custom--panel-list',
961
+ name: isCustomDragStatus ? 'vxe-table-custom--list' : '',
962
+ tag: 'ul',
963
+ ...customWrapperOns
964
+ }, {
965
+ default: () => colVNs
966
+ }),
967
+ bottomSlot
968
+ ? h('div', {
969
+ class: 'vxe-table-custom--panel-bottom'
970
+ }, $xeTable.callSlot(bottomSlot, params))
971
+ : renderEmptyElement($xeTable)
972
+ ]),
973
+ customOpts.showFooter
974
+ ? h('div', {
975
+ class: 'vxe-table-custom--footer'
976
+ }, footerSlot
977
+ ? $xeTable.callSlot(footerSlot, params)
978
+ : [
979
+ h('div', {
980
+ class: 'vxe-table-custom--footer-buttons'
981
+ }, [
982
+ VxeUIButtonComponent
983
+ ? h(VxeUIButtonComponent, {
984
+ mode: 'text',
985
+ content: customOpts.resetButtonText || getI18n('vxe.table.customRestore'),
986
+ disabled: !isCustomStatus,
987
+ onClick: resetCustomEvent
988
+ })
989
+ : renderEmptyElement($xeTable),
990
+ immediate
991
+ ? (VxeUIButtonComponent
992
+ ? h(VxeUIButtonComponent, {
993
+ mode: 'text',
994
+ content: customOpts.closeButtonText || getI18n('vxe.table.customClose'),
995
+ onClick: cancelCloseEvent
996
+ })
997
+ : renderEmptyElement($xeTable))
998
+ : (VxeUIButtonComponent
999
+ ? h(VxeUIButtonComponent, {
1000
+ mode: 'text',
1001
+ content: customOpts.cancelButtonText || getI18n('vxe.table.customCancel'),
1002
+ onClick: cancelCustomEvent
1003
+ })
1004
+ : renderEmptyElement($xeTable)),
1005
+ immediate
1006
+ ? renderEmptyElement($xeTable)
1007
+ : (VxeUIButtonComponent
1008
+ ? h(VxeUIButtonComponent, {
1009
+ mode: 'text',
1010
+ status: 'primary',
1011
+ content: customOpts.confirmButtonText || getI18n('vxe.table.customConfirm'),
1012
+ onClick: confirmCustomEvent
1013
+ })
1014
+ : renderEmptyElement($xeTable))
1015
+ ])
1016
+ ])
1017
+ : null
1018
+ ]),
1019
+ renderDragTip()
1020
+ ])
1021
+ ]
1022
+ : [])
1023
+ }
1024
+
1025
+ const renderPopupPanel = () => {
1026
+ const $xeGrid = $xeTable.xeGrid
1027
+ const $xeGantt = $xeTable.xeGantt
1028
+
1029
+ const { customStore } = props
1030
+ const { treeConfig, rowGroupConfig, aggregateConfig, resizable: allResizable } = tableProps
1031
+ const { isCustomStatus, customColumnList } = tableReactData
1032
+ const customOpts = computeCustomOpts.value
1033
+ const { immediate, showSortDragButton, showSortMoveButton, showSortPutButton } = customOpts
1034
+ const columnDragOpts = computeColumnDragOpts.value
1035
+ const { mode, modalOptions, drawerOptions, allowVisible, allowSort, allowFixed, allowResizable, checkMethod, visibleMethod } = customOpts
1036
+ const columnOpts = computeColumnOpts.value
1037
+ const { maxFixedSize } = columnOpts
1038
+ const resizableOpts = computeResizableOpts.value
1039
+ const { minWidth: reMinWidth, maxWidth: reMaxWidth } = resizableOpts
1040
+ const modalOpts = Object.assign({}, modalOptions)
1041
+ const drawerOpts = Object.assign({}, drawerOptions)
1042
+ const isMaxFixedColumn = computeIsMaxFixedColumn.value
1043
+ const { isCrossDrag } = columnDragOpts
1044
+ const slots = customOpts.slots || {}
1045
+ const headerSlot = slots.header
1046
+ const topSlot = slots.top
1047
+ const bottomSlot = slots.bottom
1048
+ const defaultSlot = slots.default
1049
+ const footerSlot = slots.footer
1050
+ const trVNs: VNode[] = []
1051
+ const isAllChecked = customStore.isAll
1052
+ const isAllIndeterminate = customStore.isIndeterminate
1053
+ const params = {
1054
+ $table: $xeTable,
1055
+ $grid: $xeGrid,
1056
+ $gantt: $xeGantt,
1057
+ columns: customColumnList,
1058
+ isAllChecked,
1059
+ isAllIndeterminate,
1060
+ isCustomStatus
1061
+ }
1062
+ XEUtils.eachTree(customColumnList, (column, index, items, path, parentItem) => {
1063
+ const isVisible = visibleMethod ? visibleMethod({ $table: $xeTable, column }) : true
1064
+ if (isVisible) {
1065
+ // 默认继承调整宽度
1066
+ let customMinWidth = 0
1067
+ let customMaxWidth = 0
1068
+ if (allowResizable) {
1069
+ const resizeParams = {
1070
+ $table: $xeTable,
1071
+ column,
1072
+ columnIndex: index,
1073
+ $columnIndex: index,
1074
+ $rowIndex: -1
1075
+ }
1076
+ if (reMinWidth) {
1077
+ customMinWidth = XEUtils.toNumber(XEUtils.isFunction(reMinWidth) ? reMinWidth(resizeParams) : reMinWidth)
1078
+ }
1079
+ if (reMaxWidth) {
1080
+ customMaxWidth = XEUtils.toNumber(XEUtils.isFunction(reMaxWidth) ? reMaxWidth(resizeParams) : reMaxWidth)
1081
+ }
1082
+ }
1083
+
1084
+ const isChecked = column.renderVisible
1085
+ const isIndeterminate = column.halfVisible
1086
+ const colTitle = formatText(column.getTitle(), 1)
1087
+ const isColGroup = column.children && column.children.length
1088
+ const isDisabled = checkMethod ? !checkMethod({ $table: $xeTable, column }) : false
1089
+ const isHidden = !isChecked
1090
+ const showSortBtn = ((isCrossDrag ? immediate : false) || column.level === 1)
1091
+ trVNs.push(
1092
+ h('tr', {
1093
+ key: column.id,
1094
+ colid: column.id,
1095
+ class: [`vxe-table-custom-popup--row level--${column.level}`, {
1096
+ 'is--group': isColGroup
1097
+ }],
1098
+ onDragstart: sortDragstartEvent,
1099
+ onDragend: sortDragendEvent,
1100
+ onDragover: sortDragoverEvent
1101
+ }, [
1102
+ allowVisible
1103
+ ? h('td', {
1104
+ class: 'vxe-table-custom-popup--column-item col--visible'
1105
+ }, [
1106
+ h('div', {
1107
+ class: ['vxe-table-custom--checkbox-option', {
1108
+ 'is--checked': isChecked,
1109
+ 'is--indeterminate': isIndeterminate,
1110
+ 'is--disabled': isDisabled
1111
+ }],
1112
+ title: getI18n('vxe.custom.setting.colVisible'),
1113
+ onClick: (evnt: MouseEvent) => {
1114
+ if (!isDisabled) {
1115
+ changeCheckboxOption(column, evnt)
1116
+ }
1117
+ }
1118
+ }, [
1119
+ h('span', {
1120
+ class: ['vxe-checkbox--icon', isIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
1121
+ })
1122
+ ])
1123
+ ])
1124
+ : renderEmptyElement($xeTable),
1125
+ h('td', {
1126
+ class: 'vxe-table-custom-popup--column-item col--name'
1127
+ }, [
1128
+ h('div', {
1129
+ class: 'vxe-table-custom-popup--name'
1130
+ }, [
1131
+ allowSort
1132
+ ? showSortDragButton && (showSortBtn
1133
+ ? h('div', {
1134
+ class: ['vxe-table-custom-popup--column-sort-btn', {
1135
+ 'is--disabled': isHidden
1136
+ }],
1137
+ title: getI18n('vxe.custom.setting.sortHelpTip'),
1138
+ ...(isHidden
1139
+ ? {}
1140
+ : {
1141
+ onMousedown: sortMousedownEvent,
1142
+ onMouseup: sortMouseupEvent
1143
+ })
1144
+ }, [
1145
+ h('i', {
1146
+ class: getIcon().TABLE_CUSTOM_SORT
1147
+ })
1148
+ ])
1149
+ : h('div', {
1150
+ class: 'vxe-table-custom-popup--column-sort-placeholder'
1151
+ }))
1152
+ : renderEmptyElement($xeTable),
1153
+ column.type === 'html'
1154
+ ? h('div', {
1155
+ key: '1',
1156
+ class: 'vxe-table-custom-popup--title',
1157
+ innerHTML: colTitle
1158
+ })
1159
+ : h('div', {
1160
+ key: '0',
1161
+ class: 'vxe-table-custom-popup--title',
1162
+ title: colTitle
1163
+ }, colTitle),
1164
+ showSortBtn && (showSortMoveButton || showSortPutButton)
1165
+ ? h('div', {
1166
+ class: 'vxe-table-custom-popup--move-btn'
1167
+ }, VxeUIButtonComponent
1168
+ ? [
1169
+ showSortMoveButton
1170
+ ? h(VxeUIButtonComponent, {
1171
+ mode: 'text',
1172
+ content: getI18n('vxe.custom.setting.moveUp'),
1173
+ title: getI18n('vxe.custom.setting.moveUpTitle'),
1174
+ disabled: index <= 0,
1175
+ onClick (evntParame) {
1176
+ sortMoveUpEvent(evntParame, column)
1177
+ }
1178
+ })
1179
+ : renderEmptyElement($xeTable),
1180
+ showSortMoveButton
1181
+ ? h(VxeUIButtonComponent, {
1182
+ mode: 'text',
1183
+ content: getI18n('vxe.custom.setting.moveDn'),
1184
+ title: getI18n('vxe.custom.setting.moveDnTitle'),
1185
+ disabled: index >= items.length - 1,
1186
+ onClick (evntParame) {
1187
+ sortMoveDnEvent(evntParame, column)
1188
+ }
1189
+ })
1190
+ : renderEmptyElement($xeTable),
1191
+ showSortPutButton && !parentItem
1192
+ ? h(VxeUIButtonComponent, {
1193
+ mode: 'text',
1194
+ content: getI18n('vxe.custom.setting.putTop'),
1195
+ title: getI18n('vxe.custom.setting.putTopTitle'),
1196
+ disabled: index <= 0,
1197
+ onClick (evntParame) {
1198
+ sortMoveTopEvent(evntParame, column)
1199
+ }
1200
+ })
1201
+ : renderEmptyElement($xeTable),
1202
+ showSortPutButton && !parentItem
1203
+ ? h(VxeUIButtonComponent, {
1204
+ mode: 'text',
1205
+ content: getI18n('vxe.custom.setting.putBottom'),
1206
+ title: getI18n('vxe.custom.setting.putBottomTitle'),
1207
+ disabled: index >= items.length - 1,
1208
+ onClick (evntParame) {
1209
+ sortMoveBottomEvent(evntParame, column)
1210
+ }
1211
+ })
1212
+ : renderEmptyElement($xeTable)
1213
+ ]
1214
+ : [])
1215
+ : renderEmptyElement($xeTable)
1216
+ ])
1217
+ ]),
1218
+ allowResizable
1219
+ ? h('td', {
1220
+ class: 'vxe-table-custom-popup--column-item col--resizable'
1221
+ }, [
1222
+ (
1223
+ (column.children && column.children.length) ||
1224
+ !(XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
1225
+ )
1226
+ ? h('span', '-')
1227
+ : (
1228
+ VxeUINumberInputComponent
1229
+ ? h(VxeUINumberInputComponent, {
1230
+ type: 'integer',
1231
+ immediate: false,
1232
+ disabled: isHidden,
1233
+ modelValue: column.renderResizeWidth,
1234
+ min: customMinWidth || undefined,
1235
+ max: customMaxWidth || undefined,
1236
+ 'onUpdate:modelValue' (value: any) {
1237
+ const width = Math.max(0, Number(value))
1238
+ column.renderResizeWidth = width
1239
+ },
1240
+ onChange () {
1241
+ changeColumnWidth(column)
1242
+ }
1243
+ })
1244
+ : renderEmptyElement($xeTable)
1245
+ )
1246
+ ])
1247
+ : renderEmptyElement($xeTable),
1248
+ allowFixed
1249
+ ? h('td', {
1250
+ class: 'vxe-table-custom-popup--column-item col--fixed'
1251
+ }, [
1252
+ parentItem
1253
+ ? h('span', '-')
1254
+ : (
1255
+ VxeUIRadioGroupComponent
1256
+ ? h(VxeUIRadioGroupComponent, {
1257
+ modelValue: column.renderFixed || '',
1258
+ type: 'button',
1259
+ size: 'mini',
1260
+ disabled: isHidden,
1261
+ options: [
1262
+ { label: getI18n('vxe.custom.setting.fixedLeft'), value: 'left', disabled: isHidden || isMaxFixedColumn },
1263
+ { label: getI18n('vxe.custom.setting.fixedUnset'), value: '', disabled: isHidden },
1264
+ { label: getI18n('vxe.custom.setting.fixedRight'), value: 'right', disabled: isHidden || isMaxFixedColumn }
1265
+ ],
1266
+ onChange ({ label, $event }) {
1267
+ changeFixedOption(column, label, $event)
1268
+ }
1269
+ })
1270
+ : renderEmptyElement($xeTable)
1271
+ )
1272
+ ])
1273
+ : renderEmptyElement($xeTable)
1274
+ ])
1275
+ )
1276
+ }
1277
+ })
1278
+ const scopedSlots: Record<string, any> = {
1279
+ default: () => {
1280
+ return h('div', {
1281
+ ref: refBodyWrapperElem,
1282
+ class: 'vxe-table-custom-popup--body-wrapper'
1283
+ }, defaultSlot
1284
+ ? $xeTable.callSlot(defaultSlot, params)
1285
+ : [
1286
+ !treeConfig && (aggregateConfig || rowGroupConfig) && $xeTable.getPivotTableAggregatePopupPanel
1287
+ ? h($xeTable.getPivotTableAggregatePopupPanel(), {
1288
+ customStore
1289
+ })
1290
+ : renderEmptyElement($xeTable),
1291
+ h('div', {
1292
+ ref: refCustomBodyElem,
1293
+ class: 'vxe-table-custom-popup--handle-wrapper'
1294
+ }, [
1295
+ topSlot
1296
+ ? h('div', {
1297
+ class: 'vxe-table-custom-popup--table-top'
1298
+ }, $xeTable.callSlot(topSlot, params))
1299
+ : renderEmptyElement($xeTable),
1300
+ h('div', {
1301
+ class: 'vxe-table-custom-popup--table-wrapper'
1302
+ }, [
1303
+ h('table', {}, [
1304
+ h('colgroup', {}, [
1305
+ allowVisible
1306
+ ? h('col', {
1307
+ class: 'vxe-table-custom-popup--table-col-seq'
1308
+ })
1309
+ : renderEmptyElement($xeTable),
1310
+ h('col', {
1311
+ class: 'vxe-table-custom-popup--table-col-title'
1312
+ }),
1313
+ allowResizable
1314
+ ? h('col', {
1315
+ class: 'vxe-table-custom-popup--table-col-width'
1316
+ })
1317
+ : renderEmptyElement($xeTable),
1318
+ allowFixed
1319
+ ? h('col', {
1320
+ class: 'vxe-table-custom-popup--table-col-fixed'
1321
+ })
1322
+ : renderEmptyElement($xeTable)
1323
+ ]),
1324
+ h('thead', {}, [
1325
+ h('tr', {}, [
1326
+ allowVisible
1327
+ ? h('th', {}, [
1328
+ h('div', {
1329
+ class: ['vxe-table-custom--checkbox-option', {
1330
+ 'is--checked': isAllChecked,
1331
+ 'is--indeterminate': isAllIndeterminate
1332
+ }],
1333
+ title: getI18n('vxe.table.allTitle'),
1334
+ onClick: allOptionEvent
1335
+ }, [
1336
+ h('span', {
1337
+ class: ['vxe-checkbox--icon', isAllIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllChecked ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
1338
+ }),
1339
+ h('span', {
1340
+ class: 'vxe-checkbox--label'
1341
+ }, getI18n('vxe.toolbar.customAll'))
1342
+ ])
1343
+ ])
1344
+ : renderEmptyElement($xeTable),
1345
+ h('th', {}, getI18n('vxe.custom.setting.colTitle')),
1346
+ allowResizable
1347
+ ? h('th', {}, getI18n('vxe.custom.setting.colResizable'))
1348
+ : renderEmptyElement($xeTable),
1349
+ allowFixed
1350
+ ? h('th', {}, getI18n(`vxe.custom.setting.${maxFixedSize ? 'colFixedMax' : 'colFixed'}`, [maxFixedSize]))
1351
+ : renderEmptyElement($xeTable)
1352
+ ])
1353
+ ]),
1354
+ h(TransitionGroup, {
1355
+ class: 'vxe-table-custom--panel-list',
1356
+ tag: 'tbody',
1357
+ name: 'vxe-table-custom--list'
1358
+ }, {
1359
+ default: () => trVNs
1360
+ })
1361
+ ])
1362
+ ]),
1363
+ bottomSlot
1364
+ ? h('div', {
1365
+ class: 'vxe-table-custom-popup--table-bottom'
1366
+ }, $xeTable.callSlot(bottomSlot, params))
1367
+ : renderEmptyElement($xeTable),
1368
+ renderDragTip()
1369
+ ])
1370
+ ])
1371
+ },
1372
+ footer: () => {
1373
+ if (footerSlot) {
1374
+ return $xeTable.callSlot(footerSlot, params)
1375
+ }
1376
+ return h('div', {
1377
+ class: 'vxe-table-custom-popup--footer'
1378
+ }, [
1379
+ VxeUIButtonComponent
1380
+ ? h(VxeUIButtonComponent, {
1381
+ content: customOpts.resetButtonText || getI18n('vxe.custom.cstmRestore'),
1382
+ disabled: !isCustomStatus,
1383
+ onClick: resetCustomEvent
1384
+ })
1385
+ : renderEmptyElement($xeTable),
1386
+ immediate
1387
+ ? (VxeUIButtonComponent
1388
+ ? h(VxeUIButtonComponent, {
1389
+ content: customOpts.closeButtonText || getI18n('vxe.table.customClose'),
1390
+ onClick: cancelCloseEvent
1391
+ })
1392
+ : renderEmptyElement($xeTable))
1393
+ : (VxeUIButtonComponent
1394
+ ? h(VxeUIButtonComponent, {
1395
+ content: customOpts.cancelButtonText || getI18n('vxe.table.customCancel'),
1396
+ onClick: cancelCustomEvent
1397
+ })
1398
+ : renderEmptyElement($xeTable)),
1399
+ immediate
1400
+ ? renderEmptyElement($xeTable)
1401
+ : (VxeUIButtonComponent
1402
+ ? h(VxeUIButtonComponent, {
1403
+ status: 'primary',
1404
+ content: customOpts.confirmButtonText || getI18n('vxe.custom.cstmConfirm'),
1405
+ onClick: confirmCustomEvent
1406
+ })
1407
+ : renderEmptyElement($xeTable))
1408
+ ])
1409
+ }
1410
+ }
1411
+ if (headerSlot) {
1412
+ scopedSlots.header = () => $xeTable.callSlot(headerSlot, params)
1413
+ }
1414
+ if (mode === 'drawer') {
1415
+ return VxeUIDrawerComponent
1416
+ ? h(VxeUIDrawerComponent, {
1417
+ key: 'drawer',
1418
+ className: ['vxe-table-custom-drawer-wrapper', 'vxe-table--ignore-clear', drawerOpts.className || ''].join(' '),
1419
+ modelValue: customStore.visible,
1420
+ title: drawerOpts.title || getI18n('vxe.custom.cstmTitle'),
1421
+ width: drawerOpts.width || Math.min(880, Math.floor(document.documentElement.clientWidth * 0.6)),
1422
+ position: drawerOpts.position,
1423
+ resize: !!drawerOpts.resize,
1424
+ escClosable: !!drawerOpts.escClosable,
1425
+ maskClosable: !!drawerOpts.maskClosable,
1426
+ destroyOnClose: true,
1427
+ showFooter: true,
1428
+ 'onUpdate:modelValue' (value: any) {
1429
+ customStore.visible = value
1430
+ }
1431
+ }, scopedSlots)
1432
+ : renderEmptyElement($xeTable)
1433
+ }
1434
+ return VxeUIModalComponent
1435
+ ? h(VxeUIModalComponent, {
1436
+ key: 'modal',
1437
+ className: ['vxe-table-custom-modal-wrapper', 'vxe-table--ignore-clear', modalOpts.className || ''].join(' '),
1438
+ modelValue: customStore.visible,
1439
+ title: modalOpts.title || getI18n('vxe.custom.cstmTitle'),
1440
+ width: modalOpts.width || Math.min(880, document.documentElement.clientWidth),
1441
+ minWidth: modalOpts.minWidth || 700,
1442
+ height: modalOpts.height || Math.min(680, document.documentElement.clientHeight),
1443
+ minHeight: modalOpts.minHeight || 400,
1444
+ showZoom: modalOpts.showZoom,
1445
+ showMaximize: modalOpts.showMaximize,
1446
+ showMinimize: modalOpts.showMinimize,
1447
+ mask: modalOpts.mask,
1448
+ lockView: modalOpts.lockView,
1449
+ resize: modalOpts.resize,
1450
+ escClosable: !!modalOpts.escClosable,
1451
+ maskClosable: !!modalOpts.maskClosable,
1452
+ destroyOnClose: true,
1453
+ showFooter: true,
1454
+ 'onUpdate:modelValue' (value: any) {
1455
+ customStore.visible = value
1456
+ }
1457
+ }, scopedSlots)
1458
+ : renderEmptyElement($xeTable)
1459
+ }
1460
+
1461
+ const renderVN = () => {
1462
+ const customOpts = computeCustomOpts.value
1463
+ if (['modal', 'drawer', 'popup'].includes(`${customOpts.mode}`)) {
1464
+ return renderPopupPanel()
1465
+ }
1466
+ return renderSimplePanel()
1467
+ }
1468
+
1469
+ nextTick(() => {
1470
+ const customOpts = computeCustomOpts.value
1471
+ const { mode } = customOpts
1472
+ if (!VxeUIModalComponent && (mode === 'modal')) {
1473
+ errLog('vxe.error.reqComp', ['vxe-modal'])
1474
+ }
1475
+ if (!VxeUIDrawerComponent && (mode === 'drawer')) {
1476
+ errLog('vxe.error.reqComp', ['vxe-drawer'])
1477
+ }
1478
+ if (!VxeUIButtonComponent) {
1479
+ errLog('vxe.error.reqComp', ['vxe-button'])
1480
+ }
1481
+ if (!VxeUINumberInputComponent) {
1482
+ errLog('vxe.error.reqComp', ['vxe-number-input'])
1483
+ }
1484
+ if (!VxeUIRadioGroupComponent) {
1485
+ errLog('vxe.error.reqComp', ['vxe-radio-group'])
1486
+ }
1487
+ })
1488
+
1489
+ const $xeTableCustomPanel: VxeTableCustomPanelConstructor = {
1490
+ xID,
1491
+ props,
1492
+ context,
1493
+ reactData: customPanelReactData,
1494
+ internalData: customPanelInternalData,
1495
+ xeTable: $xeTable,
1496
+ getRefMaps: () => refMaps,
1497
+ getComputeMaps: () => computeMaps,
1498
+ renderVN
1499
+ }
1500
+
1501
+ onUnmounted(() => {
1502
+ customPanelInternalData = createInternalData()
1503
+ })
1504
+
1505
+ provide('$xeTableCustomPanel', $xeTableCustomPanel)
1506
+
1507
+ return $xeTableCustomPanel
1508
+ },
1509
+ render () {
1510
+ return this.renderVN()
1511
+ }
1512
+ })