@zhaoyifannan/tvue 3.9.11-beta → 3.9.11-beta.0

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.
package/dist/tvue.js CHANGED
@@ -18467,26 +18467,51 @@
18467
18467
  _this6.virtualWidth = _this6.$el && _this6.$el.clientWidth ? _this6.$el.clientWidth : 800;
18468
18468
  }, 100);
18469
18469
  },
18470
+ //height:'auto' 时优先定位最近的固定高度祖先容器;无容器则回退视口计算
18471
+ getHeightContainer: function getHeightContainer() {
18472
+ var viewportHeight = document.documentElement.clientHeight;
18473
+ var el = this.$el && this.$el.parentElement;
18474
+ while (el && el !== document.body && el !== document.documentElement) {
18475
+ var style = window.getComputedStyle(el);
18476
+ var clientHeight = el.clientHeight;
18477
+ var clipped = /auto|scroll|hidden|overlay/.test(style.overflowY) && clientHeight > 0;
18478
+ var overflowed = el.scrollHeight > clientHeight + 1 && clientHeight > 0;
18479
+ if ((clipped || overflowed) && clientHeight < viewportHeight) return el;
18480
+ el = el.parentElement;
18481
+ }
18482
+ return null;
18483
+ },
18470
18484
  getTableHeight: function getTableHeight() {
18471
18485
  var _this7 = this;
18472
18486
  this.$nextTick(function () {
18473
18487
  if (_this7.isAutoHeight) {
18474
- var clientHeight = document.documentElement.clientHeight;
18475
18488
  var calcHeight = _this7.calcHeight || 0;
18476
18489
  var tableRef = _this7.$refs.table;
18477
18490
  var tablePageRef = _this7.$refs.tablePage;
18478
- // body 默认下外边距不计入 clientHeight,auto 高度需扣除,否则页面出现滚动条
18479
- var bodyGap = parseFloat(getComputedStyle(document.body).marginBottom) || 0;
18480
- var tableHeight = clientHeight - calcHeight - bodyGap;
18481
- if (tableRef) {
18482
- var height = tableRef.$el.offsetTop || 0;
18483
- tableHeight -= height;
18491
+ var container = _this7.getHeightContainer();
18492
+ var tableHeight;
18493
+ if (container) {
18494
+ //容器模式:以容器内容区底部为基准,避免 crud 撑高容器产生滚动条
18495
+ var containerRect = container.getBoundingClientRect();
18496
+ var style = window.getComputedStyle(container);
18497
+ var borderTop = parseFloat(style.borderTopWidth) || 0;
18498
+ var paddingBottom = parseFloat(style.paddingBottom) || 0;
18499
+ var contentBottom = containerRect.top + borderTop + container.clientHeight - paddingBottom;
18500
+ var tableTop = tableRef ? tableRef.$el.getBoundingClientRect().top : contentBottom;
18501
+ tableHeight = contentBottom - tableTop - calcHeight;
18502
+ } else {
18503
+ //视口模式(原有逻辑):body 默认下外边距不计入 clientHeight,需扣除
18504
+ var clientHeight = document.documentElement.clientHeight;
18505
+ var bodyGap = parseFloat(getComputedStyle(document.body).marginBottom) || 0;
18506
+ tableHeight = clientHeight - calcHeight - bodyGap;
18507
+ if (tableRef) {
18508
+ tableHeight -= tableRef.$el.offsetTop || 0;
18509
+ }
18484
18510
  }
18485
18511
  if (tablePageRef) {
18486
- var _height = tablePageRef.$el.offsetHeight || 0;
18487
- tableHeight -= _height;
18512
+ tableHeight -= tablePageRef.$el.offsetHeight || 0;
18488
18513
  }
18489
- _this7.tableHeight = tableHeight;
18514
+ _this7.tableHeight = Math.max(Math.floor(tableHeight), 0);
18490
18515
  } else {
18491
18516
  _this7.tableHeight = _this7.tableOption.height;
18492
18517
  }