vxe-table 4.18.7 → 4.18.9

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