vxe-table 4.8.16 → 4.9.1

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 (135) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/README.zh-TW.md +1 -1
  4. package/es/locale/lang/en-US.js +1 -0
  5. package/es/locale/lang/es-ES.js +1 -0
  6. package/es/locale/lang/hu-HU.js +1 -0
  7. package/es/locale/lang/ja-JP.js +1 -0
  8. package/es/locale/lang/ko-KR.js +1 -0
  9. package/es/locale/lang/pt-BR.js +1 -0
  10. package/es/locale/lang/ru-RU.js +1 -0
  11. package/es/locale/lang/uk-UA.js +1 -0
  12. package/es/locale/lang/vi-VN.js +1 -0
  13. package/es/locale/lang/zh-CHT.js +1 -0
  14. package/es/locale/lang/zh-CN.js +1 -0
  15. package/es/style.css +1 -1
  16. package/es/style.min.css +1 -1
  17. package/es/table/module/custom/hook.js +4 -0
  18. package/es/table/module/edit/hook.js +53 -34
  19. package/es/table/module/filter/hook.js +2 -3
  20. package/es/table/module/keyboard/hook.js +2 -2
  21. package/es/table/src/body.js +31 -24
  22. package/es/table/src/cell.js +99 -59
  23. package/es/table/src/emits.js +3 -0
  24. package/es/table/src/footer.js +177 -147
  25. package/es/table/src/header.js +144 -107
  26. package/es/table/src/props.js +5 -1
  27. package/es/table/src/table.js +346 -108
  28. package/es/table/src/util.js +9 -0
  29. package/es/table/style.css +33 -20
  30. package/es/table/style.min.css +1 -1
  31. package/es/ui/index.js +9 -4
  32. package/es/ui/src/log.js +1 -1
  33. package/es/vxe-table/style.css +33 -20
  34. package/es/vxe-table/style.min.css +1 -1
  35. package/helper/vetur/attributes.json +1 -1
  36. package/helper/vetur/tags.json +1 -1
  37. package/lib/index.umd.js +1035 -573
  38. package/lib/index.umd.min.js +1 -1
  39. package/lib/locale/lang/en-US.js +1 -0
  40. package/lib/locale/lang/en-US.min.js +1 -1
  41. package/lib/locale/lang/en-US.umd.js +1 -0
  42. package/lib/locale/lang/es-ES.js +1 -0
  43. package/lib/locale/lang/es-ES.min.js +1 -1
  44. package/lib/locale/lang/es-ES.umd.js +1 -0
  45. package/lib/locale/lang/hu-HU.js +1 -0
  46. package/lib/locale/lang/hu-HU.min.js +1 -1
  47. package/lib/locale/lang/hu-HU.umd.js +1 -0
  48. package/lib/locale/lang/ja-JP.js +1 -0
  49. package/lib/locale/lang/ja-JP.min.js +1 -1
  50. package/lib/locale/lang/ja-JP.umd.js +1 -0
  51. package/lib/locale/lang/ko-KR.js +1 -0
  52. package/lib/locale/lang/ko-KR.min.js +1 -1
  53. package/lib/locale/lang/ko-KR.umd.js +1 -0
  54. package/lib/locale/lang/pt-BR.js +1 -0
  55. package/lib/locale/lang/pt-BR.min.js +1 -1
  56. package/lib/locale/lang/pt-BR.umd.js +1 -0
  57. package/lib/locale/lang/ru-RU.js +1 -0
  58. package/lib/locale/lang/ru-RU.min.js +1 -1
  59. package/lib/locale/lang/ru-RU.umd.js +1 -0
  60. package/lib/locale/lang/uk-UA.js +1 -0
  61. package/lib/locale/lang/uk-UA.min.js +1 -1
  62. package/lib/locale/lang/uk-UA.umd.js +1 -0
  63. package/lib/locale/lang/vi-VN.js +1 -0
  64. package/lib/locale/lang/vi-VN.min.js +1 -1
  65. package/lib/locale/lang/zh-CHT.js +1 -0
  66. package/lib/locale/lang/zh-CHT.min.js +1 -1
  67. package/lib/locale/lang/zh-CN.js +1 -0
  68. package/lib/locale/lang/zh-CN.min.js +1 -1
  69. package/lib/locale/lang/zh-CN.umd.js +1 -0
  70. package/lib/style.css +1 -1
  71. package/lib/style.min.css +1 -1
  72. package/lib/table/module/custom/hook.js +4 -0
  73. package/lib/table/module/custom/hook.min.js +1 -1
  74. package/lib/table/module/edit/hook.js +63 -42
  75. package/lib/table/module/edit/hook.min.js +1 -1
  76. package/lib/table/module/filter/hook.js +1 -2
  77. package/lib/table/module/filter/hook.min.js +1 -1
  78. package/lib/table/module/keyboard/hook.js +2 -2
  79. package/lib/table/module/keyboard/hook.min.js +1 -1
  80. package/lib/table/src/body.js +34 -21
  81. package/lib/table/src/body.min.js +1 -1
  82. package/lib/table/src/cell.js +110 -51
  83. package/lib/table/src/cell.min.js +1 -1
  84. package/lib/table/src/emits.js +1 -1
  85. package/lib/table/src/emits.min.js +1 -1
  86. package/lib/table/src/footer.js +222 -183
  87. package/lib/table/src/footer.min.js +1 -1
  88. package/lib/table/src/header.js +188 -150
  89. package/lib/table/src/header.min.js +1 -1
  90. package/lib/table/src/props.js +5 -1
  91. package/lib/table/src/props.min.js +1 -1
  92. package/lib/table/src/table.js +380 -110
  93. package/lib/table/src/table.min.js +1 -1
  94. package/lib/table/src/util.js +10 -0
  95. package/lib/table/src/util.min.js +1 -1
  96. package/lib/table/style/style.css +33 -20
  97. package/lib/table/style/style.min.css +1 -1
  98. package/lib/ui/index.js +9 -4
  99. package/lib/ui/index.min.js +1 -1
  100. package/lib/ui/src/log.js +1 -1
  101. package/lib/ui/src/log.min.js +1 -1
  102. package/lib/vxe-table/style/style.css +33 -20
  103. package/lib/vxe-table/style/style.min.css +1 -1
  104. package/package.json +3 -3
  105. package/packages/locale/lang/en-US.ts +1 -0
  106. package/packages/locale/lang/es-ES.ts +1 -0
  107. package/packages/locale/lang/hu-HU.ts +1 -0
  108. package/packages/locale/lang/ja-JP.ts +1 -0
  109. package/packages/locale/lang/ko-KR.ts +1 -0
  110. package/packages/locale/lang/pt-BR.ts +1 -0
  111. package/packages/locale/lang/ru-RU.ts +1 -0
  112. package/packages/locale/lang/uk-UA.ts +1 -0
  113. package/packages/locale/lang/vi-VN.ts +1 -0
  114. package/packages/locale/lang/zh-CHT.ts +1 -0
  115. package/packages/locale/lang/zh-CN.ts +1 -0
  116. package/packages/table/module/custom/hook.ts +4 -0
  117. package/packages/table/module/edit/hook.ts +54 -34
  118. package/packages/table/module/filter/hook.ts +2 -3
  119. package/packages/table/module/keyboard/hook.ts +2 -2
  120. package/packages/table/src/body.ts +46 -31
  121. package/packages/table/src/cell.ts +140 -92
  122. package/packages/table/src/emits.ts +3 -0
  123. package/packages/table/src/footer.ts +189 -152
  124. package/packages/table/src/header.ts +157 -116
  125. package/packages/table/src/props.ts +5 -1
  126. package/packages/table/src/table.ts +358 -109
  127. package/packages/table/src/util.ts +10 -0
  128. package/packages/ui/index.ts +8 -3
  129. package/styles/components/table.scss +42 -35
  130. /package/es/{iconfont.1731633504443.ttf → iconfont.1731937248477.ttf} +0 -0
  131. /package/es/{iconfont.1731633504443.woff → iconfont.1731937248477.woff} +0 -0
  132. /package/es/{iconfont.1731633504443.woff2 → iconfont.1731937248477.woff2} +0 -0
  133. /package/lib/{iconfont.1731633504443.ttf → iconfont.1731937248477.ttf} +0 -0
  134. /package/lib/{iconfont.1731633504443.woff → iconfont.1731937248477.woff} +0 -0
  135. /package/lib/{iconfont.1731633504443.woff2 → iconfont.1731937248477.woff2} +0 -0
