@@ -56,20 +56,29 @@ function useQueryFilter (size, props) {
56
56
collapsed . value = value
57
57
}
58
58
59
- function genColNodes ( children , callback ) {
60
- // 添加计数 解决位置不对问题
59
+ function createNodes ( children ) {
60
+ const maxIndex = unref ( showNumber ) - 1
61
+ // 计数器
61
62
let hiddenCount = 0
63
+ const isChildHidden = ( propsHidden , index ) => {
64
+ propsHidden && ( hiddenCount += 1 )
65
+ const cHidden = unref ( collapsed ) && ( index - hiddenCount ) > maxIndex
66
+ return showCollapse ? ( propsHidden || cHidden ) : propsHidden
67
+ }
62
68
63
- const nodes = filterEmptyElement ( children ) . map ( ( child , index ) => {
69
+ return children . map ( ( child , index ) => {
64
70
const propsHidden = child . props && child . props . hidden || false
65
- propsHidden && ( hiddenCount += 1 )
66
- const colHidden = propsHidden || unref ( collapsed ) && ( index - hiddenCount > unref ( showNumber ) - 1 )
67
- const hidden = showCollapse ? colHidden : propsHidden
71
+ const hidden = isChildHidden ( propsHidden , index )
68
72
const key = ( isValidElement ( child ) && child . key ) || index
69
73
return { key : key , child : child , hidden : hidden }
70
74
} )
71
- const { length } = nodes . filter ( ( c ) => ! c . hidden )
72
- const offset = getOffset ( length , unref ( span ) )
75
+ }
76
+
77
+ function genColNodes ( children , callback ) {
78
+ const validChildren = filterEmptyElement ( children || [ ] )
79
+ const nodes = createNodes ( validChildren )
80
+ const showNodes = nodes . filter ( ( c ) => ! c . hidden )
81
+ const offset = getOffset ( showNodes . length , unref ( span ) )
73
82
const haveRow = unref ( span ) + offset === 24
74
83
return { nodes : map ( nodes , callback ) , offset, haveRow }
75
84
}
0 commit comments