@@ -13,22 +13,6 @@ const { renderer, renderEmptyElement } = VxeUI
1313const sourceType = 'table'
1414const renderType = 'header'
1515
16- function getColumnFirstChild ( column : VxeTableDefines . ColumnInfo ) : VxeTableDefines . ColumnInfo {
17- const { children } = column
18- if ( children && children . length ) {
19- return getColumnFirstChild ( children [ 0 ] )
20- }
21- return column
22- }
23-
24- function getColumnLastChild ( column : VxeTableDefines . ColumnInfo ) : VxeTableDefines . ColumnInfo {
25- const { children } = column
26- if ( children && children . length ) {
27- return getColumnLastChild ( children [ children . length - 1 ] )
28- }
29- return column
30- }
31-
3216export default defineVxeComponent ( {
3317 name : 'VxeTableHeader' ,
3418 props : {
@@ -203,15 +187,13 @@ export default defineVxeComponent({
203187 if ( showCustomHeader ) {
204188 // custom
205189 } else if ( isColGroup && ! isLastRow ) {
206- const firstCol = getColumnFirstChild ( column )
207- const lastCol = getColumnLastChild ( column )
208- if ( firstCol && lastCol && firstCol . id !== lastCol . id ) {
209- const firstColRest = fullColumnIdData [ firstCol . id ]
210- const lastColRest = fullColumnIdData [ lastCol . id ]
211- if ( firstColRest && lastColRest ) {
212- tcStyle . width = `${ lastColRest . oLeft - firstColRest . oLeft + lastCol . renderWidth } px`
190+ let childWidth = 0
191+ XEUtils . eachTree ( column . children , ( childRow ) => {
192+ if ( childRow . visible && ( ! childRow . children || ! childRow . children . length ) ) {
193+ childWidth += childRow . renderWidth
213194 }
214- }
195+ } )
196+ tcStyle . width = `${ childWidth } px`
215197 }
216198
217199 return h ( 'th' , {
0 commit comments