vxe-table 3.20.6 → 3.20.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +106 -106
  3. package/es/index.esm.js +2 -1
  4. package/es/style.css +1 -1
  5. package/es/table/src/methods.js +75 -78
  6. package/es/table/src/table.js +14 -2
  7. package/es/table/src/util.js +6 -0
  8. package/es/table/style.css +18 -48
  9. package/es/ui/index.js +1 -1
  10. package/es/ui/src/dom.js +19 -20
  11. package/es/ui/src/log.js +1 -1
  12. package/es/vxe-table/style.css +18 -48
  13. package/lib/index.common.js +2 -1
  14. package/lib/index.umd.js +1915 -3227
  15. package/lib/index.umd.min.js +1 -1
  16. package/lib/style.css +1 -1
  17. package/lib/table/src/methods.js +12 -10
  18. package/lib/table/src/methods.min.js +1 -1
  19. package/lib/table/src/table.js +13 -1
  20. package/lib/table/src/table.min.js +1 -1
  21. package/lib/table/src/util.js +6 -0
  22. package/lib/table/src/util.min.js +1 -1
  23. package/lib/table/style/style.css +18 -48
  24. package/lib/ui/index.js +1 -1
  25. package/lib/ui/index.min.js +1 -1
  26. package/lib/ui/src/dom.js +21 -20
  27. package/lib/ui/src/dom.min.js +1 -1
  28. package/lib/ui/src/log.js +1 -1
  29. package/lib/ui/src/log.min.js +1 -1
  30. package/lib/v-x-e-table/index.js +2 -1
  31. package/lib/v-x-e-table/index.min.js +1 -1
  32. package/lib/vxe-colgroup/index.js +2 -1
  33. package/lib/vxe-colgroup/index.min.js +1 -1
  34. package/lib/vxe-column/index.js +2 -1
  35. package/lib/vxe-column/index.min.js +1 -1
  36. package/lib/vxe-grid/index.js +2 -1
  37. package/lib/vxe-grid/index.min.js +1 -1
  38. package/lib/vxe-table/index.js +2 -1
  39. package/lib/vxe-table/index.min.js +1 -1
  40. package/lib/vxe-table/style/style.css +18 -48
  41. package/lib/vxe-toolbar/index.js +2 -1
  42. package/lib/vxe-toolbar/index.min.js +1 -1
  43. package/lib/vxe-ui/index.js +2 -1
  44. package/lib/vxe-ui/index.min.js +1 -1
  45. package/lib/vxe-v-x-e-table/index.js +2 -1
  46. package/lib/vxe-v-x-e-table/index.min.js +1 -1
  47. package/package.json +93 -93
  48. package/packages/colgroup/index.ts +22 -22
  49. package/packages/column/index.ts +22 -22
  50. package/packages/components.ts +42 -42
  51. package/packages/grid/index.ts +22 -22
  52. package/packages/grid/src/grid.ts +1935 -1935
  53. package/packages/index.ts +4 -4
  54. package/packages/locale/lang/ar-EG.ts +832 -832
  55. package/packages/locale/lang/de-DE.ts +832 -832
  56. package/packages/locale/lang/en-US.ts +832 -832
  57. package/packages/locale/lang/es-ES.ts +832 -832
  58. package/packages/locale/lang/fr-FR.ts +832 -832
  59. package/packages/locale/lang/hu-HU.ts +832 -832
  60. package/packages/locale/lang/hy-AM.ts +832 -832
  61. package/packages/locale/lang/id-ID.ts +832 -832
  62. package/packages/locale/lang/it-IT.ts +832 -832
  63. package/packages/locale/lang/ja-JP.ts +832 -832
  64. package/packages/locale/lang/ko-KR.ts +832 -832
  65. package/packages/locale/lang/ms-MY.ts +832 -832
  66. package/packages/locale/lang/nb-NO.ts +832 -832
  67. package/packages/locale/lang/pt-BR.ts +832 -832
  68. package/packages/locale/lang/ru-RU.ts +832 -832
  69. package/packages/locale/lang/th-TH.ts +832 -832
  70. package/packages/locale/lang/ug-CN.ts +832 -832
  71. package/packages/locale/lang/uk-UA.ts +832 -832
  72. package/packages/locale/lang/uz-UZ.ts +832 -832
  73. package/packages/locale/lang/vi-VN.ts +832 -832
  74. package/packages/locale/lang/zh-CHT.ts +832 -832
  75. package/packages/locale/lang/zh-CN.ts +832 -832
  76. package/packages/locale/lang/zh-HK.ts +3 -3
  77. package/packages/locale/lang/zh-MO.ts +3 -3
  78. package/packages/locale/lang/zh-TC.ts +3 -3
  79. package/packages/locale/lang/zh-TW.ts +3 -3
  80. package/packages/table/index.ts +49 -49
  81. package/packages/table/module/custom/mixin.ts +369 -369
  82. package/packages/table/module/custom/panel.ts +1461 -1461
  83. package/packages/table/module/edit/mixin.ts +1123 -1123
  84. package/packages/table/module/export/export-panel.ts +658 -658
  85. package/packages/table/module/export/import-panel.ts +319 -319
  86. package/packages/table/module/export/mixin.ts +1693 -1693
  87. package/packages/table/module/export/util.ts +24 -24
  88. package/packages/table/module/filter/mixin.ts +507 -507
  89. package/packages/table/module/filter/panel.ts +329 -329
  90. package/packages/table/module/keyboard/mixin.ts +513 -513
  91. package/packages/table/module/menu/mixin.ts +329 -329
  92. package/packages/table/module/menu/panel.ts +212 -212
  93. package/packages/table/module/validator/mixin.ts +626 -626
  94. package/packages/table/render/index.ts +1456 -1456
  95. package/packages/table/src/body.ts +969 -969
  96. package/packages/table/src/cell.ts +1285 -1285
  97. package/packages/table/src/column.ts +205 -205
  98. package/packages/table/src/columnInfo.ts +228 -228
  99. package/packages/table/src/footer.ts +388 -388
  100. package/packages/table/src/group.ts +51 -51
  101. package/packages/table/src/header.ts +602 -602
  102. package/packages/table/src/methods.ts +12936 -12939
  103. package/packages/table/src/props.ts +311 -311
  104. package/packages/table/src/store.ts +15 -15
  105. package/packages/table/src/table.ts +2513 -2502
  106. package/packages/table/src/util.ts +1018 -1012
  107. package/packages/toolbar/index.ts +18 -18
  108. package/packages/toolbar/src/toolbar.ts +856 -856
  109. package/packages/ui/index.ts +530 -530
  110. package/packages/ui/src/anime.ts +52 -52
  111. package/packages/ui/src/comp.ts +3 -3
  112. package/packages/ui/src/dom.ts +237 -236
  113. package/packages/ui/src/log.ts +8 -8
  114. package/packages/ui/src/utils.ts +56 -56
  115. package/packages/ui/src/vn.ts +65 -65
  116. package/packages/v-x-e-table/index.ts +4 -4
  117. package/styles/all.scss +7 -7
  118. package/styles/base.scss +16 -16
  119. package/styles/components/grid.scss +89 -89
  120. package/styles/components/icon.scss +225 -225
  121. package/styles/components/old-icon.scss +715 -715
  122. package/styles/components/table-module/all.scss +6 -6
  123. package/styles/components/table-module/custom.scss +527 -527
  124. package/styles/components/table-module/export.scss +130 -130
  125. package/styles/components/table-module/filter.scss +130 -130
  126. package/styles/components/table-module/menu.scss +81 -81
  127. package/styles/components/table.scss +2679 -2679
  128. package/styles/components/toolbar.scss +119 -119
  129. package/styles/default.scss +2 -2
  130. package/styles/helpers/baseMixin.scss +95 -95
  131. package/styles/index.scss +3 -3
  132. package/styles/modules.scss +5 -5
  133. package/styles/theme/base.scss +93 -93
  134. package/styles/theme/dark.scss +49 -49
  135. package/styles/theme/light.scss +44 -44
  136. package/styles/variable.scss +43 -43
  137. package/types/all.d.ts +53 -53
  138. package/types/index.d.ts +4 -4
  139. /package/es/{iconfont.1773972972913.ttf → iconfont.1774240303597.ttf} +0 -0
  140. /package/es/{iconfont.1773972972913.woff → iconfont.1774240303597.woff} +0 -0
  141. /package/es/{iconfont.1773972972913.woff2 → iconfont.1774240303597.woff2} +0 -0
  142. /package/lib/{iconfont.1773972972913.ttf → iconfont.1774240303597.ttf} +0 -0
  143. /package/lib/{iconfont.1773972972913.woff → iconfont.1774240303597.woff} +0 -0
  144. /package/lib/{iconfont.1773972972913.woff2 → iconfont.1774240303597.woff2} +0 -0