@@ -1,4 +1,4 @@
1
- import { createCommentVNode, defineComponent, h, ref, Ref, PropType, inject, nextTick, onMounted, onUnmounted } from 'vue'
1
+ import { createCommentVNode, defineComponent, TransitionGroup, h, ref, Ref, PropType, inject, nextTick, onMounted, onUnmounted } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
3
  import { VxeUI } from '../../ui'
4
4
  import { updateCellTitle, getPropClass, setScrollLeft } from '../../ui/src/dom'
@@ -85,37 +85,173 @@ export default defineComponent({
85
85
  }
86
86
  }
87
87
 
88
- onMounted(() => {
89
- nextTick(() => {
90
- const { fixedType } = props
91
- const { elemStore } = tableInternalData
92
- const prefix = `${fixedType || 'main'}-footer-`
93
- elemStore[`${prefix}wrapper`] = refElem
94
- elemStore[`${prefix}table`] = refFooterTable
95
- elemStore[`${prefix}colgroup`] = refFooterColgroup
96
- elemStore[`${prefix}list`] = refFooterTFoot
97
- elemStore[`${prefix}xSpace`] = refFooterXSpace
98
- })
99
- })
100
-
101
- onUnmounted(() => {
88
+ const renderRows = (tableColumn: VxeTableDefines.ColumnInfo[], footerTableData: any[], row: any, $rowIndex: number, _rowIndex: number) => {
102
89
  const { fixedType } = props
103
- const { elemStore } = tableInternalData
104
- const prefix = `${fixedType || 'main'}-footer-`
105
- elemStore[`${prefix}wrapper`] = null
106
- elemStore[`${prefix}table`] = null
107
- elemStore[`${prefix}colgroup`] = null
108
- elemStore[`${prefix}list`] = null
109
- elemStore[`${prefix}xSpace`] = null
110
- })
90
+ const { footerCellClassName, footerCellStyle, footerAlign: allFooterAlign, footerSpanMethod, align: allAlign, columnKey, showFooterOverflow: allColumnFooterOverflow } = tableProps
91
+ const { scrollXLoad, overflowX, scrollbarWidth, currentColumn, mergeFooterList } = tableReactData
92
+ const tooltipOpts = computeTooltipOpts.value
93
+ const columnOpts = computeColumnOpts.value
94
+
95
+ return tableColumn.map((column, $columnIndex) => {
96
+ const { type, showFooterOverflow, footerAlign, align, footerClassName, editRender, cellRender } = column
97
+ const renderOpts = editRender || cellRender
98
+ const compConf = renderOpts ? renderer.get(renderOpts.name) : null
99
+ const showAllTip = tooltipOpts.showAll
100
+ const isColGroup = column.children && column.children.length
101
+ const fixedHiddenColumn = fixedType ? column.fixed !== fixedType && !isColGroup : column.fixed && overflowX
102
+ const footOverflow = XEUtils.eqNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow
103
+ const footAlign = footerAlign || (compConf ? compConf.tableFooterCellAlign : '') || allFooterAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
104
+ let showEllipsis = footOverflow === 'ellipsis'
105
+ const showTitle = footOverflow === 'title'
106
+ const showTooltip = footOverflow === true || footOverflow === 'tooltip'
107
+ let hasEllipsis = showTitle || showTooltip || showEllipsis
108
+ const attrs: any = { colid: column.id }
109
+ const tfOns: any = {}
110
+ const columnIndex = $xeTable.getColumnIndex(column)
111
+ const _columnIndex = $xeTable.getVTColumnIndex(column)
112
+ const itemIndex = _columnIndex
113
+ const cellParams: VxeTableDefines.CellRenderFooterParams = {
114
+ $table: $xeTable,
115
+ $grid: $xeTable.xegrid,
116
+ row,
117
+ rowIndex: _rowIndex,
118
+ _rowIndex,
119
+ $rowIndex,
120
+ column,
121
+ columnIndex,
122
+ $columnIndex,
123
+ _columnIndex,
124
+ itemIndex,
125
+ items: row,
126
+ fixed: fixedType,
127
+ type: renderType,
128
+ data: footerTableData
129
+ }
130
+ // 纵向虚拟滚动不支持动态行高
131
+ if (scrollXLoad && !hasEllipsis) {
132
+ showEllipsis = hasEllipsis = true
133
+ }
134
+ if (showTitle || showTooltip || showAllTip) {
135
+ tfOns.onMouseenter = (evnt: MouseEvent) => {
136
+ if (showTitle) {
137
+ updateCellTitle(evnt.currentTarget, column)
138
+ } else if (showTooltip || showAllTip) {
139
+ $xeTable.triggerFooterTooltipEvent(evnt, cellParams)
140
+ }
141
+ }
142
+ }
143
+ if (showTooltip || showAllTip) {
144
+ tfOns.onMouseleave = (evnt: MouseEvent) => {
145
+ if (showTooltip || showAllTip) {
146
+ $xeTable.handleTargetLeaveEvent(evnt)
147
+ }
148
+ }
149
+ }
150
+ tfOns.onClick = (evnt: MouseEvent) => {
151
+ $xeTable.dispatchEvent('footer-cell-click', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
152
+ }
153
+ tfOns.onDblclick = (evnt: MouseEvent) => {
154
+ $xeTable.dispatchEvent('footer-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
155
+ }
156
+ // 合并行或列
157
+ if (mergeFooterList.length) {
158
+ const spanRest = mergeFooterMethod(mergeFooterList, _rowIndex, _columnIndex)
159
+ if (spanRest) {
160
+ const { rowspan, colspan } = spanRest
161
+ if (!rowspan || !colspan) {
162
+ return null
163
+ }
164
+ if (rowspan > 1) {
165
+ attrs.rowspan = rowspan
166
+ }
167
+ if (colspan > 1) {
168
+ attrs.colspan = colspan
169
+ }
170
+ }
171
+ } else if (footerSpanMethod) {
172
+ // 自定义合并方法
173
+ const { rowspan = 1, colspan = 1 } = footerSpanMethod(cellParams) || {}
174
+ if (!rowspan || !colspan) {
175
+ return null
176
+ }
177
+ if (rowspan > 1) {
178
+ attrs.rowspan = rowspan
179
+ }
180
+ if (colspan > 1) {
181
+ attrs.colspan = colspan
182
+ }
183
+ }
184
+ return h('td', {
185
+ class: ['vxe-footer--column', column.id, {
186
+ [`col--${footAlign}`]: footAlign,
187
+ [`col--${type}`]: type,
188
+ 'col--last': $columnIndex === tableColumn.length - 1,
189
+ 'fixed--hidden': fixedHiddenColumn,
190
+ 'col--ellipsis': hasEllipsis,
191
+ 'col--current': currentColumn === column
192
+ }, getPropClass(footerClassName, cellParams), getPropClass(footerCellClassName, cellParams)],
193
+ ...attrs,
194
+ style: footerCellStyle ? (XEUtils.isFunction(footerCellStyle) ? footerCellStyle(cellParams) : footerCellStyle) : null,
195
+ ...tfOns,
196
+ key: columnKey || columnOpts.useKey || columnOpts.drag ? column.id : $columnIndex
197
+ }, [
198
+ h('div', {
199
+ class: ['vxe-cell', {
200
+ 'c--title': showTitle,
201
+ 'c--tooltip': showTooltip,
202
+ 'c--ellipsis': showEllipsis
203
+ }]
204
+ }, column.renderFooter(cellParams))
205
+ ])
206
+ }).concat(scrollbarWidth
207
+ ? [
208
+ h('td', {
209
+ key: `gr${$rowIndex}`,
210
+ class: 'vxe-footer--gutter col--gutter'
211
+ })
212
+ ]
213
+ : [])
214
+ }
215
+
216
+ const renderHeads = (footerTableData: any[]) => {
217
+ const { fixedType, tableColumn } = props
218
+ const { footerRowClassName, footerRowStyle } = tableProps
219
+ const { isDragColMove } = tableReactData
220
+ const columnOpts = computeColumnOpts.value
221
+
222
+ return footerTableData.map((row, $rowIndex) => {
223
+ const _rowIndex = $rowIndex
224
+ const rowParams = { $table: $xeTable, row, _rowIndex, $rowIndex, fixed: fixedType, type: renderType }
225
+
226
+ if (columnOpts.drag) {
227
+ return h(TransitionGroup, {
228
+ name: `vxe-header--col-list${isDragColMove ? '' : '-disabled'}`,
229
+ tag: 'tr',
230
+ class: [
231
+ 'vxe-footer--row',
232
+ footerRowClassName ? XEUtils.isFunction(footerRowClassName) ? footerRowClassName(rowParams) : footerRowClassName : ''
233
+ ],
234
+ style: footerRowStyle ? (XEUtils.isFunction(footerRowStyle) ? footerRowStyle(rowParams) : footerRowStyle) : null
235
+ }, {
236
+ default: () => renderRows(tableColumn, footerTableData, row, $rowIndex, _rowIndex)
237
+ })
238
+ }
239
+ return h('tr', {
240
+ class: [
241
+ 'vxe-footer--row',
242
+ footerRowClassName ? XEUtils.isFunction(footerRowClassName) ? footerRowClassName(rowParams) : footerRowClassName : ''
243
+ ],
244
+ style: footerRowStyle ? (XEUtils.isFunction(footerRowStyle) ? footerRowStyle(rowParams) : footerRowStyle) : null
245
+ }, renderRows(tableColumn, footerTableData, row, $rowIndex, _rowIndex))
246
+ })
247
+ }
111
248
 
112
249
  const renderVN = () => {
113
250
  let { fixedType, fixedColumn, tableColumn, footerTableData } = props
114
- const { footerRowClassName, footerCellClassName, footerRowStyle, footerCellStyle, footerAlign: allFooterAlign, footerSpanMethod, align: allAlign, columnKey, showFooterOverflow: allColumnFooterOverflow } = tableProps
251
+ const { footerSpanMethod, showFooterOverflow: allColumnFooterOverflow } = tableProps
115
252
  const { visibleColumn } = tableInternalData
116
- const { scrollXLoad, overflowX, scrollbarWidth, currentColumn, mergeFooterList } = tableReactData
117
- const tooltipOpts = computeTooltipOpts.value
118
- const columnOpts = computeColumnOpts.value
253
+ const { scrollXLoad, scrollbarWidth, mergeFooterList } = tableReactData
254
+
119
255
  // 如果是使用优化模式
120
256
  if (fixedType) {
121
257
  // 如果存在展开行使用全量渲染
@@ -129,6 +265,7 @@ export default defineComponent({
129
265
  tableColumn = visibleColumn
130
266
  }
131
267
  }
268
+
132
269
  return h('div', {
133
270
  ref: refElem,
134
271
  class: ['vxe-table--footer-wrapper', fixedType ? `fixed-${fixedType}--wrapper` : 'body--wrapper'],
@@ -171,135 +308,35 @@ export default defineComponent({
171
308
  */
172
309
  h('tfoot', {
173
310
  ref: refFooterTFoot
174
- }, footerTableData.map((list, _rowIndex) => {
175
- const $rowIndex = _rowIndex
176
- const rowParams = { $table: $xeTable, row: list, _rowIndex, $rowIndex, fixed: fixedType, type: renderType }
177
- return h('tr', {
178
- class: ['vxe-footer--row', footerRowClassName ? XEUtils.isFunction(footerRowClassName) ? footerRowClassName(rowParams) : footerRowClassName : ''],
179
- style: footerRowStyle ? (XEUtils.isFunction(footerRowStyle) ? footerRowStyle(rowParams) : footerRowStyle) : null
180
- }, tableColumn.map((column, $columnIndex) => {
181
- const { type, showFooterOverflow, footerAlign, align, footerClassName, editRender, cellRender } = column
182
- const renderOpts = editRender || cellRender
183
- const compConf = renderOpts ? renderer.get(renderOpts.name) : null
184
- const showAllTip = tooltipOpts.showAll
185
- const isColGroup = column.children && column.children.length
186
- const fixedHiddenColumn = fixedType ? column.fixed !== fixedType && !isColGroup : column.fixed && overflowX
187
- const footOverflow = XEUtils.eqNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow
188
- const footAlign = footerAlign || (compConf ? compConf.tableFooterCellAlign : '') || allFooterAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
189
- let showEllipsis = footOverflow === 'ellipsis'
190
- const showTitle = footOverflow === 'title'
191
- const showTooltip = footOverflow === true || footOverflow === 'tooltip'
192
- let hasEllipsis = showTitle || showTooltip || showEllipsis
193
- const attrs: any = { colid: column.id }
194
- const tfOns: any = {}
195
- const columnIndex = $xeTable.getColumnIndex(column)
196
- const _columnIndex = $xeTable.getVTColumnIndex(column)
197
- const itemIndex = _columnIndex
198
- const cellParams: VxeTableDefines.CellRenderFooterParams = {
199
- $table: $xeTable,
200
- $grid: $xeTable.xegrid,
201
- row: list,
202
- rowIndex: _rowIndex,
203
- _rowIndex,
204
- $rowIndex,
205
- column,
206
- columnIndex,
207
- $columnIndex,
208
- _columnIndex,
209
- itemIndex,
210
- items: list,
211
- fixed: fixedType,
212
- type: renderType,
213
- data: footerTableData
214
- }
215
- // 纵向虚拟滚动不支持动态行高
216
- if (scrollXLoad && !hasEllipsis) {
217
- showEllipsis = hasEllipsis = true
218
- }
219
- if (showTitle || showTooltip || showAllTip) {
220
- tfOns.onMouseenter = (evnt: MouseEvent) => {
221
- if (showTitle) {
222
- updateCellTitle(evnt.currentTarget, column)
223
- } else if (showTooltip || showAllTip) {
224
- $xeTable.triggerFooterTooltipEvent(evnt, cellParams)
225
- }
226
- }
227
- }
228
- if (showTooltip || showAllTip) {
229
- tfOns.onMouseleave = (evnt: MouseEvent) => {
230
- if (showTooltip || showAllTip) {
231
- $xeTable.handleTargetLeaveEvent(evnt)
232
- }
233
- }
234
- }
235
- tfOns.onClick = (evnt: MouseEvent) => {
236
- $xeTable.dispatchEvent('footer-cell-click', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
237
- }
238
- tfOns.onDblclick = (evnt: MouseEvent) => {
239
- $xeTable.dispatchEvent('footer-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
240
- }
241
- // 合并行或列
242
- if (mergeFooterList.length) {
243
- const spanRest = mergeFooterMethod(mergeFooterList, _rowIndex, _columnIndex)
244
- if (spanRest) {
245
- const { rowspan, colspan } = spanRest
246
- if (!rowspan || !colspan) {
247
- return null
248
- }
249
- if (rowspan > 1) {
250
- attrs.rowspan = rowspan
251
- }
252
- if (colspan > 1) {
253
- attrs.colspan = colspan
254
- }
255
- }
256
- } else if (footerSpanMethod) {
257
- // 自定义合并方法
258
- const { rowspan = 1, colspan = 1 } = footerSpanMethod(cellParams) || {}
259
- if (!rowspan || !colspan) {
260
- return null
261
- }
262
- if (rowspan > 1) {
263
- attrs.rowspan = rowspan
264
- }
265
- if (colspan > 1) {
266
- attrs.colspan = colspan
267
- }
268
- }
269
- return h('td', {
270
- class: ['vxe-footer--column', column.id, {
271
- [`col--${footAlign}`]: footAlign,
272
- [`col--${type}`]: type,
273
- 'col--last': $columnIndex === tableColumn.length - 1,
274
- 'fixed--hidden': fixedHiddenColumn,
275
- 'col--ellipsis': hasEllipsis,
276
- 'col--current': currentColumn === column
277
- }, getPropClass(footerClassName, cellParams), getPropClass(footerCellClassName, cellParams)],
278
- ...attrs,
279
- style: footerCellStyle ? (XEUtils.isFunction(footerCellStyle) ? footerCellStyle(cellParams) : footerCellStyle) : null,
280
- ...tfOns,
281
- key: columnKey || columnOpts.useKey ? column.id : $columnIndex
282
- }, [
283
- h('div', {
284
- class: ['vxe-cell', {
285
- 'c--title': showTitle,
286
- 'c--tooltip': showTooltip,
287
- 'c--ellipsis': showEllipsis
288
- }]
289
- }, column.renderFooter(cellParams))
290
- ])
291
- }).concat(scrollbarWidth
292
- ? [
293
- h('td', {
294
- class: 'vxe-footer--gutter col--gutter'
295
- })
296
- ]
297
- : []))
298
- }))
311
+ }, renderHeads(footerTableData))
299
312
  ])
300
313
  ])
301
314
  }
302
315
 
316
+ onMounted(() => {
317
+ nextTick(() => {
318
+ const { fixedType } = props
319
+ const { elemStore } = tableInternalData
320
+ const prefix = `${fixedType || 'main'}-footer-`
321
+ elemStore[`${prefix}wrapper`] = refElem
322
+ elemStore[`${prefix}table`] = refFooterTable
323
+ elemStore[`${prefix}colgroup`] = refFooterColgroup
324
+ elemStore[`${prefix}list`] = refFooterTFoot
325
+ elemStore[`${prefix}xSpace`] = refFooterXSpace
326
+ })
327
+ })
328
+
329
+ onUnmounted(() => {
330
+ const { fixedType } = props
331
+ const { elemStore } = tableInternalData
332
+ const prefix = `${fixedType || 'main'}-footer-`
333
+ elemStore[`${prefix}wrapper`] = null
334
+ elemStore[`${prefix}table`] = null
335
+ elemStore[`${prefix}colgroup`] = null
336
+ elemStore[`${prefix}list`] = null
337
+ elemStore[`${prefix}xSpace`] = null
338
+ })
339
+
303
340
  return renderVN
304
341
  }
305
342
  })
