vxe-table 4.18.5 → 4.18.7

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 (145) hide show
  1. package/LICENSE +20 -20
  2. package/README.en.md +118 -118
  3. package/README.ja-JP.md +117 -117
  4. package/README.md +268 -268
  5. package/README.zh-TW.md +117 -117
  6. package/es/style.css +1 -1
  7. package/es/table/src/table.js +54 -0
  8. package/es/table/src/util.js +3 -4
  9. package/es/table/style.css +48 -18
  10. package/es/ui/index.js +1 -1
  11. package/es/ui/src/log.js +1 -1
  12. package/es/vxe-table/style.css +48 -18
  13. package/lib/index.common.js +1 -2
  14. package/lib/index.umd.js +2832 -2732
  15. package/lib/index.umd.min.js +1 -1
  16. package/lib/style.css +1 -1
  17. package/lib/table/src/table.js +5 -4
  18. package/lib/table/src/table.min.js +1 -1
  19. package/lib/table/src/util.js +4 -6
  20. package/lib/table/src/util.min.js +1 -1
  21. package/lib/table/style/style.css +48 -18
  22. package/lib/ui/index.js +1 -1
  23. package/lib/ui/index.min.js +1 -1
  24. package/lib/ui/src/log.js +1 -1
  25. package/lib/ui/src/log.min.js +1 -1
  26. package/lib/v-x-e-table/index.js +1 -2
  27. package/lib/v-x-e-table/index.min.js +1 -1
  28. package/lib/vxe-colgroup/index.js +1 -2
  29. package/lib/vxe-colgroup/index.min.js +1 -1
  30. package/lib/vxe-column/index.js +1 -2
  31. package/lib/vxe-column/index.min.js +1 -1
  32. package/lib/vxe-grid/index.js +1 -2
  33. package/lib/vxe-grid/index.min.js +1 -1
  34. package/lib/vxe-table/index.js +1 -2
  35. package/lib/vxe-table/index.min.js +1 -1
  36. package/lib/vxe-table/style/style.css +48 -18
  37. package/lib/vxe-toolbar/index.js +1 -2
  38. package/lib/vxe-toolbar/index.min.js +1 -1
  39. package/lib/vxe-ui/index.js +1 -2
  40. package/lib/vxe-ui/index.min.js +1 -1
  41. package/lib/vxe-v-x-e-table/index.js +1 -2
  42. package/lib/vxe-v-x-e-table/index.min.js +1 -1
  43. package/package.json +91 -91
  44. package/packages/colgroup/index.ts +22 -22
  45. package/packages/column/index.ts +22 -22
  46. package/packages/components.ts +43 -43
  47. package/packages/grid/index.ts +18 -18
  48. package/packages/grid/src/emits.ts +19 -19
  49. package/packages/grid/src/grid.ts +1768 -1768
  50. package/packages/grid/src/props.ts +23 -23
  51. package/packages/index.ts +4 -4
  52. package/packages/locale/lang/ar-EG.ts +832 -832
  53. package/packages/locale/lang/de-DE.ts +832 -832
  54. package/packages/locale/lang/en-US.ts +832 -832
  55. package/packages/locale/lang/es-ES.ts +832 -832
  56. package/packages/locale/lang/fr-FR.ts +832 -832
  57. package/packages/locale/lang/hu-HU.ts +832 -832
  58. package/packages/locale/lang/hy-AM.ts +832 -832
  59. package/packages/locale/lang/id-ID.ts +832 -832
  60. package/packages/locale/lang/it-IT.ts +832 -832
  61. package/packages/locale/lang/ja-JP.ts +832 -832
  62. package/packages/locale/lang/ko-KR.ts +832 -832
  63. package/packages/locale/lang/ms-MY.ts +832 -832
  64. package/packages/locale/lang/nb-NO.ts +832 -832
  65. package/packages/locale/lang/pt-BR.ts +832 -832
  66. package/packages/locale/lang/ru-RU.ts +832 -832
  67. package/packages/locale/lang/th-TH.ts +832 -832
  68. package/packages/locale/lang/ug-CN.ts +832 -832
  69. package/packages/locale/lang/uk-UA.ts +832 -832
  70. package/packages/locale/lang/uz-UZ.ts +832 -832
  71. package/packages/locale/lang/vi-VN.ts +832 -832
  72. package/packages/locale/lang/zh-CHT.ts +832 -832
  73. package/packages/locale/lang/zh-CN.ts +832 -832
  74. package/packages/locale/lang/zh-HK.ts +3 -3
  75. package/packages/locale/lang/zh-MO.ts +3 -3
  76. package/packages/locale/lang/zh-TC.ts +3 -3
  77. package/packages/locale/lang/zh-TW.ts +3 -3
  78. package/packages/table/index.ts +26 -26
  79. package/packages/table/module/custom/hook.ts +359 -359
  80. package/packages/table/module/custom/panel.ts +1331 -1331
  81. package/packages/table/module/edit/hook.ts +1032 -1032
  82. package/packages/table/module/export/export-panel.ts +567 -567
  83. package/packages/table/module/export/hook.ts +1654 -1654
  84. package/packages/table/module/export/import-panel.ts +266 -266
  85. package/packages/table/module/export/util.ts +24 -24
  86. package/packages/table/module/filter/hook.ts +468 -468
  87. package/packages/table/module/filter/panel.ts +301 -301
  88. package/packages/table/module/keyboard/hook.ts +495 -495
  89. package/packages/table/module/menu/hook.ts +325 -325
  90. package/packages/table/module/menu/panel.ts +201 -201
  91. package/packages/table/module/validator/hook.ts +631 -631
  92. package/packages/table/render/index.ts +1440 -1440
  93. package/packages/table/src/body.ts +932 -932
  94. package/packages/table/src/cell.ts +1290 -1290
  95. package/packages/table/src/column.ts +190 -190
  96. package/packages/table/src/columnInfo.ts +225 -225
  97. package/packages/table/src/emits.ts +123 -123
  98. package/packages/table/src/footer.ts +368 -368
  99. package/packages/table/src/group.ts +59 -59
  100. package/packages/table/src/header.ts +559 -559
  101. package/packages/table/src/props.ts +324 -324
  102. package/packages/table/src/store.ts +14 -14
  103. package/packages/table/src/table.ts +14004 -13947
  104. package/packages/table/src/use/cell-view.ts +44 -44
  105. package/packages/table/src/use/index.ts +1 -1
  106. package/packages/table/src/util.ts +1064 -1064
  107. package/packages/toolbar/index.ts +18 -18
  108. package/packages/toolbar/src/toolbar.ts +701 -701
  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 +236 -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 +55 -55
  116. package/packages/v-x-e-table/index.d.ts +4 -4
  117. package/packages/v-x-e-table/index.ts +4 -4
  118. package/styles/all.scss +7 -7
  119. package/styles/base.scss +16 -16
  120. package/styles/components/grid.scss +89 -89
  121. package/styles/components/icon.scss +225 -225
  122. package/styles/components/old-icon.scss +715 -715
  123. package/styles/components/table-module/all.scss +6 -6
  124. package/styles/components/table-module/custom.scss +527 -527
  125. package/styles/components/table-module/export.scss +130 -130
  126. package/styles/components/table-module/filter.scss +130 -130
  127. package/styles/components/table-module/menu.scss +81 -81
  128. package/styles/components/table.scss +2679 -2679
  129. package/styles/components/toolbar.scss +119 -119
  130. package/styles/default.scss +2 -2
  131. package/styles/helpers/baseMixin.scss +95 -95
  132. package/styles/index.scss +4 -4
  133. package/styles/modules.scss +5 -5
  134. package/styles/theme/base.scss +93 -93
  135. package/styles/theme/dark.scss +49 -49
  136. package/styles/theme/light.scss +44 -44
  137. package/styles/variable.scss +43 -43
  138. package/types/all.d.ts +37 -37
  139. package/types/index.d.ts +4 -4
  140. /package/es/{iconfont.1773710736571.ttf → iconfont.1773991907408.ttf} +0 -0
  141. /package/es/{iconfont.1773710736571.woff → iconfont.1773991907408.woff} +0 -0
  142. /package/es/{iconfont.1773710736571.woff2 → iconfont.1773991907408.woff2} +0 -0
  143. /package/lib/{iconfont.1773710736571.ttf → iconfont.1773991907408.ttf} +0 -0
  144. /package/lib/{iconfont.1773710736571.woff → iconfont.1773991907408.woff} +0 -0
  145. /package/lib/{iconfont.1773710736571.woff2 → iconfont.1773991907408.woff2} +0 -0
