vxe-table 4.18.4 → 4.18.6

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