@@ -1,4 +1,4 @@
1
- import { createCommentVNode, defineComponent, h, ref, Ref, PropType, inject, nextTick, watch, onMounted, onUnmounted } from 'vue'
1
+ import { createCommentVNode, defineComponent, TransitionGroup, h, ref, Ref, PropType, inject, nextTick, watch, onMounted, onUnmounted } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
3
  import { VxeUI } from '../../ui'
4
4
  import { convertHeaderColumnToRows, getColReMinWidth } from './util'
@@ -135,43 +135,136 @@ export default defineComponent({
135
135
  }
136
136
  }
137
137
 
138
- watch(() => props.tableColumn, uploadColumn)
139
-
140
- onMounted(() => {
141
- nextTick(() => {
142
- const { fixedType } = props
143
- const { internalData } = $xeTable
144
- const { elemStore } = internalData
145
- const prefix = `${fixedType || 'main'}-header-`
146
- elemStore[`${prefix}wrapper`] = refElem
147
- elemStore[`${prefix}table`] = refHeaderTable
148
- elemStore[`${prefix}colgroup`] = refHeaderColgroup
149
- elemStore[`${prefix}list`] = refHeaderTHead
150
- elemStore[`${prefix}xSpace`] = refHeaderXSpace
151
- elemStore[`${prefix}repair`] = refHeaderBorderRepair
152
- uploadColumn()
153
- })
154
- })
138
+ const renderRows = (cols: VxeTableDefines.ColumnInfo[], $rowIndex: number) => {
139
+ const { fixedType } = props
140
+ const { resizable: allResizable, border, columnKey, headerCellClassName, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps
141
+ const { currentColumn, scrollXLoad, overflowX, scrollbarWidth } = tableReactData
142
+ const columnOpts = computeColumnOpts.value
143
+ return cols.map((column, $columnIndex) => {
144
+ const { type, showHeaderOverflow, headerAlign, align, headerClassName, editRender, cellRender } = column
145
+ const colid = column.id
146
+ const renderOpts = editRender || cellRender
147
+ const compConf = renderOpts ? renderer.get(renderOpts.name) : null
148
+ const isColGroup = column.children && column.children.length
149
+ const fixedHiddenColumn = fixedType ? (column.fixed !== fixedType && !isColGroup) : !!column.fixed && overflowX
150
+ const headOverflow = XEUtils.eqNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
151
+ const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
152
+ let showEllipsis = headOverflow === 'ellipsis'
153
+ const showTitle = headOverflow === 'title'
154
+ const showTooltip = headOverflow === true || headOverflow === 'tooltip'
155
+ let hasEllipsis = showTitle || showTooltip || showEllipsis
156
+ const hasFilter = column.filters && column.filters.some((item) => item.checked)
157
+ const columnIndex = $xeTable.getColumnIndex(column)
158
+ const _columnIndex = $xeTable.getVTColumnIndex(column)
159
+ const params: VxeTableDefines.CellRenderHeaderParams = { $table: $xeTable, $grid: $xeTable.xegrid, $rowIndex, column, columnIndex, $columnIndex, _columnIndex, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, hasFilter }
160
+ const thOns: any = {
161
+ onClick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellClickEvent(evnt, params),
162
+ onDblclick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellDblclickEvent(evnt, params)
163
+ }
164
+ // 横向虚拟滚动不支持动态行高
165
+ if (scrollXLoad && !hasEllipsis) {
166
+ showEllipsis = hasEllipsis = true
167
+ }
168
+ // 按下事件处理
169
+ if (mouseConfig) {
170
+ thOns.onMousedown = (evnt: MouseEvent) => $xeTable.triggerHeaderCellMousedownEvent(evnt, params)
171
+ }
172
+ // 拖拽行事件
173
+ if (columnOpts.drag && !column.parentId) {
174
+ thOns.onDragstart = $xeTable.handleHeaderCellDragDragstartEvent
175
+ thOns.onDragend = $xeTable.handleHeaderCellDragDragendEvent
176
+ thOns.onDragover = $xeTable.handleHeaderCellDragDragoverEvent
177
+ }
178
+ return h('th', {
179
+ class: ['vxe-header--column', colid, {
180
+ [`col--${headAlign}`]: headAlign,
181
+ [`col--${type}`]: type,
182
+ 'col--last': $columnIndex === cols.length - 1,
183
+ 'col--fixed': column.fixed,
184
+ 'col--group': isColGroup,
185
+ 'col--ellipsis': hasEllipsis,
186
+ 'fixed--hidden': fixedHiddenColumn,
187
+ 'is--sortable': column.sortable,
188
+ 'col--filter': !!column.filters,
189
+ 'is--filter-active': hasFilter,
190
+ 'col--current': currentColumn === column
191
+ },
192
+ headerClassName ? (XEUtils.isFunction(headerClassName) ? headerClassName(params) : headerClassName) : '',
193
+ headerCellClassName ? (XEUtils.isFunction(headerCellClassName) ? headerCellClassName(params) : headerCellClassName) : ''
194
+ ],
195
+ colid,
196
+ colspan: column.colSpan > 1 ? column.colSpan : null,
197
+ rowspan: column.rowSpan > 1 ? column.rowSpan : null,
198
+ style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(params) : headerCellStyle) : null,
199
+ ...thOns,
200
+ key: columnKey || columnOpts.useKey || columnOpts.drag || isColGroup ? colid : $columnIndex
201
+ }, [
202
+ h('div', {
203
+ class: ['vxe-cell', {
204
+ 'c--title': showTitle,
205
+ 'c--tooltip': showTooltip,
206
+ 'c--ellipsis': showEllipsis
207
+ }]
208
+ }, column.renderHeader(params)),
209
+ /**
210
+ * 列宽拖动
211
+ */
212
+ !fixedHiddenColumn && !isColGroup && (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
213
+ ? h('div', {
214
+ class: ['vxe-resizable', {
215
+ 'is--line': !border || border === 'none'
216
+ }],
217
+ onMousedown: (evnt: MouseEvent) => resizeMousedown(evnt, params)
218
+ })
219
+ : null
220
+ ])
221
+ }).concat(scrollbarWidth
222
+ ? [
223
+ h('th', {
224
+ key: `gr${$rowIndex}`,
225
+ class: 'vxe-header--gutter col--gutter'
226
+ })
227
+ ]
228
+ : [])
229
+ }
155
230
 
156
- onUnmounted(() => {
231
+ const renderHeads = (headerGroups: VxeTableDefines.ColumnInfo[][]) => {
157
232
  const { fixedType } = props
158
- const { internalData } = $xeTable
159
- const { elemStore } = internalData
160
- const prefix = `${fixedType || 'main'}-header-`
161
- elemStore[`${prefix}wrapper`] = null
162
- elemStore[`${prefix}table`] = null
163
- elemStore[`${prefix}colgroup`] = null
164
- elemStore[`${prefix}list`] = null
165
- elemStore[`${prefix}xSpace`] = null
166
- elemStore[`${prefix}repair`] = null
167
- })
233
+ const { headerRowClassName, headerRowStyle } = tableProps
234
+ const { isDragColMove } = tableReactData
235
+ const columnOpts = computeColumnOpts.value
236
+
237
+ return headerGroups.map((cols, $rowIndex) => {
238
+ const params = { $table: $xeTable, $rowIndex, fixed: fixedType, type: renderType }
239
+
240
+ if (columnOpts.drag) {
241
+ return h(TransitionGroup, {
242
+ name: `vxe-header--col-list${isDragColMove ? '' : '-disabled'}`,
243
+ tag: 'tr',
244
+ class: [
245
+ 'vxe-header--row',
246
+ headerRowClassName ? (XEUtils.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName) : ''
247
+ ],
248
+ style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle) : null
249
+ }, {
250
+ default: () => renderRows(cols, $rowIndex)
251
+ })
252
+ }
253
+ return h('tr', {
254
+ class: [
255
+ 'vxe-header--row',
256
+ headerRowClassName ? (XEUtils.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName) : ''
257
+ ],
258
+ style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle) : null
259
+ }, renderRows(cols, $rowIndex))
260
+ })
261
+ }
168
262
 
