vxe-table 3.20.7 → 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 +10 -1
  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 +1912 -3228
  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 +9 -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 -2505
  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.1773991883171.ttf → iconfont.1774240303597.ttf} +0 -0
  140. /package/es/{iconfont.1773991883171.woff → iconfont.1774240303597.woff} +0 -0
  141. /package/es/{iconfont.1773991883171.woff2 → iconfont.1774240303597.woff2} +0 -0
  142. /package/lib/{iconfont.1773991883171.ttf → iconfont.1774240303597.ttf} +0 -0
  143. /package/lib/{iconfont.1773991883171.woff → iconfont.1774240303597.woff} +0 -0
  144. /package/lib/{iconfont.1773991883171.woff2 → iconfont.1774240303597.woff2} +0 -0
@@ -1,1285 +1,1285 @@
1
- import { CreateElement, VNode } from 'vue'
2
- import XEUtils from 'xe-utils'
3
- import { VxeUI } from '../../ui'
4
- import { getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
5
- import { updateCellTitle } from '../../ui/src/dom'
6
- import { createColumn, getRowid } from './util'
7
- import { getSlotVNs } from '../../ui/src/vn'
8
-
9
- import type { VxeTableDefines, VxeTableConstructor, VxeTablePrivateMethods, VxeComponentSlotType, TableReactData, TableInternalData } from '../../../types'
10
-
11
- const { getI18n, getIcon, renderer, renderEmptyElement } = VxeUI
12
-
13
- function renderTitlePrefixIcon (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
14
- const { $table, column } = params
15
- const titlePrefix = column.titlePrefix || column.titleHelp
16
- if (titlePrefix) {
17
- return h('i', {
18
- class: ['vxe-cell-title-prefix-icon', titlePrefix.iconStatus ? `theme--${titlePrefix.iconStatus}` : ''],
19
- on: {
20
- mouseenter (evnt: any) {
21
- $table.triggerHeaderTitleEvent(evnt, titlePrefix, params)
22
- },
23
- mouseleave (evnt: any) {
24
- $table.handleTargetLeaveEvent(evnt)
25
- }
26
- }
27
- }, [
28
- h('i', {
29
- class: titlePrefix.icon || getIcon().TABLE_TITLE_PREFIX
30
- })
31
- ])
32
- }
33
- return renderEmptyElement($table)
34
- }
35
-
36
- function renderTitleSuffixIcon (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
37
- const { $table, column } = params
38
- const titleSuffix = column.titleSuffix
39
- if (titleSuffix) {
40
- return h('i', {
41
- class: ['vxe-cell-title-suffix-icon', titleSuffix.iconStatus ? `theme--${titleSuffix.iconStatus}` : ''],
42
- on: {
43
- mouseenter (evnt: any) {
44
- $table.triggerHeaderTitleEvent(evnt, titleSuffix, params)
45
- },
46
- mouseleave (evnt: any) {
47
- $table.handleTargetLeaveEvent(evnt)
48
- }
49
- }
50
- }, [
51
- h('i', {
52
- class: titleSuffix.icon || getIcon().TABLE_TITLE_SUFFIX
53
- })
54
- ])
55
- }
56
- return renderEmptyElement($table)
57
- }
58
-
59
- function renderCellDragIcon (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
60
- const { $table } = params
61
- const tableSlots = $table.$scopedSlots
62
- const tableProps = $table
63
- const { dragConfig } = tableProps
64
- const rowDragOpts = $table.computeRowDragOpts
65
- const { icon, trigger, disabledMethod } = rowDragOpts
66
- const rDisabledMethod = disabledMethod || (dragConfig ? dragConfig.rowDisabledMethod : null)
67
- const isDisabled = rDisabledMethod && rDisabledMethod(params)
68
- const rowDragIconSlot = tableSlots.rowDragIcon || tableSlots['row-drag-icon']
69
- const ons: Record<string, any> = {}
70
- if (trigger !== 'cell') {
71
- ons.mousedown = (evnt: MouseEvent) => {
72
- if (!isDisabled) {
73
- $table.handleCellDragMousedownEvent(evnt, params)
74
- }
75
- }
76
- ons.mouseup = $table.handleCellDragMouseupEvent
77
- }
78
- return h('span', {
79
- key: 'dg',
80
- class: ['vxe-cell--drag-handle', {
81
- 'is--disabled': isDisabled
82
- }],
83
- on: ons
84
- }, rowDragIconSlot
85
- ? $table.callSlot(rowDragIconSlot as any, params, h)
86
- : [
87
- h('i', {
88
- class: icon || (dragConfig ? dragConfig.rowIcon : '') || getIcon().TABLE_DRAG_ROW
89
- })
90
- ])
91
- }
92
-
93
- function renderCellBaseVNs (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, content: VxeComponentSlotType | VxeComponentSlotType[]) {
94
- const { $table, column, level } = params
95
- const { dragSort } = column
96
- const tableProps = $table
97
- const { treeConfig, dragConfig } = tableProps
98
- const rowOpts = $table.computeRowOpts
99
- const rowDragOpts = $table.computeRowDragOpts
100
- const treeOpts = $table.computeTreeOpts
101
- const { showIcon, isPeerDrag, isCrossDrag, visibleMethod } = rowDragOpts
102
- const rVisibleMethod = visibleMethod || (dragConfig ? dragConfig.rowVisibleMethod : null)
103
- const vns: VxeComponentSlotType[] = []
104
- if (dragSort && rowOpts.drag && ((showIcon || (dragConfig ? dragConfig.showRowIcon : false)) && (!rVisibleMethod || rVisibleMethod(params)))) {
105
- if (treeConfig) {
106
- if (treeOpts.transform && (isPeerDrag || isCrossDrag || !level)) {
107
- vns.unshift(
108
- renderCellDragIcon(h, params)
109
- )
110
- }
111
- } else {
112
- vns.unshift(
113
- renderCellDragIcon(h, params)
114
- )
115
- }
116
- }
117
- return vns.concat(XEUtils.isArray(content) ? content : [content])
118
- }
119
-
120
- function renderHeaderCellDragIcon (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
121
- const { $table, column } = params
122
- const tableSlots = $table.$scopedSlots
123
- const { slots } = column
124
- const columnOpts = $table.computeColumnOpts
125
- const columnDragOpts = $table.computeColumnDragOpts
126
- const { showIcon, icon, trigger, isPeerDrag, isCrossDrag, visibleMethod, disabledMethod } = columnDragOpts
127
- if (columnOpts.drag && showIcon && (!visibleMethod || visibleMethod(params))) {
128
- if (!column.fixed && (isPeerDrag || isCrossDrag || !column.parentId)) {
129
- const isDisabled = disabledMethod && disabledMethod(params)
130
- const columnDragIconSlot = (slots ? slots.columnDragIcon || slots['column-drag-icon'] : null) || tableSlots.columnDragIcon || tableSlots['column-drag-icon']
131
- const ons: Record<string, any> = {}
132
- if (trigger !== 'cell') {
133
- ons.mousedown = (evnt: MouseEvent) => {
134
- if (!isDisabled) {
135
- $table.handleHeaderCellDragMousedownEvent(evnt, params)
136
- }
137
- }
138
- ons.mouseup = $table.handleHeaderCellDragMouseupEvent
139
- }
140
- return h('span', {
141
- key: 'dg',
142
- class: ['vxe-cell--drag-handle', {
143
- 'is--disabled': isDisabled
144
- }],
145
- on: ons
146
- }, columnDragIconSlot
147
- ? $table.callSlot(columnDragIconSlot as any, params, h)
148
- : [
149
- h('i', {
150
- class: icon || getIcon().TABLE_DRAG_COLUMN
151
- })
152
- ])
153
- }
154
- }
155
- return renderEmptyElement($table)
156
- }
157
-
158
- function renderHeaderCellBaseVNs (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, content: VNode | VNode[]) {
159
- const vns = [
160
- renderTitlePrefixIcon(h, params),
161
- renderHeaderCellDragIcon(h, params),
162
- ...(XEUtils.isArray(content) ? content : [content]),
163
- renderTitleSuffixIcon(h, params)
164
- ]
165
- return vns
166
- }
167
-
168
- function getRenderDefaultColumnTitle (h: CreateElement, column: VxeTableDefines.ColumnInfo, content: VxeComponentSlotType | VxeComponentSlotType[]) {
169
- if (column.type === 'html' && XEUtils.isString(content)) {
170
- return h('span', {
171
- key: 'ch',
172
- domProps: {
173
- innerHTML: content
174
- }
175
- })
176
- }
177
- return h('span', {
178
- key: 'ct'
179
- }, getSlotVNs(content))
180
- }
181
-
182
- function renderTitleContent (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, content: VxeComponentSlotType | VxeComponentSlotType[]) {
183
- const { $table, column } = params
184
- const tableProps = $table
185
- const tableReactData = $table as unknown as TableReactData
186
- const { showHeaderOverflow: allColumnHeaderOverflow } = tableProps
187
- const { isRowGroupStatus } = tableReactData
188
- const { showHeaderOverflow, slots } = column
189
- const titleSlot = slots ? slots.title : null
190
- const headerTooltipOpts = $table.computeHeaderTooltipOpts
191
- const showAllTip = headerTooltipOpts.showAll
192
- const headOverflow = XEUtils.eqNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
193
- const showTitle = headOverflow === 'title'
194
- const showTooltip = headOverflow === true || headOverflow === 'tooltip'
195
- const ons: Record<string, any> = {}
196
- if (showTitle || showTooltip || showAllTip) {
197
- ons.mouseenter = (evnt: MouseEvent) => {
198
- if (tableReactData.isDragResize) {
199
- return
200
- }
201
- if (showTitle) {
202
- updateCellTitle(evnt.currentTarget, column)
203
- } else if (showTooltip || showAllTip) {
204
- $table.triggerHeaderTooltipEvent(evnt, params)
205
- }
206
- }
207
- }
208
- if (showTooltip || showAllTip) {
209
- ons.mouseleave = (evnt: any) => {
210
- if (tableReactData.isDragResize) {
211
- return
212
- }
213
- if (showTooltip || showAllTip) {
214
- $table.handleTargetLeaveEvent(evnt)
215
- }
216
- }
217
- }
218
- const titleVN = getRenderDefaultColumnTitle(h, column, content)
219
- return [
220
- h('span', {
221
- class: 'vxe-cell--title',
222
- on: ons
223
- }, isRowGroupStatus && column.aggFunc && $table.getPivotTableAggregateRenderColTitles
224
- ? $table.getPivotTableAggregateRenderColTitles(h, column, titleVN)
225
- : titleSlot
226
- ? $table.callSlot(titleSlot, params, h)
227
- : [
228
- titleVN
229
- ])
230
- ]
231
- }
232
-
233
- function getFooterContent (h: CreateElement, params: VxeTableDefines.CellRenderFooterParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
234
- const { $table, column, row } = params
235
- const tableProps = $table
236
- const { editConfig } = tableProps
237
- const { slots, editRender, cellRender } = column
238
- const footerSlot = slots ? slots.footer : null
239
- if (footerSlot) {
240
- return $table.callSlot(footerSlot, params, h)
241
- }
242
- const isEnableEdit = editConfig && isEnableConf(editConfig)
243
- const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
244
- const cellRenderOpts = isEnableConf(cellRender) ? cellRender : null
245
- const renderOpts = editRenderOpts || cellRenderOpts
246
- const itemValue = $table.getFooterCellLabel(row, column)
247
- if (renderOpts) {
248
- const compConf = renderer.get(renderOpts.name)
249
- const rtFooter = compConf ? (compConf.renderTableFooter || compConf.renderFooter) : null
250
- if (rtFooter) {
251
- const footParams = Object.assign(params, {
252
- cellValue: itemValue,
253
- itemValue
254
- })
255
- return getSlotVNs(rtFooter.call($table, h, renderOpts, footParams))
256
- }
257
- }
258
- return [
259
- formatText(itemValue, 1)
260
- ]
261
- }
262
-
263
- function getDefaultCellLabel (params: VxeTableDefines.CellRenderBodyParams) {
264
- const { $table, row, column } = params
265
- return formatText($table.getCellLabel(row, column), 1)
266
- }
267
-
268
- function renderCellHandle (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & {
269
- $table: VxeTableConstructor & VxeTablePrivateMethods;
270
- }) {
271
- const { column, row, $table } = params
272
- const tableProps = $table
273
- const tableReactData = $table as unknown as TableReactData
274
- const { editConfig } = tableProps
275
- const { isRowGroupStatus } = tableReactData
276
- const { type, treeNode, rowGroupNode, editRender } = column
277
- const aggregateOpts = $table.computeAggregateOpts
278
- const { mode } = aggregateOpts
279
- const checkboxOpts = $table.computeCheckboxOpts
280
- const editOpts = $table.computeEditOpts
281
- const isDeepCell = treeNode || (isRowGroupStatus && (mode === 'column' ? column.field === row.groupField : rowGroupNode))
282
- switch (type) {
283
- case 'seq':
284
- return isDeepCell ? Cell.renderDeepIndexCell(h, params) : Cell.renderSeqCell(h, params)
285
- case 'radio':
286
- return isDeepCell ? Cell.renderDeepRadioCell(h, params) : Cell.renderRadioCell(h, params)
287
- case 'checkbox':
288
- return checkboxOpts.checkField ? (isDeepCell ? Cell.renderDeepSelectionCellByProp(h, params) : Cell.renderCheckboxCellByProp(h, params)) : (isDeepCell ? Cell.renderDeepSelectionCell(h, params) : Cell.renderCheckboxCell(h, params))
289
- case 'expand':
290
- return Cell.renderExpandCell(h, params)
291
- case 'html':
292
- return isDeepCell ? Cell.renderDeepHTMLCell(h, params) : Cell.renderHTMLCell(h, params)
293
- }
294
- const isEnableEdit = editConfig && isEnableConf(editConfig)
295
- const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
296
- if (editRenderOpts) {
297
- return editOpts.mode === 'cell' ? (isDeepCell ? Cell.renderDeepCellEdit(h, params) : Cell.renderCellEdit(h, params)) : (isDeepCell ? Cell.renderDeepRowEdit(h, params) : Cell.renderRowEdit(h, params))
298
- }
299
- return isDeepCell ? Cell.renderDeepCell(h, params) : Cell.renderDefaultCell(h, params)
300
- }
301
-
302
- function renderHeaderHandle (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & {
303
- $table: VxeTableConstructor & VxeTablePrivateMethods;
304
- }) {
305
- const { column, $table } = params
306
- const tableProps = $table
307
- const { editConfig } = tableProps
308
- const { type, filters, sortable, editRender } = column
309
- switch (type) {
310
- case 'seq':
311
- return Cell.renderSeqHeader(h, params)
312
- case 'radio':
313
- return Cell.renderRadioHeader(h, params)
314
- case 'checkbox':
315
- return Cell.renderCheckboxHeader(h, params)
316
- case 'html':
317
- if (filters && sortable) {
318
- return Cell.renderSortAndFilterHeader(h, params)
319
- } else if (sortable) {
320
- return Cell.renderSortHeader(h, params)
321
- } else if (filters) {
322
- return Cell.renderFilterHeader(h, params)
323
- }
324
- break
325
- }
326
- const isEnableEdit = editConfig && isEnableConf(editConfig)
327
- const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
328
- if (editRenderOpts) {
329
- return Cell.renderEditHeader(h, params)
330
- } else if (filters && sortable) {
331
- return Cell.renderSortAndFilterHeader(h, params)
332
- } else if (sortable) {
333
- return Cell.renderSortHeader(h, params)
334
- } else if (filters) {
335
- return Cell.renderFilterHeader(h, params)
336
- }
337
- return Cell.renderDefaultHeader(h, params)
338
- }
339
-
340
- function renderFooterHandle (h: CreateElement, params: VxeTableDefines.CellRenderFooterParams & {
341
- $table: VxeTableConstructor & VxeTablePrivateMethods;
342
- }) {
343
- return Cell.renderDefaultFooter(h, params)
344
- }
345
-
346
- export const Cell = {
347
- createColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, _vm: any) {
348
- const { type } = _vm
349
- const renConfs: any = {
350
- renderHeader: renderHeaderHandle,
351
- renderCell: renderCellHandle,
352
- renderFooter: renderFooterHandle
353
- }
354
- if (type === 'expand') {
355
- renConfs.renderData = Cell.renderExpandData
356
- }
357
- return createColumn($xeTable, _vm, renConfs)
358
- },
359
- /**
360
- * 列头标题
361
- */
362
- renderHeaderTitle (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
363
- const { $table, column } = params
364
- const tableProps = $table
365
- const { editConfig } = tableProps
366
- const { slots, editRender, cellRender } = column
367
- const headerSlot = slots ? slots.header : null
368
- if (headerSlot) {
369
- return renderTitleContent(h, params, $table.callSlot(headerSlot, params, h))
370
- }
371
- const isEnableEdit = editConfig && isEnableConf(editConfig)
372
- const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
373
- const cellRenderOpts = isEnableConf(cellRender) ? cellRender : null
374
- const renderOpts = editRenderOpts || cellRenderOpts
375
- if (renderOpts) {
376
- const compConf = renderer.get(renderOpts.name)
377
- const rtHeader = compConf ? (compConf.renderTableHeader || compConf.renderHeader) : null
378
- if (rtHeader) {
379
- return getSlotVNs(renderTitleContent(h, params, rtHeader.call($table, h, renderOpts, params)))
380
- }
381
- }
382
- return renderTitleContent(h, params, formatText(column.getTitle(), 1))
383
- },
384
- renderDefaultHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
385
- return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params))
386
- },
387
- renderDefaultCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
388
- const { $table, row, column } = params
389
- const tableProps = $table
390
- const tableReactData = $table as unknown as TableReactData
391
- const tableInternalData = $table as unknown as TableInternalData
392
- const { isRowGroupStatus } = tableReactData
393
- const { editConfig } = tableProps
394
- const { field, slots, editRender, cellRender, rowGroupNode, aggFunc, formatter } = column
395
- const isEnableEdit = editConfig && isEnableConf(editConfig)
396
- const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
397
- const cellRenderOpts = isEnableConf(cellRender) ? cellRender : null
398
- const defaultSlot = slots ? slots.default : null
399
- const gcSlot = slots ? (slots.groupContent || slots['group-content']) : null
400
- const gvSlot = slots ? (slots.groupValues || slots['group-values']) : null
401
- let cellValue: string | number | null = ''
402
- if (isRowGroupStatus && field && row.isAggregate) {
403
- const aggRow: VxeTableDefines.AggregateRowInfo = row
404
- const { fullColumnFieldData } = tableInternalData
405
- const aggregateOpts = $table.computeAggregateOpts
406
- const { mode, showTotal, totalMethod, countFields, contentMethod, formatValuesMethod, mapChildrenField } = aggregateOpts
407
- const aggData = aggRow.aggData
408
- const currAggData = aggData ? aggData[field] : null
409
- const groupField = aggRow.groupField
410
- const groupContent = aggRow.groupContent
411
- const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : []
412
- const childCount = aggRow.childCount
413
- const colRest = fullColumnFieldData[groupField] || {}
414
- const ctParams = {
415
- $table,
416
- groupField,
417
- groupColumn: (colRest ? colRest.column : null) as VxeTableDefines.ColumnInfo,
418
- column,
419
- groupValue: groupContent,
420
- childList,
421
- childCount,
422
- aggValue: null as any,
423
-
424
- /**
425
- * 已废弃
426
- * @deprecated
427
- */
428
- children: childList,
429
- /**
430
- * 已废弃
431
- * @deprecated
432
- */
433
- totalValue: childCount
434
- }
435
- if (mode === 'column' ? field === aggRow.groupField : rowGroupNode) {
436
- cellValue = groupContent
437
- if (contentMethod) {
438
- cellValue = `${contentMethod(ctParams)}`
439
- }
440
- if (showTotal) {
441
- cellValue = getI18n('vxe.table.rowGroupContentTotal', [cellValue, totalMethod ? totalMethod(ctParams) : childCount, childCount])
442
- }
443
- if (gcSlot) {
444
- return renderCellBaseVNs(h, params, $table.callSlot(gcSlot, Object.assign({ groupField, groupContent, childList, childCount }, params), h))
445
- }
446
- } else if ($table.getPivotTableAggregateCellAggValue) {
447
- cellValue = $table.getPivotTableAggregateCellAggValue(params)
448
- ctParams.aggValue = cellValue
449
- if (gvSlot) {
450
- return renderCellBaseVNs(h, params, $table.callSlot(gvSlot, Object.assign({ groupField, groupContent, childList, childCount }, params, ctParams), h))
451
- }
452
- } else if (aggFunc === true || (countFields && countFields.includes(field))) {
453
- cellValue = currAggData ? currAggData.value : childCount
454
- ctParams.aggValue = cellValue
455
- if (formatValuesMethod) {
456
- cellValue = formatValuesMethod(ctParams)
457
- }
458
- if (gvSlot) {
459
- return renderCellBaseVNs(h, params, $table.callSlot(gvSlot, Object.assign({ groupField, groupContent, childList, childCount }, params, ctParams), h))
460
- }
461
- }
462
- } else {
463
- if (defaultSlot) {
464
- return renderCellBaseVNs(h, params, $table.callSlot(defaultSlot, params, h))
465
- }
466
- const renderOpts = editRenderOpts || cellRenderOpts
467
- // formatter > (renderTableCell | renderTableDefault)
468
- if (renderOpts && !formatter) {
469
- const compConf = renderer.get(renderOpts.name)
470
- if (compConf) {
471
- const renderFn = editRenderOpts ? (compConf.renderTableCell || compConf.renderCell) : (compConf.renderTableDefault || compConf.renderDefault)
472
- if (renderFn) {
473
- return renderCellBaseVNs(h, params, getSlotVNs(renderFn.call($table, h, renderOpts, Object.assign({ $type: editRenderOpts ? 'edit' : 'cell' }, params))))
474
- }
475
- }
476
- }
477
- cellValue = $table.getCellLabel(row, column)
478
- }
479
- const cellPlaceholder = editRenderOpts ? editRenderOpts.placeholder : ''
480
- return renderCellBaseVNs(h, params, [
481
- h('span', {
482
- class: 'vxe-cell--label'
483
- }, [
484
- // 如果设置占位符
485
- editRenderOpts && eqEmptyValue(cellValue)
486
- ? h('span', {
487
- class: 'vxe-cell--placeholder'
488
- }, formatText(getFuncText(cellPlaceholder), 1))
489
- : h('span', formatText(cellValue, 1))
490
- ])
491
- ])
492
- },
493
- renderDeepCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
494
- return Cell.renderDeepNodeBtn(h, params, Cell.renderDefaultCell(h, params))
495
- },
496
- renderDefaultFooter (h: CreateElement, params: VxeTableDefines.CellRenderFooterParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
497
- return getFooterContent(h, params)
498
- },
499
-
500
- /**
501
- * 行分组
502
- */
503
- renderRowGroupBtn (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, cellVNodes: VxeComponentSlotType[]) {
504
- const { $table } = params
505
- const tableReactData = $table as unknown as TableReactData
506
- const tableInternalData = $table as unknown as TableInternalData
507
- const { row, level } = params
508
- const { rowGroupExpandedFlag } = tableReactData
509
- const { rowGroupExpandedMaps } = tableInternalData
510
- const aggregateOpts = $table.computeAggregateOpts
511
- const { mode, padding, indent, showIcon, iconOpen, iconClose } = aggregateOpts
512
- const rowid = getRowid($table, row)
513
- const isExpand = !!rowGroupExpandedFlag && !!rowGroupExpandedMaps[rowid]
514
- return h('div', {
515
- class: ['vxe-row-group--tree-node', {
516
- 'is--expanded': isExpand
517
- }],
518
- style: mode !== 'column' && padding && indent
519
- ? {
520
- paddingLeft: `${level * indent}px`
521
- }
522
- : undefined
523
- }, [
524
- showIcon && row.isAggregate
525
- ? h('span', {
526
- class: 'vxe-row-group--node-btn',
527
- on: {
528
- click (evnt: MouseEvent) {
529
- $table.triggerRowGroupExpandEvent(evnt, params)
530
- }
531
- }
532
- }, [
533
- h('i', {
534
- class: isExpand ? (iconOpen || getIcon().TABLE_ROW_GROUP_OPEN) : (iconClose || getIcon().TABLE_ROW_GROUP_CLOSE)
535
- })
536
- ])
537
- : renderEmptyElement($table),
538
- h('div', {
539
- class: 'vxe-row-group-cell'
540
- }, cellVNodes)
541
- ])
542
- },
543
- /**
544
- * 树
545
- */
546
- renderTreeNodeBtn (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, cellVNodes: VxeComponentSlotType[]) {
547
- const { $table, isHidden } = params
548
- const tableReactData = $table as unknown as TableReactData
549
- const tableInternalData = $table as unknown as TableInternalData
550
- const { treeExpandedFlag } = tableReactData
551
- const { fullAllDataRowIdData, treeExpandedMaps, treeExpandLazyLoadedMaps } = tableInternalData
552
- const treeOpts = $table.computeTreeOpts
553
- const { row, column, level } = params
554
- const { slots } = column
555
- const { padding, indent, lazy, trigger, iconLoaded, showIcon, iconOpen, iconClose } = treeOpts
556
- const childrenField = treeOpts.children || treeOpts.childrenField
557
- const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
558
- const rowChilds = row[childrenField]
559
- const hasChild = rowChilds && rowChilds.length
560
- const iconSlot = slots ? slots.icon : null
561
- let hasLazyChilds = false
562
- let isActive = false
563
- let isLazyLoading = false
564
- let isLazyLoaded = false
565
- const ons: Record<string, any> = {}
566
- if (iconSlot) {
567
- return $table.callSlot(iconSlot, params, h)
568
- }
569
- if (!isHidden) {
570
- const rowid = getRowid($table, row)
571
- isActive = !!treeExpandedFlag && !!treeExpandedMaps[rowid]
572
- if (lazy) {
573
- const rest = fullAllDataRowIdData[rowid]
574
- isLazyLoading = !!treeExpandLazyLoadedMaps[rowid]
575
- hasLazyChilds = row[hasChildField]
576
- isLazyLoaded = !!rest.treeLoaded
577
- }
578
- }
579
- if (!trigger || trigger === 'default') {
580
- ons.click = (evnt: MouseEvent) => {
581
- $table.triggerTreeExpandEvent(evnt, params)
582
- }
583
- }
584
- return [
585
- h('div', {
586
- class: ['vxe-cell--tree-node', {
587
- 'is--active': isActive
588
- }],
589
- style: padding && indent
590
- ? {
591
- paddingLeft: `${level * indent}px`
592
- }
593
- : undefined
594
- }, [
595
- showIcon && (lazy ? (isLazyLoaded ? hasChild : (hasChild || hasLazyChilds)) : hasChild)
596
- ? [
597
- h('div', {
598
- class: 'vxe-cell--tree-btn',
599
- on: ons
600
- }, [
601
- h('i', {
602
- class: isLazyLoading ? (iconLoaded || getIcon().TABLE_TREE_LOADED) : (isActive ? (iconOpen || getIcon().TABLE_TREE_OPEN) : (iconClose || getIcon().TABLE_TREE_CLOSE))
603
- })
604
- ])
605
- ]
606
- : null,
607
- h('div', {
608
- class: 'vxe-tree-cell'
609
- }, cellVNodes)
610
- ])
611
- ]
612
- },
613
- /**
614
- * 层级节点。
615
- * 行分组、树结构
616
- */
617
- renderDeepNodeBtn (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, cellVNodes: VxeComponentSlotType[]) {
618
- const { $table, row, column } = params
619
- const { rowGroupNode } = column
620
- const tableReactData = $table as unknown as TableReactData
621
- const { rowGroupList } = tableReactData
622
- if (rowGroupList.length) {
623
- const aggregateOpts = $table.computeAggregateOpts
624
- const { mode } = aggregateOpts
625
- if (mode === 'column' ? column.field === row.groupField : rowGroupNode) {
626
- return [Cell.renderRowGroupBtn(h, params, cellVNodes)]
627
- }
628
- }
629
- return [Cell.renderTreeNodeBtn(h, params, cellVNodes)]
630
- },
631
-
632
- /**
633
- * 序号
634
- */
635
- renderSeqHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
636
- const { $table, column } = params
637
- const { slots } = column
638
- return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, params, slots && slots.header ? $table.callSlot(slots.header, params, h) : formatText(column.getTitle(), 1)))
639
- },
640
- renderSeqCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
641
- const { $table, column } = params
642
- const tableProps = $table
643
- const { treeConfig } = tableProps
644
- const seqOpts = $table.computeSeqOpts
645
- const { slots } = column
646
- if (slots && slots.default) {
647
- return renderCellBaseVNs(h, params, $table.callSlot(slots.default, params, h))
648
- }
649
- const { seq } = params
650
- const seqMd = seqOpts.seqMethod
651
- return renderCellBaseVNs(h, params, [
652
- h('span', `${formatText(seqMd ? seqMd(params) : treeConfig ? seq : (seqOpts.startIndex || 0) + (seq as number), 1)}`)
653
- ])
654
- },
655
- renderDeepIndexCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
656
- return Cell.renderDeepNodeBtn(h, params, Cell.renderSeqCell(h, params))
657
- },
658
-
659
- /**
660
- * 单选
661
- */
662
- renderRadioHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
663
- const { $table, column } = params
664
- const { slots } = column
665
- const headerSlot = slots ? slots.header : null
666
- const titleSlot = slots ? slots.title : null
667
- return renderHeaderCellBaseVNs(h, params,
668
- renderTitleContent(h, params, headerSlot
669
- ? $table.callSlot(headerSlot, params, h)
670
- : [
671
- h('span', {
672
- class: 'vxe-radio--label'
673
- }, titleSlot ? $table.callSlot(titleSlot, params, h) : formatText(column.getTitle(), 1))
674
- ])
675
- )
676
- },
677
- renderRadioCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
678
- const { $table, column, isHidden } = params
679
- const tableReactData = $table as unknown as TableReactData
680
- const { selectRadioRow } = tableReactData
681
- const radioOpts = $table.computeRadioOpts
682
- const { slots } = column
683
- const { labelField, checkMethod, visibleMethod } = radioOpts
684
- const { row } = params
685
- const defaultSlot = slots ? slots.default : null
686
- const radioSlot = slots ? slots.radio : null
687
- const isChecked = row === selectRadioRow
688
- const isVisible = !visibleMethod || visibleMethod({ $table, row })
689
- let isDisabled = !!checkMethod
690
- let on: any
691
- if (!isHidden) {
692
- on = {
693
- click (evnt: any) {
694
- if (!isDisabled && isVisible) {
695
- $table.triggerRadioRowEvent(evnt, params)
696
- }
697
- }
698
- }
699
- if (checkMethod) {
700
- isDisabled = !checkMethod({ $table, row })
701
- }
702
- }
703
- const radioParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible }
704
- if (radioSlot) {
705
- return renderCellBaseVNs(h, params, $table.callSlot(radioSlot, radioParams, h))
706
- }
707
- const radioVNs = []
708
- if (isVisible) {
709
- radioVNs.push(
710
- h('span', {
711
- class: ['vxe-radio--icon', isChecked ? getIcon().TABLE_RADIO_CHECKED : (isDisabled ? getIcon().TABLE_RADIO_DISABLED_UNCHECKED : getIcon().TABLE_RADIO_UNCHECKED)]
712
- })
713
- )
714
- }
715
- if (defaultSlot || labelField) {
716
- radioVNs.push(
717
- h('span', {
718
- class: 'vxe-radio--label'
719
- }, defaultSlot ? $table.callSlot(defaultSlot, radioParams, h) : XEUtils.get(row, labelField))
720
- )
721
- }
722
- return renderCellBaseVNs(h, params, [
723
- h('span', {
724
- class: ['vxe-cell--radio', {
725
- 'is--checked': isChecked,
726
- 'is--disabled': isDisabled
727
- }],
728
- on
729
- }, radioVNs)
730
- ])
731
- },
732
- renderDeepRadioCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
733
- return Cell.renderDeepNodeBtn(h, params, Cell.renderRadioCell(h, params))
734
- },
735
-
736
- /**
737
- * 多选
738
- */
739
- renderCheckboxHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
740
- const { $table, column, isHidden } = params
741
- const tableReactData = $table as unknown as TableReactData
742
- const { isAllSelected: isAllCheckboxSelected, isIndeterminate: isAllCheckboxIndeterminate } = tableReactData
743
- const isAllCheckboxDisabled = $table.computeIsAllCheckboxDisabled
744
- const { slots } = column
745
- const headerSlot = slots ? slots.header : null
746
- const titleSlot = slots ? slots.title : null
747
- const checkboxOpts = $table.computeCheckboxOpts
748
- const { checkStrictly, showHeader, headerTitle } = checkboxOpts
749
- const colTitle = column.getTitle()
750
- const ons: Record<string, any> = {}
751
- if (!isHidden) {
752
- ons.click = (evnt: MouseEvent) => {
753
- if (!isAllCheckboxDisabled) {
754
- $table.triggerCheckAllEvent(evnt, !isAllCheckboxSelected)
755
- }
756
- }
757
- }
758
- const checkboxParams = { ...params, checked: isAllCheckboxSelected, disabled: isAllCheckboxDisabled, indeterminate: isAllCheckboxIndeterminate }
759
- if (headerSlot) {
760
- return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, checkboxParams, $table.callSlot(headerSlot, checkboxParams, h)))
761
- }
762
- if (checkStrictly ? !showHeader : showHeader === false) {
763
- return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, checkboxParams, [
764
- h('span', {
765
- class: 'vxe-checkbox--label'
766
- }, titleSlot ? $table.callSlot(titleSlot, checkboxParams, h) : colTitle)
767
- ]))
768
- }
769
- return renderHeaderCellBaseVNs(h, params,
770
- renderTitleContent(h, checkboxParams, [
771
- h('span', {
772
- class: ['vxe-cell--checkbox', {
773
- 'is--checked': isAllCheckboxSelected,
774
- 'is--disabled': isAllCheckboxDisabled,
775
- 'is--indeterminate': isAllCheckboxIndeterminate
776
- }],
777
- attrs: {
778
- title: XEUtils.eqNull(headerTitle) ? getI18n('vxe.table.allTitle') : `${headerTitle || ''}`
779
- },
780
- on: ons
781
- }, [
782
- h('span', {
783
- class: ['vxe-checkbox--icon', isAllCheckboxIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllCheckboxSelected ? getIcon().TABLE_CHECKBOX_CHECKED : (isAllCheckboxDisabled ? getIcon().TABLE_CHECKBOX_DISABLED_UNCHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED))]
784
- })
785
- ].concat(titleSlot || colTitle
786
- ? [
787
- h('span', {
788
- class: 'vxe-checkbox--label'
789
- }, titleSlot ? $table.callSlot(titleSlot, checkboxParams, h) : colTitle)
790
- ]
791
- : []))
792
- ])
793
- )
794
- },
795
- renderCheckboxCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
796
- const { $table, row, column, isHidden } = params
797
- const tableProps = $table
798
- const tableReactData = $table as unknown as TableReactData
799
- const tableInternalData = $table as unknown as TableInternalData
800
- const { treeConfig } = tableProps
801
- const { updateCheckboxFlag, isRowGroupStatus } = tableReactData
802
- const { selectCheckboxMaps, treeIndeterminateRowMaps } = tableInternalData
803
- const aggregateOpts = $table.computeAggregateOpts
804
- const { mapChildrenField } = aggregateOpts
805
- const checkboxOpts = $table.computeCheckboxOpts
806
- const { labelField, checkMethod, visibleMethod } = checkboxOpts
807
- const { slots } = column
808
- const defaultSlot = slots ? slots.default : null
809
- const checkboxSlot = slots ? slots.checkbox : null
810
- let indeterminate = false
811
- let isChecked = false
812
- let isVisible = true
813
- let isDisabled = false
814
- const ons: Record<string, any> = {}
815
- if (!isHidden) {
816
- const rowid = getRowid($table, row)
817
- isChecked = !!updateCheckboxFlag && !!selectCheckboxMaps[rowid]
818
- if (checkMethod && isRowGroupStatus && $table.isAggregateRecord(row)) {
819
- const childList: any[] = row[mapChildrenField || '']
820
- if (!childList || !childList.length || childList.every(item => !checkMethod({ $table, row: item }))) {
821
- isDisabled = true
822
- }
823
- } else {
824
- isVisible = !visibleMethod || visibleMethod({ $table, row })
825
- isDisabled = checkMethod ? !checkMethod({ $table, row }) : !!checkMethod
826
- }
827
- if (treeConfig || isRowGroupStatus) {
828
- indeterminate = !!treeIndeterminateRowMaps[rowid]
829
- }
830
- ons.click = (evnt: MouseEvent) => {
831
- if (!isDisabled && isVisible) {
832
- $table.triggerCheckRowEvent(evnt, params, !isChecked)
833
- }
834
- }
835
- }
836
- const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
837
- if (checkboxSlot) {
838
- return renderCellBaseVNs(h, params, $table.callSlot(checkboxSlot, checkboxParams, h))
839
- }
840
- const checkVNs = []
841
- if (isVisible) {
842
- checkVNs.push(
843
- h('span', {
844
- class: ['vxe-checkbox--icon', indeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : (isDisabled ? getIcon().TABLE_CHECKBOX_DISABLED_UNCHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED))]
845
- })
846
- )
847
- }
848
- if (defaultSlot || labelField) {
849
- checkVNs.push(
850
- h('span', {
851
- class: 'vxe-checkbox--label'
852
- }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams, h) : XEUtils.get(row, labelField))
853
- )
854
- }
855
- return renderCellBaseVNs(h, params, [
856
- h('span', {
857
- class: ['vxe-cell--checkbox', {
858
- 'is--checked': isChecked,
859
- 'is--disabled': isDisabled,
860
- 'is--indeterminate': indeterminate,
861
- 'is--hidden': !isVisible
862
- }],
863
- on: ons
864
- }, checkVNs)
865
- ])
866
- },
867
- renderDeepSelectionCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
868
- return Cell.renderDeepNodeBtn(h, params, Cell.renderCheckboxCell(h, params))
869
- },
870
- renderCheckboxCellByProp (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
871
- const { $table, row, column, isHidden } = params
872
- const tableProps = $table
873
- const tableReactData = $table as unknown as TableReactData
874
- const tableInternalData = $table as unknown as TableInternalData
875
- const { treeConfig } = tableProps
876
- const { updateCheckboxFlag, isRowGroupStatus } = tableReactData
877
- const { treeIndeterminateRowMaps } = tableInternalData
878
- const aggregateOpts = $table.computeAggregateOpts
879
- const { mapChildrenField } = aggregateOpts
880
- const checkboxOpts = $table.computeCheckboxOpts
881
- const { labelField, checkField, checkMethod, visibleMethod } = checkboxOpts
882
- const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
883
- const { slots } = column
884
- const defaultSlot = slots ? slots.default : null
885
- const checkboxSlot = slots ? slots.checkbox : null
886
- let indeterminate = false
887
- let isChecked = false
888
- let isVisible = true
889
- let isDisabled = false
890
- const ons: Record<string, any> = {}
891
- if (!isHidden) {
892
- const rowid = getRowid($table, row)
893
- isChecked = !!updateCheckboxFlag && XEUtils.get(row, checkField)
894
- if (checkMethod && isRowGroupStatus && $table.isAggregateRecord(row)) {
895
- const childList: any[] = row[mapChildrenField || '']
896
- if (!childList || !childList.length || childList.every(item => !checkMethod({ $table, row: item }))) {
897
- isDisabled = true
898
- }
899
- } else {
900
- isVisible = !visibleMethod || visibleMethod({ $table, row })
901
- isDisabled = checkMethod ? !checkMethod({ $table, row }) : !!checkMethod
902
- }
903
- if (treeConfig || isRowGroupStatus) {
904
- indeterminate = !!treeIndeterminateRowMaps[rowid]
905
- }
906
- ons.click = (evnt: MouseEvent) => {
907
- if (!isDisabled && isVisible) {
908
- $table.triggerCheckRowEvent(evnt, params, !isChecked)
909
- }
910
- }
911
- }
912
- const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
913
- if (checkboxSlot) {
914
- return renderCellBaseVNs(h, params, $table.callSlot(checkboxSlot, checkboxParams, h))
915
- }
916
- const checkVNs = []
917
- if (isVisible) {
918
- checkVNs.push(
919
- h('span', {
920
- class: ['vxe-checkbox--icon', indeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : (isDisabled ? getIcon().TABLE_CHECKBOX_DISABLED_UNCHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED))]
921
- })
922
- )
923
- }
924
- if (defaultSlot || labelField) {
925
- checkVNs.push(
926
- h('span', {
927
- class: 'vxe-checkbox--label'
928
- }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams, h) : XEUtils.get(row, labelField))
929
- )
930
- }
931
- return renderCellBaseVNs(h, params, [
932
- h('span', {
933
- class: ['vxe-cell--checkbox', {
934
- 'is--checked': isChecked,
935
- 'is--disabled': isDisabled,
936
- 'is--indeterminate': indeterminateField && !isChecked ? row[indeterminateField] : indeterminate,
937
- 'is--hidden': !isVisible
938
- }],
939
- on: ons
940
- }, checkVNs)
941
- ])
942
- },
943
- renderDeepSelectionCellByProp (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
944
- return Cell.renderDeepNodeBtn(h, params, Cell.renderCheckboxCellByProp(h, params))
945
- },
946
-
947
- /**
948
- * 展开行
949
- */
950
- renderExpandCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
951
- const { $table, isHidden, row, column } = params
952
- const tableReactData = $table as unknown as TableReactData
953
- const tableInternalData = $table as unknown as TableInternalData
954
- const { isRowGroupStatus } = tableReactData
955
- const { rowExpandedMaps, rowExpandLazyLoadedMaps } = tableInternalData
956
- const expandOpts = $table.computeExpandOpts
957
- const { lazy, labelField, iconLoaded, showIcon, iconOpen, iconClose, visibleMethod } = expandOpts
958
- const { slots } = column
959
- const defaultSlot = slots ? slots.default : null
960
- const iconSlot = slots ? slots.icon : null
961
- let isActive = false
962
- let isLazyLoading = false
963
- if (isRowGroupStatus && row.isAggregate) {
964
- return renderCellBaseVNs(h, params, [])
965
- }
966
- if (iconSlot) {
967
- return renderCellBaseVNs(h, params, $table.callSlot(iconSlot, params, h))
968
- }
969
- if (!isHidden) {
970
- const rowid = getRowid($table, row)
971
- isActive = !!rowExpandedMaps[rowid]
972
- if (lazy) {
973
- isLazyLoading = !!rowExpandLazyLoadedMaps[rowid]
974
- }
975
- }
976
- return renderCellBaseVNs(h, params, [
977
- showIcon && (!visibleMethod || visibleMethod(params))
978
- ? h('span', {
979
- class: ['vxe-table--expanded', {
980
- 'is--active': isActive
981
- }],
982
- on: {
983
- mousedown (evnt: MouseEvent) {
984
- evnt.stopPropagation()
985
- },
986
- click (evnt: MouseEvent) {
987
- $table.triggerRowExpandEvent(evnt, params)
988
- }
989
- }
990
- }, [
991
- h('i', {
992
- class: ['vxe-table--expand-btn', isLazyLoading ? (iconLoaded || getIcon().TABLE_EXPAND_LOADED) : (isActive ? (iconOpen || getIcon().TABLE_EXPAND_OPEN) : (iconClose || getIcon().TABLE_EXPAND_CLOSE))]
993
- })
994
- ])
995
- : renderEmptyElement($table),
996
- defaultSlot || labelField
997
- ? h('span', {
998
- class: 'vxe-table--expand-label'
999
- }, defaultSlot ? $table.callSlot(defaultSlot, params, h) : XEUtils.get(row, labelField))
1000
- : renderEmptyElement($table)
1001
- ])
1002
- },
1003
- renderExpandData (h: CreateElement, params: VxeTableDefines.CellRenderDataParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1004
- const { $table, column } = params
1005
- const { slots, contentRender } = column
1006
- if (slots && slots.content) {
1007
- return $table.callSlot(slots.content, params, h)
1008
- }
1009
- if (contentRender) {
1010
- const compConf = renderer.get(contentRender.name)
1011
- const rtExpand = compConf ? (compConf.renderTableExpand || compConf.renderExpand) : null
1012
- if (rtExpand) {
1013
- return getSlotVNs(rtExpand.call($table, h, contentRender, params))
1014
- }
1015
- }
1016
- return []
1017
- },
1018
-
1019
- /**
1020
- * HTML 标签
1021
- */
1022
- renderHTMLCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1023
- const { $table, column } = params
1024
- const { slots } = column
1025
- if (slots && slots.default) {
1026
- return renderCellBaseVNs(h, params, $table.callSlot(slots.default, params, h))
1027
- }
1028
- return renderCellBaseVNs(h, params, [
1029
- h('span', {
1030
- class: 'vxe-cell--html',
1031
- domProps: {
1032
- innerHTML: getDefaultCellLabel(params)
1033
- }
1034
- })
1035
- ])
1036
- },
1037
- renderDeepHTMLCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1038
- return Cell.renderDeepNodeBtn(h, params, Cell.renderHTMLCell(h, params))
1039
- },
1040
-
1041
- /**
1042
- * 排序和筛选
1043
- */
1044
- renderSortAndFilterHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1045
- return renderHeaderCellBaseVNs(
1046
- h,
1047
- params,
1048
- Cell.renderHeaderTitle(h, params).concat(Cell.renderSortIcon(h, params).concat(Cell.renderFilterIcon(h, params)))
1049
- )
1050
- },
1051
-
1052
- /**
1053
- * 排序
1054
- */
1055
- renderSortHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1056
- return renderHeaderCellBaseVNs(
1057
- h,
1058
- params,
1059
- Cell.renderHeaderTitle(h, params).concat(Cell.renderSortIcon(h, params))
1060
- )
1061
- },
1062
- renderSortIcon (h: CreateElement, params: (VxeTableDefines.CellRenderHeaderParams | VxeTableDefines.CellRenderHeaderParams) & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1063
- const { $table, column } = params
1064
- const sortOpts = $table.computeSortOpts
1065
- const { showIcon, allowBtn, ascTitle, descTitle, iconLayout, iconAsc, iconDesc, iconVisibleMethod } = sortOpts
1066
- const { order, slots } = column
1067
- if (showIcon && (!iconVisibleMethod || iconVisibleMethod(params))) {
1068
- const sortSlot = slots ? slots.sort : null
1069
- return sortSlot
1070
- ? getSlotVNs($table.callSlot(sortSlot, params, h)) as VNode[]
1071
- : [
1072
- h('span', {
1073
- class: ['vxe-cell--sort', `vxe-cell--sort-${iconLayout}-layout`]
1074
- }, [
1075
- h('i', {
1076
- class: ['vxe-sort--asc-btn', iconAsc || getIcon().TABLE_SORT_ASC, {
1077
- 'sort--active': order === 'asc'
1078
- }],
1079
- attrs: {
1080
- title: XEUtils.eqNull(ascTitle) ? getI18n('vxe.table.sortAsc') : `${ascTitle || ''}`
1081
- },
1082
- on: allowBtn
1083
- ? {
1084
- click (evnt: any) {
1085
- evnt.stopPropagation()
1086
- $table.triggerSortEvent(evnt, column, 'asc')
1087
- }
1088
- }
1089
- : undefined
1090
- }),
1091
- h('i', {
1092
- class: ['vxe-sort--desc-btn', iconDesc || getIcon().TABLE_SORT_DESC, {
1093
- 'sort--active': order === 'desc'
1094
- }],
1095
- attrs: {
1096
- title: XEUtils.eqNull(descTitle) ? getI18n('vxe.table.sortDesc') : `${descTitle || ''}`
1097
- },
1098
- on: allowBtn
1099
- ? {
1100
- click (evnt: any) {
1101
- evnt.stopPropagation()
1102
- $table.triggerSortEvent(evnt, column, 'desc')
1103
- }
1104
- }
1105
- : undefined
1106
- })
1107
- ])
1108
- ]
1109
- }
1110
- return []
1111
- },
1112
-
1113
- /**
1114
- * 筛选
1115
- */
1116
- renderFilterHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1117
- return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params).concat(Cell.renderFilterIcon(h, params)))
1118
- },
1119
- renderFilterIcon (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1120
- const { $table, column, hasFilter } = params
1121
- const tableReactData = $table as unknown as TableReactData
1122
- const { filterStore } = tableReactData
1123
- const filterOpts = $table.computeFilterOpts
1124
- const { showIcon, iconNone, iconMatch, iconVisibleMethod } = filterOpts
1125
- if (showIcon && (!iconVisibleMethod || iconVisibleMethod(params))) {
1126
- return [
1127
- h('span', {
1128
- class: ['vxe-cell--filter', {
1129
- 'is--active': filterStore.visible && filterStore.column === column
1130
- }],
1131
- on: {
1132
- click (evnt: MouseEvent) {
1133
- if ($table.triggerFilterEvent) {
1134
- $table.triggerFilterEvent(evnt, params.column, params)
1135
- }
1136
- }
1137
- }
1138
- }, [
1139
- h('i', {
1140
- class: ['vxe-filter--btn', hasFilter ? (iconMatch || getIcon().TABLE_FILTER_MATCH) : (iconNone || getIcon().TABLE_FILTER_NONE)],
1141
- attrs: {
1142
- title: getI18n('vxe.table.filter')
1143
- }
1144
- })
1145
- ])
1146
- ]
1147
- }
1148
- return []
1149
- },
1150
-
1151
- /**
1152
- * 可编辑
1153
- */
1154
- renderEditHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1155
- const { $table, column } = params
1156
- const tableProps = $table
1157
- const { editConfig, editRules } = tableProps
1158
- const editOpts = $table.computeEditOpts
1159
- const { sortable, filters, editRender } = column
1160
- const isEnableEdit = editConfig && isEnableConf(editConfig)
1161
- const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
1162
- let isRequired = false
1163
- if (editRules) {
1164
- const columnRules = XEUtils.get(editRules, column.field)
1165
- if (columnRules) {
1166
- isRequired = columnRules.some((rule: any) => rule.required)
1167
- }
1168
- }
1169
- let editIconVNs: VNode[] = []
1170
- if (isEnableEdit) {
1171
- const { showAsterisk, showIcon, icon } = editOpts
1172
- editIconVNs = [
1173
- isRequired && showAsterisk
1174
- ? h('i', {
1175
- class: 'vxe-cell--required-icon'
1176
- }, [
1177
- h('i', {
1178
- class: 'vxe-cell--required-icon'
1179
- })
1180
- ])
1181
- : renderEmptyElement($table),
1182
- editRenderOpts && showIcon
1183
- ? h('i', {
1184
- class: 'vxe-cell--edit-icon'
1185
- }, XEUtils.isFunction(icon)
1186
- ? getSlotVNs(icon({}))
1187
- : [
1188
- h('i', {
1189
- class: icon || getIcon().TABLE_EDIT
1190
- })
1191
- ])
1192
- : renderEmptyElement($table)
1193
- ]
1194
- }
1195
- return renderHeaderCellBaseVNs(h, params,
1196
- editIconVNs.concat(Cell.renderHeaderTitle(h, params))
1197
- .concat(sortable ? Cell.renderSortIcon(h, params) : [])
1198
- .concat(filters ? Cell.renderFilterIcon(h, params) : [])
1199
- )
1200
- },
1201
- // 行格编辑模式
1202
- renderRowEdit (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1203
- const { $table, column } = params
1204
- const tableProps = $table
1205
- const tableReactData = $table as unknown as TableReactData
1206
- const { editConfig } = tableProps
1207
- const { editStore } = tableReactData
1208
- const { actived } = editStore
1209
- const { editRender } = column
1210
- const isEnableEdit = editConfig && isEnableConf(editConfig)
1211
- const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
1212
- return Cell.runRenderer(h, params, !!(editRenderOpts && actived && actived.row === params.row))
1213
- },
1214
- renderDeepRowEdit (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1215
- return Cell.renderDeepNodeBtn(h, params, Cell.renderRowEdit(h, params))
1216
- },
1217
- // 单元格编辑模式
1218
- renderCellEdit (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1219
- const { $table, column } = params
1220
- const tableProps = $table
1221
- const tableReactData = $table as unknown as TableReactData
1222
- const { editConfig } = tableProps
1223
- const { editStore } = tableReactData
1224
- const { actived } = editStore
1225
- const { editRender } = column
1226
- const isEnableEdit = editConfig && isEnableConf(editConfig)
1227
- const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
1228
- return Cell.runRenderer(h, params, !!(editRenderOpts && actived && actived.row === params.row && actived.column === params.column))
1229
- },
1230
- renderDeepCellEdit (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1231
- return Cell.renderDeepNodeBtn(h, params, Cell.renderCellEdit(h, params))
1232
- },
1233
- runRenderer (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, isEdit: boolean) {
1234
- const { $table, row, column } = params
1235
- const tableProps = $table
1236
- const tableReactData = $table as unknown as TableReactData
1237
- const { editConfig } = tableProps
1238
- const { isRowGroupStatus } = tableReactData
1239
- const { slots, field, editRender, formatter } = column
1240
- const isEnableEdit = editConfig && isEnableConf(editConfig)
1241
- const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
1242
- const defaultSlot = slots ? slots.default : null
1243
- const gcSlot = slots ? (slots.groupContent || slots['group-content']) : null
1244
- const cellParams = Object.assign({ $type: '', isEdit }, params)
1245
- if (isEdit && editRenderOpts) {
1246
- if (slots && slots.edit) {
1247
- return $table.callSlot(slots.edit, cellParams, h)
1248
- }
1249
- const compConf = renderer.get(editRender.name)
1250
- const rtEdit = compConf ? (compConf.renderTableEdit || compConf.renderEdit) : null
1251
- if (rtEdit) {
1252
- return getSlotVNs(rtEdit.call($table, h, editRender, cellParams))
1253
- }
1254
- return []
1255
- }
1256
-
1257
- if (isRowGroupStatus && field && row.isAggregate) {
1258
- const aggRow: VxeTableDefines.AggregateRowInfo = row
1259
- const aggregateOpts = $table.computeAggregateOpts
1260
- const { mapChildrenField } = aggregateOpts
1261
- const groupField = aggRow.groupField
1262
- const groupContent = aggRow.groupContent
1263
- const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : []
1264
- const childCount = aggRow.childCount
1265
- if (gcSlot) {
1266
- return renderCellBaseVNs(h, params, $table.callSlot(gcSlot, Object.assign({ groupField, groupContent, childList, childCount }, params), h))
1267
- }
1268
- } else {
1269
- if (defaultSlot) {
1270
- return renderCellBaseVNs(h, params, $table.callSlot(defaultSlot, cellParams, h))
1271
- }
1272
- }
1273
-
1274
- if (formatter) {
1275
- return renderCellBaseVNs(h, params, [
1276
- h('span', {
1277
- class: 'vxe-cell--label'
1278
- }, [getDefaultCellLabel(cellParams)])
1279
- ])
1280
- }
1281
- return Cell.renderDefaultCell(h, cellParams)
1282
- }
1283
- } as any
1284
-
1285
- export default Cell
1
+ import { CreateElement, VNode } from 'vue'
2
+ import XEUtils from 'xe-utils'
3
+ import { VxeUI } from '../../ui'
4
+ import { getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
5
+ import { updateCellTitle } from '../../ui/src/dom'
6
+ import { createColumn, getRowid } from './util'
7
+ import { getSlotVNs } from '../../ui/src/vn'
8
+
9
+ import type { VxeTableDefines, VxeTableConstructor, VxeTablePrivateMethods, VxeComponentSlotType, TableReactData, TableInternalData } from '../../../types'
10
+
11
+ const { getI18n, getIcon, renderer, renderEmptyElement } = VxeUI
12
+
13
+ function renderTitlePrefixIcon (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
14
+ const { $table, column } = params
15
+ const titlePrefix = column.titlePrefix || column.titleHelp
16
+ if (titlePrefix) {
17
+ return h('i', {
18
+ class: ['vxe-cell-title-prefix-icon', titlePrefix.iconStatus ? `theme--${titlePrefix.iconStatus}` : ''],
19
+ on: {
20
+ mouseenter (evnt: any) {
21
+ $table.triggerHeaderTitleEvent(evnt, titlePrefix, params)
22
+ },
23
+ mouseleave (evnt: any) {
24
+ $table.handleTargetLeaveEvent(evnt)
25
+ }
26
+ }
27
+ }, [
28
+ h('i', {
29
+ class: titlePrefix.icon || getIcon().TABLE_TITLE_PREFIX
30
+ })
31
+ ])
32
+ }
33
+ return renderEmptyElement($table)
34
+ }
35
+
36
+ function renderTitleSuffixIcon (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
37
+ const { $table, column } = params
38
+ const titleSuffix = column.titleSuffix
39
+ if (titleSuffix) {
40
+ return h('i', {
41
+ class: ['vxe-cell-title-suffix-icon', titleSuffix.iconStatus ? `theme--${titleSuffix.iconStatus}` : ''],
42
+ on: {
43
+ mouseenter (evnt: any) {
44
+ $table.triggerHeaderTitleEvent(evnt, titleSuffix, params)
45
+ },
46
+ mouseleave (evnt: any) {
47
+ $table.handleTargetLeaveEvent(evnt)
48
+ }
49
+ }
50
+ }, [
51
+ h('i', {
52
+ class: titleSuffix.icon || getIcon().TABLE_TITLE_SUFFIX
53
+ })
54
+ ])
55
+ }
56
+ return renderEmptyElement($table)
57
+ }
58
+
59
+ function renderCellDragIcon (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
60
+ const { $table } = params
61
+ const tableSlots = $table.$scopedSlots
62
+ const tableProps = $table
63
+ const { dragConfig } = tableProps
64
+ const rowDragOpts = $table.computeRowDragOpts
65
+ const { icon, trigger, disabledMethod } = rowDragOpts
66
+ const rDisabledMethod = disabledMethod || (dragConfig ? dragConfig.rowDisabledMethod : null)
67
+ const isDisabled = rDisabledMethod && rDisabledMethod(params)
68
+ const rowDragIconSlot = tableSlots.rowDragIcon || tableSlots['row-drag-icon']
69
+ const ons: Record<string, any> = {}
70
+ if (trigger !== 'cell') {
71
+ ons.mousedown = (evnt: MouseEvent) => {
72
+ if (!isDisabled) {
73
+ $table.handleCellDragMousedownEvent(evnt, params)
74
+ }
75
+ }
76
+ ons.mouseup = $table.handleCellDragMouseupEvent
77
+ }
78
+ return h('span', {
79
+ key: 'dg',
80
+ class: ['vxe-cell--drag-handle', {
81
+ 'is--disabled': isDisabled
82
+ }],
83
+ on: ons
84
+ }, rowDragIconSlot
85
+ ? $table.callSlot(rowDragIconSlot as any, params, h)
86
+ : [
87
+ h('i', {
88
+ class: icon || (dragConfig ? dragConfig.rowIcon : '') || getIcon().TABLE_DRAG_ROW
89
+ })
90
+ ])
91
+ }
92
+
93
+ function renderCellBaseVNs (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, content: VxeComponentSlotType | VxeComponentSlotType[]) {
94
+ const { $table, column, level } = params
95
+ const { dragSort } = column
96
+ const tableProps = $table
97
+ const { treeConfig, dragConfig } = tableProps
98
+ const rowOpts = $table.computeRowOpts
99
+ const rowDragOpts = $table.computeRowDragOpts
100
+ const treeOpts = $table.computeTreeOpts
101
+ const { showIcon, isPeerDrag, isCrossDrag, visibleMethod } = rowDragOpts
102
+ const rVisibleMethod = visibleMethod || (dragConfig ? dragConfig.rowVisibleMethod : null)
103
+ const vns: VxeComponentSlotType[] = []
104
+ if (dragSort && rowOpts.drag && ((showIcon || (dragConfig ? dragConfig.showRowIcon : false)) && (!rVisibleMethod || rVisibleMethod(params)))) {
105
+ if (treeConfig) {
106
+ if (treeOpts.transform && (isPeerDrag || isCrossDrag || !level)) {
107
+ vns.unshift(
108
+ renderCellDragIcon(h, params)
109
+ )
110
+ }
111
+ } else {
112
+ vns.unshift(
113
+ renderCellDragIcon(h, params)
114
+ )
115
+ }
116
+ }
117
+ return vns.concat(XEUtils.isArray(content) ? content : [content])
118
+ }
119
+
120
+ function renderHeaderCellDragIcon (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
121
+ const { $table, column } = params
122
+ const tableSlots = $table.$scopedSlots
123
+ const { slots } = column
124
+ const columnOpts = $table.computeColumnOpts
125
+ const columnDragOpts = $table.computeColumnDragOpts
126
+ const { showIcon, icon, trigger, isPeerDrag, isCrossDrag, visibleMethod, disabledMethod } = columnDragOpts
127
+ if (columnOpts.drag && showIcon && (!visibleMethod || visibleMethod(params))) {
128
+ if (!column.fixed && (isPeerDrag || isCrossDrag || !column.parentId)) {
129
+ const isDisabled = disabledMethod && disabledMethod(params)
130
+ const columnDragIconSlot = (slots ? slots.columnDragIcon || slots['column-drag-icon'] : null) || tableSlots.columnDragIcon || tableSlots['column-drag-icon']
131
+ const ons: Record<string, any> = {}
132
+ if (trigger !== 'cell') {
133
+ ons.mousedown = (evnt: MouseEvent) => {
134
+ if (!isDisabled) {
135
+ $table.handleHeaderCellDragMousedownEvent(evnt, params)
136
+ }
137
+ }
138
+ ons.mouseup = $table.handleHeaderCellDragMouseupEvent
139
+ }
140
+ return h('span', {
141
+ key: 'dg',
142
+ class: ['vxe-cell--drag-handle', {
143
+ 'is--disabled': isDisabled
144
+ }],
145
+ on: ons
146
+ }, columnDragIconSlot
147
+ ? $table.callSlot(columnDragIconSlot as any, params, h)
148
+ : [
149
+ h('i', {
150
+ class: icon || getIcon().TABLE_DRAG_COLUMN
151
+ })
152
+ ])
153
+ }
154
+ }
155
+ return renderEmptyElement($table)
156
+ }
157
+
158
+ function renderHeaderCellBaseVNs (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, content: VNode | VNode[]) {
159
+ const vns = [
160
+ renderTitlePrefixIcon(h, params),
161
+ renderHeaderCellDragIcon(h, params),
162
+ ...(XEUtils.isArray(content) ? content : [content]),
163
+ renderTitleSuffixIcon(h, params)
164
+ ]
165
+ return vns
166
+ }
167
+
168
+ function getRenderDefaultColumnTitle (h: CreateElement, column: VxeTableDefines.ColumnInfo, content: VxeComponentSlotType | VxeComponentSlotType[]) {
169
+ if (column.type === 'html' && XEUtils.isString(content)) {
170
+ return h('span', {
171
+ key: 'ch',
172
+ domProps: {
173
+ innerHTML: content
174
+ }
175
+ })
176
+ }
177
+ return h('span', {
178
+ key: 'ct'
179
+ }, getSlotVNs(content))
180
+ }
181
+
182
+ function renderTitleContent (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, content: VxeComponentSlotType | VxeComponentSlotType[]) {
183
+ const { $table, column } = params
184
+ const tableProps = $table
185
+ const tableReactData = $table as unknown as TableReactData
186
+ const { showHeaderOverflow: allColumnHeaderOverflow } = tableProps
187
+ const { isRowGroupStatus } = tableReactData
188
+ const { showHeaderOverflow, slots } = column
189
+ const titleSlot = slots ? slots.title : null
190
+ const headerTooltipOpts = $table.computeHeaderTooltipOpts
191
+ const showAllTip = headerTooltipOpts.showAll
192
+ const headOverflow = XEUtils.eqNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
193
+ const showTitle = headOverflow === 'title'
194
+ const showTooltip = headOverflow === true || headOverflow === 'tooltip'
195
+ const ons: Record<string, any> = {}
196
+ if (showTitle || showTooltip || showAllTip) {
197
+ ons.mouseenter = (evnt: MouseEvent) => {
198
+ if (tableReactData.isDragResize) {
199
+ return
200
+ }
201
+ if (showTitle) {
202
+ updateCellTitle(evnt.currentTarget, column)
203
+ } else if (showTooltip || showAllTip) {
204
+ $table.triggerHeaderTooltipEvent(evnt, params)
205
+ }
206
+ }
207
+ }
208
+ if (showTooltip || showAllTip) {
209
+ ons.mouseleave = (evnt: any) => {
210
+ if (tableReactData.isDragResize) {
211
+ return
212
+ }
213
+ if (showTooltip || showAllTip) {
214
+ $table.handleTargetLeaveEvent(evnt)
215
+ }
216
+ }
217
+ }
218
+ const titleVN = getRenderDefaultColumnTitle(h, column, content)
219
+ return [
220
+ h('span', {
221
+ class: 'vxe-cell--title',
222
+ on: ons
223
+ }, isRowGroupStatus && column.aggFunc && $table.getPivotTableAggregateRenderColTitles
224
+ ? $table.getPivotTableAggregateRenderColTitles(h, column, titleVN)
225
+ : titleSlot
226
+ ? $table.callSlot(titleSlot, params, h)
227
+ : [
228
+ titleVN
229
+ ])
230
+ ]
231
+ }
232
+
233
+ function getFooterContent (h: CreateElement, params: VxeTableDefines.CellRenderFooterParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
234
+ const { $table, column, row } = params
235
+ const tableProps = $table
236
+ const { editConfig } = tableProps
237
+ const { slots, editRender, cellRender } = column
238
+ const footerSlot = slots ? slots.footer : null
239
+ if (footerSlot) {
240
+ return $table.callSlot(footerSlot, params, h)
241
+ }
242
+ const isEnableEdit = editConfig && isEnableConf(editConfig)
243
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
244
+ const cellRenderOpts = isEnableConf(cellRender) ? cellRender : null
245
+ const renderOpts = editRenderOpts || cellRenderOpts
246
+ const itemValue = $table.getFooterCellLabel(row, column)
247
+ if (renderOpts) {
248
+ const compConf = renderer.get(renderOpts.name)
249
+ const rtFooter = compConf ? (compConf.renderTableFooter || compConf.renderFooter) : null
250
+ if (rtFooter) {
251
+ const footParams = Object.assign(params, {
252
+ cellValue: itemValue,
253
+ itemValue
254
+ })
255
+ return getSlotVNs(rtFooter.call($table, h, renderOpts, footParams))
256
+ }
257
+ }
258
+ return [
259
+ formatText(itemValue, 1)
260
+ ]
261
+ }
262
+
263
+ function getDefaultCellLabel (params: VxeTableDefines.CellRenderBodyParams) {
264
+ const { $table, row, column } = params
265
+ return formatText($table.getCellLabel(row, column), 1)
266
+ }
267
+
268
+ function renderCellHandle (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & {
269
+ $table: VxeTableConstructor & VxeTablePrivateMethods;
270
+ }) {
271
+ const { column, row, $table } = params
272
+ const tableProps = $table
273
+ const tableReactData = $table as unknown as TableReactData
274
+ const { editConfig } = tableProps
275
+ const { isRowGroupStatus } = tableReactData
276
+ const { type, treeNode, rowGroupNode, editRender } = column
277
+ const aggregateOpts = $table.computeAggregateOpts
278
+ const { mode } = aggregateOpts
279
+ const checkboxOpts = $table.computeCheckboxOpts
280
+ const editOpts = $table.computeEditOpts
281
+ const isDeepCell = treeNode || (isRowGroupStatus && (mode === 'column' ? column.field === row.groupField : rowGroupNode))
282
+ switch (type) {
283
+ case 'seq':
284
+ return isDeepCell ? Cell.renderDeepIndexCell(h, params) : Cell.renderSeqCell(h, params)
285
+ case 'radio':
286
+ return isDeepCell ? Cell.renderDeepRadioCell(h, params) : Cell.renderRadioCell(h, params)
287
+ case 'checkbox':
288
+ return checkboxOpts.checkField ? (isDeepCell ? Cell.renderDeepSelectionCellByProp(h, params) : Cell.renderCheckboxCellByProp(h, params)) : (isDeepCell ? Cell.renderDeepSelectionCell(h, params) : Cell.renderCheckboxCell(h, params))
289
+ case 'expand':
290
+ return Cell.renderExpandCell(h, params)
291
+ case 'html':
292
+ return isDeepCell ? Cell.renderDeepHTMLCell(h, params) : Cell.renderHTMLCell(h, params)
293
+ }
294
+ const isEnableEdit = editConfig && isEnableConf(editConfig)
295
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
296
+ if (editRenderOpts) {
297
+ return editOpts.mode === 'cell' ? (isDeepCell ? Cell.renderDeepCellEdit(h, params) : Cell.renderCellEdit(h, params)) : (isDeepCell ? Cell.renderDeepRowEdit(h, params) : Cell.renderRowEdit(h, params))
298
+ }
299
+ return isDeepCell ? Cell.renderDeepCell(h, params) : Cell.renderDefaultCell(h, params)
300
+ }
301
+
302
+ function renderHeaderHandle (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & {
303
+ $table: VxeTableConstructor & VxeTablePrivateMethods;
304
+ }) {
305
+ const { column, $table } = params
306
+ const tableProps = $table
307
+ const { editConfig } = tableProps
308
+ const { type, filters, sortable, editRender } = column
309
+ switch (type) {
310
+ case 'seq':
311
+ return Cell.renderSeqHeader(h, params)
312
+ case 'radio':
313
+ return Cell.renderRadioHeader(h, params)
314
+ case 'checkbox':
315
+ return Cell.renderCheckboxHeader(h, params)
316
+ case 'html':
317
+ if (filters && sortable) {
318
+ return Cell.renderSortAndFilterHeader(h, params)
319
+ } else if (sortable) {
320
+ return Cell.renderSortHeader(h, params)
321
+ } else if (filters) {
322
+ return Cell.renderFilterHeader(h, params)
323
+ }
324
+ break
325
+ }
326
+ const isEnableEdit = editConfig && isEnableConf(editConfig)
327
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
328
+ if (editRenderOpts) {
329
+ return Cell.renderEditHeader(h, params)
330
+ } else if (filters && sortable) {
331
+ return Cell.renderSortAndFilterHeader(h, params)
332
+ } else if (sortable) {
333
+ return Cell.renderSortHeader(h, params)
334
+ } else if (filters) {
335
+ return Cell.renderFilterHeader(h, params)
336
+ }
337
+ return Cell.renderDefaultHeader(h, params)
338
+ }
339
+
340
+ function renderFooterHandle (h: CreateElement, params: VxeTableDefines.CellRenderFooterParams & {
341
+ $table: VxeTableConstructor & VxeTablePrivateMethods;
342
+ }) {
343
+ return Cell.renderDefaultFooter(h, params)
344
+ }
345
+
346
+ export const Cell = {
347
+ createColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, _vm: any) {
348
+ const { type } = _vm
349
+ const renConfs: any = {
350
+ renderHeader: renderHeaderHandle,
351
+ renderCell: renderCellHandle,
352
+ renderFooter: renderFooterHandle
353
+ }
354
+ if (type === 'expand') {
355
+ renConfs.renderData = Cell.renderExpandData
356
+ }
357
+ return createColumn($xeTable, _vm, renConfs)
358
+ },
359
+ /**
360
+ * 列头标题
361
+ */
362
+ renderHeaderTitle (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
363
+ const { $table, column } = params
364
+ const tableProps = $table
365
+ const { editConfig } = tableProps
366
+ const { slots, editRender, cellRender } = column
367
+ const headerSlot = slots ? slots.header : null
368
+ if (headerSlot) {
369
+ return renderTitleContent(h, params, $table.callSlot(headerSlot, params, h))
370
+ }
371
+ const isEnableEdit = editConfig && isEnableConf(editConfig)
372
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
373
+ const cellRenderOpts = isEnableConf(cellRender) ? cellRender : null
374
+ const renderOpts = editRenderOpts || cellRenderOpts
375
+ if (renderOpts) {
376
+ const compConf = renderer.get(renderOpts.name)
377
+ const rtHeader = compConf ? (compConf.renderTableHeader || compConf.renderHeader) : null
378
+ if (rtHeader) {
379
+ return getSlotVNs(renderTitleContent(h, params, rtHeader.call($table, h, renderOpts, params)))
380
+ }
381
+ }
382
+ return renderTitleContent(h, params, formatText(column.getTitle(), 1))
383
+ },
384
+ renderDefaultHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
385
+ return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params))
386
+ },
387
+ renderDefaultCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
388
+ const { $table, row, column } = params
389
+ const tableProps = $table
390
+ const tableReactData = $table as unknown as TableReactData
391
+ const tableInternalData = $table as unknown as TableInternalData
392
+ const { isRowGroupStatus } = tableReactData
393
+ const { editConfig } = tableProps
394
+ const { field, slots, editRender, cellRender, rowGroupNode, aggFunc, formatter } = column
395
+ const isEnableEdit = editConfig && isEnableConf(editConfig)
396
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
397
+ const cellRenderOpts = isEnableConf(cellRender) ? cellRender : null
398
+ const defaultSlot = slots ? slots.default : null
399
+ const gcSlot = slots ? (slots.groupContent || slots['group-content']) : null
400
+ const gvSlot = slots ? (slots.groupValues || slots['group-values']) : null
401
+ let cellValue: string | number | null = ''
402
+ if (isRowGroupStatus && field && row.isAggregate) {
403
+ const aggRow: VxeTableDefines.AggregateRowInfo = row
404
+ const { fullColumnFieldData } = tableInternalData
405
+ const aggregateOpts = $table.computeAggregateOpts
406
+ const { mode, showTotal, totalMethod, countFields, contentMethod, formatValuesMethod, mapChildrenField } = aggregateOpts
407
+ const aggData = aggRow.aggData
408
+ const currAggData = aggData ? aggData[field] : null
409
+ const groupField = aggRow.groupField
410
+ const groupContent = aggRow.groupContent
411
+ const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : []
412
+ const childCount = aggRow.childCount
413
+ const colRest = fullColumnFieldData[groupField] || {}
414
+ const ctParams = {
415
+ $table,
416
+ groupField,
417
+ groupColumn: (colRest ? colRest.column : null) as VxeTableDefines.ColumnInfo,
418
+ column,
419
+ groupValue: groupContent,
420
+ childList,
421
+ childCount,
422
+ aggValue: null as any,
423
+
424
+ /**
425
+ * 已废弃
426
+ * @deprecated
427
+ */
428
+ children: childList,
429
+ /**
430
+ * 已废弃
431
+ * @deprecated
432
+ */
433
+ totalValue: childCount
434
+ }
435
+ if (mode === 'column' ? field === aggRow.groupField : rowGroupNode) {
436
+ cellValue = groupContent
437
+ if (contentMethod) {
438
+ cellValue = `${contentMethod(ctParams)}`
439
+ }
440
+ if (showTotal) {
441
+ cellValue = getI18n('vxe.table.rowGroupContentTotal', [cellValue, totalMethod ? totalMethod(ctParams) : childCount, childCount])
442
+ }
443
+ if (gcSlot) {
444
+ return renderCellBaseVNs(h, params, $table.callSlot(gcSlot, Object.assign({ groupField, groupContent, childList, childCount }, params), h))
445
+ }
446
+ } else if ($table.getPivotTableAggregateCellAggValue) {
447
+ cellValue = $table.getPivotTableAggregateCellAggValue(params)
448
+ ctParams.aggValue = cellValue
449
+ if (gvSlot) {
450
+ return renderCellBaseVNs(h, params, $table.callSlot(gvSlot, Object.assign({ groupField, groupContent, childList, childCount }, params, ctParams), h))
451
+ }
452
+ } else if (aggFunc === true || (countFields && countFields.includes(field))) {
453
+ cellValue = currAggData ? currAggData.value : childCount
454
+ ctParams.aggValue = cellValue
455
+ if (formatValuesMethod) {
456
+ cellValue = formatValuesMethod(ctParams)
457
+ }
458
+ if (gvSlot) {
459
+ return renderCellBaseVNs(h, params, $table.callSlot(gvSlot, Object.assign({ groupField, groupContent, childList, childCount }, params, ctParams), h))
460
+ }
461
+ }
462
+ } else {
463
+ if (defaultSlot) {
464
+ return renderCellBaseVNs(h, params, $table.callSlot(defaultSlot, params, h))
465
+ }
466
+ const renderOpts = editRenderOpts || cellRenderOpts
467
+ // formatter > (renderTableCell | renderTableDefault)
468
+ if (renderOpts && !formatter) {
469
+ const compConf = renderer.get(renderOpts.name)
470
+ if (compConf) {
471
+ const renderFn = editRenderOpts ? (compConf.renderTableCell || compConf.renderCell) : (compConf.renderTableDefault || compConf.renderDefault)
472
+ if (renderFn) {
473
+ return renderCellBaseVNs(h, params, getSlotVNs(renderFn.call($table, h, renderOpts, Object.assign({ $type: editRenderOpts ? 'edit' : 'cell' }, params))))
474
+ }
475
+ }
476
+ }
477
+ cellValue = $table.getCellLabel(row, column)
478
+ }
479
+ const cellPlaceholder = editRenderOpts ? editRenderOpts.placeholder : ''
480
+ return renderCellBaseVNs(h, params, [
481
+ h('span', {
482
+ class: 'vxe-cell--label'
483
+ }, [
484
+ // 如果设置占位符
485
+ editRenderOpts && eqEmptyValue(cellValue)
486
+ ? h('span', {
487
+ class: 'vxe-cell--placeholder'
488
+ }, formatText(getFuncText(cellPlaceholder), 1))
489
+ : h('span', formatText(cellValue, 1))
490
+ ])
491
+ ])
492
+ },
493
+ renderDeepCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
494
+ return Cell.renderDeepNodeBtn(h, params, Cell.renderDefaultCell(h, params))
495
+ },
496
+ renderDefaultFooter (h: CreateElement, params: VxeTableDefines.CellRenderFooterParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
497
+ return getFooterContent(h, params)
498
+ },
499
+
500
+ /**
501
+ * 行分组
502
+ */
503
+ renderRowGroupBtn (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, cellVNodes: VxeComponentSlotType[]) {
504
+ const { $table } = params
505
+ const tableReactData = $table as unknown as TableReactData
506
+ const tableInternalData = $table as unknown as TableInternalData
507
+ const { row, level } = params
508
+ const { rowGroupExpandedFlag } = tableReactData
509
+ const { rowGroupExpandedMaps } = tableInternalData
510
+ const aggregateOpts = $table.computeAggregateOpts
511
+ const { mode, padding, indent, showIcon, iconOpen, iconClose } = aggregateOpts
512
+ const rowid = getRowid($table, row)
513
+ const isExpand = !!rowGroupExpandedFlag && !!rowGroupExpandedMaps[rowid]
514
+ return h('div', {
515
+ class: ['vxe-row-group--tree-node', {
516
+ 'is--expanded': isExpand
517
+ }],
518
+ style: mode !== 'column' && padding && indent
519
+ ? {
520
+ paddingLeft: `${level * indent}px`
521
+ }
522
+ : undefined
523
+ }, [
524
+ showIcon && row.isAggregate
525
+ ? h('span', {
526
+ class: 'vxe-row-group--node-btn',
527
+ on: {
528
+ click (evnt: MouseEvent) {
529
+ $table.triggerRowGroupExpandEvent(evnt, params)
530
+ }
531
+ }
532
+ }, [
533
+ h('i', {
534
+ class: isExpand ? (iconOpen || getIcon().TABLE_ROW_GROUP_OPEN) : (iconClose || getIcon().TABLE_ROW_GROUP_CLOSE)
535
+ })
536
+ ])
537
+ : renderEmptyElement($table),
538
+ h('div', {
539
+ class: 'vxe-row-group-cell'
540
+ }, cellVNodes)
541
+ ])
542
+ },
543
+ /**
544
+ * 树
545
+ */
546
+ renderTreeNodeBtn (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, cellVNodes: VxeComponentSlotType[]) {
547
+ const { $table, isHidden } = params
548
+ const tableReactData = $table as unknown as TableReactData
549
+ const tableInternalData = $table as unknown as TableInternalData
550
+ const { treeExpandedFlag } = tableReactData
551
+ const { fullAllDataRowIdData, treeExpandedMaps, treeExpandLazyLoadedMaps } = tableInternalData
552
+ const treeOpts = $table.computeTreeOpts
553
+ const { row, column, level } = params
554
+ const { slots } = column
555
+ const { padding, indent, lazy, trigger, iconLoaded, showIcon, iconOpen, iconClose } = treeOpts
556
+ const childrenField = treeOpts.children || treeOpts.childrenField
557
+ const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
558
+ const rowChilds = row[childrenField]
559
+ const hasChild = rowChilds && rowChilds.length
560
+ const iconSlot = slots ? slots.icon : null
561
+ let hasLazyChilds = false
562
+ let isActive = false
563
+ let isLazyLoading = false
564
+ let isLazyLoaded = false
565
+ const ons: Record<string, any> = {}
566
+ if (iconSlot) {
567
+ return $table.callSlot(iconSlot, params, h)
568
+ }
569
+ if (!isHidden) {
570
+ const rowid = getRowid($table, row)
571
+ isActive = !!treeExpandedFlag && !!treeExpandedMaps[rowid]
572
+ if (lazy) {
573
+ const rest = fullAllDataRowIdData[rowid]
574
+ isLazyLoading = !!treeExpandLazyLoadedMaps[rowid]
575
+ hasLazyChilds = row[hasChildField]
576
+ isLazyLoaded = !!rest.treeLoaded
577
+ }
578
+ }
579
+ if (!trigger || trigger === 'default') {
580
+ ons.click = (evnt: MouseEvent) => {
581
+ $table.triggerTreeExpandEvent(evnt, params)
582
+ }
583
+ }
584
+ return [
585
+ h('div', {
586
+ class: ['vxe-cell--tree-node', {
587
+ 'is--active': isActive
588
+ }],
589
+ style: padding && indent
590
+ ? {
591
+ paddingLeft: `${level * indent}px`
592
+ }
593
+ : undefined
594
+ }, [
595
+ showIcon && (lazy ? (isLazyLoaded ? hasChild : (hasChild || hasLazyChilds)) : hasChild)
596
+ ? [
597
+ h('div', {
598
+ class: 'vxe-cell--tree-btn',
599
+ on: ons
600
+ }, [
601
+ h('i', {
602
+ class: isLazyLoading ? (iconLoaded || getIcon().TABLE_TREE_LOADED) : (isActive ? (iconOpen || getIcon().TABLE_TREE_OPEN) : (iconClose || getIcon().TABLE_TREE_CLOSE))
603
+ })
604
+ ])
605
+ ]
606
+ : null,
607
+ h('div', {
608
+ class: 'vxe-tree-cell'
609
+ }, cellVNodes)
610
+ ])
611
+ ]
612
+ },
613
+ /**
614
+ * 层级节点。
615
+ * 行分组、树结构
616
+ */
617
+ renderDeepNodeBtn (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, cellVNodes: VxeComponentSlotType[]) {
618
+ const { $table, row, column } = params
619
+ const { rowGroupNode } = column
620
+ const tableReactData = $table as unknown as TableReactData
621
+ const { rowGroupList } = tableReactData
622
+ if (rowGroupList.length) {
623
+ const aggregateOpts = $table.computeAggregateOpts
624
+ const { mode } = aggregateOpts
625
+ if (mode === 'column' ? column.field === row.groupField : rowGroupNode) {
626
+ return [Cell.renderRowGroupBtn(h, params, cellVNodes)]
627
+ }
628
+ }
629
+ return [Cell.renderTreeNodeBtn(h, params, cellVNodes)]
630
+ },
631
+
632
+ /**
633
+ * 序号
634
+ */
635
+ renderSeqHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
636
+ const { $table, column } = params
637
+ const { slots } = column
638
+ return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, params, slots && slots.header ? $table.callSlot(slots.header, params, h) : formatText(column.getTitle(), 1)))
639
+ },
640
+ renderSeqCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
641
+ const { $table, column } = params
642
+ const tableProps = $table
643
+ const { treeConfig } = tableProps
644
+ const seqOpts = $table.computeSeqOpts
645
+ const { slots } = column
646
+ if (slots && slots.default) {
647
+ return renderCellBaseVNs(h, params, $table.callSlot(slots.default, params, h))
648
+ }
649
+ const { seq } = params
650
+ const seqMd = seqOpts.seqMethod
651
+ return renderCellBaseVNs(h, params, [
652
+ h('span', `${formatText(seqMd ? seqMd(params) : treeConfig ? seq : (seqOpts.startIndex || 0) + (seq as number), 1)}`)
653
+ ])
654
+ },
655
+ renderDeepIndexCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
656
+ return Cell.renderDeepNodeBtn(h, params, Cell.renderSeqCell(h, params))
657
+ },
658
+
659
+ /**
660
+ * 单选
661
+ */
662
+ renderRadioHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
663
+ const { $table, column } = params
664
+ const { slots } = column
665
+ const headerSlot = slots ? slots.header : null
666
+ const titleSlot = slots ? slots.title : null
667
+ return renderHeaderCellBaseVNs(h, params,
668
+ renderTitleContent(h, params, headerSlot
669
+ ? $table.callSlot(headerSlot, params, h)
670
+ : [
671
+ h('span', {
672
+ class: 'vxe-radio--label'
673
+ }, titleSlot ? $table.callSlot(titleSlot, params, h) : formatText(column.getTitle(), 1))
674
+ ])
675
+ )
676
+ },
677
+ renderRadioCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
678
+ const { $table, column, isHidden } = params
679
+ const tableReactData = $table as unknown as TableReactData
680
+ const { selectRadioRow } = tableReactData
681
+ const radioOpts = $table.computeRadioOpts
682
+ const { slots } = column
683
+ const { labelField, checkMethod, visibleMethod } = radioOpts
684
+ const { row } = params
685
+ const defaultSlot = slots ? slots.default : null
686
+ const radioSlot = slots ? slots.radio : null
687
+ const isChecked = row === selectRadioRow
688
+ const isVisible = !visibleMethod || visibleMethod({ $table, row })
689
+ let isDisabled = !!checkMethod
690
+ let on: any
691
+ if (!isHidden) {
692
+ on = {
693
+ click (evnt: any) {
694
+ if (!isDisabled && isVisible) {
695
+ $table.triggerRadioRowEvent(evnt, params)
696
+ }
697
+ }
698
+ }
699
+ if (checkMethod) {
700
+ isDisabled = !checkMethod({ $table, row })
701
+ }
702
+ }
703
+ const radioParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible }
704
+ if (radioSlot) {
705
+ return renderCellBaseVNs(h, params, $table.callSlot(radioSlot, radioParams, h))
706
+ }
707
+ const radioVNs = []
708
+ if (isVisible) {
709
+ radioVNs.push(
710
+ h('span', {
711
+ class: ['vxe-radio--icon', isChecked ? getIcon().TABLE_RADIO_CHECKED : (isDisabled ? getIcon().TABLE_RADIO_DISABLED_UNCHECKED : getIcon().TABLE_RADIO_UNCHECKED)]
712
+ })
713
+ )
714
+ }
715
+ if (defaultSlot || labelField) {
716
+ radioVNs.push(
717
+ h('span', {
718
+ class: 'vxe-radio--label'
719
+ }, defaultSlot ? $table.callSlot(defaultSlot, radioParams, h) : XEUtils.get(row, labelField))
720
+ )
721
+ }
722
+ return renderCellBaseVNs(h, params, [
723
+ h('span', {
724
+ class: ['vxe-cell--radio', {
725
+ 'is--checked': isChecked,
726
+ 'is--disabled': isDisabled
727
+ }],
728
+ on
729
+ }, radioVNs)
730
+ ])
731
+ },
732
+ renderDeepRadioCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
733
+ return Cell.renderDeepNodeBtn(h, params, Cell.renderRadioCell(h, params))
734
+ },
735
+
736
+ /**
737
+ * 多选
738
+ */
739
+ renderCheckboxHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
740
+ const { $table, column, isHidden } = params
741
+ const tableReactData = $table as unknown as TableReactData
742
+ const { isAllSelected: isAllCheckboxSelected, isIndeterminate: isAllCheckboxIndeterminate } = tableReactData
743
+ const isAllCheckboxDisabled = $table.computeIsAllCheckboxDisabled
744
+ const { slots } = column
745
+ const headerSlot = slots ? slots.header : null
746
+ const titleSlot = slots ? slots.title : null
747
+ const checkboxOpts = $table.computeCheckboxOpts
748
+ const { checkStrictly, showHeader, headerTitle } = checkboxOpts
749
+ const colTitle = column.getTitle()
750
+ const ons: Record<string, any> = {}
751
+ if (!isHidden) {
752
+ ons.click = (evnt: MouseEvent) => {
753
+ if (!isAllCheckboxDisabled) {
754
+ $table.triggerCheckAllEvent(evnt, !isAllCheckboxSelected)
755
+ }
756
+ }
757
+ }
758
+ const checkboxParams = { ...params, checked: isAllCheckboxSelected, disabled: isAllCheckboxDisabled, indeterminate: isAllCheckboxIndeterminate }
759
+ if (headerSlot) {
760
+ return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, checkboxParams, $table.callSlot(headerSlot, checkboxParams, h)))
761
+ }
762
+ if (checkStrictly ? !showHeader : showHeader === false) {
763
+ return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, checkboxParams, [
764
+ h('span', {
765
+ class: 'vxe-checkbox--label'
766
+ }, titleSlot ? $table.callSlot(titleSlot, checkboxParams, h) : colTitle)
767
+ ]))
768
+ }
769
+ return renderHeaderCellBaseVNs(h, params,
770
+ renderTitleContent(h, checkboxParams, [
771
+ h('span', {
772
+ class: ['vxe-cell--checkbox', {
773
+ 'is--checked': isAllCheckboxSelected,
774
+ 'is--disabled': isAllCheckboxDisabled,
775
+ 'is--indeterminate': isAllCheckboxIndeterminate
776
+ }],
777
+ attrs: {
778
+ title: XEUtils.eqNull(headerTitle) ? getI18n('vxe.table.allTitle') : `${headerTitle || ''}`
779
+ },
780
+ on: ons
781
+ }, [
782
+ h('span', {
783
+ class: ['vxe-checkbox--icon', isAllCheckboxIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllCheckboxSelected ? getIcon().TABLE_CHECKBOX_CHECKED : (isAllCheckboxDisabled ? getIcon().TABLE_CHECKBOX_DISABLED_UNCHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED))]
784
+ })
785
+ ].concat(titleSlot || colTitle
786
+ ? [
787
+ h('span', {
788
+ class: 'vxe-checkbox--label'
789
+ }, titleSlot ? $table.callSlot(titleSlot, checkboxParams, h) : colTitle)
790
+ ]
791
+ : []))
792
+ ])
793
+ )
794
+ },
795
+ renderCheckboxCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
796
+ const { $table, row, column, isHidden } = params
797
+ const tableProps = $table
798
+ const tableReactData = $table as unknown as TableReactData
799
+ const tableInternalData = $table as unknown as TableInternalData
800
+ const { treeConfig } = tableProps
801
+ const { updateCheckboxFlag, isRowGroupStatus } = tableReactData
802
+ const { selectCheckboxMaps, treeIndeterminateRowMaps } = tableInternalData
803
+ const aggregateOpts = $table.computeAggregateOpts
804
+ const { mapChildrenField } = aggregateOpts
805
+ const checkboxOpts = $table.computeCheckboxOpts
806
+ const { labelField, checkMethod, visibleMethod } = checkboxOpts
807
+ const { slots } = column
808
+ const defaultSlot = slots ? slots.default : null
809
+ const checkboxSlot = slots ? slots.checkbox : null
810
+ let indeterminate = false
811
+ let isChecked = false
812
+ let isVisible = true
813
+ let isDisabled = false
814
+ const ons: Record<string, any> = {}
815
+ if (!isHidden) {
816
+ const rowid = getRowid($table, row)
817
+ isChecked = !!updateCheckboxFlag && !!selectCheckboxMaps[rowid]
818
+ if (checkMethod && isRowGroupStatus && $table.isAggregateRecord(row)) {
819
+ const childList: any[] = row[mapChildrenField || '']
820
+ if (!childList || !childList.length || childList.every(item => !checkMethod({ $table, row: item }))) {
821
+ isDisabled = true
822
+ }
823
+ } else {
824
+ isVisible = !visibleMethod || visibleMethod({ $table, row })
825
+ isDisabled = checkMethod ? !checkMethod({ $table, row }) : !!checkMethod
826
+ }
827
+ if (treeConfig || isRowGroupStatus) {
828
+ indeterminate = !!treeIndeterminateRowMaps[rowid]
829
+ }
830
+ ons.click = (evnt: MouseEvent) => {
831
+ if (!isDisabled && isVisible) {
832
+ $table.triggerCheckRowEvent(evnt, params, !isChecked)
833
+ }
834
+ }
835
+ }
836
+ const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
837
+ if (checkboxSlot) {
838
+ return renderCellBaseVNs(h, params, $table.callSlot(checkboxSlot, checkboxParams, h))
839
+ }
840
+ const checkVNs = []
841
+ if (isVisible) {
842
+ checkVNs.push(
843
+ h('span', {
844
+ class: ['vxe-checkbox--icon', indeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : (isDisabled ? getIcon().TABLE_CHECKBOX_DISABLED_UNCHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED))]
845
+ })
846
+ )
847
+ }
848
+ if (defaultSlot || labelField) {
849
+ checkVNs.push(
850
+ h('span', {
851
+ class: 'vxe-checkbox--label'
852
+ }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams, h) : XEUtils.get(row, labelField))
853
+ )
854
+ }
855
+ return renderCellBaseVNs(h, params, [
856
+ h('span', {
857
+ class: ['vxe-cell--checkbox', {
858
+ 'is--checked': isChecked,
859
+ 'is--disabled': isDisabled,
860
+ 'is--indeterminate': indeterminate,
861
+ 'is--hidden': !isVisible
862
+ }],
863
+ on: ons
864
+ }, checkVNs)
865
+ ])
866
+ },
867
+ renderDeepSelectionCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
868
+ return Cell.renderDeepNodeBtn(h, params, Cell.renderCheckboxCell(h, params))
869
+ },
870
+ renderCheckboxCellByProp (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
871
+ const { $table, row, column, isHidden } = params
872
+ const tableProps = $table
873
+ const tableReactData = $table as unknown as TableReactData
874
+ const tableInternalData = $table as unknown as TableInternalData
875
+ const { treeConfig } = tableProps
876
+ const { updateCheckboxFlag, isRowGroupStatus } = tableReactData
877
+ const { treeIndeterminateRowMaps } = tableInternalData
878
+ const aggregateOpts = $table.computeAggregateOpts
879
+ const { mapChildrenField } = aggregateOpts
880
+ const checkboxOpts = $table.computeCheckboxOpts
881
+ const { labelField, checkField, checkMethod, visibleMethod } = checkboxOpts
882
+ const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
883
+ const { slots } = column
884
+ const defaultSlot = slots ? slots.default : null
885
+ const checkboxSlot = slots ? slots.checkbox : null
886
+ let indeterminate = false
887
+ let isChecked = false
888
+ let isVisible = true
889
+ let isDisabled = false
890
+ const ons: Record<string, any> = {}
891
+ if (!isHidden) {
892
+ const rowid = getRowid($table, row)
893
+ isChecked = !!updateCheckboxFlag && XEUtils.get(row, checkField)
894
+ if (checkMethod && isRowGroupStatus && $table.isAggregateRecord(row)) {
895
+ const childList: any[] = row[mapChildrenField || '']
896
+ if (!childList || !childList.length || childList.every(item => !checkMethod({ $table, row: item }))) {
897
+ isDisabled = true
898
+ }
899
+ } else {
900
+ isVisible = !visibleMethod || visibleMethod({ $table, row })
901
+ isDisabled = checkMethod ? !checkMethod({ $table, row }) : !!checkMethod
902
+ }
903
+ if (treeConfig || isRowGroupStatus) {
904
+ indeterminate = !!treeIndeterminateRowMaps[rowid]
905
+ }
906
+ ons.click = (evnt: MouseEvent) => {
907
+ if (!isDisabled && isVisible) {
908
+ $table.triggerCheckRowEvent(evnt, params, !isChecked)
909
+ }
910
+ }
911
+ }
912
+ const checkboxParams = { ...params, checked: isChecked, disabled: isDisabled, visible: isVisible, indeterminate }
913
+ if (checkboxSlot) {
914
+ return renderCellBaseVNs(h, params, $table.callSlot(checkboxSlot, checkboxParams, h))
915
+ }
916
+ const checkVNs = []
917
+ if (isVisible) {
918
+ checkVNs.push(
919
+ h('span', {
920
+ class: ['vxe-checkbox--icon', indeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isChecked ? getIcon().TABLE_CHECKBOX_CHECKED : (isDisabled ? getIcon().TABLE_CHECKBOX_DISABLED_UNCHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED))]
921
+ })
922
+ )
923
+ }
924
+ if (defaultSlot || labelField) {
925
+ checkVNs.push(
926
+ h('span', {
927
+ class: 'vxe-checkbox--label'
928
+ }, defaultSlot ? $table.callSlot(defaultSlot, checkboxParams, h) : XEUtils.get(row, labelField))
929
+ )
930
+ }
931
+ return renderCellBaseVNs(h, params, [
932
+ h('span', {
933
+ class: ['vxe-cell--checkbox', {
934
+ 'is--checked': isChecked,
935
+ 'is--disabled': isDisabled,
936
+ 'is--indeterminate': indeterminateField && !isChecked ? row[indeterminateField] : indeterminate,
937
+ 'is--hidden': !isVisible
938
+ }],
939
+ on: ons
940
+ }, checkVNs)
941
+ ])
942
+ },
943
+ renderDeepSelectionCellByProp (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
944
+ return Cell.renderDeepNodeBtn(h, params, Cell.renderCheckboxCellByProp(h, params))
945
+ },
946
+
947
+ /**
948
+ * 展开行
949
+ */
950
+ renderExpandCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
951
+ const { $table, isHidden, row, column } = params
952
+ const tableReactData = $table as unknown as TableReactData
953
+ const tableInternalData = $table as unknown as TableInternalData
954
+ const { isRowGroupStatus } = tableReactData
955
+ const { rowExpandedMaps, rowExpandLazyLoadedMaps } = tableInternalData
956
+ const expandOpts = $table.computeExpandOpts
957
+ const { lazy, labelField, iconLoaded, showIcon, iconOpen, iconClose, visibleMethod } = expandOpts
958
+ const { slots } = column
959
+ const defaultSlot = slots ? slots.default : null
960
+ const iconSlot = slots ? slots.icon : null
961
+ let isActive = false
962
+ let isLazyLoading = false
963
+ if (isRowGroupStatus && row.isAggregate) {
964
+ return renderCellBaseVNs(h, params, [])
965
+ }
966
+ if (iconSlot) {
967
+ return renderCellBaseVNs(h, params, $table.callSlot(iconSlot, params, h))
968
+ }
969
+ if (!isHidden) {
970
+ const rowid = getRowid($table, row)
971
+ isActive = !!rowExpandedMaps[rowid]
972
+ if (lazy) {
973
+ isLazyLoading = !!rowExpandLazyLoadedMaps[rowid]
974
+ }
975
+ }
976
+ return renderCellBaseVNs(h, params, [
977
+ showIcon && (!visibleMethod || visibleMethod(params))
978
+ ? h('span', {
979
+ class: ['vxe-table--expanded', {
980
+ 'is--active': isActive
981
+ }],
982
+ on: {
983
+ mousedown (evnt: MouseEvent) {
984
+ evnt.stopPropagation()
985
+ },
986
+ click (evnt: MouseEvent) {
987
+ $table.triggerRowExpandEvent(evnt, params)
988
+ }
989
+ }
990
+ }, [
991
+ h('i', {
992
+ class: ['vxe-table--expand-btn', isLazyLoading ? (iconLoaded || getIcon().TABLE_EXPAND_LOADED) : (isActive ? (iconOpen || getIcon().TABLE_EXPAND_OPEN) : (iconClose || getIcon().TABLE_EXPAND_CLOSE))]
993
+ })
994
+ ])
995
+ : renderEmptyElement($table),
996
+ defaultSlot || labelField
997
+ ? h('span', {
998
+ class: 'vxe-table--expand-label'
999
+ }, defaultSlot ? $table.callSlot(defaultSlot, params, h) : XEUtils.get(row, labelField))
1000
+ : renderEmptyElement($table)
1001
+ ])
1002
+ },
1003
+ renderExpandData (h: CreateElement, params: VxeTableDefines.CellRenderDataParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1004
+ const { $table, column } = params
1005
+ const { slots, contentRender } = column
1006
+ if (slots && slots.content) {
1007
+ return $table.callSlot(slots.content, params, h)
1008
+ }
1009
+ if (contentRender) {
1010
+ const compConf = renderer.get(contentRender.name)
1011
+ const rtExpand = compConf ? (compConf.renderTableExpand || compConf.renderExpand) : null
1012
+ if (rtExpand) {
1013
+ return getSlotVNs(rtExpand.call($table, h, contentRender, params))
1014
+ }
1015
+ }
1016
+ return []
1017
+ },
1018
+
1019
+ /**
1020
+ * HTML 标签
1021
+ */
1022
+ renderHTMLCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1023
+ const { $table, column } = params
1024
+ const { slots } = column
1025
+ if (slots && slots.default) {
1026
+ return renderCellBaseVNs(h, params, $table.callSlot(slots.default, params, h))
1027
+ }
1028
+ return renderCellBaseVNs(h, params, [
1029
+ h('span', {
1030
+ class: 'vxe-cell--html',
1031
+ domProps: {
1032
+ innerHTML: getDefaultCellLabel(params)
1033
+ }
1034
+ })
1035
+ ])
1036
+ },
1037
+ renderDeepHTMLCell (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1038
+ return Cell.renderDeepNodeBtn(h, params, Cell.renderHTMLCell(h, params))
1039
+ },
1040
+
1041
+ /**
1042
+ * 排序和筛选
1043
+ */
1044
+ renderSortAndFilterHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1045
+ return renderHeaderCellBaseVNs(
1046
+ h,
1047
+ params,
1048
+ Cell.renderHeaderTitle(h, params).concat(Cell.renderSortIcon(h, params).concat(Cell.renderFilterIcon(h, params)))
1049
+ )
1050
+ },
1051
+
1052
+ /**
1053
+ * 排序
1054
+ */
1055
+ renderSortHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1056
+ return renderHeaderCellBaseVNs(
1057
+ h,
1058
+ params,
1059
+ Cell.renderHeaderTitle(h, params).concat(Cell.renderSortIcon(h, params))
1060
+ )
1061
+ },
1062
+ renderSortIcon (h: CreateElement, params: (VxeTableDefines.CellRenderHeaderParams | VxeTableDefines.CellRenderHeaderParams) & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1063
+ const { $table, column } = params
1064
+ const sortOpts = $table.computeSortOpts
1065
+ const { showIcon, allowBtn, ascTitle, descTitle, iconLayout, iconAsc, iconDesc, iconVisibleMethod } = sortOpts
1066
+ const { order, slots } = column
1067
+ if (showIcon && (!iconVisibleMethod || iconVisibleMethod(params))) {
1068
+ const sortSlot = slots ? slots.sort : null
1069
+ return sortSlot
1070
+ ? getSlotVNs($table.callSlot(sortSlot, params, h)) as VNode[]
1071
+ : [
1072
+ h('span', {
1073
+ class: ['vxe-cell--sort', `vxe-cell--sort-${iconLayout}-layout`]
1074
+ }, [
1075
+ h('i', {
1076
+ class: ['vxe-sort--asc-btn', iconAsc || getIcon().TABLE_SORT_ASC, {
1077
+ 'sort--active': order === 'asc'
1078
+ }],
1079
+ attrs: {
1080
+ title: XEUtils.eqNull(ascTitle) ? getI18n('vxe.table.sortAsc') : `${ascTitle || ''}`
1081
+ },
1082
+ on: allowBtn
1083
+ ? {
1084
+ click (evnt: any) {
1085
+ evnt.stopPropagation()
1086
+ $table.triggerSortEvent(evnt, column, 'asc')
1087
+ }
1088
+ }
1089
+ : undefined
1090
+ }),
1091
+ h('i', {
1092
+ class: ['vxe-sort--desc-btn', iconDesc || getIcon().TABLE_SORT_DESC, {
1093
+ 'sort--active': order === 'desc'
1094
+ }],
1095
+ attrs: {
1096
+ title: XEUtils.eqNull(descTitle) ? getI18n('vxe.table.sortDesc') : `${descTitle || ''}`
1097
+ },
1098
+ on: allowBtn
1099
+ ? {
1100
+ click (evnt: any) {
1101
+ evnt.stopPropagation()
1102
+ $table.triggerSortEvent(evnt, column, 'desc')
1103
+ }
1104
+ }
1105
+ : undefined
1106
+ })
1107
+ ])
1108
+ ]
1109
+ }
1110
+ return []
1111
+ },
1112
+
1113
+ /**
1114
+ * 筛选
1115
+ */
1116
+ renderFilterHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1117
+ return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params).concat(Cell.renderFilterIcon(h, params)))
1118
+ },
1119
+ renderFilterIcon (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1120
+ const { $table, column, hasFilter } = params
1121
+ const tableReactData = $table as unknown as TableReactData
1122
+ const { filterStore } = tableReactData
1123
+ const filterOpts = $table.computeFilterOpts
1124
+ const { showIcon, iconNone, iconMatch, iconVisibleMethod } = filterOpts
1125
+ if (showIcon && (!iconVisibleMethod || iconVisibleMethod(params))) {
1126
+ return [
1127
+ h('span', {
1128
+ class: ['vxe-cell--filter', {
1129
+ 'is--active': filterStore.visible && filterStore.column === column
1130
+ }],
1131
+ on: {
1132
+ click (evnt: MouseEvent) {
1133
+ if ($table.triggerFilterEvent) {
1134
+ $table.triggerFilterEvent(evnt, params.column, params)
1135
+ }
1136
+ }
1137
+ }
1138
+ }, [
1139
+ h('i', {
1140
+ class: ['vxe-filter--btn', hasFilter ? (iconMatch || getIcon().TABLE_FILTER_MATCH) : (iconNone || getIcon().TABLE_FILTER_NONE)],
1141
+ attrs: {
1142
+ title: getI18n('vxe.table.filter')
1143
+ }
1144
+ })
1145
+ ])
1146
+ ]
1147
+ }
1148
+ return []
1149
+ },
1150
+
1151
+ /**
1152
+ * 可编辑
1153
+ */
1154
+ renderEditHeader (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1155
+ const { $table, column } = params
1156
+ const tableProps = $table
1157
+ const { editConfig, editRules } = tableProps
1158
+ const editOpts = $table.computeEditOpts
1159
+ const { sortable, filters, editRender } = column
1160
+ const isEnableEdit = editConfig && isEnableConf(editConfig)
1161
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
1162
+ let isRequired = false
1163
+ if (editRules) {
1164
+ const columnRules = XEUtils.get(editRules, column.field)
1165
+ if (columnRules) {
1166
+ isRequired = columnRules.some((rule: any) => rule.required)
1167
+ }
1168
+ }
1169
+ let editIconVNs: VNode[] = []
1170
+ if (isEnableEdit) {
1171
+ const { showAsterisk, showIcon, icon } = editOpts
1172
+ editIconVNs = [
1173
+ isRequired && showAsterisk
1174
+ ? h('i', {
1175
+ class: 'vxe-cell--required-icon'
1176
+ }, [
1177
+ h('i', {
1178
+ class: 'vxe-cell--required-icon'
1179
+ })
1180
+ ])
1181
+ : renderEmptyElement($table),
1182
+ editRenderOpts && showIcon
1183
+ ? h('i', {
1184
+ class: 'vxe-cell--edit-icon'
1185
+ }, XEUtils.isFunction(icon)
1186
+ ? getSlotVNs(icon({}))
1187
+ : [
1188
+ h('i', {
1189
+ class: icon || getIcon().TABLE_EDIT
1190
+ })
1191
+ ])
1192
+ : renderEmptyElement($table)
1193
+ ]
1194
+ }
1195
+ return renderHeaderCellBaseVNs(h, params,
1196
+ editIconVNs.concat(Cell.renderHeaderTitle(h, params))
1197
+ .concat(sortable ? Cell.renderSortIcon(h, params) : [])
1198
+ .concat(filters ? Cell.renderFilterIcon(h, params) : [])
1199
+ )
1200
+ },
1201
+ // 行格编辑模式
1202
+ renderRowEdit (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1203
+ const { $table, column } = params
1204
+ const tableProps = $table
1205
+ const tableReactData = $table as unknown as TableReactData
1206
+ const { editConfig } = tableProps
1207
+ const { editStore } = tableReactData
1208
+ const { actived } = editStore
1209
+ const { editRender } = column
1210
+ const isEnableEdit = editConfig && isEnableConf(editConfig)
1211
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
1212
+ return Cell.runRenderer(h, params, !!(editRenderOpts && actived && actived.row === params.row))
1213
+ },
1214
+ renderDeepRowEdit (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1215
+ return Cell.renderDeepNodeBtn(h, params, Cell.renderRowEdit(h, params))
1216
+ },
1217
+ // 单元格编辑模式
1218
+ renderCellEdit (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1219
+ const { $table, column } = params
1220
+ const tableProps = $table
1221
+ const tableReactData = $table as unknown as TableReactData
1222
+ const { editConfig } = tableProps
1223
+ const { editStore } = tableReactData
1224
+ const { actived } = editStore
1225
+ const { editRender } = column
1226
+ const isEnableEdit = editConfig && isEnableConf(editConfig)
1227
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
1228
+ return Cell.runRenderer(h, params, !!(editRenderOpts && actived && actived.row === params.row && actived.column === params.column))
1229
+ },
1230
+ renderDeepCellEdit (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }) {
1231
+ return Cell.renderDeepNodeBtn(h, params, Cell.renderCellEdit(h, params))
1232
+ },
1233
+ runRenderer (h: CreateElement, params: VxeTableDefines.CellRenderBodyParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, isEdit: boolean) {
1234
+ const { $table, row, column } = params
1235
+ const tableProps = $table
1236
+ const tableReactData = $table as unknown as TableReactData
1237
+ const { editConfig } = tableProps
1238
+ const { isRowGroupStatus } = tableReactData
1239
+ const { slots, field, editRender, formatter } = column
1240
+ const isEnableEdit = editConfig && isEnableConf(editConfig)
1241
+ const editRenderOpts = isEnableEdit && isEnableConf(editRender) ? editRender : null
1242
+ const defaultSlot = slots ? slots.default : null
1243
+ const gcSlot = slots ? (slots.groupContent || slots['group-content']) : null
1244
+ const cellParams = Object.assign({ $type: '', isEdit }, params)
1245
+ if (isEdit && editRenderOpts) {
1246
+ if (slots && slots.edit) {
1247
+ return $table.callSlot(slots.edit, cellParams, h)
1248
+ }
1249
+ const compConf = renderer.get(editRender.name)
1250
+ const rtEdit = compConf ? (compConf.renderTableEdit || compConf.renderEdit) : null
1251
+ if (rtEdit) {
1252
+ return getSlotVNs(rtEdit.call($table, h, editRender, cellParams))
1253
+ }
1254
+ return []
1255
+ }
1256
+
1257
+ if (isRowGroupStatus && field && row.isAggregate) {
1258
+ const aggRow: VxeTableDefines.AggregateRowInfo = row
1259
+ const aggregateOpts = $table.computeAggregateOpts
1260
+ const { mapChildrenField } = aggregateOpts
1261
+ const groupField = aggRow.groupField
1262
+ const groupContent = aggRow.groupContent
1263
+ const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : []
1264
+ const childCount = aggRow.childCount
1265
+ if (gcSlot) {
1266
+ return renderCellBaseVNs(h, params, $table.callSlot(gcSlot, Object.assign({ groupField, groupContent, childList, childCount }, params), h))
1267
+ }
1268
+ } else {
1269
+ if (defaultSlot) {
1270
+ return renderCellBaseVNs(h, params, $table.callSlot(defaultSlot, cellParams, h))
1271
+ }
1272
+ }
1273
+
1274
+ if (formatter) {
1275
+ return renderCellBaseVNs(h, params, [
1276
+ h('span', {
1277
+ class: 'vxe-cell--label'
1278
+ }, [getDefaultCellLabel(cellParams)])
1279
+ ])
1280
+ }
1281
+ return Cell.renderDefaultCell(h, cellParams)
1282
+ }
1283
+ } as any
1284
+
1285
+ export default Cell