@@ -1,932 +1,932 @@
1
- import { h, ref, Ref, PropType, inject, nextTick, onMounted, onUnmounted } from 'vue'
2
- import { defineVxeComponent } from '../../ui/src/comp'
3
- import XEUtils from 'xe-utils'
4
- import { VxeUI } from '../../ui'
5
- import { getRowid, createHandleGetRowId, getCellRestHeight } from './util'
6
- import { updateCellTitle, getPropClass } from '../../ui/src/dom'
7
- import { isEnableConf } from '../../ui/src/utils'
8
- import { getSlotVNs } from '../../ui/src/vn'
9
-
10
- import type { VxeTablePrivateMethods, VxeTableConstructor, VxeTableDefines, VxeComponentSlotType } from '../../../types'
11
-
12
- const { getI18n, renderer, renderEmptyElement } = VxeUI
13
-
14
- const sourceType = 'table'
15
- const renderType = 'body'
16
-
17
- export default defineVxeComponent({
18
- name: 'VxeTableBody',
19
- props: {
20
- tableData: Array as PropType<any[]>,
21
- tableColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
22
- fixedColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
23
- fixedType: {
24
- type: String as PropType<'right' | 'left' | ''>,
25
- default: ''
26
- }
27
- },
28
- setup (props) {
29
- const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTablePrivateMethods)
30
-
31
- const { xID, props: tableProps, context: tableContext, reactData: tableReactData, internalData: tableInternalData } = $xeTable
32
- const { computeEditOpts, computeMouseOpts, computeCellOffsetWidth, computeAreaOpts, computeDefaultRowHeight, computeEmptyOpts, computeTooltipOpts, computeRadioOpts, computeExpandOpts, computeTreeOpts, computeCheckboxOpts, computeCellOpts, computeValidOpts, computeRowOpts, computeColumnOpts, computeRowDragOpts, computeResizableOpts, computeVirtualXOpts, computeVirtualYOpts, computeIsBodyRenderOptimize } = $xeTable.getComputeMaps()
33
-
34
- const refElem = ref() as Ref<HTMLDivElement>
35
- const refBodyScroll = ref() as Ref<HTMLDivElement>
36
- const refBodyTable = ref() as Ref<HTMLTableElement>
37
- const refBodyColgroup = ref() as Ref<HTMLTableColElement>
38
- const refBodyTBody = ref() as Ref<HTMLTableSectionElement>
39
- const refBodyXSpace = ref() as Ref<HTMLDivElement>
40
- const refBodyYSpace = ref() as Ref<HTMLDivElement>
41
- const refBodyEmptyBlock = ref() as Ref<HTMLDivElement>
42
-
43
- // 滚动、拖动过程中不需要触发
44
- const isVMScrollProcess = () => {
45
- const { delayHover } = tableProps
46
- const { isDragResize } = tableReactData
47
- const { lastSTime } = tableInternalData
48
- return !!(isDragResize || (lastSTime && Date.now() < lastSTime + (delayHover as number)))
49
- }
50
-
51
- const renderLine = (rowid: string, params: VxeTableDefines.CellRenderBodyParams, cellHeight: number): VxeComponentSlotType[] => {
52
- const { column } = params
53
- const { treeConfig } = tableProps
54
- const cellOpts = computeCellOpts.value
55
- const rowOpts = computeRowOpts.value
56
- const defaultRowHeight = computeDefaultRowHeight.value
57
- const treeOpts = computeTreeOpts.value
58
- const { slots, treeNode } = column
59
- const { fullAllDataRowIdData } = tableInternalData
60
- if (treeConfig && treeNode && (treeOpts.showLine || treeOpts.line)) {
61
- if (slots && (slots as any).line) {
62
- return $xeTable.callSlot((slots as any).line, params)
63
- }
64
- const rowRest = fullAllDataRowIdData[rowid]
65
- let rLevel = 0
66
- let prevRow = null
67
- let parentRow = null
68
- let lineHeight = ''
69
- if (rowRest) {
70
- rLevel = rowRest.level
71
- prevRow = rowRest.items[rowRest.treeIndex - 1]
72
- parentRow = rowRest.parent
73
- }
74
- if (!rLevel && !treeOpts.showRootLine) {
75
- return []
76
- }
77
- if (prevRow) {
78
- const prevRowRest = fullAllDataRowIdData[getRowid($xeTable, prevRow)] || {}
79
- lineHeight = `${prevRowRest.lineHeight || 0}px`
80
- } else if (rLevel && parentRow) {
81
- const parentRowRest = fullAllDataRowIdData[getRowid($xeTable, parentRow)] || {}
82
- lineHeight = `calc(-1em + ${Math.floor(cellHeight / 2 + getCellRestHeight(parentRowRest, cellOpts, rowOpts, defaultRowHeight) / 2)}px)`
83
- }
84
- return [
85
- h('div', {
86
- key: 'tl',
87
- class: 'vxe-tree--line-wrapper'
88
- }, [
89
- h('div', {
90
- class: 'vxe-tree--line',
91
- style: {
92
- height: lineHeight,
93
- bottom: `-${Math.floor(cellHeight / 2)}px`,
94
- left: `calc(${(rLevel * treeOpts.indent)}px + 1em)`
95
- }
96
- })
97
- ])
98
- ]
99
- }
100
- return []
101
- }
102
-
103
- /**
104
- * 渲染列
105
- */
106
- const renderTdColumn = (
107
- seq: number | string,
108
- rowid: string,
109
- fixedType: 'left' | 'right' | '',
110
- isOptimizeMode: boolean,
111
- rowLevel: number,
112
- row: any,
113
- rowIndex: number,
114
- $rowIndex: number,
115
- _rowIndex: number,
116
- column: VxeTableDefines.ColumnInfo,
117
- $columnIndex: number,
118
- columns: VxeTableDefines.ColumnInfo[],
119
- items: any[]
120
- ) => {
121
- const $xeGrid = $xeTable.xeGrid
122
- const $xeGantt = $xeTable.xeGantt
123
-
124
- const { columnKey, resizable: allResizable, showOverflow: allShowOverflow, border, height, treeConfig, cellClassName: allCellClassName, cellStyle, align: allAlign, spanMethod, mouseConfig, editConfig, editRules, tooltipConfig, padding: allPadding } = tableProps
125
- const { tableData, tableColumn, dragRow, overflowX, overflowY, currentColumn, scrollXLoad, scrollYLoad, mergeBodyFlag, calcCellHeightFlag, resizeHeightFlag, resizeWidthFlag, editStore, isAllOverflow, validErrorMaps } = tableReactData
126
- const { fullAllDataRowIdData, fullColumnIdData, mergeBodyCellMaps, visibleColumn, afterFullData, mergeBodyList, scrollXStore, scrollYStore, keepUpdateFieldMaps } = tableInternalData
127
- const cellOpts = computeCellOpts.value
128
- const validOpts = computeValidOpts.value
129
- const checkboxOpts = computeCheckboxOpts.value
130
- const editOpts = computeEditOpts.value
131
- const tooltipOpts = computeTooltipOpts.value
132
- const resizableOpts = computeResizableOpts.value
133
- const virtualXOpts = computeVirtualXOpts.value
134
- const virtualYOpts = computeVirtualYOpts.value
135
- const { isAllColumnDrag, isAllRowDrag } = resizableOpts
136
- const rowOpts = computeRowOpts.value
137
- const rowDragOpts = computeRowDragOpts.value
138
- const defaultRowHeight = computeDefaultRowHeight.value
139
- const customCellHeight = calcCellHeightFlag ? (cellOpts.height || rowOpts.height) : 0
140
- const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = rowDragOpts
141
- const columnOpts = computeColumnOpts.value
142
- const mouseOpts = computeMouseOpts.value
143
- const areaOpts = computeAreaOpts.value
144
- const cellOffsetWidth = computeCellOffsetWidth.value
145
- const { selectCellToRow } = areaOpts
146
- const { field, type, cellRender, editRender, align, showOverflow, className, treeNode, rowResize, padding, verticalAlign, slots } = column
147
- const { verticalAlign: allVerticalAlign } = cellOpts
148
- const { actived } = editStore
149
- const rowRest = fullAllDataRowIdData[rowid] || {}
150
- const colid = column.id
151
- const colRest = fullColumnIdData[colid] || {}
152
- const renderOpts = editRender || cellRender
153
- const compConf = renderOpts ? renderer.get(renderOpts.name) : null
154
- const compCellClassName = compConf ? (compConf.tableCellClassName || compConf.cellClassName) : null
155
- const compCellStyle = compConf ? (compConf.tableCellStyle || compConf.cellStyle) : ''
156
- const showAllTip = tooltipOpts.showAll
157
- const columnIndex = colRest.index
158
- const _columnIndex = colRest._index
159
- const isEdit = isEnableConf(editRender)
160
- const resizeHeight = resizeHeightFlag ? rowRest.resizeHeight : 0
161
- let fixedHiddenColumn = overflowX && (fixedType ? column.fixed !== fixedType : !!column.fixed)
162
- const isCellPadding = XEUtils.eqNull(padding) ? (allPadding === null ? cellOpts.padding : allPadding) : padding
163
- const cellOverflow = XEUtils.eqNull(showOverflow) ? allShowOverflow : showOverflow
164
- const showEllipsis = cellOverflow === 'ellipsis'
165
- const showTitle = cellOverflow === 'title'
166
- const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
167
- const hasEllipsis = isAllOverflow || showTitle || showTooltip || showEllipsis
168
- const showResizable = (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
169
- const isCsHeight = !!customCellHeight
170
- const isRsHeight = resizeHeight > 0
171
- let isDirty
172
- const tdOns: any = {}
173
- const cellAlign = align || (compConf ? compConf.tableCellAlign : '') || allAlign
174
- const cellVerticalAlign = XEUtils.eqNull(verticalAlign) ? allVerticalAlign : verticalAlign
175
- const errorValidItem = validErrorMaps[`${rowid}:${colid}`]
176
- const showValidTip = editRules && validOpts.showErrorMessage && (validOpts.message === 'default' ? (height || tableData.length > 1) : validOpts.message === 'inline')
177
- const tdAttrs: any = { colid }
178
- const cellParams: VxeTableDefines.CellRenderBodyParams & {
179
- $table: VxeTableConstructor<any> & VxeTablePrivateMethods
180
- } = {
181
- $table: $xeTable,
182
- $grid: $xeGrid,
183
- $gantt: $xeGantt,
184
- isEdit: false,
185
- seq,
186
- rowid,
187
- row,
188
- rowIndex,
189
- $rowIndex,
190
- _rowIndex,
191
- column,
192
- columnIndex,
193
- $columnIndex,
194
- _columnIndex,
195
- fixed: fixedType,
196
- source: sourceType,
197
- type: renderType,
198
- isHidden: !!fixedHiddenColumn,
199
- level: rowLevel,
200
- visibleData: afterFullData,
201
- data: tableData,
202
- items
203
- }
204
- let isRowDragCell = false
205
- let isDisabledDrag = false
206
- if (rowOpts.drag) {
207
- isRowDragCell = rowDragOpts.trigger === 'row' || (column.dragSort && rowDragOpts.trigger === 'cell')
208
- }
209
- if (isRowDragCell) {
210
- isDisabledDrag = !!(dragDisabledMethod && dragDisabledMethod(cellParams))
211
- }
212
- // hover 进入事件
213
- if (showTitle || showTooltip || showAllTip || tooltipConfig) {
214
- tdOns.onMouseover = (evnt: MouseEvent) => {
215
- if (!isVMScrollProcess()) {
216
- if (showTitle) {
217
- updateCellTitle(evnt.currentTarget, column)
218
- } else if (showTooltip || showAllTip) {
219
- // 如果配置了显示 tooltip
220
- $xeTable.triggerBodyTooltipEvent(evnt, cellParams)
221
- }
222
- }
223
- $xeTable.dispatchEvent('cell-mouseenter', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
224
- }
225
- }
226
- // hover 退出事件
227
- if (showTooltip || showAllTip || tooltipConfig) {
228
- tdOns.onMouseleave = (evnt: MouseEvent) => {
229
- if (!isVMScrollProcess()) {
230
- if (showTooltip || showAllTip) {
231
- $xeTable.handleTargetLeaveEvent(evnt)
232
- }
233
- }
234
- $xeTable.dispatchEvent('cell-mouseleave', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
235
- }
236
- }
237
- // 按下事件处理
238
- if (isRowDragCell || checkboxOpts.range || mouseConfig) {
239
- tdOns.onMousedown = (evnt: MouseEvent) => {
240
- $xeTable.triggerCellMousedownEvent(evnt, cellParams)
241
- }
242
- }
243
- // 拖拽列事件
244
- if (isRowDragCell) {
245
- tdOns.onMouseup = $xeTable.triggerCellMouseupEvent
246
- }
247
- // 点击事件处理
248
- tdOns.onClick = (evnt: MouseEvent) => {
249
- $xeTable.triggerCellClickEvent(evnt, cellParams)
250
- }
251
- // 双击事件处理
252
- tdOns.onDblclick = (evnt: MouseEvent) => {
253
- $xeTable.triggerCellDblclickEvent(evnt, cellParams)
254
- }
255
- let isMergeCell = false
256
- let mergeColspan = 1
257
- let mergeRowspan = 1
258
- // 合并行或列
259
- if (mergeBodyFlag && mergeBodyList.length) {
260
- const spanRest = mergeBodyCellMaps[`${_rowIndex}:${_columnIndex}`]
261
- if (spanRest) {
262
- const { rowspan, colspan } = spanRest
263
- if (!rowspan || !colspan) {
264
- return renderEmptyElement($xeTable)
265
- }
266
- if (rowspan > 1) {
267
- isMergeCell = true
268
- mergeRowspan = rowspan
269
- tdAttrs.rowspan = rowspan
270
- }
271
- if (colspan > 1) {
272
- isMergeCell = true
273
- mergeColspan = colspan
274
- tdAttrs.colspan = colspan
275
- }
276
- }
277
- } else if (spanMethod) {
278
- // 自定义合并行或列的方法
279
- const { rowspan = 1, colspan = 1 } = spanMethod(cellParams) || {}
280
- if (!rowspan || !colspan) {
281
- return renderEmptyElement($xeTable)
282
- }
283
- if (rowspan > 1) {
284
- isMergeCell = true
285
- mergeRowspan = rowspan
286
- tdAttrs.rowspan = rowspan
287
- }
288
- if (colspan > 1) {
289
- isMergeCell = true
290
- mergeColspan = colspan
291
- tdAttrs.colspan = colspan
292
- }
293
- }
294
- // 如果被合并不可隐藏
295
- if (fixedHiddenColumn && isMergeCell) {
296
- if (tdAttrs.colspan > 1 || tdAttrs.rowspan > 1) {
297
- fixedHiddenColumn = false
298
- }
299
- }
300
- // 如果编辑列开启显示状态
301
- if (!fixedHiddenColumn && editConfig && (editOpts.showStatus || editOpts.showUpdateStatus) && keepUpdateFieldMaps[field]) {
302
- isDirty = $xeTable.isUpdateByRow(row, field)
303
- }
304
-
305
- const isVNAutoHeight = !hasEllipsis && (scrollYLoad || scrollXLoad)
306
- let cellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
307
-
308
- const isLastColumn = $columnIndex === columns.length - 1
309
- const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
310
-
311
- let isVNPreEmptyStatus = false
312
- if (!isMergeCell) {
313
- if (!dragRow || getRowid($xeTable, dragRow) !== rowid) {
314
- if (overflowY && scrollYLoad && tableData.length > 16 && !treeConfig && !virtualYOpts.immediate && (_rowIndex < scrollYStore.visibleStartIndex - scrollYStore.preloadSize || _rowIndex > scrollYStore.visibleEndIndex + scrollYStore.preloadSize)) {
315
- isVNPreEmptyStatus = true
316
- } else if (overflowX && scrollXLoad && tableColumn.length > 10 && !virtualXOpts.immediate && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
317
- isVNPreEmptyStatus = true
318
- }
319
- }
320
- }
321
-
322
- if (mergeRowspan > 1) {
323
- const mEndRow = afterFullData[_rowIndex + mergeRowspan - 1]
324
- if (mEndRow) {
325
- const meRowRest = fullAllDataRowIdData[getRowid($xeTable, mEndRow)]
326
- if (meRowRest) {
327
- cellHeight += meRowRest.oTop + getCellRestHeight(meRowRest, cellOpts, rowOpts, defaultRowHeight) - rowRest.oTop - getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
328
- }
329
- }
330
- }
331
-
332
- const tcStyle: Record<string, string> = {}
333
- if (hasEllipsis && resizeWidthFlag) {
334
- let mergeColWidth = 0
335
- if (mergeColspan > 1) {
336
- for (let index = 1; index < mergeColspan; index++) {
337
- const nextColumn = visibleColumn[columnIndex + index]
338
- if (nextColumn) {
339
- mergeColWidth += nextColumn.renderWidth
340
- }
341
- }
342
- }
343
- tcStyle.width = `${column.renderWidth + mergeColWidth - cellOffsetWidth}px`
344
- }
345
- if (scrollYLoad || scrollXLoad || hasEllipsis || isCsHeight || isRsHeight) {
346
- tcStyle.height = `${cellHeight}px`
347
- } else {
348
- tcStyle.minHeight = `${cellHeight}px`
349
- }
350
-
351
- const tdVNs: VxeComponentSlotType[] = []
352
- if (fixedHiddenColumn && isAllOverflow) {
353
- tdVNs.push(
354
- h('div', {
355
- key: 'tc',
356
- class: ['vxe-cell', {
357
- 'c--title': showTitle,
358
- 'c--tooltip': showTooltip,
359
- 'c--ellipsis': showEllipsis
360
- }],
361
- style: tcStyle
362
- })
363
- )
364
- } else {
365
- // 渲染单元格
366
- if (treeConfig) {
367
- tdVNs.push(...renderLine(rowid, cellParams, cellHeight))
368
- }
369
- tdVNs.push(
370
- h('div', {
371
- key: 'tc',
372
- class: ['vxe-cell', {
373
- 'c--title': showTitle,
374
- 'c--tooltip': showTooltip,
375
- 'c--ellipsis': showEllipsis
376
- }],
377
- style: tcStyle,
378
- title: showTitle ? $xeTable.getCellLabel(row, column) : null
379
- }, isVNPreEmptyStatus
380
- ? []
381
- : [
382
- h('div', {
383
- colid,
384
- rowid,
385
- class: 'vxe-cell--wrapper vxe-body-cell--wrapper'
386
- }, column.renderCell(cellParams))
387
- ])
388
- )
389
- if (showValidTip && errorValidItem) {
390
- const errRule = errorValidItem.rule
391
- const validSlot = slots ? slots.valid : null
392
- const validParams = { ...cellParams, ...errorValidItem, rule: errorValidItem }
393
- tdVNs.push(
394
- h('div', {
395
- key: 'tcv',
396
- class: ['vxe-cell--valid-error-tip', getPropClass(validOpts.className, validParams)],
397
- style: errRule && errRule.maxWidth
398
- ? {
399
- width: `${errRule.maxWidth}px`
400
- }
401
- : null
402
- }, [
403
- h('div', {
404
- class: `vxe-cell--valid-error-wrapper vxe-cell--valid-error-theme-${validOpts.theme || 'normal'}`
405
- }, [
406
- validSlot
407
- ? $xeTable.callSlot(validSlot, validParams)
408
- : [
409
- h('span', {
410
- class: 'vxe-cell--valid-error-msg'
411
- }, errorValidItem.content)
412
- ]
413
- ])
414
- ])
415
- )
416
- }
417
- }
418
-
419
- let showAreaRowStatus = false
420
- if (mouseConfig && mouseOpts.area && !_columnIndex && selectCellToRow) {
421
- showAreaRowStatus = true
422
- }
423
-
424
- if (!fixedHiddenColumn && showResizable && isAllColumnDrag) {
425
- tdVNs.push(
426
- h('div', {
427
- key: 'tcc',
428
- class: ['vxe-cell--col-resizable', {
429
- 'is--line': !border || border === 'none'
430
- }],
431
- onMousedown: (evnt: MouseEvent) => $xeTable.handleColResizeMousedownEvent(evnt, fixedType, cellParams),
432
- onDblclick: (evnt: MouseEvent) => $xeTable.handleColResizeDblclickEvent(evnt, cellParams)
433
- })
434
- )
435
- }
436
-
437
- if ((rowResize || isAllRowDrag) && rowOpts.resizable) {
438
- tdVNs.push(
439
- h('div', {
440
- key: 'tcr',
441
- class: 'vxe-cell--row-resizable',
442
- onMousedown: (evnt: MouseEvent) => $xeTable.handleRowResizeMousedownEvent(evnt, cellParams),
443
- onDblclick: (evnt: MouseEvent) => $xeTable.handleRowResizeDblclickEvent(evnt, cellParams)
444
- })
445
- )
446
- }
447
-
448
- return h('td', {
449
- class: [
450
- 'vxe-table--column vxe-body--column',
451
- colid,
452
- cellVerticalAlign ? `col--vertical-${cellVerticalAlign}` : '',
453
- cellAlign ? `col--${cellAlign}` : '',
454
- type ? `col--${type}` : '',
455
- {
456
- 'col--last': isLastColumn,
457
- 'col--tree-node': treeNode,
458
- 'col--edit': isEdit,
459
- 'col--ellipsis': hasEllipsis,
460
- 'col--cs-height': isCsHeight,
461
- 'col--rs-height': isRsHeight,
462
- 'col--to-row': showAreaRowStatus,
463
- 'col--auto-height': isVNAutoHeight,
464
- 'fixed--width': !isAutoCellWidth,
465
- 'fixed--hidden': fixedHiddenColumn,
466
- 'is--padding': isCellPadding,
467
- 'is--progress': (fixedHiddenColumn && isAllOverflow) || isVNPreEmptyStatus,
468
- 'is--drag-cell': isRowDragCell && (isCrossDrag || isPeerDrag || !rowLevel),
469
- 'is--drag-disabled': isDisabledDrag,
470
- 'col--dirty': isDirty,
471
- 'col--active': editConfig && isEdit && (actived.row === row && (actived.column === column || editOpts.mode === 'row')),
472
- 'col--valid-error': !!errorValidItem,
473
- 'show--valid-bg': errorValidItem && validOpts.showErrorBackground,
474
- 'col--current': currentColumn === column
475
- },
476
- getPropClass(compCellClassName, cellParams),
477
- getPropClass(className, cellParams),
478
- getPropClass(allCellClassName, cellParams)
479
- ],
480
- key: columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || rowOpts.useKey || columnOpts.drag ? colid : $columnIndex,
481
- ...tdAttrs,
482
- style: Object.assign({}, XEUtils.isFunction(compCellStyle) ? compCellStyle(cellParams) : compCellStyle, XEUtils.isFunction(cellStyle) ? cellStyle(cellParams) : cellStyle),
483
- ...tdOns
484
- }, isOptimizeMode && fixedHiddenColumn ? [] : tdVNs)
485
- }
486
-
487
- const renderRows = (fixedType: 'left' | 'right' | '', isOptimizeMode: boolean, tableData: any[], tableColumn: VxeTableDefines.ColumnInfo[]) => {
488
- const $xeGrid = $xeTable.xeGrid
489
- const $xeGantt = $xeTable.xeGantt
490
-
491
- const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, editConfig, treeConfig } = tableProps
492
- const { hasFixedColumn, treeExpandedFlag, scrollXLoad, scrollYLoad, isAllOverflow, rowExpandedFlag, expandColumn, selectRadioRow, pendingRowFlag, rowExpandHeightFlag, isRowGroupStatus } = tableReactData
493
- const { fullAllDataRowIdData, fullColumnIdData, treeExpandedMaps, pendingRowMaps, rowExpandedMaps } = tableInternalData
494
- const checkboxOpts = computeCheckboxOpts.value
495
- const radioOpts = computeRadioOpts.value
496
- const treeOpts = computeTreeOpts.value
497
- const editOpts = computeEditOpts.value
498
- const rowOpts = computeRowOpts.value
499
- const columnOpts = computeColumnOpts.value
500
- const { transform, seqMode } = treeOpts
501
- const childrenField = treeOpts.children || treeOpts.childrenField
502
- const rows: any[] = []
503
- const { handleGetRowId } = createHandleGetRowId($xeTable)
504
- const isDeepRow = treeConfig || isRowGroupStatus
505
- tableData.forEach((row, $rowIndex) => {
506
- const rowid = handleGetRowId(row)
507
- const rowRest = fullAllDataRowIdData[rowid] || {}
508
- let rowIndex = $rowIndex
509
- let rowLevel = 0
510
- let seq: string | number = -1
511
- let _rowIndex = -1
512
- const hasRowGroupAggregate = isRowGroupStatus && row.isAggregate
513
- const trOn: Record<string, any> = {}
514
- // 当前行事件
515
- if (rowOpts.isHover || highlightHoverRow) {
516
- trOn.onMouseover = (evnt: MouseEvent) => {
517
- if (isVMScrollProcess()) {
518
- return
519
- }
520
- $xeTable.triggerHoverEvent(evnt, { row, rowIndex })
521
- }
522
- trOn.onMouseleave = () => {
523
- if (isVMScrollProcess()) {
524
- return
525
- }
526
- $xeTable.clearHoverRow()
527
- }
528
- }
529
- if (rowRest) {
530
- rowIndex = rowRest.index
531
- _rowIndex = rowRest._index
532
- rowLevel = rowRest.level
533
- seq = rowRest.seq
534
- if (hasRowGroupAggregate || (treeConfig && transform && seqMode === 'increasing')) {
535
- seq = rowRest._index + 1
536
- } else if ((treeConfig && seqMode === 'fixed')) {
537
- seq = rowRest._tIndex + 1
538
- }
539
- }
540
- const params = {
541
- $table: $xeTable,
542
- seq,
543
- rowid,
544
- fixed: fixedType,
545
- type: renderType,
546
- level: rowLevel,
547
- row,
548
- rowIndex,
549
- $rowIndex,
550
- _rowIndex
551
- }
552
- // 行是否被展开
553
- const isExpandRow = expandColumn && !!rowExpandedFlag && !!rowExpandedMaps[rowid]
554
- // 树节点是否被展开
555
- let isExpandTree = false
556
- let rowChildren = []
557
- let isNewRow = false
558
- if (editConfig) {
559
- isNewRow = $xeTable.isInsertByRow(row)
560
- }
561
- if (treeConfig && !scrollYLoad && !transform) {
562
- rowChildren = row[childrenField]
563
- isExpandTree = !!treeExpandedFlag && rowChildren && rowChildren.length > 0 && !!treeExpandedMaps[rowid]
564
- }
565
- // 拖拽行事件
566
- if (rowOpts.drag && !isRowGroupStatus && (!treeConfig || transform)) {
567
- trOn.onDragstart = $xeTable.handleRowDragDragstartEvent
568
- trOn.onDragend = $xeTable.handleRowDragDragendEvent
569
- trOn.onDragover = $xeTable.handleRowDragDragoverEvent
570
- }
571
- const trClass = [
572
- 'vxe-body--row',
573
- isDeepRow ? `row--level-${rowLevel}` : '',
574
- {
575
- 'row--stripe': stripe && (_rowIndex + 1) % 2 === 0,
576
- 'is--new': isNewRow,
577
- 'is--expand-row': isExpandRow,
578
- 'is--expand-tree': isExpandTree,
579
- 'row--new': isNewRow && (editOpts.showStatus || editOpts.showInsertStatus),
580
- 'row--radio': radioOpts.highlight && $xeTable.eqRow(selectRadioRow, row),
581
- 'row--checked': checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
582
- 'row--pending': !!pendingRowFlag && !!pendingRowMaps[rowid],
583
- 'row--group': hasRowGroupAggregate
584
- },
585
- getPropClass(rowClassName, params)
586
- ]
587
- const tdVNs = tableColumn.map((column, $columnIndex) => {
588
- return renderTdColumn(seq, rowid, fixedType, isOptimizeMode, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData)
589
- })
590
- rows.push(
591
- h('tr', {
592
- class: trClass,
593
- rowid: rowid,
594
- style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) : null,
595
- key: rowKey || scrollXLoad || scrollYLoad || rowOpts.useKey || rowOpts.drag || columnOpts.drag || isRowGroupStatus || treeConfig ? rowid : $rowIndex,
596
- ...trOn
597
- }, tdVNs)
598
- )
599
- // 如果行被展开了
600
- if (isExpandRow) {
601
- const expandOpts = computeExpandOpts.value
602
- const { height: expandHeight, padding, mode: expandMode } = expandOpts
603
- if (expandMode === 'fixed') {
604
- const currExpHeight = rowRest.expandHeight
605
- let expHeight = 0
606
- if (rowExpandHeightFlag) {
607
- if (currExpHeight || expandHeight) {
608
- expHeight = (currExpHeight || expandHeight || 0) + 1
609
- }
610
- }
611
- rows.push(
612
- h('tr', {
613
- class: 'vxe-body--row-expanded-place',
614
- key: `expand_${rowid}`,
615
- rowid
616
- }, [
617
- h('td', {
618
- class: 'vxe-body--row-expanded-place-column',
619
- colspan: tableColumn.length,
620
- style: {
621
- height: `${expHeight}px`
622
- }
623
- })
624
- ])
625
- )
626
- } else {
627
- const cellStyle: any = {}
628
- if (expandHeight) {
629
- cellStyle.height = `${expandHeight}px`
630
- }
631
- if (treeConfig) {
632
- cellStyle.paddingLeft = `${(rowLevel * treeOpts.indent) + 30}px`
633
- }
634
- const { showOverflow } = expandColumn || {}
635
- const colid = expandColumn.id
636
- const colRest = fullColumnIdData[colid] || {}
637
- const hasEllipsis = XEUtils.eqNull(showOverflow) ? isAllOverflow : showOverflow
638
- let columnIndex = -1
639
- let $columnIndex = -1
640
- let _columnIndex = -1
641
- if (colRest) {
642
- columnIndex = colRest.index
643
- $columnIndex = colRest.$index
644
- _columnIndex = colRest._index
645
- }
646
- const expandParams: VxeTableDefines.CellRenderDataParams = {
647
- $table: $xeTable,
648
- $grid: $xeGrid,
649
- $gantt: $xeGantt,
650
- seq,
651
- column: expandColumn as VxeTableDefines.ColumnInfo,
652
- columnIndex,
653
- $columnIndex,
654
- _columnIndex,
655
- fixed: fixedType,
656
- source: sourceType,
657
- type: renderType,
658
- level: rowLevel,
659
- row,
660
- rowid,
661
- rowIndex,
662
- $rowIndex,
663
- _rowIndex,
664
- isHidden: false,
665
- isEdit: false,
666
- visibleData: [],
667
- data: [],
668
- items: []
669
- }
670
- rows.push(
671
- h('tr', {
672
- class: ['vxe-body--expanded-row', {
673
- 'is--padding': padding
674
- }],
675
- key: `expand_${rowid}`
676
- }, [
677
- h('td', {
678
- class: ['vxe-body--expanded-column', {
679
- 'fixed--hidden': fixedType && !hasFixedColumn,
680
- 'col--ellipsis': hasEllipsis
681
- }],
682
- colspan: tableColumn.length
683
- }, [
684
- h('div', {
685
- class: ['vxe-body--expanded-cell', {
686
- 'is--ellipsis': expandHeight
687
- }],
688
- style: cellStyle
689
- }, [
690
- expandColumn.renderData(expandParams)
691
- ])
692
- ])
693
- ])
694
- )
695
- }
696
- }
697
- // 如果是树形表格
698
- if (isExpandTree) {
699
- rows.push(...renderRows(fixedType, isOptimizeMode, rowChildren, tableColumn))
700
- }
701
- })
702
- return rows
703
- }
704
-
705
- onMounted(() => {
706
- nextTick(() => {
707
- const { fixedType } = props
708
- const { elemStore } = tableInternalData
709
- const prefix = `${fixedType || 'main'}-body-`
710
- elemStore[`${prefix}wrapper`] = refElem
711
- elemStore[`${prefix}scroll`] = refBodyScroll
712
- elemStore[`${prefix}table`] = refBodyTable
713
- elemStore[`${prefix}colgroup`] = refBodyColgroup
714
- elemStore[`${prefix}list`] = refBodyTBody
715
- elemStore[`${prefix}xSpace`] = refBodyXSpace
716
- elemStore[`${prefix}ySpace`] = refBodyYSpace
717
- elemStore[`${prefix}emptyBlock`] = refBodyEmptyBlock
718
- })
719
- })
720
-
721
- onUnmounted(() => {
722
- const { fixedType } = props
723
- const { elemStore } = tableInternalData
724
- const prefix = `${fixedType || 'main'}-body-`
725
- elemStore[`${prefix}wrapper`] = null
726
- elemStore[`${prefix}scroll`] = null
727
- elemStore[`${prefix}table`] = null
728
- elemStore[`${prefix}colgroup`] = null
729
- elemStore[`${prefix}list`] = null
730
- elemStore[`${prefix}xSpace`] = null
731
- elemStore[`${prefix}ySpace`] = null
732
- elemStore[`${prefix}emptyBlock`] = null
733
- })
734
-
735
- const renderVN = () => {
736
- const { slots } = tableContext
737
- const $xeGrid = $xeTable.xeGrid
738
- const $xeGantt = $xeTable.xeGantt
739
-
740
- const { fixedColumn, fixedType, tableColumn } = props
741
- const { mouseConfig } = tableProps
742
- const { isGroup, tableData, isColLoading, overflowX, scrollXLoad, scrollYLoad, dragRow, dragCol } = tableReactData
743
- const { visibleColumn, fullAllDataRowIdData, fullColumnIdData } = tableInternalData
744
- const emptyOpts = computeEmptyOpts.value
745
- const mouseOpts = computeMouseOpts.value
746
- const isBodyRenderOptimize = computeIsBodyRenderOptimize.value
747
-
748
- let renderDataList = tableData
749
- let renderColumnList = tableColumn as VxeTableDefines.ColumnInfo[]
750
- const isOptimizeMode = isBodyRenderOptimize
751
-
752
- if (!isColLoading && (fixedType || !overflowX)) {
753
- renderColumnList = visibleColumn
754
- }
755
-
756
- if (fixedType) {
757
- if (isOptimizeMode) {
758
- renderColumnList = fixedColumn || []
759
- }
760
- }
761
-
762
- // 行拖拽
763
- if (scrollYLoad && dragRow) {
764
- if (renderDataList.length > 2) {
765
- const dRowRest = fullAllDataRowIdData[getRowid($xeTable, dragRow)]
766
- if (dRowRest) {
767
- const drIndex = dRowRest._index
768
- const firstRow = renderDataList[0]
769
- const lastRow = renderDataList[renderDataList.length - 1]
770
- const firstRowRest = fullAllDataRowIdData[getRowid($xeTable, firstRow)]
771
- const lastRowRest = fullAllDataRowIdData[getRowid($xeTable, lastRow)]
772
- if (firstRowRest && lastRowRest) {
773
- const frIndex = firstRowRest._index
774
- const lrIndex = lastRowRest._index
775
- if (drIndex < frIndex) {
776
- renderDataList = [dragRow].concat(renderDataList)
777
- } else if (drIndex > lrIndex) {
778
- renderDataList = renderDataList.concat([dragRow])
779
- }
780
- }
781
- }
782
- }
783
- }
784
-
785
- if (!fixedType && !isGroup) {
786
- // 列拖拽
787
- if (scrollXLoad && dragCol) {
788
- if (renderColumnList.length > 2) {
789
- const dCowRest = fullColumnIdData[dragCol.id]
790
- if (dCowRest) {
791
- const dcIndex = dCowRest._index
792
- const firstCol = renderColumnList[0]
793
- const lastCol = renderColumnList[renderColumnList.length - 1]
794
- const firstColRest = fullColumnIdData[firstCol.id]
795
- const lastColRest = fullColumnIdData[lastCol.id]
796
- if (firstColRest && lastColRest) {
797
- const fcIndex = firstColRest._index
798
- const lcIndex = lastColRest._index
799
- if (dcIndex < fcIndex) {
800
- renderColumnList = [dragCol].concat(renderColumnList)
801
- } else if (dcIndex > lcIndex) {
802
- renderColumnList = renderColumnList.concat([dragCol])
803
- }
804
- }
805
- }
806
- }
807
- }
808
- }
809
-
810
- let emptyContent: string | VxeComponentSlotType | VxeComponentSlotType[]
811
- const emptySlot = slots ? slots.empty : null
812
- const emptyParams = { $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }
813
- if (emptySlot) {
814
- emptyContent = $xeTable.callSlot(emptySlot, emptyParams)
815
- } else {
816
- const compConf = emptyOpts.name ? renderer.get(emptyOpts.name) : null
817
- const rtEmptyView = compConf ? (compConf.renderTableEmpty || compConf.renderTableEmptyView || compConf.renderEmpty) : null
818
- if (rtEmptyView) {
819
- emptyContent = getSlotVNs(rtEmptyView(emptyOpts, emptyParams))
820
- } else {
821
- emptyContent = tableProps.emptyText || getI18n('vxe.table.emptyText')
822
- }
823
- }
824
-
825
- return h('div', {
826
- ref: refElem,
827
- class: ['vxe-table--body-wrapper', fixedType ? `fixed-${fixedType}--wrapper` : 'body--wrapper'],
828
- xid: xID
829
- }, [
830
- h('div', {
831
- ref: refBodyScroll,
832
- class: 'vxe-table--body-inner-wrapper',
833
- onScroll (evnt) {
834
- $xeTable.triggerBodyScrollEvent(evnt, fixedType)
835
- }
836
- }, [
837
- fixedType
838
- ? renderEmptyElement($xeTable)
839
- : h('div', {
840
- ref: refBodyXSpace,
841
- class: 'vxe-body--x-space'
842
- }),
843
- h('div', {
844
- ref: refBodyYSpace,
845
- class: 'vxe-body--y-space'
846
- }),
847
- h('table', {
848
- ref: refBodyTable,
849
- class: 'vxe-table--body',
850
- xid: xID,
851
- cellspacing: 0,
852
- cellpadding: 0,
853
- border: 0,
854
- xvm: isOptimizeMode ? '1' : null
855
- }, [
856
- /**
857
- * 列宽
858
- */
859
- h('colgroup', {
860
- ref: refBodyColgroup
861
- }, renderColumnList.map((column, $columnIndex) => {
862
- return h('col', {
863
- name: column.id,
864
- key: $columnIndex,
865
- style: {
866
- width: `${column.renderWidth}px`
867
- }
868
- })
869
- })),
870
- /**
871
- * 内容
872
- */
873
- h('tbody', {
874
- ref: refBodyTBody
875
- }, renderRows(fixedType, isOptimizeMode, renderDataList, renderColumnList))
876
- ]),
877
- h('div', {
878
- class: 'vxe-table--checkbox-range'
879
- }),
880
- mouseConfig && mouseOpts.area
881
- ? h('div', {
882
- class: 'vxe-table--cell-area',
883
- xid: xID
884
- }, [
885
- h('span', {
886
- class: 'vxe-table--cell-main-area'
887
- }, mouseOpts.extension
888
- ? [
889
- h('span', {
890
- class: 'vxe-table--cell-main-area-btn',
891
- onMousedown (evnt: MouseEvent) {
892
- if ($xeTable.triggerCellAreaExtendMousedownEvent) {
893
- $xeTable.triggerCellAreaExtendMousedownEvent(evnt, { $table: $xeTable, fixed: fixedType, type: renderType })
894
- }
895
- }
896
- })
897
- ]
898
- : []),
899
- h('span', {
900
- class: 'vxe-table--cell-clip-area'
901
- }),
902
- h('span', {
903
- class: 'vxe-table--cell-extend-area'
904
- }),
905
- h('span', {
906
- class: 'vxe-table--cell-multi-area'
907
- }),
908
- h('span', {
909
- class: 'vxe-table--cell-active-area'
910
- }),
911
- h('span', {
912
- class: 'vxe-table--cell-row-status-area'
913
- })
914
- ])
915
- : renderEmptyElement($xeTable),
916
- !fixedType
917
- ? h('div', {
918
- class: 'vxe-table--empty-block',
919
- ref: refBodyEmptyBlock
920
- }, [
921
- h('div', {
922
- class: 'vxe-table--empty-content'
923
- }, emptyContent)
924
- ])
925
- : renderEmptyElement($xeTable)
926
- ])
927
- ])
928
- }
929
-
930
- return renderVN
931
- }
932
- })
1
+ import { h, ref, Ref, PropType, inject, nextTick, onMounted, onUnmounted } from 'vue'
2
+ import { defineVxeComponent } from '../../ui/src/comp'
3
+ import XEUtils from 'xe-utils'
4
+ import { VxeUI } from '../../ui'
5
+ import { getRowid, createHandleGetRowId, getCellRestHeight } from './util'
6
+ import { updateCellTitle, getPropClass } from '../../ui/src/dom'
7
+ import { isEnableConf } from '../../ui/src/utils'
8
+ import { getSlotVNs } from '../../ui/src/vn'
9
+
10
+ import type { VxeTablePrivateMethods, VxeTableConstructor, VxeTableDefines, VxeComponentSlotType } from '../../../types'
11
+
12
+ const { getI18n, renderer, renderEmptyElement } = VxeUI
13
+
14
+ const sourceType = 'table'
15
+ const renderType = 'body'
16
+
17
+ export default defineVxeComponent({
18
+ name: 'VxeTableBody',
19
+ props: {
20
+ tableData: Array as PropType<any[]>,
21
+ tableColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
22
+ fixedColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
23
+ fixedType: {
24
+ type: String as PropType<'right' | 'left' | ''>,
25
+ default: ''
26
+ }
27
+ },
28
+ setup (props) {
29
+ const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTablePrivateMethods)
30
+
31
+ const { xID, props: tableProps, context: tableContext, reactData: tableReactData, internalData: tableInternalData } = $xeTable
32
+ const { computeEditOpts, computeMouseOpts, computeCellOffsetWidth, computeAreaOpts, computeDefaultRowHeight, computeEmptyOpts, computeTooltipOpts, computeRadioOpts, computeExpandOpts, computeTreeOpts, computeCheckboxOpts, computeCellOpts, computeValidOpts, computeRowOpts, computeColumnOpts, computeRowDragOpts, computeResizableOpts, computeVirtualXOpts, computeVirtualYOpts, computeIsBodyRenderOptimize } = $xeTable.getComputeMaps()
33
+
34
+ const refElem = ref() as Ref<HTMLDivElement>
35
+ const refBodyScroll = ref() as Ref<HTMLDivElement>
36
+ const refBodyTable = ref() as Ref<HTMLTableElement>
37
+ const refBodyColgroup = ref() as Ref<HTMLTableColElement>
38
+ const refBodyTBody = ref() as Ref<HTMLTableSectionElement>
39
+ const refBodyXSpace = ref() as Ref<HTMLDivElement>
40
+ const refBodyYSpace = ref() as Ref<HTMLDivElement>
41
+ const refBodyEmptyBlock = ref() as Ref<HTMLDivElement>
42
+
43
+ // 滚动、拖动过程中不需要触发
44
+ const isVMScrollProcess = () => {
45
+ const { delayHover } = tableProps
46
+ const { isDragResize } = tableReactData
47
+ const { lastSTime } = tableInternalData
48
+ return !!(isDragResize || (lastSTime && Date.now() < lastSTime + (delayHover as number)))
49
+ }
50
+
51
+ const renderLine = (rowid: string, params: VxeTableDefines.CellRenderBodyParams, cellHeight: number): VxeComponentSlotType[] => {
52
+ const { column } = params
53
+ const { treeConfig } = tableProps
54
+ const cellOpts = computeCellOpts.value
55
+ const rowOpts = computeRowOpts.value
56
+ const defaultRowHeight = computeDefaultRowHeight.value
57
+ const treeOpts = computeTreeOpts.value
58
+ const { slots, treeNode } = column
59
+ const { fullAllDataRowIdData } = tableInternalData
60
+ if (treeConfig && treeNode && (treeOpts.showLine || treeOpts.line)) {
61
+ if (slots && (slots as any).line) {
62
+ return $xeTable.callSlot((slots as any).line, params)
63
+ }
64
+ const rowRest = fullAllDataRowIdData[rowid]
65
+ let rLevel = 0
66
+ let prevRow = null
67
+ let parentRow = null
68
+ let lineHeight = ''
69
+ if (rowRest) {
70
+ rLevel = rowRest.level
71
+ prevRow = rowRest.items[rowRest.treeIndex - 1]
72
+ parentRow = rowRest.parent
73
+ }
74
+ if (!rLevel && !treeOpts.showRootLine) {
75
+ return []
76
+ }
77
+ if (prevRow) {
78
+ const prevRowRest = fullAllDataRowIdData[getRowid($xeTable, prevRow)] || {}
79
+ lineHeight = `${prevRowRest.lineHeight || 0}px`
80
+ } else if (rLevel && parentRow) {
81
+ const parentRowRest = fullAllDataRowIdData[getRowid($xeTable, parentRow)] || {}
82
+ lineHeight = `calc(-1em + ${Math.floor(cellHeight / 2 + getCellRestHeight(parentRowRest, cellOpts, rowOpts, defaultRowHeight) / 2)}px)`
83
+ }
84
+ return [
85
+ h('div', {
86
+ key: 'tl',
87
+ class: 'vxe-tree--line-wrapper'
88
+ }, [
89
+ h('div', {
90
+ class: 'vxe-tree--line',
91
+ style: {
92
+ height: lineHeight,
93
+ bottom: `-${Math.floor(cellHeight / 2)}px`,
94
+ left: `calc(${(rLevel * treeOpts.indent)}px + 1em)`
95
+ }
96
+ })
97
+ ])
98
+ ]
99
+ }
100
+ return []
101
+ }
102
+
103
+ /**
104
+ * 渲染列
105
+ */
106
+ const renderTdColumn = (
107
+ seq: number | string,
108
+ rowid: string,
109
+ fixedType: 'left' | 'right' | '',
110
+ isOptimizeMode: boolean,
111
+ rowLevel: number,
112
+ row: any,
113
+ rowIndex: number,
114
+ $rowIndex: number,
115
+ _rowIndex: number,
116
+ column: VxeTableDefines.ColumnInfo,
117
+ $columnIndex: number,
118
+ columns: VxeTableDefines.ColumnInfo[],
119
+ items: any[]
120
+ ) => {
121
+ const $xeGrid = $xeTable.xeGrid
122
+ const $xeGantt = $xeTable.xeGantt
123
+
124
+ const { columnKey, resizable: allResizable, showOverflow: allShowOverflow, border, height, treeConfig, cellClassName: allCellClassName, cellStyle, align: allAlign, spanMethod, mouseConfig, editConfig, editRules, tooltipConfig, padding: allPadding } = tableProps
125
+ const { tableData, tableColumn, dragRow, overflowX, overflowY, currentColumn, scrollXLoad, scrollYLoad, mergeBodyFlag, calcCellHeightFlag, resizeHeightFlag, resizeWidthFlag, editStore, isAllOverflow, validErrorMaps } = tableReactData
126
+ const { fullAllDataRowIdData, fullColumnIdData, mergeBodyCellMaps, visibleColumn, afterFullData, mergeBodyList, scrollXStore, scrollYStore, keepUpdateFieldMaps } = tableInternalData
127
+ const cellOpts = computeCellOpts.value
128
+ const validOpts = computeValidOpts.value
129
+ const checkboxOpts = computeCheckboxOpts.value
130
+ const editOpts = computeEditOpts.value
131
+ const tooltipOpts = computeTooltipOpts.value
132
+ const resizableOpts = computeResizableOpts.value
133
+ const virtualXOpts = computeVirtualXOpts.value
134
+ const virtualYOpts = computeVirtualYOpts.value
135
+ const { isAllColumnDrag, isAllRowDrag } = resizableOpts
136
+ const rowOpts = computeRowOpts.value
137
+ const rowDragOpts = computeRowDragOpts.value
138
+ const defaultRowHeight = computeDefaultRowHeight.value
139
+ const customCellHeight = calcCellHeightFlag ? (cellOpts.height || rowOpts.height) : 0
140
+ const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = rowDragOpts
141
+ const columnOpts = computeColumnOpts.value
142
+ const mouseOpts = computeMouseOpts.value
143
+ const areaOpts = computeAreaOpts.value
144
+ const cellOffsetWidth = computeCellOffsetWidth.value
145
+ const { selectCellToRow } = areaOpts
146
+ const { field, type, cellRender, editRender, align, showOverflow, className, treeNode, rowResize, padding, verticalAlign, slots } = column
147
+ const { verticalAlign: allVerticalAlign } = cellOpts
148
+ const { actived } = editStore
149
+ const rowRest = fullAllDataRowIdData[rowid] || {}
150
+ const colid = column.id
151
+ const colRest = fullColumnIdData[colid] || {}
152
+ const renderOpts = editRender || cellRender
153
+ const compConf = renderOpts ? renderer.get(renderOpts.name) : null
154
+ const compCellClassName = compConf ? (compConf.tableCellClassName || compConf.cellClassName) : null
155
+ const compCellStyle = compConf ? (compConf.tableCellStyle || compConf.cellStyle) : ''
156
+ const showAllTip = tooltipOpts.showAll
157
+ const columnIndex = colRest.index
158
+ const _columnIndex = colRest._index
159
+ const isEdit = isEnableConf(editRender)
160
+ const resizeHeight = resizeHeightFlag ? rowRest.resizeHeight : 0
161
+ let fixedHiddenColumn = overflowX && (fixedType ? column.fixed !== fixedType : !!column.fixed)
162
+ const isCellPadding = XEUtils.eqNull(padding) ? (allPadding === null ? cellOpts.padding : allPadding) : padding
163
+ const cellOverflow = XEUtils.eqNull(showOverflow) ? allShowOverflow : showOverflow
164
+ const showEllipsis = cellOverflow === 'ellipsis'
165
+ const showTitle = cellOverflow === 'title'
166
+ const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
167
+ const hasEllipsis = isAllOverflow || showTitle || showTooltip || showEllipsis
168
+ const showResizable = (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
169
+ const isCsHeight = !!customCellHeight
170
+ const isRsHeight = resizeHeight > 0
171
+ let isDirty
172
+ const tdOns: any = {}
173
+ const cellAlign = align || (compConf ? compConf.tableCellAlign : '') || allAlign
174
+ const cellVerticalAlign = XEUtils.eqNull(verticalAlign) ? allVerticalAlign : verticalAlign
175
+ const errorValidItem = validErrorMaps[`${rowid}:${colid}`]
176
+ const showValidTip = editRules && validOpts.showErrorMessage && (validOpts.message === 'default' ? (height || tableData.length > 1) : validOpts.message === 'inline')
177
+ const tdAttrs: any = { colid }
178
+ const cellParams: VxeTableDefines.CellRenderBodyParams & {
179
+ $table: VxeTableConstructor<any> & VxeTablePrivateMethods
180
+ } = {
181
+ $table: $xeTable,
182
+ $grid: $xeGrid,
183
+ $gantt: $xeGantt,
184
+ isEdit: false,
185
+ seq,
186
+ rowid,
187
+ row,
188
+ rowIndex,
189
+ $rowIndex,
190
+ _rowIndex,
191
+ column,
192
+ columnIndex,
193
+ $columnIndex,
194
+ _columnIndex,
195
+ fixed: fixedType,
196
+ source: sourceType,
197
+ type: renderType,
198
+ isHidden: !!fixedHiddenColumn,
199
+ level: rowLevel,
200
+ visibleData: afterFullData,
201
+ data: tableData,
202
+ items
203
+ }
204
+ let isRowDragCell = false
205
+ let isDisabledDrag = false
206
+ if (rowOpts.drag) {
207
+ isRowDragCell = rowDragOpts.trigger === 'row' || (column.dragSort && rowDragOpts.trigger === 'cell')
208
+ }
209
+ if (isRowDragCell) {
210
+ isDisabledDrag = !!(dragDisabledMethod && dragDisabledMethod(cellParams))
211
+ }
212
+ // hover 进入事件
213
+ if (showTitle || showTooltip || showAllTip || tooltipConfig) {
214
+ tdOns.onMouseover = (evnt: MouseEvent) => {
215
+ if (!isVMScrollProcess()) {
216
+ if (showTitle) {
217
+ updateCellTitle(evnt.currentTarget, column)
218
+ } else if (showTooltip || showAllTip) {
219
+ // 如果配置了显示 tooltip
220
+ $xeTable.triggerBodyTooltipEvent(evnt, cellParams)
221
+ }
222
+ }
223
+ $xeTable.dispatchEvent('cell-mouseenter', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
224
+ }
225
+ }
226
+ // hover 退出事件
227
+ if (showTooltip || showAllTip || tooltipConfig) {
228
+ tdOns.onMouseleave = (evnt: MouseEvent) => {
229
+ if (!isVMScrollProcess()) {
230
+ if (showTooltip || showAllTip) {
231
+ $xeTable.handleTargetLeaveEvent(evnt)
232
+ }
233
+ }
234
+ $xeTable.dispatchEvent('cell-mouseleave', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
235
+ }
236
+ }
237
+ // 按下事件处理
238
+ if (isRowDragCell || checkboxOpts.range || mouseConfig) {
239
+ tdOns.onMousedown = (evnt: MouseEvent) => {
240
+ $xeTable.triggerCellMousedownEvent(evnt, cellParams)
241
+ }
242
+ }
243
+ // 拖拽列事件
244
+ if (isRowDragCell) {
245
+ tdOns.onMouseup = $xeTable.triggerCellMouseupEvent
246
+ }
247
+ // 点击事件处理
248
+ tdOns.onClick = (evnt: MouseEvent) => {
249
+ $xeTable.triggerCellClickEvent(evnt, cellParams)
250
+ }
251
+ // 双击事件处理
252
+ tdOns.onDblclick = (evnt: MouseEvent) => {
253
+ $xeTable.triggerCellDblclickEvent(evnt, cellParams)
254
+ }
255
+ let isMergeCell = false
256
+ let mergeColspan = 1
257
+ let mergeRowspan = 1
258
+ // 合并行或列
259
+ if (mergeBodyFlag && mergeBodyList.length) {
260
+ const spanRest = mergeBodyCellMaps[`${_rowIndex}:${_columnIndex}`]
261
+ if (spanRest) {
262
+ const { rowspan, colspan } = spanRest
263
+ if (!rowspan || !colspan) {
264
+ return renderEmptyElement($xeTable)
265
+ }
266
+ if (rowspan > 1) {
267
+ isMergeCell = true
268
+ mergeRowspan = rowspan
269
+ tdAttrs.rowspan = rowspan
270
+ }
271
+ if (colspan > 1) {
272
+ isMergeCell = true
273
+ mergeColspan = colspan
274
+ tdAttrs.colspan = colspan
275
+ }
276
+ }
277
+ } else if (spanMethod) {
278
+ // 自定义合并行或列的方法
279
+ const { rowspan = 1, colspan = 1 } = spanMethod(cellParams) || {}
280
+ if (!rowspan || !colspan) {
281
+ return renderEmptyElement($xeTable)
282
+ }
283
+ if (rowspan > 1) {
284
+ isMergeCell = true
285
+ mergeRowspan = rowspan
286
+ tdAttrs.rowspan = rowspan
287
+ }
288
+ if (colspan > 1) {
289
+ isMergeCell = true
290
+ mergeColspan = colspan
291
+ tdAttrs.colspan = colspan
292
+ }
293
+ }
294
+ // 如果被合并不可隐藏
295
+ if (fixedHiddenColumn && isMergeCell) {
296
+ if (tdAttrs.colspan > 1 || tdAttrs.rowspan > 1) {
297
+ fixedHiddenColumn = false
298
+ }
299
+ }
300
+ // 如果编辑列开启显示状态
301
+ if (!fixedHiddenColumn && editConfig && (editOpts.showStatus || editOpts.showUpdateStatus) && keepUpdateFieldMaps[field]) {
302
+ isDirty = $xeTable.isUpdateByRow(row, field)
303
+ }
304
+
305
+ const isVNAutoHeight = !hasEllipsis && (scrollYLoad || scrollXLoad)
306
+ let cellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
307
+
308
+ const isLastColumn = $columnIndex === columns.length - 1
309
+ const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
310
+
311
+ let isVNPreEmptyStatus = false
312
+ if (!isMergeCell) {
313
+ if (!dragRow || getRowid($xeTable, dragRow) !== rowid) {
314
+ if (overflowY && scrollYLoad && tableData.length > 16 && !treeConfig && !virtualYOpts.immediate && (_rowIndex < scrollYStore.visibleStartIndex - scrollYStore.preloadSize || _rowIndex > scrollYStore.visibleEndIndex + scrollYStore.preloadSize)) {
315
+ isVNPreEmptyStatus = true
316
+ } else if (overflowX && scrollXLoad && tableColumn.length > 10 && !virtualXOpts.immediate && !column.fixed && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
317
+ isVNPreEmptyStatus = true
318
+ }
319
+ }
320
+ }
321
+
322
+ if (mergeRowspan > 1) {
323
+ const mEndRow = afterFullData[_rowIndex + mergeRowspan - 1]
324
+ if (mEndRow) {
325
+ const meRowRest = fullAllDataRowIdData[getRowid($xeTable, mEndRow)]
326
+ if (meRowRest) {
327
+ cellHeight += meRowRest.oTop + getCellRestHeight(meRowRest, cellOpts, rowOpts, defaultRowHeight) - rowRest.oTop - getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
328
+ }
329
+ }
330
+ }
331
+
332
+ const tcStyle: Record<string, string> = {}
333
+ if (hasEllipsis && resizeWidthFlag) {
334
+ let mergeColWidth = 0
335
+ if (mergeColspan > 1) {
336
+ for (let index = 1; index < mergeColspan; index++) {
337
+ const nextColumn = visibleColumn[columnIndex + index]
338
+ if (nextColumn) {
339
+ mergeColWidth += nextColumn.renderWidth
340
+ }
341
+ }
342
+ }
343
+ tcStyle.width = `${column.renderWidth + mergeColWidth - cellOffsetWidth}px`
344
+ }
345
+ if (scrollYLoad || scrollXLoad || hasEllipsis || isCsHeight || isRsHeight) {
346
+ tcStyle.height = `${cellHeight}px`
347
+ } else {
348
+ tcStyle.minHeight = `${cellHeight}px`
349
+ }
350
+
351
+ const tdVNs: VxeComponentSlotType[] = []
352
+ if (fixedHiddenColumn && isAllOverflow) {
353
+ tdVNs.push(
354
+ h('div', {
355
+ key: 'tc',
356
+ class: ['vxe-cell', {
357
+ 'c--title': showTitle,
358
+ 'c--tooltip': showTooltip,
359
+ 'c--ellipsis': showEllipsis
360
+ }],
361
+ style: tcStyle
362
+ })
363
+ )
364
+ } else {
365
+ // 渲染单元格
366
+ if (treeConfig) {
367
+ tdVNs.push(...renderLine(rowid, cellParams, cellHeight))
368
+ }
369
+ tdVNs.push(
370
+ h('div', {
371
+ key: 'tc',
372
+ class: ['vxe-cell', {
373
+ 'c--title': showTitle,
374
+ 'c--tooltip': showTooltip,
375
+ 'c--ellipsis': showEllipsis
376
+ }],
377
+ style: tcStyle,
378
+ title: showTitle ? $xeTable.getCellLabel(row, column) : null
379
+ }, isVNPreEmptyStatus
380
+ ? []
381
+ : [
382
+ h('div', {
383
+ colid,
384
+ rowid,
385
+ class: 'vxe-cell--wrapper vxe-body-cell--wrapper'
386
+ }, column.renderCell(cellParams))
387
+ ])
388
+ )
389
+ if (showValidTip && errorValidItem) {
390
+ const errRule = errorValidItem.rule
391
+ const validSlot = slots ? slots.valid : null
392
+ const validParams = { ...cellParams, ...errorValidItem, rule: errorValidItem }
393
+ tdVNs.push(
394
+ h('div', {
395
+ key: 'tcv',
396
+ class: ['vxe-cell--valid-error-tip', getPropClass(validOpts.className, validParams)],
397
+ style: errRule && errRule.maxWidth
398
+ ? {
399
+ width: `${errRule.maxWidth}px`
400
+ }
401
+ : null
402
+ }, [
403
+ h('div', {
404
+ class: `vxe-cell--valid-error-wrapper vxe-cell--valid-error-theme-${validOpts.theme || 'normal'}`
405
+ }, [
406
+ validSlot
407
+ ? $xeTable.callSlot(validSlot, validParams)
408
+ : [
409
+ h('span', {
410
+ class: 'vxe-cell--valid-error-msg'
411
+ }, errorValidItem.content)
412
+ ]
413
+ ])
414
+ ])
415
+ )
416
+ }
417
+ }
418
+
419
+ let showAreaRowStatus = false
420
+ if (mouseConfig && mouseOpts.area && !_columnIndex && selectCellToRow) {
421
+ showAreaRowStatus = true
422
+ }
423
+
424
+ if (!fixedHiddenColumn && showResizable && isAllColumnDrag) {
425
+ tdVNs.push(
426
+ h('div', {
427
+ key: 'tcc',
428
+ class: ['vxe-cell--col-resizable', {
429
+ 'is--line': !border || border === 'none'
430
+ }],
431
+ onMousedown: (evnt: MouseEvent) => $xeTable.handleColResizeMousedownEvent(evnt, fixedType, cellParams),
432
+ onDblclick: (evnt: MouseEvent) => $xeTable.handleColResizeDblclickEvent(evnt, cellParams)
433
+ })
434
+ )
435
+ }
436
+
437
+ if ((rowResize || isAllRowDrag) && rowOpts.resizable) {
438
+ tdVNs.push(
439
+ h('div', {
440
+ key: 'tcr',
441
+ class: 'vxe-cell--row-resizable',
442
+ onMousedown: (evnt: MouseEvent) => $xeTable.handleRowResizeMousedownEvent(evnt, cellParams),
443
+ onDblclick: (evnt: MouseEvent) => $xeTable.handleRowResizeDblclickEvent(evnt, cellParams)
444
+ })
445
+ )
446
+ }
447
+
448
+ return h('td', {
449
+ class: [
450
+ 'vxe-table--column vxe-body--column',
451
+ colid,
452
+ cellVerticalAlign ? `col--vertical-${cellVerticalAlign}` : '',
453
+ cellAlign ? `col--${cellAlign}` : '',
454
+ type ? `col--${type}` : '',
455
+ {
456
+ 'col--last': isLastColumn,
457
+ 'col--tree-node': treeNode,
458
+ 'col--edit': isEdit,
459
+ 'col--ellipsis': hasEllipsis,
460
+ 'col--cs-height': isCsHeight,
461
+ 'col--rs-height': isRsHeight,
462
+ 'col--to-row': showAreaRowStatus,
463
+ 'col--auto-height': isVNAutoHeight,
464
+ 'fixed--width': !isAutoCellWidth,
465
+ 'fixed--hidden': fixedHiddenColumn,
466
+ 'is--padding': isCellPadding,
467
+ 'is--progress': (fixedHiddenColumn && isAllOverflow) || isVNPreEmptyStatus,
468
+ 'is--drag-cell': isRowDragCell && (isCrossDrag || isPeerDrag || !rowLevel),
469
+ 'is--drag-disabled': isDisabledDrag,
470
+ 'col--dirty': isDirty,
471
+ 'col--active': editConfig && isEdit && (actived.row === row && (actived.column === column || editOpts.mode === 'row')),
472
+ 'col--valid-error': !!errorValidItem,
473
+ 'show--valid-bg': errorValidItem && validOpts.showErrorBackground,
474
+ 'col--current': currentColumn === column
475
+ },
476
+ getPropClass(compCellClassName, cellParams),
477
+ getPropClass(className, cellParams),
478
+ getPropClass(allCellClassName, cellParams)
479
+ ],
480
+ key: columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || rowOpts.useKey || columnOpts.drag ? colid : $columnIndex,
481
+ ...tdAttrs,
482
+ style: Object.assign({}, XEUtils.isFunction(compCellStyle) ? compCellStyle(cellParams) : compCellStyle, XEUtils.isFunction(cellStyle) ? cellStyle(cellParams) : cellStyle),
483
+ ...tdOns
484
+ }, isOptimizeMode && fixedHiddenColumn ? [] : tdVNs)
485
+ }
486
+
487
+ const renderRows = (fixedType: 'left' | 'right' | '', isOptimizeMode: boolean, tableData: any[], tableColumn: VxeTableDefines.ColumnInfo[]) => {
488
+ const $xeGrid = $xeTable.xeGrid
489
+ const $xeGantt = $xeTable.xeGantt
490
+
491
+ const { stripe, rowKey, highlightHoverRow, rowClassName, rowStyle, editConfig, treeConfig } = tableProps
492
+ const { hasFixedColumn, treeExpandedFlag, scrollXLoad, scrollYLoad, isAllOverflow, rowExpandedFlag, expandColumn, selectRadioRow, pendingRowFlag, rowExpandHeightFlag, isRowGroupStatus } = tableReactData
493
+ const { fullAllDataRowIdData, fullColumnIdData, treeExpandedMaps, pendingRowMaps, rowExpandedMaps } = tableInternalData
494
+ const checkboxOpts = computeCheckboxOpts.value
495
+ const radioOpts = computeRadioOpts.value
496
+ const treeOpts = computeTreeOpts.value
497
+ const editOpts = computeEditOpts.value
498
+ const rowOpts = computeRowOpts.value
499
+ const columnOpts = computeColumnOpts.value
500
+ const { transform, seqMode } = treeOpts
501
+ const childrenField = treeOpts.children || treeOpts.childrenField
502
+ const rows: any[] = []
503
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
504
+ const isDeepRow = treeConfig || isRowGroupStatus
505
+ tableData.forEach((row, $rowIndex) => {
506
+ const rowid = handleGetRowId(row)
507
+ const rowRest = fullAllDataRowIdData[rowid] || {}
508
+ let rowIndex = $rowIndex
509
+ let rowLevel = 0
510
+ let seq: string | number = -1
511
+ let _rowIndex = -1
512
+ const hasRowGroupAggregate = isRowGroupStatus && row.isAggregate
513
+ const trOn: Record<string, any> = {}
514
+ // 当前行事件
515
+ if (rowOpts.isHover || highlightHoverRow) {
516
+ trOn.onMouseover = (evnt: MouseEvent) => {
517
+ if (isVMScrollProcess()) {
518
+ return
519
+ }
520
+ $xeTable.triggerHoverEvent(evnt, { row, rowIndex })
521
+ }
522
+ trOn.onMouseleave = () => {
523
+ if (isVMScrollProcess()) {
524
+ return
525
+ }
526
+ $xeTable.clearHoverRow()
527
+ }
528
+ }
529
+ if (rowRest) {
530
+ rowIndex = rowRest.index
531
+ _rowIndex = rowRest._index
532
+ rowLevel = rowRest.level
533
+ seq = rowRest.seq
534
+ if (hasRowGroupAggregate || (treeConfig && transform && seqMode === 'increasing')) {
535
+ seq = rowRest._index + 1
536
+ } else if ((treeConfig && seqMode === 'fixed')) {
537
+ seq = rowRest._tIndex + 1
538
+ }
539
+ }
540
+ const params = {
541
+ $table: $xeTable,
542
+ seq,
543
+ rowid,
544
+ fixed: fixedType,
545
+ type: renderType,
546
+ level: rowLevel,
547
+ row,
548
+ rowIndex,
549
+ $rowIndex,
550
+ _rowIndex
551
+ }
552
+ // 行是否被展开
553
+ const isExpandRow = expandColumn && !!rowExpandedFlag && !!rowExpandedMaps[rowid]
554
+ // 树节点是否被展开
555
+ let isExpandTree = false
556
+ let rowChildren = []
557
+ let isNewRow = false
558
+ if (editConfig) {
559
+ isNewRow = $xeTable.isInsertByRow(row)
560
+ }
561
+ if (treeConfig && !scrollYLoad && !transform) {
562
+ rowChildren = row[childrenField]
563
+ isExpandTree = !!treeExpandedFlag && rowChildren && rowChildren.length > 0 && !!treeExpandedMaps[rowid]
564
+ }
565
+ // 拖拽行事件
566
+ if (rowOpts.drag && !isRowGroupStatus && (!treeConfig || transform)) {
567
+ trOn.onDragstart = $xeTable.handleRowDragDragstartEvent
568
+ trOn.onDragend = $xeTable.handleRowDragDragendEvent
569
+ trOn.onDragover = $xeTable.handleRowDragDragoverEvent
570
+ }
571
+ const trClass = [
572
+ 'vxe-body--row',
573
+ isDeepRow ? `row--level-${rowLevel}` : '',
574
+ {
575
+ 'row--stripe': stripe && (_rowIndex + 1) % 2 === 0,
576
+ 'is--new': isNewRow,
577
+ 'is--expand-row': isExpandRow,
578
+ 'is--expand-tree': isExpandTree,
579
+ 'row--new': isNewRow && (editOpts.showStatus || editOpts.showInsertStatus),
580
+ 'row--radio': radioOpts.highlight && $xeTable.eqRow(selectRadioRow, row),
581
+ 'row--checked': checkboxOpts.highlight && $xeTable.isCheckedByCheckboxRow(row),
582
+ 'row--pending': !!pendingRowFlag && !!pendingRowMaps[rowid],
583
+ 'row--group': hasRowGroupAggregate
584
+ },
585
+ getPropClass(rowClassName, params)
586
+ ]
587
+ const tdVNs = tableColumn.map((column, $columnIndex) => {
588
+ return renderTdColumn(seq, rowid, fixedType, isOptimizeMode, rowLevel, row, rowIndex, $rowIndex, _rowIndex, column, $columnIndex, tableColumn, tableData)
589
+ })
590
+ rows.push(
591
+ h('tr', {
592
+ class: trClass,
593
+ rowid: rowid,
594
+ style: rowStyle ? (XEUtils.isFunction(rowStyle) ? rowStyle(params) : rowStyle) : null,
595
+ key: rowKey || scrollXLoad || scrollYLoad || rowOpts.useKey || rowOpts.drag || columnOpts.drag || isRowGroupStatus || treeConfig ? rowid : $rowIndex,
596
+ ...trOn
597
+ }, tdVNs)
598
+ )
599
+ // 如果行被展开了
600
+ if (isExpandRow) {
601
+ const expandOpts = computeExpandOpts.value
602
+ const { height: expandHeight, padding, mode: expandMode } = expandOpts
603
+ if (expandMode === 'fixed') {
604
+ const currExpHeight = rowRest.expandHeight
605
+ let expHeight = 0
606
+ if (rowExpandHeightFlag) {
607
+ if (currExpHeight || expandHeight) {
608
+ expHeight = (currExpHeight || expandHeight || 0) + 1
609
+ }
610
+ }
611
+ rows.push(
612
+ h('tr', {
613
+ class: 'vxe-body--row-expanded-place',
614
+ key: `expand_${rowid}`,
615
+ rowid
616
+ }, [
617
+ h('td', {
618
+ class: 'vxe-body--row-expanded-place-column',
619
+ colspan: tableColumn.length,
620
+ style: {
621
+ height: `${expHeight}px`
622
+ }
623
+ })
624
+ ])
625
+ )
626
+ } else {
627
+ const cellStyle: any = {}
628
+ if (expandHeight) {
629
+ cellStyle.height = `${expandHeight}px`
630
+ }
631
+ if (treeConfig) {
632
+ cellStyle.paddingLeft = `${(rowLevel * treeOpts.indent) + 30}px`
633
+ }
634
+ const { showOverflow } = expandColumn || {}
635
+ const colid = expandColumn.id
636
+ const colRest = fullColumnIdData[colid] || {}
637
+ const hasEllipsis = XEUtils.eqNull(showOverflow) ? isAllOverflow : showOverflow
638
+ let columnIndex = -1
639
+ let $columnIndex = -1
640
+ let _columnIndex = -1
641
+ if (colRest) {
642
+ columnIndex = colRest.index
643
+ $columnIndex = colRest.$index
644
+ _columnIndex = colRest._index
645
+ }
646
+ const expandParams: VxeTableDefines.CellRenderDataParams = {
647
+ $table: $xeTable,
648
+ $grid: $xeGrid,
649
+ $gantt: $xeGantt,
650
+ seq,
651
+ column: expandColumn as VxeTableDefines.ColumnInfo,
652
+ columnIndex,
653
+ $columnIndex,
654
+ _columnIndex,
655
+ fixed: fixedType,
656
+ source: sourceType,
657
+ type: renderType,
658
+ level: rowLevel,
659
+ row,
660
+ rowid,
661
+ rowIndex,
662
+ $rowIndex,
663
+ _rowIndex,
664
+ isHidden: false,
665
+ isEdit: false,
666
+ visibleData: [],
667
+ data: [],
668
+ items: []
669
+ }
670
+ rows.push(
671
+ h('tr', {
672
+ class: ['vxe-body--expanded-row', {
673
+ 'is--padding': padding
674
+ }],
675
+ key: `expand_${rowid}`
676
+ }, [
677
+ h('td', {
678
+ class: ['vxe-body--expanded-column', {
679
+ 'fixed--hidden': fixedType && !hasFixedColumn,
680
+ 'col--ellipsis': hasEllipsis
681
+ }],
682
+ colspan: tableColumn.length
683
+ }, [
684
+ h('div', {
685
+ class: ['vxe-body--expanded-cell', {
686
+ 'is--ellipsis': expandHeight
687
+ }],
688
+ style: cellStyle
689
+ }, [
690
+ expandColumn.renderData(expandParams)
691
+ ])
692
+ ])
693
+ ])
694
+ )
695
+ }
696
+ }
697
+ // 如果是树形表格
698
+ if (isExpandTree) {
699
+ rows.push(...renderRows(fixedType, isOptimizeMode, rowChildren, tableColumn))
700
+ }
701
+ })
702
+ return rows
703
+ }
704
+
705
+ onMounted(() => {
706
+ nextTick(() => {
707
+ const { fixedType } = props
708
+ const { elemStore } = tableInternalData
709
+ const prefix = `${fixedType || 'main'}-body-`
710
+ elemStore[`${prefix}wrapper`] = refElem
711
+ elemStore[`${prefix}scroll`] = refBodyScroll
712
+ elemStore[`${prefix}table`] = refBodyTable
713
+ elemStore[`${prefix}colgroup`] = refBodyColgroup
714
+ elemStore[`${prefix}list`] = refBodyTBody
715
+ elemStore[`${prefix}xSpace`] = refBodyXSpace
716
+ elemStore[`${prefix}ySpace`] = refBodyYSpace
717
+ elemStore[`${prefix}emptyBlock`] = refBodyEmptyBlock
718
+ })
719
+ })
720
+
721
+ onUnmounted(() => {
722
+ const { fixedType } = props
723
+ const { elemStore } = tableInternalData
724
+ const prefix = `${fixedType || 'main'}-body-`
725
+ elemStore[`${prefix}wrapper`] = null
726
+ elemStore[`${prefix}scroll`] = null
727
+ elemStore[`${prefix}table`] = null
728
+ elemStore[`${prefix}colgroup`] = null
729
+ elemStore[`${prefix}list`] = null
730
+ elemStore[`${prefix}xSpace`] = null
731
+ elemStore[`${prefix}ySpace`] = null
732
+ elemStore[`${prefix}emptyBlock`] = null
733
+ })
734
+
735
+ const renderVN = () => {
736
+ const { slots } = tableContext
737
+ const $xeGrid = $xeTable.xeGrid
738
+ const $xeGantt = $xeTable.xeGantt
739
+
740
+ const { fixedColumn, fixedType, tableColumn } = props
741
+ const { mouseConfig } = tableProps
742
+ const { isGroup, tableData, isColLoading, overflowX, scrollXLoad, scrollYLoad, dragRow, dragCol } = tableReactData
743
+ const { visibleColumn, fullAllDataRowIdData, fullColumnIdData } = tableInternalData
744
+ const emptyOpts = computeEmptyOpts.value
745
+ const mouseOpts = computeMouseOpts.value
746
+ const isBodyRenderOptimize = computeIsBodyRenderOptimize.value
747
+
748
+ let renderDataList = tableData
749
+ let renderColumnList = tableColumn as VxeTableDefines.ColumnInfo[]
750
+ const isOptimizeMode = isBodyRenderOptimize
751
+
752
+ if (!isColLoading && (fixedType || !overflowX)) {
753
+ renderColumnList = visibleColumn
754
+ }
755
+
756
+ if (fixedType) {
757
+ if (isOptimizeMode) {
758
+ renderColumnList = fixedColumn || []
759
+ }
760
+ }
761
+
762
+ // 行拖拽
763
+ if (scrollYLoad && dragRow) {
764
+ if (renderDataList.length > 2) {
765
+ const dRowRest = fullAllDataRowIdData[getRowid($xeTable, dragRow)]
766
+ if (dRowRest) {
767
+ const drIndex = dRowRest._index
768
+ const firstRow = renderDataList[0]
769
+ const lastRow = renderDataList[renderDataList.length - 1]
770
+ const firstRowRest = fullAllDataRowIdData[getRowid($xeTable, firstRow)]
771
+ const lastRowRest = fullAllDataRowIdData[getRowid($xeTable, lastRow)]
772
+ if (firstRowRest && lastRowRest) {
773
+ const frIndex = firstRowRest._index
774
+ const lrIndex = lastRowRest._index
775
+ if (drIndex < frIndex) {
776
+ renderDataList = [dragRow].concat(renderDataList)
777
+ } else if (drIndex > lrIndex) {
778
+ renderDataList = renderDataList.concat([dragRow])
779
+ }
780
+ }
781
+ }
782
+ }
783
+ }
784
+
785
+ if (!fixedType && !isGroup) {
786
+ // 列拖拽
787
+ if (scrollXLoad && dragCol) {
788
+ if (renderColumnList.length > 2) {
789
+ const dCowRest = fullColumnIdData[dragCol.id]
790
+ if (dCowRest) {
791
+ const dcIndex = dCowRest._index
792
+ const firstCol = renderColumnList[0]
793
+ const lastCol = renderColumnList[renderColumnList.length - 1]
794
+ const firstColRest = fullColumnIdData[firstCol.id]
795
+ const lastColRest = fullColumnIdData[lastCol.id]
796
+ if (firstColRest && lastColRest) {
797
+ const fcIndex = firstColRest._index
798
+ const lcIndex = lastColRest._index
799
+ if (dcIndex < fcIndex) {
800
+ renderColumnList = [dragCol].concat(renderColumnList)
801
+ } else if (dcIndex > lcIndex) {
802
+ renderColumnList = renderColumnList.concat([dragCol])
803
+ }
804
+ }
805
+ }
806
+ }
807
+ }
808
+ }
809
+
810
+ let emptyContent: string | VxeComponentSlotType | VxeComponentSlotType[]
811
+ const emptySlot = slots ? slots.empty : null
812
+ const emptyParams = { $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt }
813
+ if (emptySlot) {
814
+ emptyContent = $xeTable.callSlot(emptySlot, emptyParams)
815
+ } else {
816
+ const compConf = emptyOpts.name ? renderer.get(emptyOpts.name) : null
817
+ const rtEmptyView = compConf ? (compConf.renderTableEmpty || compConf.renderTableEmptyView || compConf.renderEmpty) : null
818
+ if (rtEmptyView) {
819
+ emptyContent = getSlotVNs(rtEmptyView(emptyOpts, emptyParams))
820
+ } else {
821
+ emptyContent = tableProps.emptyText || getI18n('vxe.table.emptyText')
822
+ }
823
+ }
824
+
825
+ return h('div', {
826
+ ref: refElem,
827
+ class: ['vxe-table--body-wrapper', fixedType ? `fixed-${fixedType}--wrapper` : 'body--wrapper'],
828
+ xid: xID
829
+ }, [
830
+ h('div', {
831
+ ref: refBodyScroll,
832
+ class: 'vxe-table--body-inner-wrapper',
833
+ onScroll (evnt) {
834
+ $xeTable.triggerBodyScrollEvent(evnt, fixedType)
835
+ }
836
+ }, [
837
+ fixedType
838
+ ? renderEmptyElement($xeTable)
839
+ : h('div', {
840
+ ref: refBodyXSpace,
841
+ class: 'vxe-body--x-space'
842
+ }),
843
+ h('div', {
844
+ ref: refBodyYSpace,
845
+ class: 'vxe-body--y-space'
846
+ }),
847
+ h('table', {
848
+ ref: refBodyTable,
849
+ class: 'vxe-table--body',
850
+ xid: xID,
851
+ cellspacing: 0,
852
+ cellpadding: 0,
853
+ border: 0,
854
+ xvm: isOptimizeMode ? '1' : null
855
+ }, [
856
+ /**
857
+ * 列宽
858
+ */
859
+ h('colgroup', {
860
+ ref: refBodyColgroup
861
+ }, renderColumnList.map((column, $columnIndex) => {
862
+ return h('col', {
863
+ name: column.id,
864
+ key: $columnIndex,
865
+ style: {
866
+ width: `${column.renderWidth}px`
867
+ }
868
+ })
869
+ })),
870
+ /**
871
+ * 内容
872
+ */
873
+ h('tbody', {
874
+ ref: refBodyTBody
875
+ }, renderRows(fixedType, isOptimizeMode, renderDataList, renderColumnList))
876
+ ]),
877
+ h('div', {
878
+ class: 'vxe-table--checkbox-range'
879
+ }),
880
+ mouseConfig && mouseOpts.area
881
+ ? h('div', {
882
+ class: 'vxe-table--cell-area',
883
+ xid: xID
884
+ }, [
885
+ h('span', {
886
+ class: 'vxe-table--cell-main-area'
887
+ }, mouseOpts.extension
888
+ ? [
889
+ h('span', {
890
+ class: 'vxe-table--cell-main-area-btn',
891
+ onMousedown (evnt: MouseEvent) {
892
+ if ($xeTable.triggerCellAreaExtendMousedownEvent) {
893
+ $xeTable.triggerCellAreaExtendMousedownEvent(evnt, { $table: $xeTable, fixed: fixedType, type: renderType })
894
+ }
895
+ }
896
+ })
897
+ ]
898
+ : []),
899
+ h('span', {
900
+ class: 'vxe-table--cell-clip-area'
901
+ }),
902
+ h('span', {
903
+ class: 'vxe-table--cell-extend-area'
904
+ }),
905
+ h('span', {
906
+ class: 'vxe-table--cell-multi-area'
907
+ }),
908
+ h('span', {
909
+ class: 'vxe-table--cell-active-area'
910
+ }),
911
+ h('span', {
912
+ class: 'vxe-table--cell-row-status-area'
913
+ })
914
+ ])
915
+ : renderEmptyElement($xeTable),
916
+ !fixedType
917
+ ? h('div', {
918
+ class: 'vxe-table--empty-block',
919
+ ref: refBodyEmptyBlock
920
+ }, [
921
+ h('div', {
922
+ class: 'vxe-table--empty-content'
923
+ }, emptyContent)
924
+ ])
925
+ : renderEmptyElement($xeTable)
926
+ ])
927
+ ])
928
+ }
929
+
930
+ return renderVN
931
+ }
932
+ })