169
263
  const renderVN = () => {
170
264
  const { fixedType, fixedColumn, tableColumn } = props
171
- const { resizable: allResizable, border, columnKey, headerRowClassName, headerCellClassName, headerRowStyle, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps
172
- const { isGroup, currentColumn, scrollXLoad, overflowX, scrollbarWidth } = tableReactData
265
+ const { showHeaderOverflow: allColumnHeaderOverflow } = tableProps
266
+ const { isGroup, scrollXLoad, scrollbarWidth } = tableReactData
173
267
  const { visibleColumn } = tableInternalData
174
- const columnOpts = computeColumnOpts.value
175
268
  let headerGroups: VxeTableDefines.ColumnInfo[][] = headerColumn.value
176
269
  let renderColumnList = tableColumn as VxeTableDefines.ColumnInfo[]
177
270
  if (isGroup) {
@@ -226,90 +319,7 @@ export default defineComponent({
226
319
  */
227
320
  h('thead', {
228
321
  ref: refHeaderTHead
229
- }, headerGroups.map((cols, $rowIndex) => {
230
- return h('tr', {
231
- class: ['vxe-header--row', headerRowClassName ? (XEUtils.isFunction(headerRowClassName) ? headerRowClassName({ $table: $xeTable, $rowIndex, fixed: fixedType, type: renderType }) : headerRowClassName) : ''],
232
- style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle({ $table: $xeTable, $rowIndex, fixed: fixedType, type: renderType }) : headerRowStyle) : null
233
- }, cols.map((column, $columnIndex) => {
234
- const { type, showHeaderOverflow, headerAlign, align, headerClassName, editRender, cellRender } = column
235
- const colid = column.id
236
- const renderOpts = editRender || cellRender
237
- const compConf = renderOpts ? renderer.get(renderOpts.name) : null
238
- const isColGroup = column.children && column.children.length
239
- const fixedHiddenColumn = fixedType ? (column.fixed !== fixedType && !isColGroup) : !!column.fixed && overflowX
240
- const headOverflow = XEUtils.eqNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
241
- const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
242
- let showEllipsis = headOverflow === 'ellipsis'
243
- const showTitle = headOverflow === 'title'
244
- const showTooltip = headOverflow === true || headOverflow === 'tooltip'
245
- let hasEllipsis = showTitle || showTooltip || showEllipsis
246
- const hasFilter = column.filters && column.filters.some((item) => item.checked)
247
- const columnIndex = $xeTable.getColumnIndex(column)
248
- const _columnIndex = $xeTable.getVTColumnIndex(column)
249
- const params: VxeTableDefines.CellRenderHeaderParams = { $table: $xeTable, $grid: $xeTable.xegrid, $rowIndex, column, columnIndex, $columnIndex, _columnIndex, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, hasFilter }
250
- const thOns: any = {
251
- onClick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellClickEvent(evnt, params),
252
- onDblclick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellDblclickEvent(evnt, params)
253
- }
254
- // 横向虚拟滚动不支持动态行高
255
- if (scrollXLoad && !hasEllipsis) {
256
- showEllipsis = hasEllipsis = true
257
- }
258
- // 按下事件处理
259
- if (mouseConfig) {
260
- thOns.onMousedown = (evnt: MouseEvent) => $xeTable.triggerHeaderCellMousedownEvent(evnt, params)
261
- }
262
- return h('th', {
263
- class: ['vxe-header--column', colid, {
264
- [`col--${headAlign}`]: headAlign,
265
- [`col--${type}`]: type,
266
- 'col--last': $columnIndex === cols.length - 1,
267
- 'col--fixed': column.fixed,
268
- 'col--group': isColGroup,
269
- 'col--ellipsis': hasEllipsis,
270
- 'fixed--hidden': fixedHiddenColumn,
271
- 'is--sortable': column.sortable,
272
- 'col--filter': !!column.filters,
273
- 'is--filter-active': hasFilter,
274
- 'col--current': currentColumn === column
275
- },
276
- headerClassName ? (XEUtils.isFunction(headerClassName) ? headerClassName(params) : headerClassName) : '',
277
- headerCellClassName ? (XEUtils.isFunction(headerCellClassName) ? headerCellClassName(params) : headerCellClassName) : ''
278
- ],
279
- colid,
280
- colspan: column.colSpan > 1 ? column.colSpan : null,
281
- rowspan: column.rowSpan > 1 ? column.rowSpan : null,
282
- style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(params) : headerCellStyle) : null,
283
- ...thOns,
284
- key: columnKey || columnOpts.useKey || isColGroup ? colid : $columnIndex
285
- }, [
286
- h('div', {
287
- class: ['vxe-cell', {
288
- 'c--title': showTitle,
289
- 'c--tooltip': showTooltip,
290
- 'c--ellipsis': showEllipsis
291
- }]
292
- }, column.renderHeader(params)),
293
- /**
294
- * 列宽拖动
295
- */
296
- !fixedHiddenColumn && !isColGroup && (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
297
- ? h('div', {
298
- class: ['vxe-resizable', {
299
- 'is--line': !border || border === 'none'
300
- }],
301
- onMousedown: (evnt: MouseEvent) => resizeMousedown(evnt, params)
302
- })
303
- : null
304
- ])
305
- }).concat(scrollbarWidth
306
- ? [
307
- h('th', {
308
- class: 'vxe-header--gutter col--gutter'
309
- })
310
- ]
311
- : []))
312
- }))
322
+ }, renderHeads(headerGroups))
313
323
  ]),
