@@ -10,7 +10,7 @@ export default {
1010 resizeColumns : [ ] , // 所有需要自适应的列集合
1111 initTotalColumnsWidth : 0 , // 所有列初始化时的总宽度
1212 hasContainerWidth : false , // 容器是否有宽度(display:none 时没有)
13- containerWidthCheckTimer :null
13+ containerWidthCheckTimer : null
1414 }
1515 } ,
1616
@@ -41,12 +41,12 @@ export default {
4141 // 如果初始化时document上包含滚动条,渲染完document滚动条消失会造成表格宽度计算有误的问题
4242 containerWidthCheck ( ) {
4343
44- this . containerWidthCheckTimer = setTimeout ( x => {
44+ this . containerWidthCheckTimer = setTimeout ( x => {
4545
4646 let tableContainerWidth = this . $el . clientWidth ;
4747
4848 // 3为容错值
49- if ( tableContainerWidth - this . internalWidth > 3 ) {
49+ if ( tableContainerWidth - this . internalWidth > 3 ) {
5050
5151 this . tableResize ( ) ;
5252 }
@@ -110,41 +110,36 @@ export default {
110110 return false ;
111111 }
112112
113- var self = this ,
114- maxWidth = self . maxWidth ,
115- maxHeight = ( self . height && self . height > 0 ) ? self . height : this . getTotalColumnsHeight ( ) ,
116- minWidth = self . minWidth ,
117- minHeight = self . minHeight ,
113+ var totalColumnsHeight = this . getTotalColumnsHeight ( ) ,
114+ maxWidth = this . maxWidth ,
115+ maxHeight = ( this . height && this . height > 0 ) ? this . height : totalColumnsHeight ,
116+ minWidth = this . minWidth ,
117+ minHeight = this . minHeight > totalColumnsHeight ? totalColumnsHeight : this . minHeight ,
118118 view = this . $el ,
119119 viewOffset = utils . getViewportOffset ( view ) ,
120120 currentWidth = view . getBoundingClientRect !== 'undefined' ? view . getBoundingClientRect ( ) . width : view . clientWidth ,
121121 currentHeight = view . getBoundingClientRect !== 'undefined' ? view . getBoundingClientRect ( ) . height : view . clientHeight ,
122- right = window . document . documentElement . clientWidth - currentWidth - viewOffset . left ,
122+ // right = window.document.documentElement.clientWidth - currentWidth - viewOffset.left,
123123 bottom = window . document . documentElement . clientHeight - currentHeight - viewOffset . top - 2 ; //
124124
125125
126- if ( self . isVerticalResize && currentHeight > 0 ) {
127- // (窗口高度缩小 && 当前高度大于最小高度) || (窗口高度扩大 && 当前高度小于最大高度)
128- bottom -= self . verticalResizeOffset ;
129- if ( ( currentHeight > minHeight ) || ( currentHeight < maxHeight ) ) {
130- var currentHeight = currentHeight + bottom ; // - self.VerticalResizeOffset;
131- currentHeight = currentHeight > maxHeight ? maxHeight : currentHeight ;
132- currentHeight = currentHeight < minHeight ? minHeight : currentHeight ;
133- self . internalHeight = currentHeight ;
134- }
135- }
126+ if ( this . isVerticalResize && currentHeight > 0 ) {
136127
137- if ( self . isHorizontalResize && self . internalWidth && self . internalWidth > 0 && currentWidth > 0 ) {
128+ bottom -= this . verticalResizeOffset ;
138129
139- // (窗口宽度缩小 && 当前宽度大于最小宽度) ||(窗口宽度扩大 && 当前宽度小于最大宽度)
140- if ( ( right <= 0 && currentWidth > minWidth ) || ( right >= 0 && currentWidth < maxWidth ) ) {
130+ currentHeight = currentHeight + bottom ; // - this.VerticalResizeOffset;
131+ currentHeight = currentHeight > maxHeight ? maxHeight : currentHeight ;
132+ currentHeight = currentHeight < minHeight ? minHeight : currentHeight ;
133+ this . internalHeight = currentHeight ;
134+ }
141135
142- currentWidth = currentWidth > maxWidth ? maxWidth : currentWidth ;
143- currentWidth = currentWidth < minWidth ? minWidth : currentWidth ;
136+ if ( this . isHorizontalResize && this . internalWidth && this . internalWidth > 0 && currentWidth > 0 ) {
144137
145- self . internalWidth = currentWidth ;
146- self . changeColumnsWidth ( currentWidth ) ;
147- }
138+ currentWidth = currentWidth > maxWidth ? maxWidth : currentWidth ;
139+ currentWidth = currentWidth < minWidth ? minWidth : currentWidth ;
140+
141+ this . internalWidth = currentWidth ;
142+ this . changeColumnsWidth ( currentWidth ) ;
148143 }
149144 } ,
150145
0 commit comments