Commit f25f12527e6ae61bcca3a4b6d87ee869c7de84c4

Authored by huanghong
1 parent 14d1de05

Refactor

src/components/table/mixin.js
... ... @@ -27,7 +27,7 @@ export default {
27 27 // when browser has scrollBar,set a width to resolve scroll position bug
28 28 if (width && this.columns.length === index + 1 && top && this.$parent.bodyHeight !== 0) {
29 29 let scrollBarWidth = this.$parent.scrollBarWidth;
30   - if (!this.$parent.showScrollBar) scrollBarWidth = 0;
  30 + if (!this.$parent.showVerticalScrollBar) scrollBarWidth = 0;
31 31 width += scrollBarWidth;
32 32 }
33 33 // when fixed type,reset first right fixed column's width
... ... @@ -35,7 +35,7 @@ export default {
35 35 const firstFixedIndex = this.columns.findIndex((col) => col.fixed === 'right');
36 36 if (firstFixedIndex === index) {
37 37 let scrollBarWidth = this.$parent.scrollBarWidth;
38   - if (!this.$parent.showScrollBar) scrollBarWidth = 0;
  38 + if (!this.$parent.showVerticalScrollBar) scrollBarWidth = 0;
39 39 width += scrollBarWidth;
40 40 }
41 41 }
... ...
src/components/table/table-head.vue
... ... @@ -86,7 +86,7 @@
86 86 styles () {
87 87 const style = Object.assign({}, this.styleObject);
88 88 let scrollBarWidth = this.$parent.scrollBarWidth;
89   - if(!this.$parent.showScrollBar) scrollBarWidth = 0;
  89 + if(!this.$parent.showVerticalScrollBar) scrollBarWidth = 0;
90 90 const width = this.$parent.bodyHeight === 0 ? parseInt(this.styleObject.width) : parseInt(this.styleObject.width) + scrollBarWidth;
91 91 style.width = `${width}px`;
92 92 return style;
... ...
src/components/table/table.vue
... ... @@ -187,7 +187,7 @@
187 187 scrollBarWidth: getScrollBarSize(),
188 188 currentContext: this.context,
189 189 cloneData: deepCopy(this.data), // when Cell has a button to delete row data, clickCurrentRow will throw an error, so clone a data
190   - showScrollBar:false,
  190 + showVerticalScrollBar:false,
191 191 };
192 192 },
193 193 computed: {
... ... @@ -378,20 +378,20 @@
378 378 this.fixedHeader();
379 379  
380 380 if (this.$refs.tbody) {
381   - let bodyContent = this.$refs.tbody.$el;
382   - let className = bodyContent.parentElement.className;
383   - bodyContent.parentElement.className = '';
384   - let bodyContentHeight = bodyContent.offsetHeight;
385   - let bodyContentWidth = bodyContent.offsetWidth;
386   - bodyContent.parentElement.className = className;
387   - let bodyWidth = this.$refs.tbody.$el.parentElement.offsetWidth;
388   - let bodyHeight = this.$refs.tbody.$el.parentElement.offsetHeight;
  381 + let bodyContentEl = this.$refs.tbody.$el;
  382 + let bodyEl = bodyContentEl.parentElement;
  383 + let className = bodyEl.className;
  384 + bodyEl.className = '';
  385 + let bodyContentHeight = bodyContentEl.offsetHeight;
  386 + let bodyContentWidth = bodyContentEl.offsetWidth;
  387 + bodyEl.className = className;
  388 + let bodyWidth = bodyEl.offsetWidth;
  389 + let bodyHeight = bodyEl.offsetHeight;
389 390 let scrollBarWidth = 0;
390 391 if (bodyWidth < bodyContentWidth) {
391 392 scrollBarWidth = this.scrollBarWidth;
392 393 }
393   - let show = this.bodyHeight? bodyHeight - scrollBarWidth < bodyContentHeight : false;
394   - this.showScrollBar = show;
  394 + this.showVerticalScrollBar = this.bodyHeight? bodyHeight - scrollBarWidth < bodyContentHeight : false;
395 395 }
396 396 }
397 397 });
... ...