314
324
  /**
315
325
  * 其他
@@ -321,6 +331,37 @@ export default defineComponent({
321
331
  ])
322
332
  }
323
333
 
334
+ watch(() => props.tableColumn, uploadColumn)
335
+
336
+ onMounted(() => {
337
+ nextTick(() => {
338
+ const { fixedType } = props
339
+ const { internalData } = $xeTable
340
+ const { elemStore } = internalData
341
+ const prefix = `${fixedType || 'main'}-header-`
342
+ elemStore[`${prefix}wrapper`] = refElem
343
+ elemStore[`${prefix}table`] = refHeaderTable
344
+ elemStore[`${prefix}colgroup`] = refHeaderColgroup
345
+ elemStore[`${prefix}list`] = refHeaderTHead
346
+ elemStore[`${prefix}xSpace`] = refHeaderXSpace
347
+ elemStore[`${prefix}repair`] = refHeaderBorderRepair
348
+ uploadColumn()
349
+ })
350
+ })
351
+
352
+ onUnmounted(() => {
353
+ const { fixedType } = props
354
+ const { internalData } = $xeTable
355
+ const { elemStore } = internalData
356
+ const prefix = `${fixedType || 'main'}-header-`
357
+ elemStore[`${prefix}wrapper`] = null
358
+ elemStore[`${prefix}table`] = null
359
+ elemStore[`${prefix}colgroup`] = null
360
+ elemStore[`${prefix}list`] = null
361
+ elemStore[`${prefix}xSpace`] = null
362
+ elemStore[`${prefix}repair`] = null
363
+ })
364
+
324
365
  return renderVN
325
366
  }
326
367
  })