@@ -1,2502 +1,2513 @@
1
- import { CreateElement } from 'vue'
2
- import XEUtils from 'xe-utils'
3
- import { getFuncText, isEnableConf } from '../../ui/src/utils'
4
- import { initTpImg, toCssUnit } from '../../ui/src/dom'
5
- import { createReactData, createInternalData, createHandleGetRowId, getCalcHeight, hasDeepKey } from './util'
6
- import { VxeUI } from '../../ui'
7
- import methods from './methods'
8
- import TableBodyComponent from './body'
9
- import TableHeaderComponent from './header'
10
- import TableFooterComponent from './footer'
11
- import { tableProps } from './props'
12
- import { getSlotVNs } from '../../ui/src/vn'
13
- import { warnLog, errLog } from '../../ui/src/log'
14
- import { crossTableDragRowGlobal, getCrossTableDragRowInfo } from './store'
15
- import TableCustomPanelComponent from '../module/custom/panel'
16
- import TableFilterPanelComponent from '../module/filter/panel'
17
- import TableImportPanelComponent from '../module/export/import-panel'
18
- import TableExportPanelComponent from '../module/export/export-panel'
19
- import TableMenuPanelComponent from '../module/menu/panel'
20
-
21
- import filterMixin from '../module/filter/mixin'
22
- import menuMixin from '../module/menu/mixin'
23
- import editMixin from '../module/edit/mixin'
24
- import exportMixin from '../module/export/mixin'
25
- import keyboardMixin from '../module/keyboard/mixin'
26
- import validatorMixin from '../module/validator/mixin'
27
- import customMixin from '../module/custom/mixin'
28
-
29
- import type { VxeTabsConstructor, VxeTabsPrivateMethods, VxeComponentStyleType } from 'vxe-pc-ui'
30
- import type { VxeTableConstructor, VxeTablePrivateMethods, VxeTablePropTypes, TableInternalData, TableReactData, VxeTableDefines } from '../../../types'
31
-
32
- const { getConfig, getIcon, getI18n, renderer, globalResize, globalEvents, globalMixins, renderEmptyElement } = VxeUI
33
-
34
- function handleUpdateMergeBodyCells ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) {
35
- const internalData = $xeTable as unknown as TableInternalData
36
-
37
- internalData.mergeBodyList = []
38
- internalData.mergeBodyMaps = {}
39
- internalData.mergeBodyCellMaps = {}
40
- $xeTable.setMergeCells(merges)
41
- }
42
-
43
- function handleUpdateMergeHeaderCells ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) {
44
- const internalData = $xeTable as unknown as TableInternalData
45
-
46
- internalData.mergeHeaderList = []
47
- internalData.mergeHeaderMaps = {}
48
- internalData.mergeHeaderCellMaps = {}
49
- $xeTable.setMergeHeaderCells(merges)
50
- }
51
-
52
- function handleUpdateMergeFooterCells ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) {
53
- const internalData = $xeTable as unknown as TableInternalData
54
-
55
- internalData.mergeFooterList = []
56
- internalData.mergeFooterMaps = {}
57
- internalData.mergeFooterCellMaps = {}
58
- $xeTable.setMergeFooterCells(merges)
59
- }
60
-
61
- function handleKeyField ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
62
- const internalData = $xeTable as unknown as TableInternalData
63
-
64
- const keyField = $xeTable.computeRowField
65
- internalData.currKeyField = keyField
66
- internalData.isCurrDeepKey = hasDeepKey(keyField)
67
- }
68
-
69
- function updateColumnAllOverflow ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
70
- const props = $xeTable
71
- const reactData = $xeTable as unknown as TableReactData
72
- const internalData = $xeTable as unknown as TableInternalData
73
-
74
- const { showOverflow } = props
75
- const { isGroup } = reactData
76
- const { tableFullColumn, collectColumn } = internalData
77
- let isAllOverflow = !!showOverflow
78
- const handleFunc = (column: VxeTableDefines.ColumnInfo) => {
79
- if (isAllOverflow && column.showOverflow === false) {
80
- isAllOverflow = false
81
- }
82
- }
83
- if (isGroup) {
84
- XEUtils.eachTree(collectColumn, handleFunc)
85
- } else {
86
- tableFullColumn.forEach(handleFunc)
87
- }
88
- reactData.isAllOverflow = isAllOverflow
89
- }
90
-
91
- /**
92
- * 渲染浮固定列
93
- * 分别渲染左边固定列和右边固定列
94
- * 如果宽度足够情况下,则不需要渲染固定列
95
- */
96
- function renderViewFixed (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods, fixedType: any) {
97
- const props = $xeTable
98
- const reactData = $xeTable as unknown as TableReactData
99
-
100
- const { showHeader, showFooter } = props
101
- const { tableData, tableColumn, tableGroupColumn, columnStore, footerTableData } = reactData
102
- const scrollbarOpts = $xeTable.computeScrollbarOpts
103
- const scrollbarXOpts = $xeTable.computeScrollbarXOpts
104
- const scrollbarYOpts = $xeTable.computeScrollbarYOpts
105
- const { overscrollBehavior: overscrollXBehavior } = scrollbarXOpts
106
- const { overscrollBehavior: overscrollYBehavior } = scrollbarYOpts
107
- const isFixedLeft = fixedType === 'left'
108
- const fixedColumn = isFixedLeft ? columnStore.leftList : columnStore.rightList
109
- const osXBehavior = XEUtils.eqNull(overscrollXBehavior) ? scrollbarOpts.overscrollBehavior : overscrollXBehavior
110
- const osYBehavior = XEUtils.eqNull(overscrollYBehavior) ? scrollbarOpts.overscrollBehavior : overscrollYBehavior
111
- return h('div', {
112
- ref: isFixedLeft ? 'refLeftContainer' : 'refRightContainer',
113
- class: [`vxe-table--fixed-${fixedType}-wrapper`, `sx--${scrollbarXOpts.visible}`, `sy--${scrollbarYOpts.visible}`, {
114
- [`x-ob--${osXBehavior}`]: osXBehavior,
115
- [`y-ob--${osYBehavior}`]: osYBehavior
116
- }]
117
- }, [
118
- showHeader
119
- ? h(TableHeaderComponent, {
120
- props: {
121
- fixedType,
122
- tableData,
123
- tableColumn,
124
- tableGroupColumn,
125
- fixedColumn
126
- },
127
- ref: `${fixedType}Header`
128
- })
129
- : renderEmptyElement($xeTable),
130
- h(TableBodyComponent, {
131
- props: {
132
- fixedType,
133
- tableData,
134
- tableColumn,
135
- fixedColumn
136
- },
137
- ref: `${fixedType}Body`
138
- }),
139
- showFooter
140
- ? h(TableFooterComponent, {
141
- props: {
142
- footerTableData,
143
- tableColumn,
144
- fixedColumn,
145
- fixedType
146
- },
147
- ref: `${fixedType}Footer`
148
- })
149
- : renderEmptyElement($xeTable)
150
- ])
151
- }
152
-
153
- function renderEmptyBody (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
154
- const slots = $xeTable.$scopedSlots
155
- const $xeGrid = $xeTable.$xeGrid
156
- const $xeGantt = $xeTable.$xeGantt
157
-
158
- const emptyOpts = $xeTable.computeEmptyOpts
159
- const emptySlot = slots.empty
160
- let emptyContent: any = ''
161
- const emptyParams = { $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }
162
- if (emptySlot) {
163
- emptyContent = emptySlot.call($xeTable, emptyParams)
164
- } else {
165
- const compConf = emptyOpts.name ? renderer.get(emptyOpts.name) : null
166
- const rtEmptyView = compConf ? (compConf.renderTableEmpty || compConf.renderTableEmptyView || compConf.renderEmpty) : null
167
- if (rtEmptyView) {
168
- emptyContent = getSlotVNs(rtEmptyView.call($xeTable, h, emptyOpts, emptyParams))
169
- } else {
170
- emptyContent = getFuncText($xeTable.emptyText) || getI18n('vxe.table.emptyText')
171
- }
172
- }
173
- return emptyContent
174
- }
175
-
176
- const renderDragTipContents = (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) => {
177
- const props = $xeTable
178
- const reactData = $xeTable as unknown as TableReactData
179
- const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable)
180
-
181
- const { dragConfig } = props
182
- const { dragRow, dragCol, dragTipText } = reactData
183
- const columnDragOpts = $xeTable.computeColumnDragOpts
184
- const rowDragOpts = $xeTable.computeRowDragOpts
185
- const rowDragSlots = rowDragOpts.slots || {}
186
- const rTipSlot = rowDragSlots.tip || (dragConfig && dragConfig.slots ? dragConfig.slots.rowTip : null)
187
- const columnDragSlots = columnDragOpts.slots || {}
188
- const cTipSlot = columnDragSlots.tip
189
- const dRow = dragRow || (rowDragOpts.isCrossTableDrag ? crossTableDragRowInfo.row : null)
190
-
191
- if (dRow && rTipSlot) {
192
- return $xeTable.callSlot(rTipSlot, { row: dRow }, h)
193
- }
194
- if (dragCol && cTipSlot) {
195
- return $xeTable.callSlot(cTipSlot, { column: dragCol }, h)
196
- }
197
- return [h('span', dragTipText)]
198
- }
199
-
200
- const renderDragTip = (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) => {
201
- const reactData = $xeTable as unknown as TableReactData
202
- const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable)
203
-
204
- const { dragRow, dragCol } = reactData
205
- const rowOpts = $xeTable.computeRowOpts
206
- const columnOpts = $xeTable.computeColumnOpts
207
- const rowDragOpts = $xeTable.computeRowDragOpts
208
- const columnDragOpts = $xeTable.computeColumnDragOpts
209
- const dRow = dragRow || (rowDragOpts.isCrossTableDrag ? crossTableDragRowInfo.row : null)
210
-
211
- if (rowOpts.drag || columnOpts.drag) {
212
- return h('div', {
213
- class: 'vxe-table--drag-wrapper'
214
- }, [
215
- h('div', {
216
- ref: 'refDragRowLineElem',
217
- class: ['vxe-table--drag-row-line', {
218
- 'is--guides': rowDragOpts.showGuidesStatus
219
- }]
220
- }),
221
- h('div', {
222
- ref: 'refDragColLineElem',
223
- class: ['vxe-table--drag-col-line', {
224
- 'is--guides': columnDragOpts.showGuidesStatus
225
- }]
226
- }),
227
- (dRow && rowDragOpts.showDragTip) || (dragCol && columnDragOpts.showDragTip)
228
- ? h('div', {
229
- ref: 'refDragTipElem',
230
- class: 'vxe-table--drag-sort-tip'
231
- }, [
232
- h('div', {
233
- class: 'vxe-table--drag-sort-tip-wrapper'
234
- }, [
235
- h('div', {
236
- class: 'vxe-table--drag-sort-tip-status'
237
- }, [
238
- h('span', {
239
- class: ['vxe-table--drag-sort-tip-normal-status', dRow ? getIcon().TABLE_DRAG_STATUS_ROW : getIcon().TABLE_DRAG_STATUS_COLUMN]
240
- }),
241
- h('span', {
242
- class: ['vxe-table--drag-sort-tip-sub-status', getIcon().TABLE_DRAG_STATUS_SUB_ROW]
243
- }),
244
- h('span', {
245
- class: ['vxe-table--drag-sort-tip-disabled-status', getIcon().TABLE_DRAG_DISABLED]
246
- })
247
- ]),
248
- h('div', {
249
- class: 'vxe-table--drag-sort-tip-content'
250
- }, renderDragTipContents(h, $xeTable))
251
- ])
252
- ])
253
- : renderEmptyElement($xeTable)
254
- ])
255
- }
256
- return renderEmptyElement($xeTable)
257
- }
258
-
259
- function handleUpdateResize ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
260
- const el = $xeTable.$refs.refElem as HTMLDivElement
261
- if (el && el.clientWidth && el.clientHeight) {
262
- $xeTable.recalculate()
263
- }
264
- }
265
-
266
- function renderRowExpandedVNs (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
267
- const props = $xeTable
268
- const reactData = $xeTable as unknown as TableReactData
269
- const internalData = $xeTable as unknown as TableInternalData
270
- const $xeGrid = $xeTable.$xeGrid
271
- const $xeGantt = $xeTable.$xeGantt
272
-
273
- const { treeConfig } = props
274
- const { expandColumn, isRowGroupStatus } = reactData
275
- const tableRowExpandedList: any[] = ($xeTable as any).computeTableRowExpandedList
276
- const expandOpts = $xeTable.computeExpandOpts
277
- const { mode } = expandOpts
278
- if (mode !== 'fixed') {
279
- return renderEmptyElement($xeTable)
280
- }
281
- const expandVNs = [
282
- h('div', {
283
- key: 'repY',
284
- ref: 'refRowExpandYSpaceElem'
285
- })
286
- ]
287
-
288
- if (expandColumn) {
289
- const { handleGetRowId } = createHandleGetRowId($xeTable)
290
- tableRowExpandedList.forEach((row) => {
291
- const expandOpts = $xeTable.computeExpandOpts
292
- const { height: expandHeight, padding, indent } = expandOpts
293
- const { fullAllDataRowIdData, fullColumnIdData } = internalData
294
- const treeOpts = $xeTable.computeTreeOpts
295
- const { transform, seqMode } = treeOpts
296
- const cellStyle: Record<string, string> = {}
297
- const rowid = handleGetRowId(row)
298
- const rowRest = fullAllDataRowIdData[rowid]
299
- const colid = expandColumn.id
300
- const colRest = fullColumnIdData[colid] || {}
301
- let rowLevel = 0
302
- let seq: string | number = -1
303
- let _rowIndex = -1
304
- let rowIndex = -1
305
- let $rowIndex = -1
306
- if (rowRest) {
307
- rowIndex = rowRest.index
308
- $rowIndex = rowRest.$index
309
- _rowIndex = rowRest._index
310
- rowLevel = rowRest.level
311
- seq = rowRest.seq
312
- if (isRowGroupStatus || (treeConfig && transform && seqMode === 'increasing')) {
313
- seq = rowRest._index + 1
314
- } else if ((treeConfig && seqMode === 'fixed')) {
315
- seq = rowRest._tIndex + 1
316
- }
317
- }
318
- if (expandHeight) {
319
- cellStyle.height = `${expandHeight}px`
320
- }
321
- if (isRowGroupStatus || treeConfig) {
322
- cellStyle.paddingLeft = `${(rowLevel * (XEUtils.isNumber(indent) ? indent : treeOpts.indent)) + 30}px`
323
- }
324
- let columnIndex = -1
325
- let $columnIndex = -1
326
- let _columnIndex = -1
327
- if (colRest) {
328
- columnIndex = colRest.index
329
- $columnIndex = colRest.$index
330
- _columnIndex = colRest._index
331
- }
332
- const expandParams: VxeTableDefines.CellRenderDataParams = {
333
- $table: $xeTable,
334
- $grid: $xeGrid,
335
- $gantt: $xeGantt,
336
- seq,
337
- column: expandColumn,
338
- columnIndex,
339
- $columnIndex,
340
- _columnIndex,
341
- fixed: '',
342
- source: 'table',
343
- type: 'body',
344
- level: rowLevel,
345
- rowid,
346
- row,
347
- rowIndex,
348
- $rowIndex,
349
- _rowIndex,
350
- isHidden: false,
351
- isEdit: false,
352
- visibleData: [],
353
- data: [],
354
- items: []
355
- }
356
- expandVNs.push(
357
- h('div', {
358
- key: rowid,
359
- class: ['vxe-body--row-expanded-cell', {
360
- 'is--padding': padding,
361
- 'is--ellipsis': expandHeight
362
- }],
363
- attrs: {
364
- rowid
365
- },
366
- style: cellStyle
367
- }, [
368
- h('div', {
369
- class: 'vxe-body--row-expanded-content'
370
- }, expandColumn.renderData(h, expandParams))
371
- ])
372
- )
373
- })
374
- }
375
-
376
- return h('div', {
377
- ref: 'refRowExpandElem',
378
- class: 'vxe-table--row-expanded-wrapper'
379
- }, expandVNs)
380
- }
381
-
382
- function renderScrollX (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
383
- return h('div', {
384
- key: 'vsx',
385
- ref: 'refScrollXVirtualElem',
386
- class: 'vxe-table--scroll-x-virtual'
387
- }, [
388
- h('div', {
389
- ref: 'refScrollXLeftCornerElem',
390
- class: 'vxe-table--scroll-x-left-corner'
391
- }),
392
- h('div', {
393
- ref: 'refScrollXWrapperElem',
394
- class: 'vxe-table--scroll-x-wrapper'
395
- }, [
396
- h('div', {
397
- ref: 'refScrollXHandleElem',
398
- class: 'vxe-table--scroll-x-handle',
399
- on: {
400
- scroll: $xeTable.triggerVirtualScrollXEvent
401
- }
402
- }, [
403
- h('div', {
404
- ref: 'refScrollXSpaceElem',
405
- class: 'vxe-table--scroll-x-space'
406
- })
407
- ]),
408
- h('div', {
409
- class: 'vxe-table--scroll-x-handle-appearance'
410
- })
411
- ]),
412
- h('div', {
413
- ref: 'refScrollXRightCornerElem',
414
- class: 'vxe-table--scroll-x-right-corner'
415
- })
416
- ])
417
- }
418
-
419
- function renderScrollY (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
420
- return h('div', {
421
- ref: 'refScrollYVirtualElem',
422
- class: 'vxe-table--scroll-y-virtual'
423
- }, [
424
- h('div', {
425
- ref: 'refScrollYTopCornerElem',
426
- class: 'vxe-table--scroll-y-top-corner'
427
- }),
428
- h('div', {
429
- ref: 'refScrollYWrapperElem',
430
- class: 'vxe-table--scroll-y-wrapper'
431
- }, [
432
- h('div', {
433
- ref: 'refScrollYHandleElem',
434
- class: 'vxe-table--scroll-y-handle',
435
- on: {
436
- scroll: $xeTable.triggerVirtualScrollYEvent
437
- }
438
- }, [
439
- h('div', {
440
- ref: 'refScrollYSpaceElem',
441
- class: 'vxe-table--scroll-y-space'
442
- })
443
- ])
444
- ]),
445
- h('div', {
446
- ref: 'refScrollYBottomCornerElem',
447
- class: 'vxe-table--scroll-y-bottom-corner'
448
- })
449
- ])
450
- }
451
-
452
- function renderViewport (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
453
- const props = $xeTable
454
- const reactData = $xeTable as unknown as TableReactData
455
-
456
- const { showHeader, showFooter } = props
457
- const { overflowX, tableData, tableColumn, tableGroupColumn, footerTableData, columnStore } = reactData
458
- const scrollbarOpts = $xeTable.computeScrollbarOpts
459
- const scrollbarXOpts = $xeTable.computeScrollbarXOpts
460
- const scrollbarYOpts = $xeTable.computeScrollbarYOpts
461
- const { overscrollBehavior: overscrollXBehavior } = scrollbarXOpts
462
- const { overscrollBehavior: overscrollYBehavior } = scrollbarYOpts
463
- const { leftList, rightList } = columnStore
464
- const osXBehavior = XEUtils.eqNull(overscrollXBehavior) ? scrollbarOpts.overscrollBehavior : overscrollXBehavior
465
- const osYBehavior = XEUtils.eqNull(overscrollYBehavior) ? scrollbarOpts.overscrollBehavior : overscrollYBehavior
466
-
467
- return h('div', {
468
- ref: 'refTableViewportElem',
469
- class: ['vxe-table--viewport-wrapper', {
470
- [`x-ob--${osXBehavior}`]: osXBehavior,
471
- [`y-ob--${osYBehavior}`]: osYBehavior
472
- }]
473
- }, [
474
- h('div', {
475
- class: ['vxe-table--main-wrapper', `sx--${scrollbarXOpts.visible}`, `sy--${scrollbarYOpts.visible}`]
476
- }, [
477
- /**
478
- * 表头
479
- */
480
- showHeader
481
- ? h(TableHeaderComponent, {
482
- ref: 'refTableHeader',
483
- props: {
484
- tableData,
485
- tableColumn,
486
- tableGroupColumn
487
- }
488
- })
489
- : renderEmptyElement($xeTable),
490
- /**
491
- * 表体
492
- */
493
- h(TableBodyComponent, {
494
- ref: 'refTableBody',
495
- props: {
496
- tableData,
497
- tableColumn
498
- }
499
- }),
500
- /**
501
- * 表尾
502
- */
503
- showFooter
504
- ? h(TableFooterComponent, {
505
- ref: 'refTableFooter',
506
- props: {
507
- footerTableData,
508
- tableColumn
509
- }
510
- })
511
- : renderEmptyElement($xeTable)
512
- ]),
513
- h('div', {
514
- class: 'vxe-table--fixed-wrapper'
515
- }, [
516
- leftList && leftList.length && overflowX ? renderViewFixed(h, $xeTable, 'left') : renderEmptyElement($xeTable),
517
- rightList && rightList.length && overflowX ? renderViewFixed(h, $xeTable, 'right') : renderEmptyElement($xeTable)
518
- ]),
519
- renderRowExpandedVNs(h, $xeTable)
520
- ])
521
- }
522
-
523
- function renderBody (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
524
- const scrollbarYToLeft = $xeTable.computeScrollbarYToLeft
525
- return h('div', {
526
- class: 'vxe-table--layout-wrapper'
527
- }, scrollbarYToLeft
528
- ? [
529
- renderScrollY(h, $xeTable),
530
- renderViewport(h, $xeTable)
531
- ]
532
- : [
533
- renderViewport(h, $xeTable),
534
- renderScrollY(h, $xeTable)
535
- ])
536
- }
537
-
538
- export default {
539
- name: 'VxeTable',
540
- mixins: [
541
- globalMixins.sizeMixin,
542
- filterMixin,
543
- menuMixin,
544
- editMixin,
545
- exportMixin,
546
- keyboardMixin,
547
- validatorMixin,
548
- customMixin
549
- ],
550
- props: tableProps,
551
- provide () {
552
- const $xeTable = this
553
- return {
554
- $xeTable,
555
- xecolgroup: null
556
- }
557
- },
558
- inject: {
559
- $xeTabs: {
560
- default: null
561
- },
562
- $xeParentTable: {
563
- from: '$xeTable',
564
- default: null
565
- },
566
- $xeGrid: {
567
- default: null
568
- },
569
- $xeGantt: {
570
- default: null
571
- }
572
- },
573
- data () {
574
- const xID = XEUtils.uniqueId()
575
-
576
- const reactData = createReactData()
577
-
578
- return {
579
- xID,
580
- ...reactData,
581
-
582
- // 私有属性
583
- reScrollFlag: 0,
584
- reLayoutFlag: 0,
585
- footFlag: 0,
586
- kfFlag: 0,
587
- mergeFooteCellFlag: 0,
588
- crossTableDragRowInfo: crossTableDragRowGlobal
589
- }
590
- },
591
- computed: {
592
- ...({} as {
593
- $xeTabs(): (VxeTabsConstructor & VxeTabsPrivateMethods) | null
594
- }),
595
- tableId () {
596
- return this.computeTableId
597
- },
598
- computeTableId () {
599
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
600
- const props = $xeTable
601
- const $xeGrid = $xeTable.$xeGrid
602
- const $xeGantt = $xeTable.$xeGantt
603
-
604
- const { id } = props
605
- if (id) {
606
- if (XEUtils.isFunction(id)) {
607
- return `${id({ $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }) || ''}`
608
- }
609
- return `${id}`
610
- }
611
- return ''
612
- },
613
- computeRowField () {
614
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
615
- const props = $xeTable
616
-
617
- const rowOpts = $xeTable.computeRowOpts
618
- return `${props.rowId || rowOpts.keyField || '_X_ROW_KEY'}`
619
- },
620
- validOpts () {
621
- return this.computeValidOpts
622
- },
623
- computeValidOpts () {
624
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
625
- const props = $xeTable
626
-
627
- const opts = Object.assign({}, getConfig().table.validConfig, props.validConfig)
628
- // 兼容老版本
629
- if (XEUtils.isBoolean(opts.showMessage)) {
630
- opts.showErrorMessage = opts.showMessage
631
- }
632
- return opts
633
- },
634
- sXOpts () {
635
- return this.computeVirtualXOpts
636
- },
637
- computeSXOpts () {
638
- return this.computeVirtualXOpts
639
- },
640
- computeScrollXThreshold () {
641
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
642
-
643
- const virtualXOpts = $xeTable.computeVirtualXOpts
644
- const { threshold } = virtualXOpts
645
- if (threshold) {
646
- return XEUtils.toNumber(threshold)
647
- }
648
- return 0
649
- },
650
- sYOpts () {
651
- return this.computeVirtualYOpts
652
- },
653
- computeSYOpts () {
654
- return this.computeVirtualYOpts
655
- },
656
- computeVirtualXOpts () {
657
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
658
- const props = $xeTable
659
-
660
- const { virtualXConfig, scrollX } = props
661
- const globalVirtualXConfig = getConfig().table.virtualXConfig
662
- const globalScrollX = getConfig().table.scrollX
663
- if (virtualXConfig) {
664
- return Object.assign({}, globalVirtualXConfig, virtualXConfig) as VxeTablePropTypes.VirtualXConfig & { gt: number }
665
- }
666
- if (scrollX) {
667
- // 已废弃,保留兼容
668
- return Object.assign({}, globalScrollX, scrollX) as VxeTablePropTypes.VirtualXConfig & { gt: number }
669
- }
670
- if (globalVirtualXConfig) {
671
- return Object.assign({}, globalVirtualXConfig, virtualXConfig) as VxeTablePropTypes.VirtualXConfig & { gt: number }
672
- }
673
- // 已废弃,保留兼容
674
- return Object.assign({}, globalScrollX, scrollX) as VxeTablePropTypes.VirtualXConfig & { gt: number }
675
- },
676
- computeVirtualYOpts () {
677
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
678
- const props = $xeTable
679
-
680
- const { virtualYConfig, scrollY } = props
681
- const globalVirtualYConfig = getConfig().table.virtualYConfig
682
- const globalScrollY = getConfig().table.scrollY
683
- if (virtualYConfig) {
684
- return Object.assign({}, globalVirtualYConfig, virtualYConfig) as VxeTablePropTypes.VirtualYConfig & { gt: number }
685
- }
686
- if (scrollY) {
687
- // 已废弃,保留兼容
688
- return Object.assign({}, globalScrollY, scrollY) as VxeTablePropTypes.VirtualYConfig & { gt: number }
689
- }
690
- if (globalVirtualYConfig) {
691
- return Object.assign({}, globalVirtualYConfig, virtualYConfig) as VxeTablePropTypes.VirtualYConfig & { gt: number }
692
- }
693
- // 已废弃,保留兼容
694
- return Object.assign({}, globalScrollY, scrollY) as VxeTablePropTypes.VirtualYConfig & { gt: number }
695
- },
696
- computeScrollbarOpts () {
697
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
698
- const props = $xeTable
699
-
700
- return Object.assign({}, getConfig().table.scrollbarConfig, props.scrollbarConfig)
701
- },
702
- computeScrollbarXOpts () {
703
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
704
- const props = $xeTable
705
-
706
- const scrollbarOpts = $xeTable.computeScrollbarOpts
707
- return Object.assign({}, scrollbarOpts.x, props.scrollbarConfig?.x || {})
708
- },
709
- computeScrollbarYOpts () {
710
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
711
- const props = $xeTable
712
-
713
- const scrollbarOpts = $xeTable.computeScrollbarOpts
714
- return Object.assign({}, scrollbarOpts.y, props.scrollbarConfig?.y || {})
715
- },
716
- computeScrollbarXToTop () {
717
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
718
-
719
- const scrollbarXOpts = $xeTable.computeScrollbarXOpts
720
- return scrollbarXOpts.position === 'top'
721
- },
722
- computeScrollbarYToLeft () {
723
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
724
-
725
- const scrollbarYOpts = $xeTable.computeScrollbarYOpts
726
- return scrollbarYOpts.position === 'left'
727
- },
728
- computeScrollYThreshold () {
729
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
730
-
731
- const virtualYOpts = $xeTable.computeVirtualYOpts
732
- const { threshold } = virtualYOpts
733
- if (threshold) {
734
- return XEUtils.toNumber(threshold)
735
- }
736
- return 0
737
- },
738
- rowHeightMaps () {
739
- return this.computeRowHeightMaps
740
- },
741
- computeRowHeightMaps () {
742
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
743
- const reactData = $xeTable as unknown as TableReactData
744
-
745
- return reactData.rowHeightStore
746
- },
747
- computeDefaultRowHeight () {
748
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
749
-
750
- const vSize = $xeTable.computeSize
751
- const rowHeightMaps = $xeTable.computeRowHeightMaps
752
- return rowHeightMaps[vSize || 'default'] || 18
753
- },
754
- columnOpts () {
755
- return this.computeColumnOpts
756
- },
757
- computeColumnOpts () {
758
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
759
- const props = $xeTable
760
-
761
- return Object.assign({}, getConfig().table.columnConfig, props.columnConfig)
762
- },
763
- computeCurrentColumnOpts () {
764
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
765
- const props = $xeTable
766
-
767
- return Object.assign({}, getConfig().table.currentColumnConfig, props.currentColumnConfig)
768
- },
769
- computeCellOpts () {
770
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
771
- const props = $xeTable
772
-
773
- const cellOpts = Object.assign({}, getConfig().table.cellConfig, props.cellConfig)
774
- if (cellOpts.height) {
775
- cellOpts.height = XEUtils.toNumber(cellOpts.height)
776
- }
777
- return cellOpts
778
- },
779
- computeHeaderCellOpts () {
780
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
781
- const $xeGantt = $xeTable.$xeGantt
782
- const props = $xeTable
783
-
784
- const headerCellOpts = Object.assign({}, getConfig().table.headerCellConfig, props.headerCellConfig)
785
- const defaultRowHeight = $xeTable.computeDefaultRowHeight
786
- const cellOpts = $xeTable.computeCellOpts
787
- let headCellHeight = XEUtils.toNumber(getCalcHeight(headerCellOpts.height || cellOpts.height))
788
- if ($xeGantt) {
789
- const taskViewScales = $xeGantt.computeTaskViewScales
790
- if (taskViewScales && taskViewScales.length > 2) {
791
- const ganttMinHeadCellHeight = defaultRowHeight / 2 * taskViewScales.length
792
- headCellHeight = Math.max(ganttMinHeadCellHeight, headCellHeight)
793
- }
794
- }
795
- headerCellOpts.height = headCellHeight
796
- return headerCellOpts
797
- },
798
- computeFooterCellOpts () {
799
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
800
- const props = $xeTable
801
-
802
- const footerCellOpts = Object.assign({}, getConfig().table.footerCellConfig, props.footerCellConfig)
803
- const cellOpts = $xeTable.computeCellOpts
804
- footerCellOpts.height = XEUtils.toNumber(getCalcHeight(footerCellOpts.height || cellOpts.height))
805
- return footerCellOpts
806
- },
807
- rowOpts () {
808
- return this.computeRowOpts
809
- },
810
- computeRowOpts () {
811
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
812
- const props = $xeTable
813
-
814
- return Object.assign({}, getConfig().table.rowConfig, props.rowConfig)
815
- },
816
- computeAggregateOpts () {
817
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
818
- const props = $xeTable
819
-
820
- return Object.assign({}, getConfig().table.aggregateConfig || getConfig().table.rowGroupConfig, props.aggregateConfig || props.rowGroupConfig)
821
- },
822
- computeAggregateAccuracyOpts () {
823
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
824
- const props = $xeTable
825
-
826
- return Object.assign({}, getConfig().table.aggregateAccuracyConfig, props.aggregateAccuracyConfig)
827
- },
828
- computeRowGroupOpts () {
829
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
830
-
831
- return $xeTable.computeAggregateOpts
832
- },
833
- computeCurrentRowOpts () {
834
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
835
- const props = $xeTable
836
-
837
- return Object.assign({}, getConfig().table.currentRowConfig, props.currentRowConfig)
838
- },
839
- computeRowDragOpts () {
840
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
841
- const props = $xeTable
842
-
843
- return Object.assign({}, getConfig().table.rowDragConfig, props.rowDragConfig)
844
- },
845
- computeColumnDragOpts () {
846
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
847
- const props = $xeTable
848
-
849
- return Object.assign({}, getConfig().table.columnDragConfig, props.columnDragConfig)
850
- },
851
- resizeOpts () {
852
- return this.computeResizeOpts
853
- },
854
- computeResizeOpts () {
855
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
856
- const props = $xeTable
857
-
858
- return Object.assign({}, getConfig().table.resizeConfig, props.resizeConfig)
859
- },
860
- resizableOpts () {
861
- return this.computeResizableOpts
862
- },
863
- computeResizableOpts () {
864
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
865
- const props = $xeTable
866
-
867
- return Object.assign({}, getConfig().table.resizableConfig, props.resizableConfig)
868
- },
869
- seqOpts () {
870
- return this.computeSeqOpts
871
- },
872
- computeSeqOpts () {
873
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
874
- const props = $xeTable
875
-
876
- return Object.assign({ startIndex: 0 }, getConfig().table.seqConfig, props.seqConfig)
877
- },
878
- radioOpts () {
879
- return this.computeRadioOpts
880
- },
881
- computeRadioOpts () {
882
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
883
- const props = $xeTable
884
-
885
- return Object.assign({}, getConfig().table.radioConfig, props.radioConfig)
886
- },
887
- checkboxOpts () {
888
- return this.computeCheckboxOpts
889
- },
890
- computeCheckboxOpts () {
891
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
892
- const props = $xeTable
893
-
894
- return Object.assign({}, getConfig().table.checkboxConfig, props.checkboxConfig)
895
- },
896
- tooltipOpts () {
897
- return this.computeTooltipOpts
898
- },
899
- computeTooltipOpts () {
900
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
901
- const props = $xeTable
902
-
903
- return Object.assign({}, getConfig().tooltip, getConfig().table.tooltipConfig, props.tooltipConfig)
904
- },
905
- tipConfig () {
906
- return { ...this.tooltipOpts }
907
- },
908
- computeHeaderTooltipOpts () {
909
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
910
- const props = $xeTable
911
-
912
- return Object.assign({}, getConfig().tooltip, getConfig().table.headerTooltipConfig, props.headerTooltipConfig)
913
- },
914
- computeFooterTooltipOpts () {
915
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
916
- const props = $xeTable
917
-
918
- return Object.assign({}, getConfig().tooltip, getConfig().table.footerTooltipConfig, props.footerTooltipConfig)
919
- },
920
- computeTableTipConfig () {
921
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
922
- const reactData = $xeTable as unknown as TableReactData
923
-
924
- const { tooltipStore } = reactData
925
- const tooltipOpts = $xeTable.computeTooltipOpts
926
- return Object.assign({}, tooltipOpts, tooltipStore.currOpts)
927
- },
928
- computeValidTipConfig () {
929
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
930
-
931
- const tooltipOpts = $xeTable.computeTooltipOpts
932
- return Object.assign({}, tooltipOpts)
933
- },
934
- validTipOpts () {
935
- return Object.assign({ isArrow: false }, this.tooltipOpts)
936
- },
937
- editOpts () {
938
- return this.computeEditOpts
939
- },
940
- computeEditOpts () {
941
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
942
- const props = $xeTable
943
-
944
- return Object.assign({}, getConfig().table.editConfig, props.editConfig)
945
- },
946
- computeEditDirtyOpts () {
947
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
948
- const props = $xeTable
949
-
950
- return Object.assign({}, getConfig().table.editDirtyConfig, props.editDirtyConfig)
951
- },
952
- sortOpts () {
953
- return this.computeSortOpts
954
- },
955
- computeSortOpts () {
956
- return Object.assign({ orders: ['asc', 'desc', null] }, getConfig().table.sortConfig, this.sortConfig)
957
- },
958
- filterOpts () {
959
- return this.computeFilterOpts
960
- },
961
- computeFilterOpts () {
962
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
963
- const props = $xeTable
964
-
965
- return Object.assign({}, getConfig().table.filterConfig, props.filterConfig)
966
- },
967
- computeFloatingFilterOpts () {
968
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
969
- const props = $xeTable
970
-
971
- return Object.assign({}, getConfig().table.floatingFilterConfig, props.floatingFilterConfig)
972
- },
973
- mouseOpts () {
974
- return this.computeMouseOpts
975
- },
976
- computeMouseOpts () {
977
- return Object.assign({}, getConfig().table.mouseConfig, this.mouseConfig)
978
- },
979
- areaOpts () {
980
- return this.computeAreaOpts
981
- },
982
- computeAreaOpts () {
983
- return Object.assign({}, getConfig().table.areaConfig, this.areaConfig)
984
- },
985
- keyboardOpts () {
986
- return this.computeKeyboardOpts
987
- },
988
- computeKeyboardOpts () {
989
- return Object.assign({}, getConfig().table.keyboardConfig, this.keyboardConfig)
990
- },
991
- clipOpts () {
992
- return this.computeClipOpts
993
- },
994
- computeClipOpts () {
995
- return Object.assign({}, getConfig().table.clipConfig, this.clipConfig)
996
- },
997
- fnrOpts () {
998
- return this.computeFnrOpts
999
- },
1000
- computeFNROpts () {
1001
- return this.computeFnrOpts
1002
- },
1003
- computeFnrOpts () {
1004
- return Object.assign({}, getConfig().table.fnrConfig, this.fnrConfig)
1005
- },
1006
- headerCtxMenu () {
1007
- return this.computeHeaderMenu
1008
- },
1009
- computeHeaderMenu () {
1010
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1011
-
1012
- const menuOpts = $xeTable.computeMenuOpts
1013
- const headerOpts = menuOpts.header
1014
- return headerOpts && headerOpts.options ? headerOpts.options : []
1015
- },
1016
- bodyCtxMenu () {
1017
- return this.computeBodyMenu
1018
- },
1019
- computeBodyMenu () {
1020
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1021
-
1022
- const menuOpts = $xeTable.computeMenuOpts
1023
- const bodyOpts = menuOpts.body
1024
- return bodyOpts && bodyOpts.options ? bodyOpts.options : []
1025
- },
1026
- footerCtxMenu () {
1027
- return this.computeFooterMenu
1028
- },
1029
- computeFooterMenu () {
1030
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1031
-
1032
- const menuOpts = $xeTable.computeMenuOpts
1033
- const footerOpts = menuOpts.footer
1034
- return footerOpts && footerOpts.options ? footerOpts.options : []
1035
- },
1036
- isCtxMenu () {
1037
- return this.computeIsContentMenu
1038
- },
1039
- computeIsMenu () {
1040
- return this.computeIsContentMenu
1041
- },
1042
- computeIsContentMenu () {
1043
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1044
- const props = $xeTable
1045
-
1046
- const menuOpts = $xeTable.computeMenuOpts
1047
- const headerMenu = $xeTable.computeHeaderMenu
1048
- const bodyMenu = $xeTable.computeBodyMenu
1049
- const footerMenu = $xeTable.computeFooterMenu
1050
- return !!(((props as any).contextMenu || props.menuConfig) && isEnableConf(menuOpts) && (headerMenu.length || bodyMenu.length || footerMenu.length))
1051
- },
1052
- ctxMenuList () {
1053
- return this.computeMenuList
1054
- },
1055
- computeMenuList () {
1056
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1057
- const reactData = $xeTable as unknown as TableReactData
1058
-
1059
- const { ctxMenuStore } = reactData
1060
- const rest: any[] = []
1061
- ctxMenuStore.list.forEach((list) => {
1062
- list.forEach((item) => {
1063
- rest.push(item)
1064
- })
1065
- })
1066
- return rest
1067
- },
1068
- ctxMenuOpts () {
1069
- return this.computeMenuOpts
1070
- },
1071
- computeMenuOpts () {
1072
- return Object.assign({}, getConfig().table.menuConfig, this.contextMenu, this.menuConfig)
1073
- },
1074
- computeLeftFixedWidth () {
1075
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1076
- const reactData = $xeTable as unknown as TableReactData
1077
-
1078
- const { columnStore } = reactData
1079
- const { leftList } = columnStore
1080
- let leftWidth = 0
1081
- for (let i = 0; i < leftList.length; i++) {
1082
- const column = leftList[i]
1083
- leftWidth += column.renderWidth
1084
- }
1085
- return leftWidth
1086
- },
1087
- computeRightFixedWidth () {
1088
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1089
- const reactData = $xeTable as unknown as TableReactData
1090
-
1091
- const { columnStore } = reactData
1092
- const { rightList } = columnStore
1093
- let leftWidth = 0
1094
- for (let i = 0; i < rightList.length; i++) {
1095
- const column = rightList[i]
1096
- leftWidth += column.renderWidth
1097
- }
1098
- return leftWidth
1099
- },
1100
- computeBodyMergeCoverFixed () {
1101
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1102
- const reactData = $xeTable as unknown as TableReactData
1103
- const internalData = $xeTable as unknown as TableInternalData
1104
-
1105
- const { columnStore, mergeBodyFlag } = reactData
1106
- const { mergeBodyList, visibleColumn } = internalData
1107
- const { leftList, rightList } = columnStore
1108
- const rscIndex = visibleColumn.length - rightList.length
1109
- if (mergeBodyFlag && (leftList.length || rightList.length)) {
1110
- const lecIndex = leftList.length
1111
- for (let i = 0; i < mergeBodyList.length; i++) {
1112
- const { col, colspan } = mergeBodyList[i]
1113
- if (col < lecIndex || (col + colspan) > rscIndex) {
1114
- return true
1115
- }
1116
- }
1117
- }
1118
- return false
1119
- },
1120
- computeIsHeaderRenderOptimize () {
1121
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1122
- const props = $xeTable
1123
- const reactData = $xeTable as unknown as TableReactData
1124
-
1125
- const { spanMethod, footerSpanMethod, showHeaderOverflow: allColumnHeaderOverflow } = props
1126
- const { isGroup, scrollXLoad } = reactData
1127
- let isOptimizeMode = false
1128
- if (isGroup) {
1129
- // 分组表头
1130
- } else {
1131
- // 如果是使用优化模式
1132
- if (scrollXLoad && allColumnHeaderOverflow) {
1133
- if (spanMethod || footerSpanMethod) {
1134
- // 如果不支持优化模式
1135
- } else {
1136
- isOptimizeMode = true
1137
- }
1138
- }
1139
- }
1140
- return isOptimizeMode
1141
- },
1142
- computeIsBodyRenderOptimize () {
1143
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1144
- const props = $xeTable
1145
- const reactData = $xeTable as unknown as TableReactData
1146
-
1147
- const { spanMethod, footerSpanMethod } = props
1148
- const { scrollXLoad, scrollYLoad, isAllOverflow, expandColumn } = reactData
1149
- const bodyMergeCoverFixed = $xeTable.computeBodyMergeCoverFixed
1150
- const expandOpts = $xeTable.computeExpandOpts
1151
- let isOptimizeMode = false
1152
- // 如果是使用优化模式
1153
- if (scrollXLoad || scrollYLoad || isAllOverflow) {
1154
- // 如果是展开行,内联模式,不支持优化
1155
- // 如果是方法合并,不支持优化
1156
- // 如果固定列且配置式合并,不支持优化
1157
- if ((expandColumn && expandOpts.mode !== 'fixed') || bodyMergeCoverFixed || spanMethod || footerSpanMethod) {
1158
- // 如果不支持优化模式
1159
- } else {
1160
- isOptimizeMode = true
1161
- }
1162
- }
1163
- return isOptimizeMode
1164
- },
1165
- computeIsFooterRenderOptimize () {
1166
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1167
- const props = $xeTable
1168
- const reactData = $xeTable as unknown as TableReactData
1169
-
1170
- const { spanMethod, footerSpanMethod, showFooterOverflow: allColumnFooterOverflow } = props
1171
- const { scrollXLoad } = reactData
1172
- let isOptimizeMode = false
1173
- // 如果是使用优化模式
1174
- if (scrollXLoad && allColumnFooterOverflow) {
1175
- if (spanMethod || footerSpanMethod) {
1176
- // 如果不支持优化模式
1177
- } else {
1178
- isOptimizeMode = true
1179
- }
1180
- }
1181
- return isOptimizeMode
1182
- },
1183
- exportOpts () {
1184
- return this.computeExportOpts
1185
- },
1186
- computeExportOpts () {
1187
- return Object.assign({}, getConfig().table.exportConfig, this.exportConfig)
1188
- },
1189
- importOpts () {
1190
- return this.computeImportOpts
1191
- },
1192
- computeImportOpts () {
1193
- return Object.assign({}, getConfig().table.importConfig, this.importConfig)
1194
- },
1195
- printOpts () {
1196
- return this.computePrintOpts
1197
- },
1198
- computePrintOpts () {
1199
- return Object.assign({}, getConfig().table.printConfig, this.printConfig)
1200
- },
1201
- expandOpts () {
1202
- return this.computeExpandOpts
1203
- },
1204
- computeExpandOpts () {
1205
- return Object.assign({}, getConfig().table.expandConfig, this.expandConfig)
1206
- },
1207
- treeOpts () {
1208
- return this.computeTreeOpts
1209
- },
1210
- computeTreeOpts () {
1211
- return Object.assign({}, getConfig().table.treeConfig, this.treeConfig)
1212
- },
1213
- emptyOpts () {
1214
- return this.computeEmptyOpts
1215
- },
1216
- computeEmptyOpts () {
1217
- return Object.assign({}, getConfig().table.emptyRender, this.emptyRender)
1218
- },
1219
- loadingOpts () {
1220
- return this.computeLoadingOpts
1221
- },
1222
- computeLoadingOpts () {
1223
- return Object.assign({}, getConfig().table.loadingConfig, this.loadingConfig)
1224
- },
1225
- computeCellOffsetWidth () {
1226
- return this.border ? Math.max(2, Math.ceil(this.scrollbarWidth / this.tableColumn.length)) : 1
1227
- },
1228
- customOpts () {
1229
- return this.computeCustomOpts
1230
- },
1231
- computeCustomOpts () {
1232
- return Object.assign({}, getConfig().table.customConfig, this.customConfig)
1233
- },
1234
- computeCustomSimpleMode () {
1235
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1236
- const props = $xeTable
1237
-
1238
- const { minHeight, height } = props
1239
- const customOpts = $xeTable.computeCustomOpts
1240
- const { mode, popupOptions, placement } = customOpts
1241
- if (!placement || placement === 'top-left' || placement === 'top-right') {
1242
- if (!(mode === 'modal' || mode === 'drawer')) {
1243
- const { mode } = popupOptions || {}
1244
- if (!mode || mode === 'auto') {
1245
- if (height || minHeight) {
1246
- return 'inside'
1247
- }
1248
- return 'outside'
1249
- }
1250
- if (mode) {
1251
- return mode
1252
- }
1253
- }
1254
- }
1255
- return ''
1256
- },
1257
- computeTableStyle () {
1258
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1259
-
1260
- const scrollbarOpts = $xeTable.computeScrollbarOpts
1261
- const { width, height } = scrollbarOpts
1262
- const tStys: VxeComponentStyleType = {}
1263
- if (width) {
1264
- tStys['--vxe-ui-table-view-scrollbar-width'] = toCssUnit(width)
1265
- }
1266
- if (height) {
1267
- tStys['--vxe-ui-table-view-scrollbar-height'] = toCssUnit(height)
1268
- }
1269
- return tStys
1270
- },
1271
- computeTableRowExpandedList () {
1272
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1273
- const reactData = $xeTable as unknown as TableReactData
1274
- const internalData = $xeTable as unknown as TableInternalData
1275
-
1276
- const { tableData, rowExpandedFlag, expandColumn, rowGroupExpandedFlag, treeExpandedFlag } = reactData
1277
- const { visibleDataRowIdData, rowExpandedMaps } = internalData
1278
- const expandList: any[] = []
1279
- if (tableData.length && expandColumn && rowExpandedFlag && rowGroupExpandedFlag && treeExpandedFlag) {
1280
- XEUtils.each(rowExpandedMaps, (row, rowid) => {
1281
- if (visibleDataRowIdData[rowid]) {
1282
- expandList.push(row)
1283
- }
1284
- })
1285
- }
1286
- return expandList
1287
- },
1288
- computeAutoWidthColumnList () {
1289
- const { tableColumn, visibleColumn } = this
1290
- return tableColumn.length || visibleColumn.length ? visibleColumn.filter((column: any) => column.width === 'auto' || column.minWidth === 'auto') : []
1291
- },
1292
- computeFixedColumnSize () {
1293
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1294
- const reactData = $xeTable as unknown as TableReactData
1295
- const internalData = $xeTable as unknown as TableInternalData
1296
-
1297
- const { tableColumn } = reactData
1298
- const { collectColumn } = internalData
1299
- let fixedSize = 0
1300
- // 只判断第一层
1301
- if (tableColumn.length && collectColumn.length) {
1302
- collectColumn.forEach((column: any) => {
1303
- if (column.renderFixed) {
1304
- fixedSize++
1305
- }
1306
- })
1307
- }
1308
- return fixedSize
1309
- },
1310
- fixedColumnSize () {
1311
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1312
-
1313
- return $xeTable.computeFixedColumnSize
1314
- },
1315
- computeIsMaxFixedColumn () {
1316
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1317
-
1318
- const fixedColumnSize = $xeTable.computeFixedColumnSize
1319
- const columnOpts = $xeTable.columnOpts
1320
- const { maxFixedSize } = columnOpts
1321
- if (maxFixedSize) {
1322
- return fixedColumnSize >= maxFixedSize
1323
- }
1324
- return false
1325
- },
1326
- computeKeepFields () {
1327
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1328
- const reactData = $xeTable as unknown as TableReactData
1329
- const internalData = $xeTable as unknown as TableInternalData
1330
-
1331
- const { tableFullColumn } = internalData
1332
- const { updateColFlag } = reactData
1333
- const editDirtyOpts = $xeTable.computeEditDirtyOpts
1334
- const { includeFields, excludeFields } = editDirtyOpts
1335
- const kpFields: string[] = []
1336
- if (updateColFlag) {
1337
- if (includeFields && includeFields.length) {
1338
- return includeFields
1339
- }
1340
- const exfMaps: Record<string, number> = {}
1341
- if (excludeFields && excludeFields.length) {
1342
- excludeFields.forEach(field => {
1343
- exfMaps[field] = 1
1344
- })
1345
- }
1346
- for (let i = 0; i < tableFullColumn.length; i++) {
1347
- const column = tableFullColumn[i]
1348
- const { field, type, editRender, cellRender } = column
1349
- if (field && !type && (editRender || cellRender) && !exfMaps[field]) {
1350
- kpFields.push(field)
1351
- }
1352
- }
1353
- }
1354
- return kpFields
1355
- },
1356
- computeTableBorder () {
1357
- const $xeTable = this
1358
- const props = $xeTable
1359
-
1360
- const { border } = props
1361
- if (border === true) {
1362
- return 'full'
1363
- }
1364
- if (border) {
1365
- return border
1366
- }
1367
- return 'default'
1368
- },
1369
- /**
1370
- * 判断列全选的复选框是否禁用
1371
- */
1372
- computeIsAllCheckboxDisabled () {
1373
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1374
- const props = $xeTable
1375
- const reactData = $xeTable as unknown as TableReactData
1376
- const internalData = $xeTable as unknown as TableInternalData
1377
-
1378
- const { treeConfig } = props
1379
- const { tableData } = reactData
1380
- const { tableFullData } = internalData
1381
- const checkboxOpts = $xeTable.computeCheckboxOpts
1382
- const { strict, checkMethod } = checkboxOpts
1383
- if (strict) {
1384
- if (tableData.length || tableFullData.length) {
1385
- if (checkMethod) {
1386
- if (treeConfig) {
1387
- // 暂时不支持树形结构
1388
- }
1389
- // 如果所有行都被禁用
1390
- return tableFullData.every((row) => !checkMethod({ $table: $xeTable, row }))
1391
- }
1392
- return false
1393
- }
1394
- return true
1395
- }
1396
- return false
1397
- },
1398
- isAllCheckboxDisabled () {
1399
- return this.computeIsAllCheckboxDisabled
1400
- },
1401
- computeVirtualScrollBars () {
1402
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1403
- const reactData = $xeTable as unknown as TableReactData
1404
-
1405
- const { overflowX, scrollXLoad, overflowY, scrollYLoad } = reactData
1406
- return {
1407
- x: overflowX && scrollXLoad,
1408
- y: overflowY && scrollYLoad
1409
- }
1410
- },
1411
- computeRowGroupFields () {
1412
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1413
-
1414
- const aggregateOpts = $xeTable.computeAggregateOpts
1415
- return aggregateOpts.groupFields
1416
- },
1417
- computeRowGroupColumns () {
1418
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1419
- const reactData = $xeTable as unknown as TableReactData
1420
- const internalData = $xeTable as unknown as TableInternalData
1421
-
1422
- const { rowGroupList } = reactData
1423
- const { fullColumnFieldData } = internalData
1424
- const rgColumns: VxeTableDefines.ColumnInfo[] = []
1425
- rowGroupList.forEach(aggConf => {
1426
- const colRest = fullColumnFieldData[aggConf.field]
1427
- if (colRest) {
1428
- rgColumns.push(colRest.column)
1429
- }
1430
- })
1431
- return rgColumns
1432
- },
1433
- computeAggFuncColumns () {
1434
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1435
- const reactData = $xeTable as unknown as TableReactData
1436
-
1437
- const { rowGroupList, tableColumn } = reactData
1438
- if (rowGroupList.length) {
1439
- return tableColumn.filter(column => column.field && column.aggFunc)
1440
- }
1441
- return []
1442
- },
1443
- computeUndoHistoryOpts () {
1444
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1445
- const props = $xeTable
1446
-
1447
- return Object.assign({}, getConfig().table.undoHistoryConfig, props.undoHistoryConfig)
1448
- },
1449
- tabsResizeFlag () {
1450
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1451
- const $xeTabs = $xeTable.$xeTabs
1452
-
1453
- return $xeTabs ? $xeTabs.reactData.resizeFlag : null
1454
- },
1455
- computeVxeLanguage () {
1456
- return VxeUI.getLanguage()
1457
- },
1458
- computeScrollbarVisible () {
1459
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1460
-
1461
- const scrollbarXOpts = $xeTable.computeScrollbarXOpts
1462
- const scrollbarYOpts = $xeTable.computeScrollbarYOpts
1463
- return `${scrollbarXOpts.visible}${scrollbarYOpts.visible}`
1464
- }
1465
- } as any,
1466
- watch: {
1467
- data (value: any) {
1468
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1469
- const reactData = $xeTable as unknown as TableReactData
1470
-
1471
- const { initStatus } = this
1472
- if (value && value.length >= 20000) {
1473
- warnLog('vxe.error.errLargeData', ['loadData(data), reloadData(data)'])
1474
- }
1475
- this.loadTableData(value || [], true, true).then(() => {
1476
- const { scrollXLoad, scrollYLoad, expandColumn } = reactData
1477
- const expandOpts = $xeTable.computeExpandOpts
1478
- this.inited = true
1479
- this.initStatus = true
1480
- if (!initStatus) {
1481
- this.handleLoadDefaults()
1482
- }
1483
- // const checkboxColumn = this.tableFullColumn.find(column => column.type === 'checkbox')
1484
- // if (checkboxColumn && this.tableFullData.length > 300 && !this.checkboxOpts.checkField) {
1485
- // warnLog('vxe.error.checkProp', ['checkbox-config.checkField'])
1486
- // }
1487
- if ((scrollXLoad || scrollYLoad) && (expandColumn && expandOpts.mode !== 'fixed')) {
1488
- warnLog('vxe.error.scrollErrProp', ['column.type=expand'])
1489
- }
1490
- this.recalculate()
1491
- })
1492
- },
1493
- staticColumns (value: any) {
1494
- this.$nextTick(() => this.handleInitColumn(XEUtils.clone(value)))
1495
- },
1496
- tableColumn () {
1497
- this.analyColumnWidth()
1498
- },
1499
- upDataFlag () {
1500
- this.$nextTick().then(() => this.updateData())
1501
- },
1502
- reColumnFlag () {
1503
- this.$nextTick().then(() => this.refreshColumn())
1504
- },
1505
-
1506
- computeSize () {
1507
- this.reLayoutFlag++
1508
- },
1509
- showHeader () {
1510
- this.reLayoutFlag++
1511
- },
1512
- showFooter () {
1513
- this.reLayoutFlag++
1514
- },
1515
- showHeaderOverflow () {
1516
- this.reLayoutFlag++
1517
- },
1518
- showOverflow () {
1519
- const $xeTable = this
1520
-
1521
- updateColumnAllOverflow($xeTable)
1522
- this.reLayoutFlag++
1523
- },
1524
- showFooterOverflow () {
1525
- this.reLayoutFlag++
1526
- },
1527
- overflowX () {
1528
- this.reLayoutFlag++
1529
- },
1530
- overflowY () {
1531
- this.reLayoutFlag++
1532
- },
1533
- height () {
1534
- this.reLayoutFlag++
1535
- },
1536
- maxHeight () {
1537
- this.reLayoutFlag++
1538
- },
1539
- computeScrollbarXToTop () {
1540
- this.reLayoutFlag++
1541
- },
1542
- computeScrollbarYToLeft () {
1543
- this.reLayoutFlag++
1544
- },
1545
- computeVxeLanguage () {
1546
- this.reLayoutFlag++
1547
- },
1548
- computeScrollbarVisible () {
1549
- this.reLayoutFlag++
1550
- },
1551
- reLayoutFlag () {
1552
- const $xeTable = this
1553
-
1554
- $xeTable.$nextTick(() => $xeTable.recalculate(true))
1555
- },
1556
-
1557
- footerData () {
1558
- this.footFlag++
1559
- },
1560
- footFlag () {
1561
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1562
- const internalData = $xeTable as unknown as TableInternalData
1563
-
1564
- internalData.footerFullDataRowData = {}
1565
- $xeTable.updateFooter()
1566
- },
1567
-
1568
- updateColFlag () {
1569
- this.kfFlag++
1570
- },
1571
- computeKeepFields () {
1572
- this.kfFlag++
1573
- },
1574
- kfFlag () {
1575
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1576
- const internalData = $xeTable as unknown as TableInternalData
1577
-
1578
- const keepFields = $xeTable.computeKeepFields
1579
- const kpfMaps: Record<string, number> = {}
1580
- keepFields.forEach(field => {
1581
- kpfMaps[field] = 1
1582
- })
1583
- internalData.keepUpdateFieldMaps = kpfMaps
1584
- },
1585
-
1586
- syncResize (value: any) {
1587
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1588
-
1589
- if (value) {
1590
- handleUpdateResize($xeTable)
1591
- $xeTable.$nextTick(() => {
1592
- handleUpdateResize($xeTable)
1593
- setTimeout(() => handleUpdateResize($xeTable))
1594
- })
1595
- }
1596
- },
1597
- tabsResizeFlag () {
1598
- this.handleGlobalResizeEvent()
1599
- },
1600
- mergeCells (value: any) {
1601
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1602
-
1603
- handleUpdateMergeBodyCells($xeTable, value)
1604
- },
1605
- mergeHeaderCells (value: any) {
1606
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1607
-
1608
- handleUpdateMergeHeaderCells($xeTable, value)
1609
- },
1610
- mergeFooterCells () {
1611
- this.mergeFooteCellFlag++
1612
- },
1613
- mergeFooterItems () {
1614
- this.mergeFooteCellFlag++
1615
- },
1616
- mergeFooteCellFlag () {
1617
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1618
- const props = $xeTable
1619
-
1620
- const mFooterCells = props.mergeFooterCells || props.mergeFooterItems
1621
- handleUpdateMergeFooterCells($xeTable, mFooterCells || [])
1622
- },
1623
-
1624
- computeRowGroupFields (val: any) {
1625
- const $xeTable = this
1626
-
1627
- $xeTable.handleUpdateRowGroup(val)
1628
- },
1629
- computeRowField () {
1630
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1631
- const reactData = $xeTable as unknown as TableReactData
1632
- const internalData = $xeTable as unknown as TableInternalData
1633
-
1634
- // 行主键被改变,重载表格
1635
- const { inited, tableFullData } = internalData
1636
- if (inited) {
1637
- handleKeyField($xeTable)
1638
- reactData.tableData = []
1639
- $xeTable.$nextTick(() => {
1640
- $xeTable.reloadData(tableFullData)
1641
- })
1642
- }
1643
- }
1644
- } as any,
1645
- created () {
1646
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1647
- const props = $xeTable
1648
- const internalData = $xeTable as unknown as TableInternalData
1649
-
1650
- XEUtils.assign(internalData, createInternalData())
1651
-
1652
- handleKeyField($xeTable)
1653
-
1654
- const { exportConfig, importConfig, treeConfig, minHeight } = props
1655
- const { scrollXStore, scrollYStore } = internalData
1656
- const columnOpts = $xeTable.computeColumnOpts
1657
- const columnDragOpts = $xeTable.computeColumnDragOpts
1658
- const editOpts = $xeTable.computeEditOpts
1659
- const treeOpts = $xeTable.computeTreeOpts
1660
- const radioOpts = $xeTable.computeRadioOpts
1661
- const checkboxOpts = $xeTable.computeCheckboxOpts
1662
- const expandOpts = $xeTable.computeExpandOpts
1663
- const rowOpts = $xeTable.computeRowOpts
1664
- const customOpts = $xeTable.computeCustomOpts
1665
- const mouseOpts = $xeTable.computeMouseOpts
1666
- const exportOpts = $xeTable.computeExportOpts
1667
- const importOpts = $xeTable.computeImportOpts
1668
- // const currentRowOpts = $xeTable.computeCurrentRowOpts
1669
- // const currentColumnOpts = $xeTable.computeCurrentColumnOpts
1670
- // const keyboardOpts = $xeTable.computeKeyboardOpts
1671
- const aggregateOpts = $xeTable.computeAggregateOpts
1672
- const rowDragOpts = $xeTable.computeRowDragOpts
1673
- const areaOpts = $xeTable.computeAreaOpts
1674
- const { groupFields } = aggregateOpts
1675
-
1676
- if (props.rowId) {
1677
- warnLog('vxe.error.delProp', ['row-id', 'row-config.keyField'])
1678
- }
1679
- if (props.rowKey) {
1680
- warnLog('vxe.error.delProp', ['row-key', 'row-config.useKey'])
1681
- }
1682
- if (props.columnKey) {
1683
- warnLog('vxe.error.delProp', ['column-id', 'column-config.useKey'])
1684
- }
1685
- if (!(props.rowId || rowOpts.keyField) && (checkboxOpts.reserve || checkboxOpts.checkRowKeys || radioOpts.reserve || radioOpts.checkRowKey || expandOpts.expandRowKeys || treeOpts.expandRowKeys)) {
1686
- warnLog('vxe.error.reqProp', ['row-config.keyField'])
1687
- }
1688
- if (props.editConfig && editOpts.showStatus && !props.keepSource) {
1689
- warnLog('vxe.error.reqProp', ['keep-source'])
1690
- }
1691
- // if (treeConfig && (treeOpts.showLine || treeOpts.line) && !showOverflow) {
1692
- // warnLog('vxe.error.reqProp', ['show-overflow'])
1693
- // }
1694
- if (treeConfig && !treeOpts.transform && props.stripe) {
1695
- warnLog('vxe.error.noTree', ['stripe'])
1696
- }
1697
- if (props.showFooter && !(props.footerMethod || props.footerData)) {
1698
- warnLog('vxe.error.reqProp', ['footer-data | footer-method'])
1699
- }
1700
- if (rowOpts.height) {
1701
- warnLog('vxe.error.delProp', ['row-config.height', 'cell-config.height'])
1702
- }
1703
- if (this.tooltipOpts.enabled) {
1704
- warnLog('vxe.error.delProp', ['tooltip-config.enabled', 'tooltip-config.showAll'])
1705
- }
1706
- if (this.highlightCurrentRow) {
1707
- warnLog('vxe.error.delProp', ['highlight-current-row', 'row-config.isCurrent'])
1708
- }
1709
- if (this.highlightHoverRow) {
1710
- warnLog('vxe.error.delProp', ['highlight-hover-row', 'row-config.isHover'])
1711
- }
1712
- if (this.highlightCurrentColumn) {
1713
- warnLog('vxe.error.delProp', ['highlight-current-column', 'column-config.isCurrent'])
1714
- }
1715
- if (this.highlightHoverColumn) {
1716
- warnLog('vxe.error.delProp', ['highlight-hover-column', 'column-config.isHover'])
1717
- }
1718
- if (props.resizable) {
1719
- warnLog('vxe.error.delProp', ['resizable', 'column-config.resizable'])
1720
- }
1721
- // if (props.virtualXConfig && props.scrollX) {
1722
- // warnLog('vxe.error.notSupportProp', ['virtual-x-config', 'scroll-x', 'scroll-x=null'])
1723
- // }
1724
- // if (props.virtualYConfig && props.scrollY) {
1725
- // warnLog('vxe.error.notSupportProp', ['virtual-y-config', 'scroll-y', 'scroll-y=null'])
1726
- // }
1727
- if (props.aggregateConfig && props.rowGroupConfig) {
1728
- warnLog('vxe.error.notSupportProp', ['aggregate-config', 'row-group-config', 'row-group-config=null'])
1729
- }
1730
- // if (props.scrollY) {
1731
- // warnLog('vxe.error.delProp', ['scroll-y', 'virtual-y-config'])
1732
- // }
1733
- // if (props.scrollX) {
1734
- // warnLog('vxe.error.delProp', ['scroll-x', 'virtual-x-config'])
1735
- // }
1736
- // 检查导入导出类型,如果自定义导入导出方法,则不校验类型
1737
- if (importConfig && importOpts.types && !importOpts.importMethod && !XEUtils.includeArrays(XEUtils.keys(importOpts._typeMaps), importOpts.types)) {
1738
- warnLog('vxe.error.errProp', [`export-config.types=${importOpts.types.join(',')}`, importOpts.types.filter((type) => XEUtils.includes(XEUtils.keys(importOpts._typeMaps), type)).join(',') || XEUtils.keys(importOpts._typeMaps).join(',')])
1739
- }
1740
- if (exportConfig && exportOpts.types && !exportOpts.exportMethod && !XEUtils.includeArrays(XEUtils.keys(exportOpts._typeMaps), exportOpts.types)) {
1741
- warnLog('vxe.error.errProp', [`export-config.types=${exportOpts.types.join(',')}`, exportOpts.types.filter((type) => XEUtils.includes(XEUtils.keys(exportOpts._typeMaps), type)).join(',') || XEUtils.keys(exportOpts._typeMaps).join(',')])
1742
- }
1743
-
1744
- if (!props.id) {
1745
- if ((props.customConfig ? isEnableConf(customOpts) : customOpts.enabled) && customOpts.storage) {
1746
- errLog('vxe.error.reqProp', ['id'])
1747
- }
1748
- }
1749
- if (treeConfig && checkboxOpts.range) {
1750
- errLog('vxe.error.noTree', ['checkbox-config.range'])
1751
- }
1752
- if (rowOpts.height && !this.showOverflow) {
1753
- warnLog('vxe.error.notProp', ['table.show-overflow'])
1754
- }
1755
- if (!$xeTable.triggerClAreaModnEvent) {
1756
- if (props.areaConfig) {
1757
- warnLog('vxe.error.notProp', ['area-config'])
1758
- }
1759
- if (props.clipConfig) {
1760
- warnLog('vxe.error.notProp', ['clip-config'])
1761
- }
1762
- if (props.fnrConfig) {
1763
- warnLog('vxe.error.notProp', ['fnr-config'])
1764
- }
1765
- if (mouseOpts.area) {
1766
- errLog('vxe.error.notProp', ['mouse-config.area'])
1767
- return
1768
- }
1769
- if (mouseOpts.area && areaOpts.selectCellByHeader && columnOpts.drag && columnDragOpts.trigger === 'cell') {
1770
- errLog('vxe.error.notSupportProp', ['area-config.selectCellByHeader & column-config.drag', 'column-drag-config.trigger=cell', 'column-drag-config.trigger=default | area-config.selectCellByHeader=false'])
1771
- }
1772
- }
1773
- if (!$xeTable.handlePivotTableAggregateData) {
1774
- if (customOpts.allowGroup) {
1775
- errLog('vxe.error.notProp', ['custom-config.allowGroup'])
1776
- return
1777
- }
1778
- if (customOpts.allowValues) {
1779
- errLog('vxe.error.notProp', ['custom-config.allowValues'])
1780
- return
1781
- }
1782
- }
1783
- if (treeConfig && rowOpts.drag && !treeOpts.transform) {
1784
- warnLog('vxe.error.notSupportProp', ['row-config.drag', 'tree-config.transform=false', 'tree-config.transform=true'])
1785
- }
1786
- if (treeConfig && rowDragOpts.isCrossTableDrag && !rowDragOpts.isCrossDrag) {
1787
- errLog('vxe.error.reqSupportProp', ['tree-config & row-drag-config.isCrossTableDrag', 'row-drag-config.isCrossDrag'])
1788
- }
1789
- if (props.dragConfig) {
1790
- warnLog('vxe.error.delProp', ['drag-config', 'row-drag-config'])
1791
- }
1792
- if (props.rowGroupConfig) {
1793
- warnLog('vxe.error.delProp', ['row-group-config', 'aggregate-config'])
1794
- }
1795
- if (aggregateOpts.countFields) {
1796
- warnLog('vxe.error.delProp', ['row-group-config.countFields', 'column.agg-func'])
1797
- }
1798
- if (aggregateOpts.aggregateMethod) {
1799
- warnLog('vxe.error.delProp', ['row-group-config.aggregateMethod', 'aggregate-config.calcValuesMethod'])
1800
- }
1801
- if (aggregateOpts.countMethod) {
1802
- warnLog('vxe.error.delProp', ['aggregate-config.countMethod', 'aggregate-config.calcValuesMethod'])
1803
- }
1804
- if (props.treeConfig && treeOpts.children) {
1805
- warnLog('vxe.error.delProp', ['tree-config.children', 'tree-config.childrenField'])
1806
- }
1807
- if (props.treeConfig && treeOpts.line) {
1808
- warnLog('vxe.error.delProp', ['tree-config.line', 'tree-config.showLine'])
1809
- }
1810
- if (mouseOpts.area && mouseOpts.selected) {
1811
- warnLog('vxe.error.errConflicts', ['mouse-config.area', 'mouse-config.selected'])
1812
- }
1813
- if (mouseOpts.area && (props.treeConfig && !treeOpts.transform)) {
1814
- errLog('vxe.error.noTree', ['mouse-config.area'])
1815
- }
1816
- if (props.editConfig && editOpts.activeMethod) {
1817
- warnLog('vxe.error.delProp', ['table.edit-config.activeMethod', 'table.edit-config.beforeEditMethod'])
1818
- }
1819
- if (props.treeConfig && checkboxOpts.isShiftKey) {
1820
- errLog('vxe.error.errConflicts', ['tree-config', 'checkbox-config.isShiftKey'])
1821
- }
1822
- if (checkboxOpts.halfField) {
1823
- warnLog('vxe.error.delProp', ['checkbox-config.halfField', 'checkbox-config.indeterminateField'])
1824
- }
1825
- if (props.editConfig && isEnableConf(editOpts) && props.editRules && (minHeight === 0 || minHeight === '0')) {
1826
- warnLog('vxe.error.reqSupportProp', ['edit-config & edit-rules', 'min-height'])
1827
- }
1828
-
1829
- if (treeConfig) {
1830
- XEUtils.arrayEach(['rowField', 'parentField', 'childrenField', 'hasChildField', 'mapChildrenField'], key => {
1831
- const val = treeOpts[key as 'rowField']
1832
- if (val && val.indexOf('.') > -1) {
1833
- errLog('vxe.error.errProp', [`${key}=${val}`, `${key}=${val.split('.')[0]}`])
1834
- }
1835
- })
1836
- }
1837
-
1838
- // 在 v3.0 中废弃 context-menu
1839
- if (this.contextMenu) {
1840
- warnLog('vxe.error.delProp', ['context-menu', 'menu-config'])
1841
- if (!XEUtils.isObject(this.contextMenu)) {
1842
- warnLog('vxe.error.errProp', [`table.context-menu=${this.contextMenu}`, 'table.context-menu={}'])
1843
- }
1844
- }
1845
- if (props.menuConfig && !XEUtils.isObject(props.menuConfig)) {
1846
- warnLog('vxe.error.errProp', [`table.menu-config=${props.menuConfig}`, 'table.menu-config={}'])
1847
- }
1848
- if (props.exportConfig && !XEUtils.isObject(props.exportConfig)) {
1849
- warnLog('vxe.error.errProp', [`table.export-config=${props.exportConfig}`, 'table.export-config={}'])
1850
- }
1851
- if (props.importConfig && !XEUtils.isObject(props.importConfig)) {
1852
- warnLog('vxe.error.errProp', [`table.import-config=${props.importConfig}`, 'table.import-config={}'])
1853
- }
1854
- if (props.printConfig && !XEUtils.isObject(props.printConfig)) {
1855
- warnLog('vxe.error.errProp', [`table.print-config=${props.printConfig}`, 'table.print-config={}'])
1856
- }
1857
- if (props.treeConfig && !XEUtils.isObject(props.treeConfig)) {
1858
- warnLog('vxe.error.errProp', [`table.tree-config=${props.treeConfig}`, 'table.tree-config={}'])
1859
- }
1860
- if (props.customConfig && !XEUtils.isObject(props.customConfig)) {
1861
- warnLog('vxe.error.errProp', [`table.custom-config=${props.customConfig}`, 'table.custom-config={}'])
1862
- }
1863
- if (props.editConfig && !XEUtils.isObject(props.editConfig)) {
1864
- warnLog('vxe.error.errProp', [`table.edit-config=${props.editConfig}`, 'table.edit-config={}'])
1865
- }
1866
- if (props.emptyRender && !XEUtils.isObject(props.emptyRender)) {
1867
- warnLog('vxe.error.errProp', [`table.empty-render=${props.emptyRender}`, 'table.empty-render={}'])
1868
- }
1869
-
1870
- if (rowOpts.currentMethod) {
1871
- warnLog('vxe.error.delProp', ['row-config.currentMethod', 'current-row-config.beforeSelectMethod'])
1872
- }
1873
- if (columnOpts.currentMethod) {
1874
- warnLog('vxe.error.delProp', ['row-config.currentMethod', 'current-column-config.beforeSelectMethod'])
1875
- }
1876
- // if ((rowOpts.isCurrent || highlightCurrentRow) && props.keyboardConfig && keyboardOpts.isArrow && !XEUtils.isBoolean(currentRowOpts.isFollowSelected)) {
1877
- // warnLog('vxe.error.notConflictProp', ['row-config.isCurrent & keyboard-config.isArrow', 'current-row-config.isFollowSelected'])
1878
- // }
1879
- // if ((columnOpts.isCurrent || highlightCurrentColumn) && props.keyboardConfig && keyboardOpts.isArrow && !XEUtils.isBoolean(currentColumnOpts.isFollowSelected)) {
1880
- // warnLog('vxe.error.notConflictProp', ['column-config.isCurrent & keyboard-config.isArrow', 'current-column-config.isFollowSelected'])
1881
- // }
1882
-
1883
- // 如果不支持虚拟滚动
1884
- // if (props.spanMethod) {
1885
- // if (virtualXOpts.enabled) {
1886
- // warnLog('vxe.error.notConflictProp', ['span-method', 'virtual-x-config.enabled=false'])
1887
- // }
1888
- // if (virtualYOpts.enabled) {
1889
- // warnLog('vxe.error.notConflictProp', ['span-method', 'virtual-y-config.enabled=false'])
1890
- // }
1891
- // }
1892
- // if (props.footerSpanMethod) {
1893
- // if (virtualXOpts.enabled) {
1894
- // warnLog('vxe.error.notConflictProp', ['footer-span-method', 'virtual-x-config.enabled=false'])
1895
- // }
1896
- // }
1897
-
1898
- // 检查是否有安装需要的模块
1899
- if (props.editConfig && !$xeTable.insert) {
1900
- errLog('vxe.error.reqModule', ['Edit'])
1901
- }
1902
- if (props.editRules && !$xeTable.validate) {
1903
- errLog('vxe.error.reqModule', ['Validator'])
1904
- }
1905
- if ((checkboxOpts.range || props.keyboardConfig || props.mouseConfig) && !$xeTable.handleCellMousedownEvent) {
1906
- errLog('vxe.error.reqModule', ['Keyboard'])
1907
- }
1908
- if ((props.printConfig || props.importConfig || props.exportConfig) && !$xeTable.exportData) {
1909
- errLog('vxe.error.reqModule', ['Export'])
1910
- }
1911
-
1912
- Object.assign(scrollYStore, {
1913
- startIndex: 0,
1914
- endIndex: 1,
1915
- visibleSize: 0
1916
- })
1917
- Object.assign(scrollXStore, {
1918
- startIndex: 0,
1919
- endIndex: 1,
1920
- visibleSize: 0
1921
- })
1922
-
1923
- this.handleUpdateRowGroup(groupFields)
1924
-
1925
- this.initData()
1926
-
1927
- globalEvents.on($xeTable, 'paste', this.handleGlobalPasteEvent)
1928
- globalEvents.on($xeTable, 'copy', this.handleGlobalCopyEvent)
1929
- globalEvents.on($xeTable, 'cut', this.handleGlobalCutEvent)
1930
- globalEvents.on($xeTable, 'mousedown', this.handleGlobalMousedownEvent)
1931
- globalEvents.on($xeTable, 'blur', this.handleGlobalBlurEvent)
1932
- globalEvents.on($xeTable, 'mousewheel', this.handleGlobalMousewheelEvent)
1933
- globalEvents.on($xeTable, 'keydown', this.handleGlobalKeydownEvent)
1934
- globalEvents.on($xeTable, 'resize', this.handleGlobalResizeEvent)
1935
- globalEvents.on($xeTable, 'contextmenu', this.handleGlobalContextmenuEvent)
1936
- $xeTable.preventEvent(null, 'created')
1937
- },
1938
- mounted () {
1939
- const $xeTable = this
1940
- const props = $xeTable
1941
- const internalData = $xeTable as unknown as TableInternalData
1942
- const $xeGrid = $xeTable.$xeGrid
1943
- const $xeGantt = $xeTable.$xeGantt
1944
- const $xeGGWrapper = $xeGrid || $xeGantt
1945
-
1946
- const columnOpts = $xeTable.computeColumnOpts
1947
- const rowOpts = $xeTable.computeRowOpts
1948
- const customOpts = $xeTable.computeCustomOpts
1949
- const virtualYOpts = $xeTable.computeVirtualYOpts
1950
-
1951
- if ($xeGantt) {
1952
- const classifyWrapperEl = $xeGantt.$refs.refClassifyWrapperElem as HTMLDivElement
1953
- const teleportWrapperEl = $xeTable.$refs.refTeleportWrapper as HTMLDivElement
1954
- if (classifyWrapperEl) {
1955
- if (teleportWrapperEl) {
1956
- classifyWrapperEl.appendChild(teleportWrapperEl)
1957
- }
1958
- internalData.teleportToWrapperElem = classifyWrapperEl
1959
- }
1960
- }
1961
- if ($xeGGWrapper) {
1962
- const popupContainerElem = $xeGGWrapper.$refs.refPopupContainerElem as HTMLDivElement
1963
- const popupWrapperEl = $xeTable.$refs.refPopupWrapperElem as HTMLDivElement
1964
- if (popupContainerElem) {
1965
- if (popupWrapperEl) {
1966
- popupContainerElem.appendChild(popupWrapperEl)
1967
- }
1968
- internalData.popupToWrapperElem = popupContainerElem
1969
- }
1970
- }
1971
-
1972
- if (columnOpts.drag || rowOpts.drag || customOpts.allowSort) {
1973
- initTpImg()
1974
- }
1975
-
1976
- const { $listeners } = this
1977
- if (!this.menuConfig && ($listeners['menu-click'] || $listeners['cell-menu'] || $listeners['header-cell-menu'] || $listeners['footer-cell-menu'])) {
1978
- warnLog('vxe.error.reqProp', ['menu-config'])
1979
- }
1980
- if (!this.tooltipConfig && ($listeners['cell-mouseenter'] || $listeners['cell-mouseleave'])) {
1981
- warnLog('vxe.error.reqProp', ['tooltip-config'])
1982
- }
1983
-
1984
- $xeTable.$nextTick(() => {
1985
- // 使用已安装的组件,如果未安装则不渲染
1986
- const VxeUILoadingComponent = VxeUI.getComponent('VxeLoading')
1987
- const VxeUITooltipComponent = VxeUI.getComponent('VxeTooltip')
1988
-
1989
- if (props.loading) {
1990
- if (!VxeUILoadingComponent && !this.$scopedSlots.loading) {
1991
- errLog('vxe.error.errProp', ['loading=true', 'loading=false | <template #loading>...</template>'])
1992
- errLog('vxe.error.reqComp', ['vxe-loading'])
1993
- }
1994
- }
1995
- if ((props.showOverflow === true || props.showOverflow === 'tooltip') ||
1996
- (props.showHeaderOverflow === true || props.showHeaderOverflow === 'tooltip') ||
1997
- (props.showFooterOverflow === true || props.showFooterOverflow === 'tooltip') ||
1998
- props.tooltipConfig || props.editRules) {
1999
- if (!VxeUITooltipComponent) {
2000
- if (props.showOverflow === true) {
2001
- errLog('vxe.error.errProp', ['show-overflow=true', 'show-overflow=title'])
2002
- }
2003
- if (props.showOverflow === 'tooltip') {
2004
- errLog('vxe.error.errProp', ['show-overflow=tooltip', 'show-overflow=title'])
2005
- }
2006
- if (props.showHeaderOverflow === true) {
2007
- errLog('vxe.error.errProp', ['show-header-overflow=true', 'show-header-overflow=title'])
2008
- }
2009
- if (props.showHeaderOverflow === 'tooltip') {
2010
- errLog('vxe.error.errProp', ['show-header-overflow=tooltip', 'show-header-overflow=title'])
2011
- }
2012
- if (props.showFooterOverflow === true) {
2013
- errLog('vxe.error.errProp', ['show-footer-overflow=true', 'show-footer-overflow=title'])
2014
- }
2015
- if (props.showFooterOverflow === 'tooltip') {
2016
- errLog('vxe.error.errProp', ['show-footer-overflow=tooltip', 'show-footer-overflow=title'])
2017
- }
2018
- errLog('vxe.error.reqComp', ['vxe-tooltip'])
2019
- }
2020
- }
2021
-
2022
- if (this.autoResize) {
2023
- const resizeObserver = globalResize.create(() => {
2024
- if (this.autoResize) {
2025
- this.handleResizeEvent()
2026
- }
2027
- })
2028
- resizeObserver.observe(this.$el)
2029
- resizeObserver.observe(this.getParentElem())
2030
- this.$resize = resizeObserver
2031
- }
2032
- })
2033
-
2034
- if (virtualYOpts.mode !== 'scroll') {
2035
- const tableViewportEl = $xeTable.$refs.refTableViewportElem as HTMLDivElement
2036
- if (tableViewportEl) {
2037
- tableViewportEl.addEventListener('wheel', $xeTable.triggerBodyWheelEvent, { passive: false })
2038
- }
2039
- }
2040
-
2041
- $xeTable.preventEvent(null, 'mounted')
2042
- },
2043
- activated () {
2044
- this.recalculate().then(() => this.refreshScroll())
2045
- this.preventEvent(null, 'activated')
2046
- },
2047
- deactivated () {
2048
- const $xeTable = this
2049
- const reactData = $xeTable as unknown as TableReactData
2050
- const internalData = $xeTable as unknown as TableInternalData
2051
-
2052
- const { filterStore } = reactData
2053
- if (filterStore.visible) {
2054
- $xeTable.clearFilter()
2055
- }
2056
- $xeTable.closeTooltip()
2057
- internalData.isActivated = false
2058
- this.preventEvent(null, 'deactivated')
2059
- },
2060
- beforeDestroy () {
2061
- const $xeTable = this
2062
- const reactData = $xeTable as unknown as TableReactData
2063
- const internalData = $xeTable as unknown as TableInternalData
2064
-
2065
- const { _sToTime } = internalData
2066
- if (_sToTime) {
2067
- clearTimeout(_sToTime)
2068
- }
2069
-
2070
- const teleportWrapperEl = $xeTable.$refs.refTeleportWrapper as HTMLDivElement
2071
- if (teleportWrapperEl && teleportWrapperEl.parentElement) {
2072
- teleportWrapperEl.parentElement.removeChild(teleportWrapperEl)
2073
- }
2074
- const popupWrapperEl = $xeTable.$refs.refPopupWrapperElem as HTMLDivElement
2075
- if (popupWrapperEl && popupWrapperEl.parentElement) {
2076
- popupWrapperEl.parentElement.removeChild(popupWrapperEl)
2077
- }
2078
-
2079
- const tableViewportEl = $xeTable.$refs.refTableViewportElem as HTMLDivElement
2080
- if (tableViewportEl) {
2081
- tableViewportEl.removeEventListener('wheel', $xeTable.triggerBodyWheelEvent)
2082
- }
2083
-
2084
- if (this.$resize) {
2085
- this.$resize.disconnect()
2086
- }
2087
-
2088
- $xeTable.closeTooltip()
2089
- $xeTable.closeFilter()
2090
- $xeTable.closeMenu()
2091
-
2092
- globalEvents.off($xeTable, 'paste')
2093
- globalEvents.off($xeTable, 'copy')
2094
- globalEvents.off($xeTable, 'cut')
2095
- globalEvents.off($xeTable, 'mousedown')
2096
- globalEvents.off($xeTable, 'blur')
2097
- globalEvents.off($xeTable, 'mousewheel')
2098
- globalEvents.off($xeTable, 'keydown')
2099
- globalEvents.off($xeTable, 'resize')
2100
- globalEvents.off($xeTable, 'contextmenu')
2101
-
2102
- $xeTable.preventEvent(null, 'beforeDestroy')
2103
-
2104
- XEUtils.assign(reactData, createReactData())
2105
- XEUtils.assign(internalData, createInternalData())
2106
- },
2107
- destroyed () {
2108
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2109
-
2110
- $xeTable.preventEvent(null, 'destroyed')
2111
- },
2112
- render (h: CreateElement) {
2113
- // 使用已安装的组件,如果未安装则不渲染
2114
- const VxeUILoadingComponent = VxeUI.getComponent('VxeLoading')
2115
- const VxeUITooltipComponent = VxeUI.getComponent('VxeTooltip')
2116
-
2117
- const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2118
- const $xeGrid = $xeTable.$xeGrid
2119
- const $xeGantt = $xeTable.$xeGantt
2120
- const props = $xeTable
2121
- const slots = $xeTable.$scopedSlots
2122
- const reactData = $xeTable as unknown as TableReactData
2123
-
2124
- const { xID } = $xeTable
2125
-
2126
- const { loading, stripe, showHeader, height, treeConfig, mouseConfig, showFooter, highlightCell, highlightHoverRow, highlightHoverColumn, editConfig, editRules } = props
2127
- const { isGroup, overflowX, overflowY, scrollXLoad, scrollYLoad, tableData, initStore, isRowGroupStatus, columnStore, filterStore, customStore, tooltipStore } = reactData
2128
- const { leftList, rightList } = columnStore
2129
- const loadingSlot = slots.loading
2130
- const tipSlots = {
2131
- header: slots.headerTooltip || slots['header-tooltip'],
2132
- body: slots.tooltip,
2133
- footer: slots.footerTooltip || slots['footer-tooltip']
2134
- }
2135
- const currTooltipSlot = tooltipStore.visible && tooltipStore.type ? tipSlots[tooltipStore.type] : null
2136
- const tableStyle = ($xeTable as any).computeTableStyle as VxeComponentStyleType
2137
- const rowDragOpts = $xeTable.computeRowDragOpts
2138
- const tableTipConfig = $xeTable.computeTableTipConfig
2139
- const validTipConfig = $xeTable.computeValidTipConfig
2140
- const validOpts = $xeTable.computeValidOpts
2141
- const checkboxOpts = $xeTable.computeCheckboxOpts
2142
- const treeOpts = $xeTable.computeTreeOpts
2143
- const rowOpts = $xeTable.computeRowOpts
2144
- const columnOpts = $xeTable.computeColumnOpts
2145
- const vSize = $xeTable.computeSize
2146
- const tableBorder = $xeTable.computeTableBorder
2147
- const mouseOpts = $xeTable.computeMouseOpts
2148
- const areaOpts = $xeTable.computeAreaOpts
2149
- const loadingOpts = $xeTable.computeLoadingOpts
2150
- const isContentMenu = $xeTable.computeIsContentMenu
2151
- const currLoading = reactData.isColLoading || reactData.isRowLoading || loading
2152
- const resizableOpts = $xeTable.computeResizableOpts
2153
- const isArea = mouseConfig && mouseOpts.area
2154
- const columnDragOpts = $xeTable.computeColumnDragOpts
2155
- const scrollbarXToTop = $xeTable.computeScrollbarXToTop
2156
- const scrollbarYToLeft = $xeTable.computeScrollbarYToLeft
2157
- const customSimpleMode = $xeTable.computeCustomSimpleMode
2158
- const showCustomSimpleOutside = customSimpleMode === 'outside'
2159
- const { isCrossTableDrag } = rowDragOpts
2160
- const tbOns: {
2161
- contextmenu: (...args: any[]) => void
2162
- keydown: (...args: any[]) => void
2163
- dragover?: (...args: any[]) => void
2164
- } = {
2165
- contextmenu: this.contextMenuEvent,
2166
- keydown: this.keydownEvent
2167
- }
2168
- if (isCrossTableDrag && !tableData.length) {
2169
- tbOns.dragover = $xeTable.handleCrossTableRowDragoverEmptyEvent
2170
- }
2171
- return h('div', {
2172
- ref: 'refElem',
2173
- class: ['vxe-table', 'vxe-table--render-default', `tid_${xID}`, `border--${tableBorder}`, `sx-pos--${scrollbarXToTop ? 'top' : 'bottom'}`, `sy-pos--${scrollbarYToLeft ? 'left' : 'right'}`, {
2174
- [`size--${vSize}`]: vSize,
2175
- [`valid-msg--${validOpts.msgMode}`]: !!editRules,
2176
- 'vxe-editable': !!editConfig,
2177
- 'old-cell-valid': editRules && getConfig().cellVaildMode === 'obsolete',
2178
- 'cell--highlight': highlightCell,
2179
- 'cell--selected': mouseConfig && mouseOpts.selected,
2180
- 'cell--area': isArea,
2181
- 'header-cell--area': isArea && areaOpts.selectCellByHeader,
2182
- 'body-cell--area': isArea && areaOpts.selectCellByBody,
2183
- 'row--highlight': rowOpts.isHover || highlightHoverRow,
2184
- 'column--highlight': columnOpts.isHover || highlightHoverColumn,
2185
- 'checkbox--range': checkboxOpts.range,
2186
- 'col--drag-cell': columnOpts.drag && columnDragOpts.trigger === 'cell',
2187
- 'is--header': showHeader,
2188
- 'not--header': !showHeader,
2189
- 'is--footer': showFooter,
2190
- 'not--footer': !showFooter,
2191
- 'is--group': isGroup,
2192
- 'is-row-group': isRowGroupStatus,
2193
- 'is--tree-line': treeConfig && (treeOpts.showLine || treeOpts.line),
2194
- 'is--fixed-left': leftList.length,
2195
- 'is--fixed-right': rightList.length,
2196
- 'is--animat': !!props.animat,
2197
- 'is--round': props.round,
2198
- 'is--stripe': !treeConfig && stripe,
2199
- 'is--loading': currLoading,
2200
- 'is--empty': !currLoading && !tableData.length,
2201
- 'is--scroll-y': overflowY,
2202
- 'not--scroll-y': !overflowY,
2203
- 'is--scroll-x': overflowX,
2204
- 'not--scroll-x': !overflowX,
2205
- 'is--virtual-x': scrollXLoad,
2206
- 'is--virtual-y': scrollYLoad
2207
- }],
2208
- style: tableStyle,
2209
- attrs: {
2210
- spellcheck: false
2211
- },
2212
- on: tbOns
2213
- }, [
2214
- /**
2215
- * 隐藏列
2216
- */
2217
- h('div', {
2218
- class: 'vxe-table-slots',
2219
- ref: 'hideColumn'
2220
- }, this.$slots.default),
2221
- h('div', {
2222
- ref: 'refVarElem',
2223
- class: 'vxe-table-vars'
2224
- }, [
2225
- h('div', {
2226
- class: 'vxe-table-var-default'
2227
- }),
2228
- h('div', {
2229
- class: 'vxe-table-var-medium'
2230
- }),
2231
- h('div', {
2232
- class: 'vxe-table-var-small'
2233
- }),
2234
- h('div', {
2235
- class: 'vxe-table-var-mini'
2236
- })
2237
- ]),
2238
- h('div', {
2239
- key: 'tw',
2240
- class: 'vxe-table--render-wrapper'
2241
- }, scrollbarXToTop
2242
- ? [
2243
- renderScrollX(h, $xeTable),
2244
- renderBody(h, $xeTable)
2245
- ]
2246
- : [
2247
- renderBody(h, $xeTable),
2248
- renderScrollX(h, $xeTable)
2249
- ]),
2250
- /**
2251
- * 空数据
2252
- */
2253
- h('div', {
2254
- key: 'tn',
2255
- ref: 'refEmptyPlaceholder',
2256
- class: 'vxe-table--empty-place-wrapper',
2257
- attrs: {
2258
- xid: xID
2259
- }
2260
- }, [
2261
- h('div', {
2262
- class: 'vxe-table--empty-placeholder'
2263
- }, [
2264
- h('div', {
2265
- class: 'vxe-table--empty-content'
2266
- }, renderEmptyBody(h, $xeTable))
2267
- ])
2268
- ]),
2269
- /**
2270
- * 边框线
2271
- */
2272
- h('div', {
2273
- key: 'tl',
2274
- class: 'vxe-table--border-line'
2275
- }),
2276
- /**
2277
- * 列宽线
2278
- */
2279
- h('div', {
2280
- key: 'tcl',
2281
- ref: 'refColResizeBar',
2282
- class: 'vxe-table--resizable-col-bar'
2283
- }, resizableOpts.showDragTip
2284
- ? [
2285
- h('div', {
2286
- ref: 'refColResizeTip',
2287
- class: 'vxe-table--resizable-number-tip'
2288
- })
2289
- ]
2290
- : []),
2291
- h('div', {
2292
- key: 'ttw'
2293
- }, [
2294
- h('div', {
2295
- ref: 'refTeleportWrapper'
2296
- }, [
2297
- /**
2298
- * 行高线
2299
- */
2300
- h('div', {
2301
- key: 'trl',
2302
- ref: 'refRowResizeBar',
2303
- class: 'vxe-table--resizable-row-bar'
2304
- }, resizableOpts.showDragTip
2305
- ? [
2306
- h('div', {
2307
- class: 'vxe-table--resizable-number-tip'
2308
- })
2309
- ]
2310
- : []),
2311
- /**
2312
- * 自定义列
2313
- */
2314
- !showCustomSimpleOutside && initStore.custom
2315
- ? h(TableCustomPanelComponent, {
2316
- key: 'cs',
2317
- ref: 'refTableCustom',
2318
- props: {
2319
- customStore
2320
- }
2321
- })
2322
- : renderEmptyElement($xeTable),
2323
- /**
2324
- * 加载中
2325
- */
2326
- VxeUILoadingComponent
2327
- ? h(VxeUILoadingComponent, {
2328
- key: 'lg',
2329
- class: 'vxe-table--loading',
2330
- props: {
2331
- value: currLoading,
2332
- icon: loadingOpts.icon,
2333
- text: loadingOpts.text
2334
- },
2335
- scopedSlots: loadingSlot
2336
- ? {
2337
- default: () => $xeTable.callSlot(loadingSlot, { $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, loading: currLoading }, h)
2338
- }
2339
- : {}
2340
- })
2341
- : loadingSlot
2342
- ? h('div', {
2343
- class: ['vxe-loading--custom-wrapper', {
2344
- 'is--visible': currLoading
2345
- }]
2346
- }, $xeTable.callSlot(loadingSlot, { $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, loading: currLoading }, h))
2347
- : renderEmptyElement($xeTable),
2348
- /**
2349
- * 拖拽提示
2350
- */
2351
- renderDragTip(h, this)
2352
- ])
2353
- ]),
2354
- h('div', {
2355
- key: 'tpw'
2356
- }, [
2357
- h('div', {
2358
- ref: 'refPopupWrapperElem'
2359
- }, [
2360
- /**
2361
- * 自定义列
2362
- */
2363
- showCustomSimpleOutside && initStore.custom
2364
- ? h(TableCustomPanelComponent, {
2365
- key: 'cs',
2366
- ref: 'refTableCustom',
2367
- props: {
2368
- customStore
2369
- }
2370
- })
2371
- : renderEmptyElement($xeTable),
2372
- /**
2373
- * 筛选
2374
- */
2375
- initStore.filter
2376
- ? h(TableFilterPanelComponent, {
2377
- key: 'tf',
2378
- ref: 'refTableFilter',
2379
- props: {
2380
- filterStore
2381
- }
2382
- })
2383
- : renderEmptyElement($xeTable),
2384
- /**
2385
- * 快捷菜单
2386
- */
2387
- isContentMenu
2388
- ? h(TableMenuPanelComponent, {
2389
- key: 'tm',
2390
- ref: 'refTableMenu'
2391
- })
2392
- : renderEmptyElement($xeTable)
2393
- ])
2394
- ]),
2395
- /**
2396
- * 导入
2397
- */
2398
- initStore.import && this.importConfig
2399
- ? h(TableImportPanelComponent, {
2400
- key: 'it',
2401
- props: {
2402
- defaultOptions: this.importParams,
2403
- storeData: this.importStore
2404
- }
2405
- })
2406
- : renderEmptyElement($xeTable),
2407
- /**
2408
- * 导出
2409
- */
2410
- initStore.export && (this.exportConfig || this.printConfig)
2411
- ? h(TableExportPanelComponent, {
2412
- key: 'et',
2413
- props: {
2414
- defaultOptions: this.exportParams,
2415
- storeData: this.exportStore
2416
- }
2417
- })
2418
- : renderEmptyElement($xeTable),
2419
- h('div', {}, [
2420
- /**
2421
- * 提示相关
2422
- */
2423
- VxeUITooltipComponent
2424
- ? h(VxeUITooltipComponent, {
2425
- key: 'ctp',
2426
- ref: 'refCommTooltip',
2427
- props: {
2428
- isArrow: false,
2429
- enterable: false
2430
- }
2431
- })
2432
- : renderEmptyElement($xeTable),
2433
- /**
2434
- * 工具提示
2435
- */
2436
- VxeUITooltipComponent
2437
- ? h(VxeUITooltipComponent, {
2438
- key: 'btp',
2439
- ref: 'refTooltip',
2440
- props: {
2441
- theme: tableTipConfig.theme,
2442
- enterable: tableTipConfig.enterable,
2443
- enterDelay: tableTipConfig.enterDelay,
2444
- leaveDelay: tableTipConfig.leaveDelay,
2445
- useHTML: tableTipConfig.useHTML,
2446
- width: tableTipConfig.width,
2447
- height: tableTipConfig.height,
2448
- minWidth: tableTipConfig.minWidth,
2449
- minHeight: tableTipConfig.minHeight,
2450
- maxWidth: tableTipConfig.maxWidth,
2451
- maxHeight: tableTipConfig.maxHeight
2452
- },
2453
- scopedSlots: currTooltipSlot
2454
- ? {
2455
- content: () => {
2456
- const { type, row, column, content: tooltipContent } = tooltipStore
2457
- if (currTooltipSlot) {
2458
- if (column && type === 'header') {
2459
- return h('div', {
2460
- key: type
2461
- }, currTooltipSlot({ column, tooltipContent, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }))
2462
- }
2463
- if (row && column && type === 'body') {
2464
- return h('div', {
2465
- key: type
2466
- }, currTooltipSlot({ row, column, tooltipContent, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }))
2467
- }
2468
- if (row && column && type === 'footer') {
2469
- return h('div', {
2470
- key: type
2471
- }, currTooltipSlot({ row, column, tooltipContent, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }))
2472
- }
2473
- }
2474
- return renderEmptyElement($xeTable)
2475
- }
2476
- }
2477
- : {}
2478
- })
2479
- : renderEmptyElement($xeTable),
2480
- /**
2481
- * 校验提示
2482
- */
2483
- VxeUITooltipComponent && this.editRules && validOpts.showErrorMessage && (validOpts.message === 'default' ? !height : validOpts.message === 'tooltip')
2484
- ? h(VxeUITooltipComponent, {
2485
- key: 'vtp',
2486
- ref: 'refValidTooltip',
2487
- class: [{
2488
- 'old-cell-valid': editRules && getConfig().cellVaildMode === 'obsolete'
2489
- }, 'vxe-table--valid-error'],
2490
- props: {
2491
- theme: validTipConfig.theme,
2492
- enterable: validTipConfig.enterable,
2493
- enterDelay: validTipConfig.enterDelay,
2494
- leaveDelay: validTipConfig.leaveDelay
2495
- }
2496
- })
2497
- : renderEmptyElement($xeTable)
2498
- ])
2499
- ])
2500
- },
2501
- methods
2502
- } as any
1
+ import { CreateElement } from 'vue'
2
+ import XEUtils from 'xe-utils'
3
+ import { getFuncText, isEnableConf } from '../../ui/src/utils'
4
+ import { initTpImg, toCssUnit } from '../../ui/src/dom'
5
+ import { createReactData, createInternalData, createHandleGetRowId, getCalcHeight, hasDeepKey } from './util'
6
+ import { VxeUI } from '../../ui'
7
+ import methods from './methods'
8
+ import TableBodyComponent from './body'
9
+ import TableHeaderComponent from './header'
10
+ import TableFooterComponent from './footer'
11
+ import { tableProps } from './props'
12
+ import { getSlotVNs } from '../../ui/src/vn'
13
+ import { warnLog, errLog } from '../../ui/src/log'
14
+ import { crossTableDragRowGlobal, getCrossTableDragRowInfo } from './store'
15
+ import TableCustomPanelComponent from '../module/custom/panel'
16
+ import TableFilterPanelComponent from '../module/filter/panel'
17
+ import TableImportPanelComponent from '../module/export/import-panel'
18
+ import TableExportPanelComponent from '../module/export/export-panel'
19
+ import TableMenuPanelComponent from '../module/menu/panel'
20
+
21
+ import filterMixin from '../module/filter/mixin'
22
+ import menuMixin from '../module/menu/mixin'
23
+ import editMixin from '../module/edit/mixin'
24
+ import exportMixin from '../module/export/mixin'
25
+ import keyboardMixin from '../module/keyboard/mixin'
26
+ import validatorMixin from '../module/validator/mixin'
27
+ import customMixin from '../module/custom/mixin'
28
+
29
+ import type { VxeTabsConstructor, VxeTabsPrivateMethods, VxeComponentStyleType } from 'vxe-pc-ui'
30
+ import type { VxeTableConstructor, VxeTablePrivateMethods, VxeTablePropTypes, TableInternalData, TableReactData, VxeTableDefines } from '../../../types'
31
+
32
+ const { getConfig, getIcon, getI18n, renderer, globalResize, globalEvents, globalMixins, renderEmptyElement } = VxeUI
33
+
34
+ function handleUpdateMergeBodyCells ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) {
35
+ const internalData = $xeTable as unknown as TableInternalData
36
+
37
+ internalData.mergeBodyList = []
38
+ internalData.mergeBodyMaps = {}
39
+ internalData.mergeBodyCellMaps = {}
40
+ internalData.mergeBodyRowMaps = {}
41
+ internalData.mergeBodyColMaps = {}
42
+ $xeTable.setMergeCells(merges)
43
+ }
44
+
45
+ function handleUpdateMergeHeaderCells ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) {
46
+ const internalData = $xeTable as unknown as TableInternalData
47
+
48
+ internalData.mergeHeaderList = []
49
+ internalData.mergeHeaderMaps = {}
50
+ internalData.mergeHeaderCellMaps = {}
51
+ internalData.mergeHeaderRowMaps = {}
52
+ internalData.mergeBodyColMaps = {}
53
+ $xeTable.setMergeHeaderCells(merges)
54
+ }
55
+
56
+ function handleUpdateMergeFooterCells ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[]) {
57
+ const internalData = $xeTable as unknown as TableInternalData
58
+
59
+ internalData.mergeFooterList = []
60
+ internalData.mergeFooterMaps = {}
61
+ internalData.mergeFooterCellMaps = {}
62
+ internalData.mergeFooterRowMaps = {}
63
+ internalData.mergeFooterColMaps = {}
64
+ $xeTable.setMergeFooterCells(merges)
65
+ }
66
+
67
+ function handleKeyField ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
68
+ const internalData = $xeTable as unknown as TableInternalData
69
+
70
+ const keyField = $xeTable.computeRowField
71
+ internalData.currKeyField = keyField
72
+ internalData.isCurrDeepKey = hasDeepKey(keyField)
73
+ }
74
+
75
+ function updateColumnAllOverflow ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
76
+ const props = $xeTable
77
+ const reactData = $xeTable as unknown as TableReactData
78
+ const internalData = $xeTable as unknown as TableInternalData
79
+
80
+ const { showOverflow } = props
81
+ const { isGroup } = reactData
82
+ const { fullAllDataRowIdData, tableFullColumn, collectColumn } = internalData
83
+ let isAllOverflow = !!showOverflow
84
+ const handleFunc = (column: VxeTableDefines.ColumnInfo) => {
85
+ if (isAllOverflow && column.showOverflow === false) {
86
+ isAllOverflow = false
87
+ }
88
+ }
89
+ if (isGroup) {
90
+ XEUtils.eachTree(collectColumn, handleFunc)
91
+ } else {
92
+ tableFullColumn.forEach(handleFunc)
93
+ }
94
+ XEUtils.each(fullAllDataRowIdData, (rowRest: VxeTableDefines.RowCacheItem) => {
95
+ rowRest.height = 0
96
+ })
97
+ reactData.isAllOverflow = isAllOverflow
98
+ }
99
+
100
+ /**
101
+ * 渲染浮固定列
102
+ * 分别渲染左边固定列和右边固定列
103
+ * 如果宽度足够情况下,则不需要渲染固定列
104
+ */
105
+ function renderViewFixed (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods, fixedType: any) {
106
+ const props = $xeTable
107
+ const reactData = $xeTable as unknown as TableReactData
108
+
109
+ const { showHeader, showFooter } = props
110
+ const { tableData, tableColumn, tableGroupColumn, columnStore, footerTableData } = reactData
111
+ const scrollbarOpts = $xeTable.computeScrollbarOpts
112
+ const scrollbarXOpts = $xeTable.computeScrollbarXOpts
113
+ const scrollbarYOpts = $xeTable.computeScrollbarYOpts
114
+ const { overscrollBehavior: overscrollXBehavior } = scrollbarXOpts
115
+ const { overscrollBehavior: overscrollYBehavior } = scrollbarYOpts
116
+ const isFixedLeft = fixedType === 'left'
117
+ const fixedColumn = isFixedLeft ? columnStore.leftList : columnStore.rightList
118
+ const osXBehavior = XEUtils.eqNull(overscrollXBehavior) ? scrollbarOpts.overscrollBehavior : overscrollXBehavior
119
+ const osYBehavior = XEUtils.eqNull(overscrollYBehavior) ? scrollbarOpts.overscrollBehavior : overscrollYBehavior
120
+ return h('div', {
121
+ ref: isFixedLeft ? 'refLeftContainer' : 'refRightContainer',
122
+ class: [`vxe-table--fixed-${fixedType}-wrapper`, `sx--${scrollbarXOpts.visible}`, `sy--${scrollbarYOpts.visible}`, {
123
+ [`x-ob--${osXBehavior}`]: osXBehavior,
124
+ [`y-ob--${osYBehavior}`]: osYBehavior
125
+ }]
126
+ }, [
127
+ showHeader
128
+ ? h(TableHeaderComponent, {
129
+ props: {
130
+ fixedType,
131
+ tableData,
132
+ tableColumn,
133
+ tableGroupColumn,
134
+ fixedColumn
135
+ },
136
+ ref: `${fixedType}Header`
137
+ })
138
+ : renderEmptyElement($xeTable),
139
+ h(TableBodyComponent, {
140
+ props: {
141
+ fixedType,
142
+ tableData,
143
+ tableColumn,
144
+ fixedColumn
145
+ },
146
+ ref: `${fixedType}Body`
147
+ }),
148
+ showFooter
149
+ ? h(TableFooterComponent, {
150
+ props: {
151
+ footerTableData,
152
+ tableColumn,
153
+ fixedColumn,
154
+ fixedType
155
+ },
156
+ ref: `${fixedType}Footer`
157
+ })
158
+ : renderEmptyElement($xeTable)
159
+ ])
160
+ }
161
+
162
+ function renderEmptyBody (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
163
+ const slots = $xeTable.$scopedSlots
164
+ const $xeGrid = $xeTable.$xeGrid
165
+ const $xeGantt = $xeTable.$xeGantt
166
+
167
+ const emptyOpts = $xeTable.computeEmptyOpts
168
+ const emptySlot = slots.empty
169
+ let emptyContent: any = ''
170
+ const emptyParams = { $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }
171
+ if (emptySlot) {
172
+ emptyContent = emptySlot.call($xeTable, emptyParams)
173
+ } else {
174
+ const compConf = emptyOpts.name ? renderer.get(emptyOpts.name) : null
175
+ const rtEmptyView = compConf ? (compConf.renderTableEmpty || compConf.renderTableEmptyView || compConf.renderEmpty) : null
176
+ if (rtEmptyView) {
177
+ emptyContent = getSlotVNs(rtEmptyView.call($xeTable, h, emptyOpts, emptyParams))
178
+ } else {
179
+ emptyContent = getFuncText($xeTable.emptyText) || getI18n('vxe.table.emptyText')
180
+ }
181
+ }
182
+ return emptyContent
183
+ }
184
+
185
+ const renderDragTipContents = (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) => {
186
+ const props = $xeTable
187
+ const reactData = $xeTable as unknown as TableReactData
188
+ const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable)
189
+
190
+ const { dragConfig } = props
191
+ const { dragRow, dragCol, dragTipText } = reactData
192
+ const columnDragOpts = $xeTable.computeColumnDragOpts
193
+ const rowDragOpts = $xeTable.computeRowDragOpts
194
+ const rowDragSlots = rowDragOpts.slots || {}
195
+ const rTipSlot = rowDragSlots.tip || (dragConfig && dragConfig.slots ? dragConfig.slots.rowTip : null)
196
+ const columnDragSlots = columnDragOpts.slots || {}
197
+ const cTipSlot = columnDragSlots.tip
198
+ const dRow = dragRow || (rowDragOpts.isCrossTableDrag ? crossTableDragRowInfo.row : null)
199
+
200
+ if (dRow && rTipSlot) {
201
+ return $xeTable.callSlot(rTipSlot, { row: dRow }, h)
202
+ }
203
+ if (dragCol && cTipSlot) {
204
+ return $xeTable.callSlot(cTipSlot, { column: dragCol }, h)
205
+ }
206
+ return [h('span', dragTipText)]
207
+ }
208
+
209
+ const renderDragTip = (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) => {
210
+ const reactData = $xeTable as unknown as TableReactData
211
+ const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable)
212
+
213
+ const { dragRow, dragCol } = reactData
214
+ const rowOpts = $xeTable.computeRowOpts
215
+ const columnOpts = $xeTable.computeColumnOpts
216
+ const rowDragOpts = $xeTable.computeRowDragOpts
217
+ const columnDragOpts = $xeTable.computeColumnDragOpts
218
+ const dRow = dragRow || (rowDragOpts.isCrossTableDrag ? crossTableDragRowInfo.row : null)
219
+
220
+ if (rowOpts.drag || columnOpts.drag) {
221
+ return h('div', {
222
+ class: 'vxe-table--drag-wrapper'
223
+ }, [
224
+ h('div', {
225
+ ref: 'refDragRowLineElem',
226
+ class: ['vxe-table--drag-row-line', {
227
+ 'is--guides': rowDragOpts.showGuidesStatus
228
+ }]
229
+ }),
230
+ h('div', {
231
+ ref: 'refDragColLineElem',
232
+ class: ['vxe-table--drag-col-line', {
233
+ 'is--guides': columnDragOpts.showGuidesStatus
234
+ }]
235
+ }),
236
+ (dRow && rowDragOpts.showDragTip) || (dragCol && columnDragOpts.showDragTip)
237
+ ? h('div', {
238
+ ref: 'refDragTipElem',
239
+ class: 'vxe-table--drag-sort-tip'
240
+ }, [
241
+ h('div', {
242
+ class: 'vxe-table--drag-sort-tip-wrapper'
243
+ }, [
244
+ h('div', {
245
+ class: 'vxe-table--drag-sort-tip-status'
246
+ }, [
247
+ h('span', {
248
+ class: ['vxe-table--drag-sort-tip-normal-status', dRow ? getIcon().TABLE_DRAG_STATUS_ROW : getIcon().TABLE_DRAG_STATUS_COLUMN]
249
+ }),
250
+ h('span', {
251
+ class: ['vxe-table--drag-sort-tip-sub-status', getIcon().TABLE_DRAG_STATUS_SUB_ROW]
252
+ }),
253
+ h('span', {
254
+ class: ['vxe-table--drag-sort-tip-disabled-status', getIcon().TABLE_DRAG_DISABLED]
255
+ })
256
+ ]),
257
+ h('div', {
258
+ class: 'vxe-table--drag-sort-tip-content'
259
+ }, renderDragTipContents(h, $xeTable))
260
+ ])
261
+ ])
262
+ : renderEmptyElement($xeTable)
263
+ ])
264
+ }
265
+ return renderEmptyElement($xeTable)
266
+ }
267
+
268
+ function handleUpdateResize ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
269
+ const el = $xeTable.$refs.refElem as HTMLDivElement
270
+ if (el && el.clientWidth && el.clientHeight) {
271
+ $xeTable.recalculate()
272
+ }
273
+ }
274
+
275
+ function renderRowExpandedVNs (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
276
+ const props = $xeTable
277
+ const reactData = $xeTable as unknown as TableReactData
278
+ const internalData = $xeTable as unknown as TableInternalData
279
+ const $xeGrid = $xeTable.$xeGrid
280
+ const $xeGantt = $xeTable.$xeGantt
281
+
282
+ const { treeConfig } = props
283
+ const { expandColumn, isRowGroupStatus } = reactData
284
+ const tableRowExpandedList: any[] = ($xeTable as any).computeTableRowExpandedList
285
+ const expandOpts = $xeTable.computeExpandOpts
286
+ const { mode } = expandOpts
287
+ if (mode !== 'fixed') {
288
+ return renderEmptyElement($xeTable)
289
+ }
290
+ const expandVNs = [
291
+ h('div', {
292
+ key: 'repY',
293
+ ref: 'refRowExpandYSpaceElem'
294
+ })
295
+ ]
296
+
297
+ if (expandColumn) {
298
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
299
+ tableRowExpandedList.forEach((row) => {
300
+ const expandOpts = $xeTable.computeExpandOpts
301
+ const { height: expandHeight, padding, indent } = expandOpts
302
+ const { fullAllDataRowIdData, fullColumnIdData } = internalData
303
+ const treeOpts = $xeTable.computeTreeOpts
304
+ const { transform, seqMode } = treeOpts
305
+ const cellStyle: Record<string, string> = {}
306
+ const rowid = handleGetRowId(row)
307
+ const rowRest = fullAllDataRowIdData[rowid]
308
+ const colid = expandColumn.id
309
+ const colRest = fullColumnIdData[colid] || {}
310
+ let rowLevel = 0
311
+ let seq: string | number = -1
312
+ let _rowIndex = -1
313
+ let rowIndex = -1
314
+ let $rowIndex = -1
315
+ if (rowRest) {
316
+ rowIndex = rowRest.index
317
+ $rowIndex = rowRest.$index
318
+ _rowIndex = rowRest._index
319
+ rowLevel = rowRest.level
320
+ seq = rowRest.seq
321
+ if (isRowGroupStatus || (treeConfig && transform && seqMode === 'increasing')) {
322
+ seq = rowRest._index + 1
323
+ } else if ((treeConfig && seqMode === 'fixed')) {
324
+ seq = rowRest._tIndex + 1
325
+ }
326
+ }
327
+ if (expandHeight) {
328
+ cellStyle.height = `${expandHeight}px`
329
+ }
330
+ if (isRowGroupStatus || treeConfig) {
331
+ cellStyle.paddingLeft = `${(rowLevel * (XEUtils.isNumber(indent) ? indent : treeOpts.indent)) + 30}px`
332
+ }
333
+ let columnIndex = -1
334
+ let $columnIndex = -1
335
+ let _columnIndex = -1
336
+ if (colRest) {
337
+ columnIndex = colRest.index
338
+ $columnIndex = colRest.$index
339
+ _columnIndex = colRest._index
340
+ }
341
+ const expandParams: VxeTableDefines.CellRenderDataParams = {
342
+ $table: $xeTable,
343
+ $grid: $xeGrid,
344
+ $gantt: $xeGantt,
345
+ seq,
346
+ column: expandColumn,
347
+ columnIndex,
348
+ $columnIndex,
349
+ _columnIndex,
350
+ fixed: '',
351
+ source: 'table',
352
+ type: 'body',
353
+ level: rowLevel,
354
+ rowid,
355
+ row,
356
+ rowIndex,
357
+ $rowIndex,
358
+ _rowIndex,
359
+ isHidden: false,
360
+ isEdit: false,
361
+ visibleData: [],
362
+ data: [],
363
+ items: []
364
+ }
365
+ expandVNs.push(
366
+ h('div', {
367
+ key: rowid,
368
+ class: ['vxe-body--row-expanded-cell', {
369
+ 'is--padding': padding,
370
+ 'is--ellipsis': expandHeight
371
+ }],
372
+ attrs: {
373
+ rowid
374
+ },
375
+ style: cellStyle
376
+ }, [
377
+ h('div', {
378
+ class: 'vxe-body--row-expanded-content'
379
+ }, expandColumn.renderData(h, expandParams))
380
+ ])
381
+ )
382
+ })
383
+ }
384
+
385
+ return h('div', {
386
+ ref: 'refRowExpandElem',
387
+ class: 'vxe-table--row-expanded-wrapper'
388
+ }, expandVNs)
389
+ }
390
+
391
+ function renderScrollX (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
392
+ return h('div', {
393
+ key: 'vsx',
394
+ ref: 'refScrollXVirtualElem',
395
+ class: 'vxe-table--scroll-x-virtual'
396
+ }, [
397
+ h('div', {
398
+ ref: 'refScrollXLeftCornerElem',
399
+ class: 'vxe-table--scroll-x-left-corner'
400
+ }),
401
+ h('div', {
402
+ ref: 'refScrollXWrapperElem',
403
+ class: 'vxe-table--scroll-x-wrapper'
404
+ }, [
405
+ h('div', {
406
+ ref: 'refScrollXHandleElem',
407
+ class: 'vxe-table--scroll-x-handle',
408
+ on: {
409
+ scroll: $xeTable.triggerVirtualScrollXEvent
410
+ }
411
+ }, [
412
+ h('div', {
413
+ ref: 'refScrollXSpaceElem',
414
+ class: 'vxe-table--scroll-x-space'
415
+ })
416
+ ]),
417
+ h('div', {
418
+ class: 'vxe-table--scroll-x-handle-appearance'
419
+ })
420
+ ]),
421
+ h('div', {
422
+ ref: 'refScrollXRightCornerElem',
423
+ class: 'vxe-table--scroll-x-right-corner'
424
+ })
425
+ ])
426
+ }
427
+
428
+ function renderScrollY (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
429
+ return h('div', {
430
+ ref: 'refScrollYVirtualElem',
431
+ class: 'vxe-table--scroll-y-virtual'
432
+ }, [
433
+ h('div', {
434
+ ref: 'refScrollYTopCornerElem',
435
+ class: 'vxe-table--scroll-y-top-corner'
436
+ }),
437
+ h('div', {
438
+ ref: 'refScrollYWrapperElem',
439
+ class: 'vxe-table--scroll-y-wrapper'
440
+ }, [
441
+ h('div', {
442
+ ref: 'refScrollYHandleElem',
443
+ class: 'vxe-table--scroll-y-handle',
444
+ on: {
445
+ scroll: $xeTable.triggerVirtualScrollYEvent
446
+ }
447
+ }, [
448
+ h('div', {
449
+ ref: 'refScrollYSpaceElem',
450
+ class: 'vxe-table--scroll-y-space'
451
+ })
452
+ ])
453
+ ]),
454
+ h('div', {
455
+ ref: 'refScrollYBottomCornerElem',
456
+ class: 'vxe-table--scroll-y-bottom-corner'
457
+ })
458
+ ])
459
+ }
460
+
461
+ function renderViewport (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
462
+ const props = $xeTable
463
+ const reactData = $xeTable as unknown as TableReactData
464
+
465
+ const { showHeader, showFooter } = props
466
+ const { overflowX, tableData, tableColumn, tableGroupColumn, footerTableData, columnStore } = reactData
467
+ const scrollbarOpts = $xeTable.computeScrollbarOpts
468
+ const scrollbarXOpts = $xeTable.computeScrollbarXOpts
469
+ const scrollbarYOpts = $xeTable.computeScrollbarYOpts
470
+ const { overscrollBehavior: overscrollXBehavior } = scrollbarXOpts
471
+ const { overscrollBehavior: overscrollYBehavior } = scrollbarYOpts
472
+ const { leftList, rightList } = columnStore
473
+ const osXBehavior = XEUtils.eqNull(overscrollXBehavior) ? scrollbarOpts.overscrollBehavior : overscrollXBehavior
474
+ const osYBehavior = XEUtils.eqNull(overscrollYBehavior) ? scrollbarOpts.overscrollBehavior : overscrollYBehavior
475
+
476
+ return h('div', {
477
+ ref: 'refTableViewportElem',
478
+ class: ['vxe-table--viewport-wrapper', {
479
+ [`x-ob--${osXBehavior}`]: osXBehavior,
480
+ [`y-ob--${osYBehavior}`]: osYBehavior
481
+ }]
482
+ }, [
483
+ h('div', {
484
+ class: ['vxe-table--main-wrapper', `sx--${scrollbarXOpts.visible}`, `sy--${scrollbarYOpts.visible}`]
485
+ }, [
486
+ /**
487
+ * 表头
488
+ */
489
+ showHeader
490
+ ? h(TableHeaderComponent, {
491
+ ref: 'refTableHeader',
492
+ props: {
493
+ tableData,
494
+ tableColumn,
495
+ tableGroupColumn
496
+ }
497
+ })
498
+ : renderEmptyElement($xeTable),
499
+ /**
500
+ * 表体
501
+ */
502
+ h(TableBodyComponent, {
503
+ ref: 'refTableBody',
504
+ props: {
505
+ tableData,
506
+ tableColumn
507
+ }
508
+ }),
509
+ /**
510
+ * 表尾
511
+ */
512
+ showFooter
513
+ ? h(TableFooterComponent, {
514
+ ref: 'refTableFooter',
515
+ props: {
516
+ footerTableData,
517
+ tableColumn
518
+ }
519
+ })
520
+ : renderEmptyElement($xeTable)
521
+ ]),
522
+ h('div', {
523
+ class: 'vxe-table--fixed-wrapper'
524
+ }, [
525
+ leftList && leftList.length && overflowX ? renderViewFixed(h, $xeTable, 'left') : renderEmptyElement($xeTable),
526
+ rightList && rightList.length && overflowX ? renderViewFixed(h, $xeTable, 'right') : renderEmptyElement($xeTable)
527
+ ]),
528
+ renderRowExpandedVNs(h, $xeTable)
529
+ ])
530
+ }
531
+
532
+ function renderBody (h: CreateElement, $xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
533
+ const scrollbarYToLeft = $xeTable.computeScrollbarYToLeft
534
+ return h('div', {
535
+ class: 'vxe-table--layout-wrapper'
536
+ }, scrollbarYToLeft
537
+ ? [
538
+ renderScrollY(h, $xeTable),
539
+ renderViewport(h, $xeTable)
540
+ ]
541
+ : [
542
+ renderViewport(h, $xeTable),
543
+ renderScrollY(h, $xeTable)
544
+ ])
545
+ }
546
+
547
+ export default {
548
+ name: 'VxeTable',
549
+ mixins: [
550
+ globalMixins.sizeMixin,
551
+ filterMixin,
552
+ menuMixin,
553
+ editMixin,
554
+ exportMixin,
555
+ keyboardMixin,
556
+ validatorMixin,
557
+ customMixin
558
+ ],
559
+ props: tableProps,
560
+ provide () {
561
+ const $xeTable = this
562
+ return {
563
+ $xeTable,
564
+ xecolgroup: null
565
+ }
566
+ },
567
+ inject: {
568
+ $xeTabs: {
569
+ default: null
570
+ },
571
+ $xeParentTable: {
572
+ from: '$xeTable',
573
+ default: null
574
+ },
575
+ $xeGrid: {
576
+ default: null
577
+ },
578
+ $xeGantt: {
579
+ default: null
580
+ }
581
+ },
582
+ data () {
583
+ const xID = XEUtils.uniqueId()
584
+
585
+ const reactData = createReactData()
586
+
587
+ return {
588
+ xID,
589
+ ...reactData,
590
+
591
+ // 私有属性
592
+ reScrollFlag: 0,
593
+ reLayoutFlag: 0,
594
+ footFlag: 0,
595
+ kfFlag: 0,
596
+ mergeFooteCellFlag: 0,
597
+ crossTableDragRowInfo: crossTableDragRowGlobal
598
+ }
599
+ },
600
+ computed: {
601
+ ...({} as {
602
+ $xeTabs(): (VxeTabsConstructor & VxeTabsPrivateMethods) | null
603
+ }),
604
+ tableId () {
605
+ return this.computeTableId
606
+ },
607
+ computeTableId () {
608
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
609
+ const props = $xeTable
610
+ const $xeGrid = $xeTable.$xeGrid
611
+ const $xeGantt = $xeTable.$xeGantt
612
+
613
+ const { id } = props
614
+ if (id) {
615
+ if (XEUtils.isFunction(id)) {
616
+ return `${id({ $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }) || ''}`
617
+ }
618
+ return `${id}`
619
+ }
620
+ return ''
621
+ },
622
+ computeRowField () {
623
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
624
+ const props = $xeTable
625
+
626
+ const rowOpts = $xeTable.computeRowOpts
627
+ return `${props.rowId || rowOpts.keyField || '_X_ROW_KEY'}`
628
+ },
629
+ validOpts () {
630
+ return this.computeValidOpts
631
+ },
632
+ computeValidOpts () {
633
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
634
+ const props = $xeTable
635
+
636
+ const opts = Object.assign({}, getConfig().table.validConfig, props.validConfig)
637
+ // 兼容老版本
638
+ if (XEUtils.isBoolean(opts.showMessage)) {
639
+ opts.showErrorMessage = opts.showMessage
640
+ }
641
+ return opts
642
+ },
643
+ sXOpts () {
644
+ return this.computeVirtualXOpts
645
+ },
646
+ computeSXOpts () {
647
+ return this.computeVirtualXOpts
648
+ },
649
+ computeScrollXThreshold () {
650
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
651
+
652
+ const virtualXOpts = $xeTable.computeVirtualXOpts
653
+ const { threshold } = virtualXOpts
654
+ if (threshold) {
655
+ return XEUtils.toNumber(threshold)
656
+ }
657
+ return 0
658
+ },
659
+ sYOpts () {
660
+ return this.computeVirtualYOpts
661
+ },
662
+ computeSYOpts () {
663
+ return this.computeVirtualYOpts
664
+ },
665
+ computeVirtualXOpts () {
666
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
667
+ const props = $xeTable
668
+
669
+ const { virtualXConfig, scrollX } = props
670
+ const globalVirtualXConfig = getConfig().table.virtualXConfig
671
+ const globalScrollX = getConfig().table.scrollX
672
+ if (virtualXConfig) {
673
+ return Object.assign({}, globalVirtualXConfig, virtualXConfig) as VxeTablePropTypes.VirtualXConfig & { gt: number }
674
+ }
675
+ if (scrollX) {
676
+ // 已废弃,保留兼容
677
+ return Object.assign({}, globalScrollX, scrollX) as VxeTablePropTypes.VirtualXConfig & { gt: number }
678
+ }
679
+ if (globalVirtualXConfig) {
680
+ return Object.assign({}, globalVirtualXConfig, virtualXConfig) as VxeTablePropTypes.VirtualXConfig & { gt: number }
681
+ }
682
+ // 已废弃,保留兼容
683
+ return Object.assign({}, globalScrollX, scrollX) as VxeTablePropTypes.VirtualXConfig & { gt: number }
684
+ },
685
+ computeVirtualYOpts () {
686
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
687
+ const props = $xeTable
688
+
689
+ const { virtualYConfig, scrollY } = props
690
+ const globalVirtualYConfig = getConfig().table.virtualYConfig
691
+ const globalScrollY = getConfig().table.scrollY
692
+ if (virtualYConfig) {
693
+ return Object.assign({}, globalVirtualYConfig, virtualYConfig) as VxeTablePropTypes.VirtualYConfig & { gt: number }
694
+ }
695
+ if (scrollY) {
696
+ // 已废弃,保留兼容
697
+ return Object.assign({}, globalScrollY, scrollY) as VxeTablePropTypes.VirtualYConfig & { gt: number }
698
+ }
699
+ if (globalVirtualYConfig) {
700
+ return Object.assign({}, globalVirtualYConfig, virtualYConfig) as VxeTablePropTypes.VirtualYConfig & { gt: number }
701
+ }
702
+ // 已废弃,保留兼容
703
+ return Object.assign({}, globalScrollY, scrollY) as VxeTablePropTypes.VirtualYConfig & { gt: number }
704
+ },
705
+ computeScrollbarOpts () {
706
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
707
+ const props = $xeTable
708
+
709
+ return Object.assign({}, getConfig().table.scrollbarConfig, props.scrollbarConfig)
710
+ },
711
+ computeScrollbarXOpts () {
712
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
713
+ const props = $xeTable
714
+
715
+ const scrollbarOpts = $xeTable.computeScrollbarOpts
716
+ return Object.assign({}, scrollbarOpts.x, props.scrollbarConfig?.x || {})
717
+ },
718
+ computeScrollbarYOpts () {
719
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
720
+ const props = $xeTable
721
+
722
+ const scrollbarOpts = $xeTable.computeScrollbarOpts
723
+ return Object.assign({}, scrollbarOpts.y, props.scrollbarConfig?.y || {})
724
+ },
725
+ computeScrollbarXToTop () {
726
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
727
+
728
+ const scrollbarXOpts = $xeTable.computeScrollbarXOpts
729
+ return scrollbarXOpts.position === 'top'
730
+ },
731
+ computeScrollbarYToLeft () {
732
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
733
+
734
+ const scrollbarYOpts = $xeTable.computeScrollbarYOpts
735
+ return scrollbarYOpts.position === 'left'
736
+ },
737
+ computeScrollYThreshold () {
738
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
739
+
740
+ const virtualYOpts = $xeTable.computeVirtualYOpts
741
+ const { threshold } = virtualYOpts
742
+ if (threshold) {
743
+ return XEUtils.toNumber(threshold)
744
+ }
745
+ return 0
746
+ },
747
+ rowHeightMaps () {
748
+ return this.computeRowHeightMaps
749
+ },
750
+ computeRowHeightMaps () {
751
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
752
+ const reactData = $xeTable as unknown as TableReactData
753
+
754
+ return reactData.rowHeightStore
755
+ },
756
+ computeDefaultRowHeight () {
757
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
758
+
759
+ const vSize = $xeTable.computeSize
760
+ const rowHeightMaps = $xeTable.computeRowHeightMaps
761
+ return rowHeightMaps[vSize || 'default'] || 18
762
+ },
763
+ columnOpts () {
764
+ return this.computeColumnOpts
765
+ },
766
+ computeColumnOpts () {
767
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
768
+ const props = $xeTable
769
+
770
+ return Object.assign({}, getConfig().table.columnConfig, props.columnConfig)
771
+ },
772
+ computeCurrentColumnOpts () {
773
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
774
+ const props = $xeTable
775
+
776
+ return Object.assign({}, getConfig().table.currentColumnConfig, props.currentColumnConfig)
777
+ },
778
+ computeCellOpts () {
779
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
780
+ const props = $xeTable
781
+
782
+ const cellOpts = Object.assign({}, getConfig().table.cellConfig, props.cellConfig)
783
+ if (cellOpts.height) {
784
+ cellOpts.height = XEUtils.toNumber(cellOpts.height)
785
+ }
786
+ return cellOpts
787
+ },
788
+ computeHeaderCellOpts () {
789
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
790
+ const $xeGantt = $xeTable.$xeGantt
791
+ const props = $xeTable
792
+
793
+ const headerCellOpts = Object.assign({}, getConfig().table.headerCellConfig, props.headerCellConfig)
794
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight
795
+ const cellOpts = $xeTable.computeCellOpts
796
+ let headCellHeight = XEUtils.toNumber(getCalcHeight(headerCellOpts.height || cellOpts.height))
797
+ if ($xeGantt) {
798
+ const taskViewScales = $xeGantt.computeTaskViewScales
799
+ if (taskViewScales && taskViewScales.length > 2) {
800
+ const ganttMinHeadCellHeight = defaultRowHeight / 2 * taskViewScales.length
801
+ headCellHeight = Math.max(ganttMinHeadCellHeight, headCellHeight)
802
+ }
803
+ }
804
+ headerCellOpts.height = headCellHeight
805
+ return headerCellOpts
806
+ },
807
+ computeFooterCellOpts () {
808
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
809
+ const props = $xeTable
810
+
811
+ const footerCellOpts = Object.assign({}, getConfig().table.footerCellConfig, props.footerCellConfig)
812
+ const cellOpts = $xeTable.computeCellOpts
813
+ footerCellOpts.height = XEUtils.toNumber(getCalcHeight(footerCellOpts.height || cellOpts.height))
814
+ return footerCellOpts
815
+ },
816
+ rowOpts () {
817
+ return this.computeRowOpts
818
+ },
819
+ computeRowOpts () {
820
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
821
+ const props = $xeTable
822
+
823
+ return Object.assign({}, getConfig().table.rowConfig, props.rowConfig)
824
+ },
825
+ computeAggregateOpts () {
826
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
827
+ const props = $xeTable
828
+
829
+ return Object.assign({}, getConfig().table.aggregateConfig || getConfig().table.rowGroupConfig, props.aggregateConfig || props.rowGroupConfig)
830
+ },
831
+ computeAggregateAccuracyOpts () {
832
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
833
+ const props = $xeTable
834
+
835
+ return Object.assign({}, getConfig().table.aggregateAccuracyConfig, props.aggregateAccuracyConfig)
836
+ },
837
+ computeRowGroupOpts () {
838
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
839
+
840
+ return $xeTable.computeAggregateOpts
841
+ },
842
+ computeCurrentRowOpts () {
843
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
844
+ const props = $xeTable
845
+
846
+ return Object.assign({}, getConfig().table.currentRowConfig, props.currentRowConfig)
847
+ },
848
+ computeRowDragOpts () {
849
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
850
+ const props = $xeTable
851
+
852
+ return Object.assign({}, getConfig().table.rowDragConfig, props.rowDragConfig)
853
+ },
854
+ computeColumnDragOpts () {
855
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
856
+ const props = $xeTable
857
+
858
+ return Object.assign({}, getConfig().table.columnDragConfig, props.columnDragConfig)
859
+ },
860
+ resizeOpts () {
861
+ return this.computeResizeOpts
862
+ },
863
+ computeResizeOpts () {
864
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
865
+ const props = $xeTable
866
+
867
+ return Object.assign({}, getConfig().table.resizeConfig, props.resizeConfig)
868
+ },
869
+ resizableOpts () {
870
+ return this.computeResizableOpts
871
+ },
872
+ computeResizableOpts () {
873
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
874
+ const props = $xeTable
875
+
876
+ return Object.assign({}, getConfig().table.resizableConfig, props.resizableConfig)
877
+ },
878
+ seqOpts () {
879
+ return this.computeSeqOpts
880
+ },
881
+ computeSeqOpts () {
882
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
883
+ const props = $xeTable
884
+
885
+ return Object.assign({ startIndex: 0 }, getConfig().table.seqConfig, props.seqConfig)
886
+ },
887
+ radioOpts () {
888
+ return this.computeRadioOpts
889
+ },
890
+ computeRadioOpts () {
891
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
892
+ const props = $xeTable
893
+
894
+ return Object.assign({}, getConfig().table.radioConfig, props.radioConfig)
895
+ },
896
+ checkboxOpts () {
897
+ return this.computeCheckboxOpts
898
+ },
899
+ computeCheckboxOpts () {
900
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
901
+ const props = $xeTable
902
+
903
+ return Object.assign({}, getConfig().table.checkboxConfig, props.checkboxConfig)
904
+ },
905
+ tooltipOpts () {
906
+ return this.computeTooltipOpts
907
+ },
908
+ computeTooltipOpts () {
909
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
910
+ const props = $xeTable
911
+
912
+ return Object.assign({}, getConfig().tooltip, getConfig().table.tooltipConfig, props.tooltipConfig)
913
+ },
914
+ tipConfig () {
915
+ return { ...this.tooltipOpts }
916
+ },
917
+ computeHeaderTooltipOpts () {
918
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
919
+ const props = $xeTable
920
+
921
+ return Object.assign({}, getConfig().tooltip, getConfig().table.headerTooltipConfig, props.headerTooltipConfig)
922
+ },
923
+ computeFooterTooltipOpts () {
924
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
925
+ const props = $xeTable
926
+
927
+ return Object.assign({}, getConfig().tooltip, getConfig().table.footerTooltipConfig, props.footerTooltipConfig)
928
+ },
929
+ computeTableTipConfig () {
930
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
931
+ const reactData = $xeTable as unknown as TableReactData
932
+
933
+ const { tooltipStore } = reactData
934
+ const tooltipOpts = $xeTable.computeTooltipOpts
935
+ return Object.assign({}, tooltipOpts, tooltipStore.currOpts)
936
+ },
937
+ computeValidTipConfig () {
938
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
939
+
940
+ const tooltipOpts = $xeTable.computeTooltipOpts
941
+ return Object.assign({}, tooltipOpts)
942
+ },
943
+ validTipOpts () {
944
+ return Object.assign({ isArrow: false }, this.tooltipOpts)
945
+ },
946
+ editOpts () {
947
+ return this.computeEditOpts
948
+ },
949
+ computeEditOpts () {
950
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
951
+ const props = $xeTable
952
+
953
+ return Object.assign({}, getConfig().table.editConfig, props.editConfig)
954
+ },
955
+ computeEditDirtyOpts () {
956
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
957
+ const props = $xeTable
958
+
959
+ return Object.assign({}, getConfig().table.editDirtyConfig, props.editDirtyConfig)
960
+ },
961
+ sortOpts () {
962
+ return this.computeSortOpts
963
+ },
964
+ computeSortOpts () {
965
+ return Object.assign({ orders: ['asc', 'desc', null] }, getConfig().table.sortConfig, this.sortConfig)
966
+ },
967
+ filterOpts () {
968
+ return this.computeFilterOpts
969
+ },
970
+ computeFilterOpts () {
971
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
972
+ const props = $xeTable
973
+
974
+ return Object.assign({}, getConfig().table.filterConfig, props.filterConfig)
975
+ },
976
+ computeFloatingFilterOpts () {
977
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
978
+ const props = $xeTable
979
+
980
+ return Object.assign({}, getConfig().table.floatingFilterConfig, props.floatingFilterConfig)
981
+ },
982
+ mouseOpts () {
983
+ return this.computeMouseOpts
984
+ },
985
+ computeMouseOpts () {
986
+ return Object.assign({}, getConfig().table.mouseConfig, this.mouseConfig)
987
+ },
988
+ areaOpts () {
989
+ return this.computeAreaOpts
990
+ },
991
+ computeAreaOpts () {
992
+ return Object.assign({}, getConfig().table.areaConfig, this.areaConfig)
993
+ },
994
+ keyboardOpts () {
995
+ return this.computeKeyboardOpts
996
+ },
997
+ computeKeyboardOpts () {
998
+ return Object.assign({}, getConfig().table.keyboardConfig, this.keyboardConfig)
999
+ },
1000
+ clipOpts () {
1001
+ return this.computeClipOpts
1002
+ },
1003
+ computeClipOpts () {
1004
+ return Object.assign({}, getConfig().table.clipConfig, this.clipConfig)
1005
+ },
1006
+ fnrOpts () {
1007
+ return this.computeFnrOpts
1008
+ },
1009
+ computeFNROpts () {
1010
+ return this.computeFnrOpts
1011
+ },
1012
+ computeFnrOpts () {
1013
+ return Object.assign({}, getConfig().table.fnrConfig, this.fnrConfig)
1014
+ },
1015
+ headerCtxMenu () {
1016
+ return this.computeHeaderMenu
1017
+ },
1018
+ computeHeaderMenu () {
1019
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1020
+
1021
+ const menuOpts = $xeTable.computeMenuOpts
1022
+ const headerOpts = menuOpts.header
1023
+ return headerOpts && headerOpts.options ? headerOpts.options : []
1024
+ },
1025
+ bodyCtxMenu () {
1026
+ return this.computeBodyMenu
1027
+ },
1028
+ computeBodyMenu () {
1029
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1030
+
1031
+ const menuOpts = $xeTable.computeMenuOpts
1032
+ const bodyOpts = menuOpts.body
1033
+ return bodyOpts && bodyOpts.options ? bodyOpts.options : []
1034
+ },
1035
+ footerCtxMenu () {
1036
+ return this.computeFooterMenu
1037
+ },
1038
+ computeFooterMenu () {
1039
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1040
+
1041
+ const menuOpts = $xeTable.computeMenuOpts
1042
+ const footerOpts = menuOpts.footer
1043
+ return footerOpts && footerOpts.options ? footerOpts.options : []
1044
+ },
1045
+ isCtxMenu () {
1046
+ return this.computeIsContentMenu
1047
+ },
1048
+ computeIsMenu () {
1049
+ return this.computeIsContentMenu
1050
+ },
1051
+ computeIsContentMenu () {
1052
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1053
+ const props = $xeTable
1054
+
1055
+ const menuOpts = $xeTable.computeMenuOpts
1056
+ const headerMenu = $xeTable.computeHeaderMenu
1057
+ const bodyMenu = $xeTable.computeBodyMenu
1058
+ const footerMenu = $xeTable.computeFooterMenu
1059
+ return !!(((props as any).contextMenu || props.menuConfig) && isEnableConf(menuOpts) && (headerMenu.length || bodyMenu.length || footerMenu.length))
1060
+ },
1061
+ ctxMenuList () {
1062
+ return this.computeMenuList
1063
+ },
1064
+ computeMenuList () {
1065
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1066
+ const reactData = $xeTable as unknown as TableReactData
1067
+
1068
+ const { ctxMenuStore } = reactData
1069
+ const rest: any[] = []
1070
+ ctxMenuStore.list.forEach((list) => {
1071
+ list.forEach((item) => {
1072
+ rest.push(item)
1073
+ })
1074
+ })
1075
+ return rest
1076
+ },
1077
+ ctxMenuOpts () {
1078
+ return this.computeMenuOpts
1079
+ },
1080
+ computeMenuOpts () {
1081
+ return Object.assign({}, getConfig().table.menuConfig, this.contextMenu, this.menuConfig)
1082
+ },
1083
+ computeLeftFixedWidth () {
1084
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1085
+ const reactData = $xeTable as unknown as TableReactData
1086
+
1087
+ const { columnStore } = reactData
1088
+ const { leftList } = columnStore
1089
+ let leftWidth = 0
1090
+ for (let i = 0; i < leftList.length; i++) {
1091
+ const column = leftList[i]
1092
+ leftWidth += column.renderWidth
1093
+ }
1094
+ return leftWidth
1095
+ },
1096
+ computeRightFixedWidth () {
1097
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1098
+ const reactData = $xeTable as unknown as TableReactData
1099
+
1100
+ const { columnStore } = reactData
1101
+ const { rightList } = columnStore
1102
+ let leftWidth = 0
1103
+ for (let i = 0; i < rightList.length; i++) {
1104
+ const column = rightList[i]
1105
+ leftWidth += column.renderWidth
1106
+ }
1107
+ return leftWidth
1108
+ },
1109
+ computeBodyMergeCoverFixed () {
1110
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1111
+ const reactData = $xeTable as unknown as TableReactData
1112
+ const internalData = $xeTable as unknown as TableInternalData
1113
+
1114
+ const { columnStore, mergeBodyFlag } = reactData
1115
+ const { mergeBodyList, visibleColumn } = internalData
1116
+ const { leftList, rightList } = columnStore
1117
+ const rscIndex = visibleColumn.length - rightList.length
1118
+ if (mergeBodyFlag && (leftList.length || rightList.length)) {
1119
+ const lecIndex = leftList.length
1120
+ for (let i = 0; i < mergeBodyList.length; i++) {
1121
+ const { col, colspan } = mergeBodyList[i]
1122
+ if (col < lecIndex && col + colspan > lecIndex) {
1123
+ return true
1124
+ } else if (col < rscIndex && col + colspan > rscIndex) {
1125
+ return true
1126
+ }
1127
+ }
1128
+ }
1129
+ return false
1130
+ },
1131
+ computeIsHeaderRenderOptimize () {
1132
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1133
+ const props = $xeTable
1134
+ const reactData = $xeTable as unknown as TableReactData
1135
+
1136
+ const { spanMethod, footerSpanMethod, showHeaderOverflow: allColumnHeaderOverflow } = props
1137
+ const { isGroup, scrollXLoad } = reactData
1138
+ let isOptimizeMode = false
1139
+ if (isGroup) {
1140
+ // 分组表头
1141
+ } else {
1142
+ // 如果是使用优化模式
1143
+ if (scrollXLoad && allColumnHeaderOverflow) {
1144
+ if (spanMethod || footerSpanMethod) {
1145
+ // 如果不支持优化模式
1146
+ } else {
1147
+ isOptimizeMode = true
1148
+ }
1149
+ }
1150
+ }
1151
+ return isOptimizeMode
1152
+ },
1153
+ computeIsBodyRenderOptimize () {
1154
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1155
+ const props = $xeTable
1156
+ const reactData = $xeTable as unknown as TableReactData
1157
+
1158
+ const { spanMethod, footerSpanMethod } = props
1159
+ const { scrollXLoad, scrollYLoad, isAllOverflow, expandColumn } = reactData
1160
+ const bodyMergeCoverFixed = $xeTable.computeBodyMergeCoverFixed
1161
+ const expandOpts = $xeTable.computeExpandOpts
1162
+ let isOptimizeMode = false
1163
+ // 如果是使用优化模式
1164
+ if (scrollXLoad || scrollYLoad || isAllOverflow) {
1165
+ // 如果是展开行,内联模式,不支持优化
1166
+ // 如果是方法合并,不支持优化
1167
+ // 如果固定列且配置式合并,不支持优化
1168
+ if ((expandColumn && expandOpts.mode !== 'fixed') || bodyMergeCoverFixed || spanMethod || footerSpanMethod) {
1169
+ // 如果不支持优化模式
1170
+ } else {
1171
+ isOptimizeMode = true
1172
+ }
1173
+ }
1174
+ return isOptimizeMode
1175
+ },
1176
+ computeIsFooterRenderOptimize () {
1177
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1178
+ const props = $xeTable
1179
+ const reactData = $xeTable as unknown as TableReactData
1180
+
1181
+ const { spanMethod, footerSpanMethod, showFooterOverflow: allColumnFooterOverflow } = props
1182
+ const { scrollXLoad } = reactData
1183
+ let isOptimizeMode = false
1184
+ // 如果是使用优化模式
1185
+ if (scrollXLoad && allColumnFooterOverflow) {
1186
+ if (spanMethod || footerSpanMethod) {
1187
+ // 如果不支持优化模式
1188
+ } else {
1189
+ isOptimizeMode = true
1190
+ }
1191
+ }
1192
+ return isOptimizeMode
1193
+ },
1194
+ exportOpts () {
1195
+ return this.computeExportOpts
1196
+ },
1197
+ computeExportOpts () {
1198
+ return Object.assign({}, getConfig().table.exportConfig, this.exportConfig)
1199
+ },
1200
+ importOpts () {
1201
+ return this.computeImportOpts
1202
+ },
1203
+ computeImportOpts () {
1204
+ return Object.assign({}, getConfig().table.importConfig, this.importConfig)
1205
+ },
1206
+ printOpts () {
1207
+ return this.computePrintOpts
1208
+ },
1209
+ computePrintOpts () {
1210
+ return Object.assign({}, getConfig().table.printConfig, this.printConfig)
1211
+ },
1212
+ expandOpts () {
1213
+ return this.computeExpandOpts
1214
+ },
1215
+ computeExpandOpts () {
1216
+ return Object.assign({}, getConfig().table.expandConfig, this.expandConfig)
1217
+ },
1218
+ treeOpts () {
1219
+ return this.computeTreeOpts
1220
+ },
1221
+ computeTreeOpts () {
1222
+ return Object.assign({}, getConfig().table.treeConfig, this.treeConfig)
1223
+ },
1224
+ emptyOpts () {
1225
+ return this.computeEmptyOpts
1226
+ },
1227
+ computeEmptyOpts () {
1228
+ return Object.assign({}, getConfig().table.emptyRender, this.emptyRender)
1229
+ },
1230
+ loadingOpts () {
1231
+ return this.computeLoadingOpts
1232
+ },
1233
+ computeLoadingOpts () {
1234
+ return Object.assign({}, getConfig().table.loadingConfig, this.loadingConfig)
1235
+ },
1236
+ computeCellOffsetWidth () {
1237
+ return this.border ? Math.max(2, Math.ceil(this.scrollbarWidth / this.tableColumn.length)) : 1
1238
+ },
1239
+ customOpts () {
1240
+ return this.computeCustomOpts
1241
+ },
1242
+ computeCustomOpts () {
1243
+ return Object.assign({}, getConfig().table.customConfig, this.customConfig)
1244
+ },
1245
+ computeCustomSimpleMode () {
1246
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1247
+ const props = $xeTable
1248
+
1249
+ const { minHeight, height } = props
1250
+ const customOpts = $xeTable.computeCustomOpts
1251
+ const { mode, popupOptions, placement } = customOpts
1252
+ if (!placement || placement === 'top-left' || placement === 'top-right') {
1253
+ if (!(mode === 'modal' || mode === 'drawer')) {
1254
+ const { mode } = popupOptions || {}
1255
+ if (!mode || mode === 'auto') {
1256
+ if (height || minHeight) {
1257
+ return 'inside'
1258
+ }
1259
+ return 'outside'
1260
+ }
1261
+ if (mode) {
1262
+ return mode
1263
+ }
1264
+ }
1265
+ }
1266
+ return ''
1267
+ },
1268
+ computeTableStyle () {
1269
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1270
+
1271
+ const scrollbarOpts = $xeTable.computeScrollbarOpts
1272
+ const { width, height } = scrollbarOpts
1273
+ const tStys: VxeComponentStyleType = {}
1274
+ if (width) {
1275
+ tStys['--vxe-ui-table-view-scrollbar-width'] = toCssUnit(width)
1276
+ }
1277
+ if (height) {
1278
+ tStys['--vxe-ui-table-view-scrollbar-height'] = toCssUnit(height)
1279
+ }
1280
+ return tStys
1281
+ },
1282
+ computeTableRowExpandedList () {
1283
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1284
+ const reactData = $xeTable as unknown as TableReactData
1285
+ const internalData = $xeTable as unknown as TableInternalData
1286
+
1287
+ const { tableData, rowExpandedFlag, expandColumn, rowGroupExpandedFlag, treeExpandedFlag } = reactData
1288
+ const { visibleDataRowIdData, rowExpandedMaps } = internalData
1289
+ const expandList: any[] = []
1290
+ if (tableData.length && expandColumn && rowExpandedFlag && rowGroupExpandedFlag && treeExpandedFlag) {
1291
+ XEUtils.each(rowExpandedMaps, (row, rowid) => {
1292
+ if (visibleDataRowIdData[rowid]) {
1293
+ expandList.push(row)
1294
+ }
1295
+ })
1296
+ }
1297
+ return expandList
1298
+ },
1299
+ computeAutoWidthColumnList () {
1300
+ const { tableColumn, visibleColumn } = this
1301
+ return tableColumn.length || visibleColumn.length ? visibleColumn.filter((column: any) => column.width === 'auto' || column.minWidth === 'auto') : []
1302
+ },
1303
+ computeFixedColumnSize () {
1304
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1305
+ const reactData = $xeTable as unknown as TableReactData
1306
+ const internalData = $xeTable as unknown as TableInternalData
1307
+
1308
+ const { tableColumn } = reactData
1309
+ const { collectColumn } = internalData
1310
+ let fixedSize = 0
1311
+ // 只判断第一层
1312
+ if (tableColumn.length && collectColumn.length) {
1313
+ collectColumn.forEach((column: any) => {
1314
+ if (column.renderFixed) {
1315
+ fixedSize++
1316
+ }
1317
+ })
1318
+ }
1319
+ return fixedSize
1320
+ },
1321
+ fixedColumnSize () {
1322
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1323
+
1324
+ return $xeTable.computeFixedColumnSize
1325
+ },
1326
+ computeIsMaxFixedColumn () {
1327
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1328
+
1329
+ const fixedColumnSize = $xeTable.computeFixedColumnSize
1330
+ const columnOpts = $xeTable.columnOpts
1331
+ const { maxFixedSize } = columnOpts
1332
+ if (maxFixedSize) {
1333
+ return fixedColumnSize >= maxFixedSize
1334
+ }
1335
+ return false
1336
+ },
1337
+ computeKeepFields () {
1338
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1339
+ const reactData = $xeTable as unknown as TableReactData
1340
+ const internalData = $xeTable as unknown as TableInternalData
1341
+
1342
+ const { tableFullColumn } = internalData
1343
+ const { updateColFlag } = reactData
1344
+ const editDirtyOpts = $xeTable.computeEditDirtyOpts
1345
+ const { includeFields, excludeFields } = editDirtyOpts
1346
+ const kpFields: string[] = []
1347
+ if (updateColFlag) {
1348
+ if (includeFields && includeFields.length) {
1349
+ return includeFields
1350
+ }
1351
+ const exfMaps: Record<string, number> = {}
1352
+ if (excludeFields && excludeFields.length) {
1353
+ excludeFields.forEach(field => {
1354
+ exfMaps[field] = 1
1355
+ })
1356
+ }
1357
+ for (let i = 0; i < tableFullColumn.length; i++) {
1358
+ const column = tableFullColumn[i]
1359
+ const { field, type, editRender, cellRender } = column
1360
+ if (field && !type && (editRender || cellRender) && !exfMaps[field]) {
1361
+ kpFields.push(field)
1362
+ }
1363
+ }
1364
+ }
1365
+ return kpFields
1366
+ },
1367
+ computeTableBorder () {
1368
+ const $xeTable = this
1369
+ const props = $xeTable
1370
+
1371
+ const { border } = props
1372
+ if (border === true) {
1373
+ return 'full'
1374
+ }
1375
+ if (border) {
1376
+ return border
1377
+ }
1378
+ return 'default'
1379
+ },
1380
+ /**
1381
+ * 判断列全选的复选框是否禁用
1382
+ */
1383
+ computeIsAllCheckboxDisabled () {
1384
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1385
+ const props = $xeTable
1386
+ const reactData = $xeTable as unknown as TableReactData
1387
+ const internalData = $xeTable as unknown as TableInternalData
1388
+
1389
+ const { treeConfig } = props
1390
+ const { tableData } = reactData
1391
+ const { tableFullData } = internalData
1392
+ const checkboxOpts = $xeTable.computeCheckboxOpts
1393
+ const { strict, checkMethod } = checkboxOpts
1394
+ if (strict) {
1395
+ if (tableData.length || tableFullData.length) {
1396
+ if (checkMethod) {
1397
+ if (treeConfig) {
1398
+ // 暂时不支持树形结构
1399
+ }
1400
+ // 如果所有行都被禁用
1401
+ return tableFullData.every((row) => !checkMethod({ $table: $xeTable, row }))
1402
+ }
1403
+ return false
1404
+ }
1405
+ return true
1406
+ }
1407
+ return false
1408
+ },
1409
+ isAllCheckboxDisabled () {
1410
+ return this.computeIsAllCheckboxDisabled
1411
+ },
1412
+ computeVirtualScrollBars () {
1413
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1414
+ const reactData = $xeTable as unknown as TableReactData
1415
+
1416
+ const { overflowX, scrollXLoad, overflowY, scrollYLoad } = reactData
1417
+ return {
1418
+ x: overflowX && scrollXLoad,
1419
+ y: overflowY && scrollYLoad
1420
+ }
1421
+ },
1422
+ computeRowGroupFields () {
1423
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1424
+
1425
+ const aggregateOpts = $xeTable.computeAggregateOpts
1426
+ return aggregateOpts.groupFields
1427
+ },
1428
+ computeRowGroupColumns () {
1429
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1430
+ const reactData = $xeTable as unknown as TableReactData
1431
+ const internalData = $xeTable as unknown as TableInternalData
1432
+
1433
+ const { rowGroupList } = reactData
1434
+ const { fullColumnFieldData } = internalData
1435
+ const rgColumns: VxeTableDefines.ColumnInfo[] = []
1436
+ rowGroupList.forEach(aggConf => {
1437
+ const colRest = fullColumnFieldData[aggConf.field]
1438
+ if (colRest) {
1439
+ rgColumns.push(colRest.column)
1440
+ }
1441
+ })
1442
+ return rgColumns
1443
+ },
1444
+ computeAggFuncColumns () {
1445
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1446
+ const reactData = $xeTable as unknown as TableReactData
1447
+
1448
+ const { rowGroupList, tableColumn } = reactData
1449
+ if (rowGroupList.length) {
1450
+ return tableColumn.filter(column => column.field && column.aggFunc)
1451
+ }
1452
+ return []
1453
+ },
1454
+ computeUndoHistoryOpts () {
1455
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1456
+ const props = $xeTable
1457
+
1458
+ return Object.assign({}, getConfig().table.undoHistoryConfig, props.undoHistoryConfig)
1459
+ },
1460
+ tabsResizeFlag () {
1461
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1462
+ const $xeTabs = $xeTable.$xeTabs
1463
+
1464
+ return $xeTabs ? $xeTabs.reactData.resizeFlag : null
1465
+ },
1466
+ computeVxeLanguage () {
1467
+ return VxeUI.getLanguage()
1468
+ },
1469
+ computeScrollbarVisible () {
1470
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1471
+
1472
+ const scrollbarXOpts = $xeTable.computeScrollbarXOpts
1473
+ const scrollbarYOpts = $xeTable.computeScrollbarYOpts
1474
+ return `${scrollbarXOpts.visible}${scrollbarYOpts.visible}`
1475
+ }
1476
+ } as any,
1477
+ watch: {
1478
+ data (value: any) {
1479
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1480
+ const reactData = $xeTable as unknown as TableReactData
1481
+
1482
+ const { initStatus } = this
1483
+ if (value && value.length >= 20000) {
1484
+ warnLog('vxe.error.errLargeData', ['loadData(data), reloadData(data)'])
1485
+ }
1486
+ this.loadTableData(value || [], true, true).then(() => {
1487
+ const { scrollXLoad, scrollYLoad, expandColumn } = reactData
1488
+ const expandOpts = $xeTable.computeExpandOpts
1489
+ this.inited = true
1490
+ this.initStatus = true
1491
+ if (!initStatus) {
1492
+ this.handleLoadDefaults()
1493
+ }
1494
+ // const checkboxColumn = this.tableFullColumn.find(column => column.type === 'checkbox')
1495
+ // if (checkboxColumn && this.tableFullData.length > 300 && !this.checkboxOpts.checkField) {
1496
+ // warnLog('vxe.error.checkProp', ['checkbox-config.checkField'])
1497
+ // }
1498
+ if ((scrollXLoad || scrollYLoad) && (expandColumn && expandOpts.mode !== 'fixed')) {
1499
+ warnLog('vxe.error.scrollErrProp', ['column.type=expand'])
1500
+ }
1501
+ this.recalculate()
1502
+ })
1503
+ },
1504
+ staticColumns (value: any) {
1505
+ this.$nextTick(() => this.handleInitColumn(XEUtils.clone(value)))
1506
+ },
1507
+ tableColumn () {
1508
+ this.analyColumnWidth()
1509
+ },
1510
+ upDataFlag () {
1511
+ this.$nextTick().then(() => this.updateData())
1512
+ },
1513
+ reColumnFlag () {
1514
+ this.$nextTick().then(() => this.refreshColumn())
1515
+ },
1516
+
1517
+ computeSize () {
1518
+ this.reLayoutFlag++
1519
+ },
1520
+ showHeader () {
1521
+ this.reLayoutFlag++
1522
+ },
1523
+ showFooter () {
1524
+ this.reLayoutFlag++
1525
+ },
1526
+ showHeaderOverflow () {
1527
+ this.reLayoutFlag++
1528
+ },
1529
+ showOverflow () {
1530
+ const $xeTable = this
1531
+
1532
+ updateColumnAllOverflow($xeTable)
1533
+ this.reLayoutFlag++
1534
+ },
1535
+ showFooterOverflow () {
1536
+ this.reLayoutFlag++
1537
+ },
1538
+ overflowX () {
1539
+ this.reLayoutFlag++
1540
+ },
1541
+ overflowY () {
1542
+ this.reLayoutFlag++
1543
+ },
1544
+ height () {
1545
+ this.reLayoutFlag++
1546
+ },
1547
+ maxHeight () {
1548
+ this.reLayoutFlag++
1549
+ },
1550
+ computeScrollbarXToTop () {
1551
+ this.reLayoutFlag++
1552
+ },
1553
+ computeScrollbarYToLeft () {
1554
+ this.reLayoutFlag++
1555
+ },
1556
+ computeVxeLanguage () {
1557
+ this.reLayoutFlag++
1558
+ },
1559
+ computeScrollbarVisible () {
1560
+ this.reLayoutFlag++
1561
+ },
1562
+ reLayoutFlag () {
1563
+ const $xeTable = this
1564
+
1565
+ $xeTable.$nextTick(() => $xeTable.recalculate(true))
1566
+ },
1567
+
1568
+ footerData () {
1569
+ this.footFlag++
1570
+ },
1571
+ footFlag () {
1572
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1573
+ const internalData = $xeTable as unknown as TableInternalData
1574
+
1575
+ internalData.footerFullDataRowData = {}
1576
+ $xeTable.updateFooter()
1577
+ },
1578
+
1579
+ updateColFlag () {
1580
+ this.kfFlag++
1581
+ },
1582
+ computeKeepFields () {
1583
+ this.kfFlag++
1584
+ },
1585
+ kfFlag () {
1586
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1587
+ const internalData = $xeTable as unknown as TableInternalData
1588
+
1589
+ const keepFields = $xeTable.computeKeepFields
1590
+ const kpfMaps: Record<string, number> = {}
1591
+ keepFields.forEach(field => {
1592
+ kpfMaps[field] = 1
1593
+ })
1594
+ internalData.keepUpdateFieldMaps = kpfMaps
1595
+ },
1596
+
1597
+ syncResize (value: any) {
1598
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1599
+
1600
+ if (value) {
1601
+ handleUpdateResize($xeTable)
1602
+ $xeTable.$nextTick(() => {
1603
+ handleUpdateResize($xeTable)
1604
+ setTimeout(() => handleUpdateResize($xeTable))
1605
+ })
1606
+ }
1607
+ },
1608
+ tabsResizeFlag () {
1609
+ this.handleGlobalResizeEvent()
1610
+ },
1611
+ mergeCells (value: any) {
1612
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1613
+
1614
+ handleUpdateMergeBodyCells($xeTable, value)
1615
+ },
1616
+ mergeHeaderCells (value: any) {
1617
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1618
+
1619
+ handleUpdateMergeHeaderCells($xeTable, value)
1620
+ },
1621
+ mergeFooterCells () {
1622
+ this.mergeFooteCellFlag++
1623
+ },
1624
+ mergeFooterItems () {
1625
+ this.mergeFooteCellFlag++
1626
+ },
1627
+ mergeFooteCellFlag () {
1628
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1629
+ const props = $xeTable
1630
+
1631
+ const mFooterCells = props.mergeFooterCells || props.mergeFooterItems
1632
+ handleUpdateMergeFooterCells($xeTable, mFooterCells || [])
1633
+ },
1634
+
1635
+ computeRowGroupFields (val: any) {
1636
+ const $xeTable = this
1637
+
1638
+ $xeTable.handleUpdateRowGroup(val)
1639
+ },
1640
+ computeRowField () {
1641
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1642
+ const reactData = $xeTable as unknown as TableReactData
1643
+ const internalData = $xeTable as unknown as TableInternalData
1644
+
1645
+ // 行主键被改变,重载表格
1646
+ const { inited, tableFullData } = internalData
1647
+ if (inited) {
1648
+ handleKeyField($xeTable)
1649
+ reactData.tableData = []
1650
+ $xeTable.$nextTick(() => {
1651
+ $xeTable.reloadData(tableFullData)
1652
+ })
1653
+ }
1654
+ }
1655
+ } as any,
1656
+ created () {
1657
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
1658
+ const props = $xeTable
1659
+ const internalData = $xeTable as unknown as TableInternalData
1660
+
1661
+ XEUtils.assign(internalData, createInternalData())
1662
+
1663
+ handleKeyField($xeTable)
1664
+
1665
+ const { exportConfig, importConfig, treeConfig, minHeight } = props
1666
+ const { scrollXStore, scrollYStore } = internalData
1667
+ const columnOpts = $xeTable.computeColumnOpts
1668
+ const columnDragOpts = $xeTable.computeColumnDragOpts
1669
+ const editOpts = $xeTable.computeEditOpts
1670
+ const treeOpts = $xeTable.computeTreeOpts
1671
+ const radioOpts = $xeTable.computeRadioOpts
1672
+ const checkboxOpts = $xeTable.computeCheckboxOpts
1673
+ const expandOpts = $xeTable.computeExpandOpts
1674
+ const rowOpts = $xeTable.computeRowOpts
1675
+ const customOpts = $xeTable.computeCustomOpts
1676
+ const mouseOpts = $xeTable.computeMouseOpts
1677
+ const exportOpts = $xeTable.computeExportOpts
1678
+ const importOpts = $xeTable.computeImportOpts
1679
+ // const currentRowOpts = $xeTable.computeCurrentRowOpts
1680
+ // const currentColumnOpts = $xeTable.computeCurrentColumnOpts
1681
+ // const keyboardOpts = $xeTable.computeKeyboardOpts
1682
+ const aggregateOpts = $xeTable.computeAggregateOpts
1683
+ const rowDragOpts = $xeTable.computeRowDragOpts
1684
+ const areaOpts = $xeTable.computeAreaOpts
1685
+ const { groupFields } = aggregateOpts
1686
+
1687
+ if (props.rowId) {
1688
+ warnLog('vxe.error.delProp', ['row-id', 'row-config.keyField'])
1689
+ }
1690
+ if (props.rowKey) {
1691
+ warnLog('vxe.error.delProp', ['row-key', 'row-config.useKey'])
1692
+ }
1693
+ if (props.columnKey) {
1694
+ warnLog('vxe.error.delProp', ['column-id', 'column-config.useKey'])
1695
+ }
1696
+ if (!(props.rowId || rowOpts.keyField) && (checkboxOpts.reserve || checkboxOpts.checkRowKeys || radioOpts.reserve || radioOpts.checkRowKey || expandOpts.expandRowKeys || treeOpts.expandRowKeys)) {
1697
+ warnLog('vxe.error.reqProp', ['row-config.keyField'])
1698
+ }
1699
+ if (props.editConfig && editOpts.showStatus && !props.keepSource) {
1700
+ warnLog('vxe.error.reqProp', ['keep-source'])
1701
+ }
1702
+ // if (treeConfig && (treeOpts.showLine || treeOpts.line) && !showOverflow) {
1703
+ // warnLog('vxe.error.reqProp', ['show-overflow'])
1704
+ // }
1705
+ if (treeConfig && !treeOpts.transform && props.stripe) {
1706
+ warnLog('vxe.error.noTree', ['stripe'])
1707
+ }
1708
+ if (props.showFooter && !(props.footerMethod || props.footerData)) {
1709
+ warnLog('vxe.error.reqProp', ['footer-data | footer-method'])
1710
+ }
1711
+ if (rowOpts.height) {
1712
+ warnLog('vxe.error.delProp', ['row-config.height', 'cell-config.height'])
1713
+ }
1714
+ if (this.tooltipOpts.enabled) {
1715
+ warnLog('vxe.error.delProp', ['tooltip-config.enabled', 'tooltip-config.showAll'])
1716
+ }
1717
+ if (this.highlightCurrentRow) {
1718
+ warnLog('vxe.error.delProp', ['highlight-current-row', 'row-config.isCurrent'])
1719
+ }
1720
+ if (this.highlightHoverRow) {
1721
+ warnLog('vxe.error.delProp', ['highlight-hover-row', 'row-config.isHover'])
1722
+ }
1723
+ if (this.highlightCurrentColumn) {
1724
+ warnLog('vxe.error.delProp', ['highlight-current-column', 'column-config.isCurrent'])
1725
+ }
1726
+ if (this.highlightHoverColumn) {
1727
+ warnLog('vxe.error.delProp', ['highlight-hover-column', 'column-config.isHover'])
1728
+ }
1729
+ if (props.resizable) {
1730
+ warnLog('vxe.error.delProp', ['resizable', 'column-config.resizable'])
1731
+ }
1732
+ // if (props.virtualXConfig && props.scrollX) {
1733
+ // warnLog('vxe.error.notSupportProp', ['virtual-x-config', 'scroll-x', 'scroll-x=null'])
1734
+ // }
1735
+ // if (props.virtualYConfig && props.scrollY) {
1736
+ // warnLog('vxe.error.notSupportProp', ['virtual-y-config', 'scroll-y', 'scroll-y=null'])
1737
+ // }
1738
+ if (props.aggregateConfig && props.rowGroupConfig) {
1739
+ warnLog('vxe.error.notSupportProp', ['aggregate-config', 'row-group-config', 'row-group-config=null'])
1740
+ }
1741
+ // if (props.scrollY) {
1742
+ // warnLog('vxe.error.delProp', ['scroll-y', 'virtual-y-config'])
1743
+ // }
1744
+ // if (props.scrollX) {
1745
+ // warnLog('vxe.error.delProp', ['scroll-x', 'virtual-x-config'])
1746
+ // }
1747
+ // 检查导入导出类型,如果自定义导入导出方法,则不校验类型
1748
+ if (importConfig && importOpts.types && !importOpts.importMethod && !XEUtils.includeArrays(XEUtils.keys(importOpts._typeMaps), importOpts.types)) {
1749
+ warnLog('vxe.error.errProp', [`export-config.types=${importOpts.types.join(',')}`, importOpts.types.filter((type) => XEUtils.includes(XEUtils.keys(importOpts._typeMaps), type)).join(',') || XEUtils.keys(importOpts._typeMaps).join(',')])
1750
+ }
1751
+ if (exportConfig && exportOpts.types && !exportOpts.exportMethod && !XEUtils.includeArrays(XEUtils.keys(exportOpts._typeMaps), exportOpts.types)) {
1752
+ warnLog('vxe.error.errProp', [`export-config.types=${exportOpts.types.join(',')}`, exportOpts.types.filter((type) => XEUtils.includes(XEUtils.keys(exportOpts._typeMaps), type)).join(',') || XEUtils.keys(exportOpts._typeMaps).join(',')])
1753
+ }
1754
+
1755
+ if (!props.id) {
1756
+ if ((props.customConfig ? isEnableConf(customOpts) : customOpts.enabled) && customOpts.storage) {
1757
+ errLog('vxe.error.reqProp', ['id'])
1758
+ }
1759
+ }
1760
+ if (treeConfig && checkboxOpts.range) {
1761
+ errLog('vxe.error.noTree', ['checkbox-config.range'])
1762
+ }
1763
+ if (rowOpts.height && !this.showOverflow) {
1764
+ warnLog('vxe.error.notProp', ['table.show-overflow'])
1765
+ }
1766
+ if (!$xeTable.triggerClAreaModnEvent) {
1767
+ if (props.areaConfig) {
1768
+ warnLog('vxe.error.notProp', ['area-config'])
1769
+ }
1770
+ if (props.clipConfig) {
1771
+ warnLog('vxe.error.notProp', ['clip-config'])
1772
+ }
1773
+ if (props.fnrConfig) {
1774
+ warnLog('vxe.error.notProp', ['fnr-config'])
1775
+ }
1776
+ if (mouseOpts.area) {
1777
+ errLog('vxe.error.notProp', ['mouse-config.area'])
1778
+ return
1779
+ }
1780
+ if (mouseOpts.area && areaOpts.selectCellByHeader && columnOpts.drag && columnDragOpts.trigger === 'cell') {
1781
+ errLog('vxe.error.notSupportProp', ['area-config.selectCellByHeader & column-config.drag', 'column-drag-config.trigger=cell', 'column-drag-config.trigger=default | area-config.selectCellByHeader=false'])
1782
+ }
1783
+ }
1784
+ if (!$xeTable.handlePivotTableAggregateData) {
1785
+ if (customOpts.allowGroup) {
1786
+ errLog('vxe.error.notProp', ['custom-config.allowGroup'])
1787
+ return
1788
+ }
1789
+ if (customOpts.allowValues) {
1790
+ errLog('vxe.error.notProp', ['custom-config.allowValues'])
1791
+ return
1792
+ }
1793
+ }
1794
+ if (treeConfig && rowOpts.drag && !treeOpts.transform) {
1795
+ warnLog('vxe.error.notSupportProp', ['row-config.drag', 'tree-config.transform=false', 'tree-config.transform=true'])
1796
+ }
1797
+ if (treeConfig && rowDragOpts.isCrossTableDrag && !rowDragOpts.isCrossDrag) {
1798
+ errLog('vxe.error.reqSupportProp', ['tree-config & row-drag-config.isCrossTableDrag', 'row-drag-config.isCrossDrag'])
1799
+ }
1800
+ if (props.dragConfig) {
1801
+ warnLog('vxe.error.delProp', ['drag-config', 'row-drag-config'])
1802
+ }
1803
+ if (props.rowGroupConfig) {
1804
+ warnLog('vxe.error.delProp', ['row-group-config', 'aggregate-config'])
1805
+ }
1806
+ if (aggregateOpts.countFields) {
1807
+ warnLog('vxe.error.delProp', ['row-group-config.countFields', 'column.agg-func'])
1808
+ }
1809
+ if (aggregateOpts.aggregateMethod) {
1810
+ warnLog('vxe.error.delProp', ['row-group-config.aggregateMethod', 'aggregate-config.calcValuesMethod'])
1811
+ }
1812
+ if (aggregateOpts.countMethod) {
1813
+ warnLog('vxe.error.delProp', ['aggregate-config.countMethod', 'aggregate-config.calcValuesMethod'])
1814
+ }
1815
+ if (props.treeConfig && treeOpts.children) {
1816
+ warnLog('vxe.error.delProp', ['tree-config.children', 'tree-config.childrenField'])
1817
+ }
1818
+ if (props.treeConfig && treeOpts.line) {
1819
+ warnLog('vxe.error.delProp', ['tree-config.line', 'tree-config.showLine'])
1820
+ }
1821
+ if (mouseOpts.area && mouseOpts.selected) {
1822
+ warnLog('vxe.error.errConflicts', ['mouse-config.area', 'mouse-config.selected'])
1823
+ }
1824
+ if (mouseOpts.area && (props.treeConfig && !treeOpts.transform)) {
1825
+ errLog('vxe.error.noTree', ['mouse-config.area'])
1826
+ }
1827
+ if (props.editConfig && editOpts.activeMethod) {
1828
+ warnLog('vxe.error.delProp', ['table.edit-config.activeMethod', 'table.edit-config.beforeEditMethod'])
1829
+ }
1830
+ if (props.treeConfig && checkboxOpts.isShiftKey) {
1831
+ errLog('vxe.error.errConflicts', ['tree-config', 'checkbox-config.isShiftKey'])
1832
+ }
1833
+ if (checkboxOpts.halfField) {
1834
+ warnLog('vxe.error.delProp', ['checkbox-config.halfField', 'checkbox-config.indeterminateField'])
1835
+ }
1836
+ if (props.editConfig && isEnableConf(editOpts) && props.editRules && (minHeight === 0 || minHeight === '0')) {
1837
+ warnLog('vxe.error.reqSupportProp', ['edit-config & edit-rules', 'min-height'])
1838
+ }
1839
+
1840
+ if (treeConfig) {
1841
+ XEUtils.arrayEach(['rowField', 'parentField', 'childrenField', 'hasChildField', 'mapChildrenField'], key => {
1842
+ const val = treeOpts[key as 'rowField']
1843
+ if (val && val.indexOf('.') > -1) {
1844
+ errLog('vxe.error.errProp', [`${key}=${val}`, `${key}=${val.split('.')[0]}`])
1845
+ }
1846
+ })
1847
+ }
1848
+
1849
+ // 在 v3.0 中废弃 context-menu
1850
+ if (this.contextMenu) {
1851
+ warnLog('vxe.error.delProp', ['context-menu', 'menu-config'])
1852
+ if (!XEUtils.isObject(this.contextMenu)) {
1853
+ warnLog('vxe.error.errProp', [`table.context-menu=${this.contextMenu}`, 'table.context-menu={}'])
1854
+ }
1855
+ }
1856
+ if (props.menuConfig && !XEUtils.isObject(props.menuConfig)) {
1857
+ warnLog('vxe.error.errProp', [`table.menu-config=${props.menuConfig}`, 'table.menu-config={}'])
1858
+ }
1859
+ if (props.exportConfig && !XEUtils.isObject(props.exportConfig)) {
1860
+ warnLog('vxe.error.errProp', [`table.export-config=${props.exportConfig}`, 'table.export-config={}'])
1861
+ }
1862
+ if (props.importConfig && !XEUtils.isObject(props.importConfig)) {
1863
+ warnLog('vxe.error.errProp', [`table.import-config=${props.importConfig}`, 'table.import-config={}'])
1864
+ }
1865
+ if (props.printConfig && !XEUtils.isObject(props.printConfig)) {
1866
+ warnLog('vxe.error.errProp', [`table.print-config=${props.printConfig}`, 'table.print-config={}'])
1867
+ }
1868
+ if (props.treeConfig && !XEUtils.isObject(props.treeConfig)) {
1869
+ warnLog('vxe.error.errProp', [`table.tree-config=${props.treeConfig}`, 'table.tree-config={}'])
1870
+ }
1871
+ if (props.customConfig && !XEUtils.isObject(props.customConfig)) {
1872
+ warnLog('vxe.error.errProp', [`table.custom-config=${props.customConfig}`, 'table.custom-config={}'])
1873
+ }
1874
+ if (props.editConfig && !XEUtils.isObject(props.editConfig)) {
1875
+ warnLog('vxe.error.errProp', [`table.edit-config=${props.editConfig}`, 'table.edit-config={}'])
1876
+ }
1877
+ if (props.emptyRender && !XEUtils.isObject(props.emptyRender)) {
1878
+ warnLog('vxe.error.errProp', [`table.empty-render=${props.emptyRender}`, 'table.empty-render={}'])
1879
+ }
1880
+
1881
+ if (rowOpts.currentMethod) {
1882
+ warnLog('vxe.error.delProp', ['row-config.currentMethod', 'current-row-config.beforeSelectMethod'])
1883
+ }
1884
+ if (columnOpts.currentMethod) {
1885
+ warnLog('vxe.error.delProp', ['row-config.currentMethod', 'current-column-config.beforeSelectMethod'])
1886
+ }
1887
+ // if ((rowOpts.isCurrent || highlightCurrentRow) && props.keyboardConfig && keyboardOpts.isArrow && !XEUtils.isBoolean(currentRowOpts.isFollowSelected)) {
1888
+ // warnLog('vxe.error.notConflictProp', ['row-config.isCurrent & keyboard-config.isArrow', 'current-row-config.isFollowSelected'])
1889
+ // }
1890
+ // if ((columnOpts.isCurrent || highlightCurrentColumn) && props.keyboardConfig && keyboardOpts.isArrow && !XEUtils.isBoolean(currentColumnOpts.isFollowSelected)) {
1891
+ // warnLog('vxe.error.notConflictProp', ['column-config.isCurrent & keyboard-config.isArrow', 'current-column-config.isFollowSelected'])
1892
+ // }
1893
+
1894
+ // 如果不支持虚拟滚动
1895
+ // if (props.spanMethod) {
1896
+ // if (virtualXOpts.enabled) {
1897
+ // warnLog('vxe.error.notConflictProp', ['span-method', 'virtual-x-config.enabled=false'])
1898
+ // }
1899
+ // if (virtualYOpts.enabled) {
1900
+ // warnLog('vxe.error.notConflictProp', ['span-method', 'virtual-y-config.enabled=false'])
1901
+ // }
1902
+ // }
1903
+ // if (props.footerSpanMethod) {
1904
+ // if (virtualXOpts.enabled) {
1905
+ // warnLog('vxe.error.notConflictProp', ['footer-span-method', 'virtual-x-config.enabled=false'])
1906
+ // }
1907
+ // }
1908
+
1909
+ // 检查是否有安装需要的模块
1910
+ if (props.editConfig && !$xeTable.insert) {
1911
+ errLog('vxe.error.reqModule', ['Edit'])
1912
+ }
1913
+ if (props.editRules && !$xeTable.validate) {
1914
+ errLog('vxe.error.reqModule', ['Validator'])
1915
+ }
1916
+ if ((checkboxOpts.range || props.keyboardConfig || props.mouseConfig) && !$xeTable.handleCellMousedownEvent) {
1917
+ errLog('vxe.error.reqModule', ['Keyboard'])
1918
+ }
1919
+ if ((props.printConfig || props.importConfig || props.exportConfig) && !$xeTable.exportData) {
1920
+ errLog('vxe.error.reqModule', ['Export'])
1921
+ }
1922
+
1923
+ Object.assign(scrollYStore, {
1924
+ startIndex: 0,
1925
+ endIndex: 1,
1926
+ visibleSize: 0
1927
+ })
1928
+ Object.assign(scrollXStore, {
1929
+ startIndex: 0,
1930
+ endIndex: 1,
1931
+ visibleSize: 0
1932
+ })
1933
+
1934
+ this.handleUpdateRowGroup(groupFields)
1935
+
1936
+ this.initData()
1937
+
1938
+ globalEvents.on($xeTable, 'paste', this.handleGlobalPasteEvent)
1939
+ globalEvents.on($xeTable, 'copy', this.handleGlobalCopyEvent)
1940
+ globalEvents.on($xeTable, 'cut', this.handleGlobalCutEvent)
1941
+ globalEvents.on($xeTable, 'mousedown', this.handleGlobalMousedownEvent)
1942
+ globalEvents.on($xeTable, 'blur', this.handleGlobalBlurEvent)
1943
+ globalEvents.on($xeTable, 'mousewheel', this.handleGlobalMousewheelEvent)
1944
+ globalEvents.on($xeTable, 'keydown', this.handleGlobalKeydownEvent)
1945
+ globalEvents.on($xeTable, 'resize', this.handleGlobalResizeEvent)
1946
+ globalEvents.on($xeTable, 'contextmenu', this.handleGlobalContextmenuEvent)
1947
+ $xeTable.preventEvent(null, 'created')
1948
+ },
1949
+ mounted () {
1950
+ const $xeTable = this
1951
+ const props = $xeTable
1952
+ const internalData = $xeTable as unknown as TableInternalData
1953
+ const $xeGrid = $xeTable.$xeGrid
1954
+ const $xeGantt = $xeTable.$xeGantt
1955
+ const $xeGGWrapper = $xeGrid || $xeGantt
1956
+
1957
+ const columnOpts = $xeTable.computeColumnOpts
1958
+ const rowOpts = $xeTable.computeRowOpts
1959
+ const customOpts = $xeTable.computeCustomOpts
1960
+ const virtualYOpts = $xeTable.computeVirtualYOpts
1961
+
1962
+ if ($xeGantt) {
1963
+ const classifyWrapperEl = $xeGantt.$refs.refClassifyWrapperElem as HTMLDivElement
1964
+ const teleportWrapperEl = $xeTable.$refs.refTeleportWrapper as HTMLDivElement
1965
+ if (classifyWrapperEl) {
1966
+ if (teleportWrapperEl) {
1967
+ classifyWrapperEl.appendChild(teleportWrapperEl)
1968
+ }
1969
+ internalData.teleportToWrapperElem = classifyWrapperEl
1970
+ }
1971
+ }
1972
+ if ($xeGGWrapper) {
1973
+ const popupContainerElem = $xeGGWrapper.$refs.refPopupContainerElem as HTMLDivElement
1974
+ const popupWrapperEl = $xeTable.$refs.refPopupWrapperElem as HTMLDivElement
1975
+ if (popupContainerElem) {
1976
+ if (popupWrapperEl) {
1977
+ popupContainerElem.appendChild(popupWrapperEl)
1978
+ }
1979
+ internalData.popupToWrapperElem = popupContainerElem
1980
+ }
1981
+ }
1982
+
1983
+ if (columnOpts.drag || rowOpts.drag || customOpts.allowSort) {
1984
+ initTpImg()
1985
+ }
1986
+
1987
+ const { $listeners } = this
1988
+ if (!this.menuConfig && ($listeners['menu-click'] || $listeners['cell-menu'] || $listeners['header-cell-menu'] || $listeners['footer-cell-menu'])) {
1989
+ warnLog('vxe.error.reqProp', ['menu-config'])
1990
+ }
1991
+ if (!this.tooltipConfig && ($listeners['cell-mouseenter'] || $listeners['cell-mouseleave'])) {
1992
+ warnLog('vxe.error.reqProp', ['tooltip-config'])
1993
+ }
1994
+
1995
+ $xeTable.$nextTick(() => {
1996
+ // 使用已安装的组件,如果未安装则不渲染
1997
+ const VxeUILoadingComponent = VxeUI.getComponent('VxeLoading')
1998
+ const VxeUITooltipComponent = VxeUI.getComponent('VxeTooltip')
1999
+
2000
+ if (props.loading) {
2001
+ if (!VxeUILoadingComponent && !this.$scopedSlots.loading) {
2002
+ errLog('vxe.error.errProp', ['loading=true', 'loading=false | <template #loading>...</template>'])
2003
+ errLog('vxe.error.reqComp', ['vxe-loading'])
2004
+ }
2005
+ }
2006
+ if ((props.showOverflow === true || props.showOverflow === 'tooltip') ||
2007
+ (props.showHeaderOverflow === true || props.showHeaderOverflow === 'tooltip') ||
2008
+ (props.showFooterOverflow === true || props.showFooterOverflow === 'tooltip') ||
2009
+ props.tooltipConfig || props.editRules) {
2010
+ if (!VxeUITooltipComponent) {
2011
+ if (props.showOverflow === true) {
2012
+ errLog('vxe.error.errProp', ['show-overflow=true', 'show-overflow=title'])
2013
+ }
2014
+ if (props.showOverflow === 'tooltip') {
2015
+ errLog('vxe.error.errProp', ['show-overflow=tooltip', 'show-overflow=title'])
2016
+ }
2017
+ if (props.showHeaderOverflow === true) {
2018
+ errLog('vxe.error.errProp', ['show-header-overflow=true', 'show-header-overflow=title'])
2019
+ }
2020
+ if (props.showHeaderOverflow === 'tooltip') {
2021
+ errLog('vxe.error.errProp', ['show-header-overflow=tooltip', 'show-header-overflow=title'])
2022
+ }
2023
+ if (props.showFooterOverflow === true) {
2024
+ errLog('vxe.error.errProp', ['show-footer-overflow=true', 'show-footer-overflow=title'])
2025
+ }
2026
+ if (props.showFooterOverflow === 'tooltip') {
2027
+ errLog('vxe.error.errProp', ['show-footer-overflow=tooltip', 'show-footer-overflow=title'])
2028
+ }
2029
+ errLog('vxe.error.reqComp', ['vxe-tooltip'])
2030
+ }
2031
+ }
2032
+
2033
+ if (this.autoResize) {
2034
+ const resizeObserver = globalResize.create(() => {
2035
+ if (this.autoResize) {
2036
+ this.handleResizeEvent()
2037
+ }
2038
+ })
2039
+ resizeObserver.observe(this.$el)
2040
+ resizeObserver.observe(this.getParentElem())
2041
+ this.$resize = resizeObserver
2042
+ }
2043
+ })
2044
+
2045
+ if (virtualYOpts.mode !== 'scroll') {
2046
+ const tableViewportEl = $xeTable.$refs.refTableViewportElem as HTMLDivElement
2047
+ if (tableViewportEl) {
2048
+ tableViewportEl.addEventListener('wheel', $xeTable.triggerBodyWheelEvent, { passive: false })
2049
+ }
2050
+ }
2051
+
2052
+ $xeTable.preventEvent(null, 'mounted')
2053
+ },
2054
+ activated () {
2055
+ this.recalculate().then(() => this.refreshScroll())
2056
+ this.preventEvent(null, 'activated')
2057
+ },
2058
+ deactivated () {
2059
+ const $xeTable = this
2060
+ const reactData = $xeTable as unknown as TableReactData
2061
+ const internalData = $xeTable as unknown as TableInternalData
2062
+
2063
+ const { filterStore } = reactData
2064
+ if (filterStore.visible) {
2065
+ $xeTable.clearFilter()
2066
+ }
2067
+ $xeTable.closeTooltip()
2068
+ internalData.isActivated = false
2069
+ this.preventEvent(null, 'deactivated')
2070
+ },
2071
+ beforeDestroy () {
2072
+ const $xeTable = this
2073
+ const reactData = $xeTable as unknown as TableReactData
2074
+ const internalData = $xeTable as unknown as TableInternalData
2075
+
2076
+ const { _sToTime } = internalData
2077
+ if (_sToTime) {
2078
+ clearTimeout(_sToTime)
2079
+ }
2080
+
2081
+ const teleportWrapperEl = $xeTable.$refs.refTeleportWrapper as HTMLDivElement
2082
+ if (teleportWrapperEl && teleportWrapperEl.parentElement) {
2083
+ teleportWrapperEl.parentElement.removeChild(teleportWrapperEl)
2084
+ }
2085
+ const popupWrapperEl = $xeTable.$refs.refPopupWrapperElem as HTMLDivElement
2086
+ if (popupWrapperEl && popupWrapperEl.parentElement) {
2087
+ popupWrapperEl.parentElement.removeChild(popupWrapperEl)
2088
+ }
2089
+
2090
+ const tableViewportEl = $xeTable.$refs.refTableViewportElem as HTMLDivElement
2091
+ if (tableViewportEl) {
2092
+ tableViewportEl.removeEventListener('wheel', $xeTable.triggerBodyWheelEvent)
2093
+ }
2094
+
2095
+ if (this.$resize) {
2096
+ this.$resize.disconnect()
2097
+ }
2098
+
2099
+ $xeTable.closeTooltip()
2100
+ $xeTable.closeFilter()
2101
+ $xeTable.closeMenu()
2102
+
2103
+ globalEvents.off($xeTable, 'paste')
2104
+ globalEvents.off($xeTable, 'copy')
2105
+ globalEvents.off($xeTable, 'cut')
2106
+ globalEvents.off($xeTable, 'mousedown')
2107
+ globalEvents.off($xeTable, 'blur')
2108
+ globalEvents.off($xeTable, 'mousewheel')
2109
+ globalEvents.off($xeTable, 'keydown')
2110
+ globalEvents.off($xeTable, 'resize')
2111
+ globalEvents.off($xeTable, 'contextmenu')
2112
+
2113
+ $xeTable.preventEvent(null, 'beforeDestroy')
2114
+
2115
+ XEUtils.assign(reactData, createReactData())
2116
+ XEUtils.assign(internalData, createInternalData())
2117
+ },
2118
+ destroyed () {
2119
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2120
+
2121
+ $xeTable.preventEvent(null, 'destroyed')
2122
+ },
2123
+ render (h: CreateElement) {
2124
+ // 使用已安装的组件,如果未安装则不渲染
2125
+ const VxeUILoadingComponent = VxeUI.getComponent('VxeLoading')
2126
+ const VxeUITooltipComponent = VxeUI.getComponent('VxeTooltip')
2127
+
2128
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
2129
+ const $xeGrid = $xeTable.$xeGrid
2130
+ const $xeGantt = $xeTable.$xeGantt
2131
+ const props = $xeTable
2132
+ const slots = $xeTable.$scopedSlots
2133
+ const reactData = $xeTable as unknown as TableReactData
2134
+
2135
+ const { xID } = $xeTable
2136
+
2137
+ const { loading, stripe, showHeader, height, treeConfig, mouseConfig, showFooter, highlightCell, highlightHoverRow, highlightHoverColumn, editConfig, editRules } = props
2138
+ const { isGroup, overflowX, overflowY, scrollXLoad, scrollYLoad, tableData, initStore, isRowGroupStatus, columnStore, filterStore, customStore, tooltipStore } = reactData
2139
+ const { leftList, rightList } = columnStore
2140
+ const loadingSlot = slots.loading
2141
+ const tipSlots = {
2142
+ header: slots.headerTooltip || slots['header-tooltip'],
2143
+ body: slots.tooltip,
2144
+ footer: slots.footerTooltip || slots['footer-tooltip']
2145
+ }
2146
+ const currTooltipSlot = tooltipStore.visible && tooltipStore.type ? tipSlots[tooltipStore.type] : null
2147
+ const tableStyle = ($xeTable as any).computeTableStyle as VxeComponentStyleType
2148
+ const rowDragOpts = $xeTable.computeRowDragOpts
2149
+ const tableTipConfig = $xeTable.computeTableTipConfig
2150
+ const validTipConfig = $xeTable.computeValidTipConfig
2151
+ const validOpts = $xeTable.computeValidOpts
2152
+ const checkboxOpts = $xeTable.computeCheckboxOpts
2153
+ const treeOpts = $xeTable.computeTreeOpts
2154
+ const rowOpts = $xeTable.computeRowOpts
2155
+ const columnOpts = $xeTable.computeColumnOpts
2156
+ const vSize = $xeTable.computeSize
2157
+ const tableBorder = $xeTable.computeTableBorder
2158
+ const mouseOpts = $xeTable.computeMouseOpts
2159
+ const areaOpts = $xeTable.computeAreaOpts
2160
+ const loadingOpts = $xeTable.computeLoadingOpts
2161
+ const isContentMenu = $xeTable.computeIsContentMenu
2162
+ const currLoading = reactData.isColLoading || reactData.isRowLoading || loading
2163
+ const resizableOpts = $xeTable.computeResizableOpts
2164
+ const isArea = mouseConfig && mouseOpts.area
2165
+ const columnDragOpts = $xeTable.computeColumnDragOpts
2166
+ const scrollbarXToTop = $xeTable.computeScrollbarXToTop
2167
+ const scrollbarYToLeft = $xeTable.computeScrollbarYToLeft
2168
+ const customSimpleMode = $xeTable.computeCustomSimpleMode
2169
+ const showCustomSimpleOutside = customSimpleMode === 'outside'
2170
+ const { isCrossTableDrag } = rowDragOpts
2171
+ const tbOns: {
2172
+ contextmenu: (...args: any[]) => void
2173
+ keydown: (...args: any[]) => void
2174
+ dragover?: (...args: any[]) => void
2175
+ } = {
2176
+ contextmenu: this.contextMenuEvent,
2177
+ keydown: this.keydownEvent
2178
+ }
2179
+ if (isCrossTableDrag && !tableData.length) {
2180
+ tbOns.dragover = $xeTable.handleCrossTableRowDragoverEmptyEvent
2181
+ }
2182
+ return h('div', {
2183
+ ref: 'refElem',
2184
+ class: ['vxe-table', 'vxe-table--render-default', `tid_${xID}`, `border--${tableBorder}`, `sx-pos--${scrollbarXToTop ? 'top' : 'bottom'}`, `sy-pos--${scrollbarYToLeft ? 'left' : 'right'}`, {
2185
+ [`size--${vSize}`]: vSize,
2186
+ [`valid-msg--${validOpts.msgMode}`]: !!editRules,
2187
+ 'vxe-editable': !!editConfig,
2188
+ 'old-cell-valid': editRules && getConfig().cellVaildMode === 'obsolete',
2189
+ 'cell--highlight': highlightCell,
2190
+ 'cell--selected': mouseConfig && mouseOpts.selected,
2191
+ 'cell--area': isArea,
2192
+ 'header-cell--area': isArea && areaOpts.selectCellByHeader,
2193
+ 'body-cell--area': isArea && areaOpts.selectCellByBody,
2194
+ 'row--highlight': rowOpts.isHover || highlightHoverRow,
2195
+ 'column--highlight': columnOpts.isHover || highlightHoverColumn,
2196
+ 'checkbox--range': checkboxOpts.range,
2197
+ 'col--drag-cell': columnOpts.drag && columnDragOpts.trigger === 'cell',
2198
+ 'is--header': showHeader,
2199
+ 'not--header': !showHeader,
2200
+ 'is--footer': showFooter,
2201
+ 'not--footer': !showFooter,
2202
+ 'is--group': isGroup,
2203
+ 'is-row-group': isRowGroupStatus,
2204
+ 'is--tree-line': treeConfig && (treeOpts.showLine || treeOpts.line),
2205
+ 'is--fixed-left': leftList.length,
2206
+ 'is--fixed-right': rightList.length,
2207
+ 'is--animat': !!props.animat,
2208
+ 'is--round': props.round,
2209
+ 'is--stripe': !treeConfig && stripe,
2210
+ 'is--loading': currLoading,
2211
+ 'is--empty': !currLoading && !tableData.length,
2212
+ 'is--scroll-y': overflowY,
2213
+ 'not--scroll-y': !overflowY,
2214
+ 'is--scroll-x': overflowX,
2215
+ 'not--scroll-x': !overflowX,
2216
+ 'is--virtual-x': scrollXLoad,
2217
+ 'is--virtual-y': scrollYLoad
2218
+ }],
2219
+ style: tableStyle,
2220
+ attrs: {
2221
+ spellcheck: false
2222
+ },
2223
+ on: tbOns
2224
+ }, [
2225
+ /**
2226
+ * 隐藏列
2227
+ */
2228
+ h('div', {
2229
+ class: 'vxe-table-slots',
2230
+ ref: 'hideColumn'
2231
+ }, this.$slots.default),
2232
+ h('div', {
2233
+ ref: 'refVarElem',
2234
+ class: 'vxe-table-vars'
2235
+ }, [
2236
+ h('div', {
2237
+ class: 'vxe-table-var-default'
2238
+ }),
2239
+ h('div', {
2240
+ class: 'vxe-table-var-medium'
2241
+ }),
2242
+ h('div', {
2243
+ class: 'vxe-table-var-small'
2244
+ }),
2245
+ h('div', {
2246
+ class: 'vxe-table-var-mini'
2247
+ })
2248
+ ]),
2249
+ h('div', {
2250
+ key: 'tw',
2251
+ class: 'vxe-table--render-wrapper'
2252
+ }, scrollbarXToTop
2253
+ ? [
2254
+ renderScrollX(h, $xeTable),
2255
+ renderBody(h, $xeTable)
2256
+ ]
2257
+ : [
2258
+ renderBody(h, $xeTable),
2259
+ renderScrollX(h, $xeTable)
2260
+ ]),
2261
+ /**
2262
+ * 空数据
2263
+ */
2264
+ h('div', {
2265
+ key: 'tn',
2266
+ ref: 'refEmptyPlaceholder',
2267
+ class: 'vxe-table--empty-place-wrapper',
2268
+ attrs: {
2269
+ xid: xID
2270
+ }
2271
+ }, [
2272
+ h('div', {
2273
+ class: 'vxe-table--empty-placeholder'
2274
+ }, [
2275
+ h('div', {
2276
+ class: 'vxe-table--empty-content'
2277
+ }, renderEmptyBody(h, $xeTable))
2278
+ ])
2279
+ ]),
2280
+ /**
2281
+ * 边框线
2282
+ */
2283
+ h('div', {
2284
+ key: 'tl',
2285
+ class: 'vxe-table--border-line'
2286
+ }),
2287
+ /**
2288
+ * 列宽线
2289
+ */
2290
+ h('div', {
2291
+ key: 'tcl',
2292
+ ref: 'refColResizeBar',
2293
+ class: 'vxe-table--resizable-col-bar'
2294
+ }, resizableOpts.showDragTip
2295
+ ? [
2296
+ h('div', {
2297
+ ref: 'refColResizeTip',
2298
+ class: 'vxe-table--resizable-number-tip'
2299
+ })
2300
+ ]
2301
+ : []),
2302
+ h('div', {
2303
+ key: 'ttw'
2304
+ }, [
2305
+ h('div', {
2306
+ ref: 'refTeleportWrapper'
2307
+ }, [
2308
+ /**
2309
+ * 行高线
2310
+ */
2311
+ h('div', {
2312
+ key: 'trl',
2313
+ ref: 'refRowResizeBar',
2314
+ class: 'vxe-table--resizable-row-bar'
2315
+ }, resizableOpts.showDragTip
2316
+ ? [
2317
+ h('div', {
2318
+ class: 'vxe-table--resizable-number-tip'
2319
+ })
2320
+ ]
2321
+ : []),
2322
+ /**
2323
+ * 自定义列
2324
+ */
2325
+ !showCustomSimpleOutside && initStore.custom
2326
+ ? h(TableCustomPanelComponent, {
2327
+ key: 'cs',
2328
+ ref: 'refTableCustom',
2329
+ props: {
2330
+ customStore
2331
+ }
2332
+ })
2333
+ : renderEmptyElement($xeTable),
2334
+ /**
2335
+ * 加载中
2336
+ */
2337
+ VxeUILoadingComponent
2338
+ ? h(VxeUILoadingComponent, {
2339
+ key: 'lg',
2340
+ class: 'vxe-table--loading',
2341
+ props: {
2342
+ value: currLoading,
2343
+ icon: loadingOpts.icon,
2344
+ text: loadingOpts.text
2345
+ },
2346
+ scopedSlots: loadingSlot
2347
+ ? {
2348
+ default: () => $xeTable.callSlot(loadingSlot, { $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, loading: currLoading }, h)
2349
+ }
2350
+ : {}
2351
+ })
2352
+ : loadingSlot
2353
+ ? h('div', {
2354
+ class: ['vxe-loading--custom-wrapper', {
2355
+ 'is--visible': currLoading
2356
+ }]
2357
+ }, $xeTable.callSlot(loadingSlot, { $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, loading: currLoading }, h))
2358
+ : renderEmptyElement($xeTable),
2359
+ /**
2360
+ * 拖拽提示
2361
+ */
2362
+ renderDragTip(h, this)
2363
+ ])
2364
+ ]),
2365
+ h('div', {
2366
+ key: 'tpw'
2367
+ }, [
2368
+ h('div', {
2369
+ ref: 'refPopupWrapperElem'
2370
+ }, [
2371
+ /**
2372
+ * 自定义列
2373
+ */
2374
+ showCustomSimpleOutside && initStore.custom
2375
+ ? h(TableCustomPanelComponent, {
2376
+ key: 'cs',
2377
+ ref: 'refTableCustom',
2378
+ props: {
2379
+ customStore
2380
+ }
2381
+ })
2382
+ : renderEmptyElement($xeTable),
2383
+ /**
2384
+ * 筛选
2385
+ */
2386
+ initStore.filter
2387
+ ? h(TableFilterPanelComponent, {
2388
+ key: 'tf',
2389
+ ref: 'refTableFilter',
2390
+ props: {
2391
+ filterStore
2392
+ }
2393
+ })
2394
+ : renderEmptyElement($xeTable),
2395
+ /**
2396
+ * 快捷菜单
2397
+ */
2398
+ isContentMenu
2399
+ ? h(TableMenuPanelComponent, {
2400
+ key: 'tm',
2401
+ ref: 'refTableMenu'
2402
+ })
2403
+ : renderEmptyElement($xeTable)
2404
+ ])
2405
+ ]),
2406
+ /**
2407
+ * 导入
2408
+ */
2409
+ initStore.import && this.importConfig
2410
+ ? h(TableImportPanelComponent, {
2411
+ key: 'it',
2412
+ props: {
2413
+ defaultOptions: this.importParams,
2414
+ storeData: this.importStore
2415
+ }
2416
+ })
2417
+ : renderEmptyElement($xeTable),
2418
+ /**
2419
+ * 导出
2420
+ */
2421
+ initStore.export && (this.exportConfig || this.printConfig)
2422
+ ? h(TableExportPanelComponent, {
2423
+ key: 'et',
2424
+ props: {
2425
+ defaultOptions: this.exportParams,
2426
+ storeData: this.exportStore
2427
+ }
2428
+ })
2429
+ : renderEmptyElement($xeTable),
2430
+ h('div', {}, [
2431
+ /**
2432
+ * 提示相关
2433
+ */
2434
+ VxeUITooltipComponent
2435
+ ? h(VxeUITooltipComponent, {
2436
+ key: 'ctp',
2437
+ ref: 'refCommTooltip',
2438
+ props: {
2439
+ isArrow: false,
2440
+ enterable: false
2441
+ }
2442
+ })
2443
+ : renderEmptyElement($xeTable),
2444
+ /**
2445
+ * 工具提示
2446
+ */
2447
+ VxeUITooltipComponent
2448
+ ? h(VxeUITooltipComponent, {
2449
+ key: 'btp',
2450
+ ref: 'refTooltip',
2451
+ props: {
2452
+ theme: tableTipConfig.theme,
2453
+ enterable: tableTipConfig.enterable,
2454
+ enterDelay: tableTipConfig.enterDelay,
2455
+ leaveDelay: tableTipConfig.leaveDelay,
2456
+ useHTML: tableTipConfig.useHTML,
2457
+ width: tableTipConfig.width,
2458
+ height: tableTipConfig.height,
2459
+ minWidth: tableTipConfig.minWidth,
2460
+ minHeight: tableTipConfig.minHeight,
2461
+ maxWidth: tableTipConfig.maxWidth,
2462
+ maxHeight: tableTipConfig.maxHeight
2463
+ },
2464
+ scopedSlots: currTooltipSlot
2465
+ ? {
2466
+ content: () => {
2467
+ const { type, row, column, content: tooltipContent } = tooltipStore
2468
+ if (currTooltipSlot) {
2469
+ if (column && type === 'header') {
2470
+ return h('div', {
2471
+ key: type
2472
+ }, currTooltipSlot({ column, tooltipContent, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }))
2473
+ }
2474
+ if (row && column && type === 'body') {
2475
+ return h('div', {
2476
+ key: type
2477
+ }, currTooltipSlot({ row, column, tooltipContent, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }))
2478
+ }
2479
+ if (row && column && type === 'footer') {
2480
+ return h('div', {
2481
+ key: type
2482
+ }, currTooltipSlot({ row, column, tooltipContent, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }))
2483
+ }
2484
+ }
2485
+ return renderEmptyElement($xeTable)
2486
+ }
2487
+ }
2488
+ : {}
2489
+ })
2490
+ : renderEmptyElement($xeTable),
2491
+ /**
2492
+ * 校验提示
2493
+ */
2494
+ VxeUITooltipComponent && this.editRules && validOpts.showErrorMessage && (validOpts.message === 'default' ? !height : validOpts.message === 'tooltip')
2495
+ ? h(VxeUITooltipComponent, {
2496
+ key: 'vtp',
2497
+ ref: 'refValidTooltip',
2498
+ class: [{
2499
+ 'old-cell-valid': editRules && getConfig().cellVaildMode === 'obsolete'
2500
+ }, 'vxe-table--valid-error'],
2501
+ props: {
2502
+ theme: validTipConfig.theme,
2503
+ enterable: validTipConfig.enterable,
2504
+ enterDelay: validTipConfig.enterDelay,
2505
+ leaveDelay: validTipConfig.leaveDelay
2506
+ }
2507
+ })
2508
+ : renderEmptyElement($xeTable)
2509
+ ])
2510
+ ])
2511
+ },
2512
+ methods
2513
+ } as any