wkjp-list-page 1.0.23 → 1.0.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wkjp-list-page",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "Vue2 + ElementUI CommonListPage component",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -669,13 +669,63 @@ export default {
669
669
  textDisplayLength(text) {
670
670
  return String(text == null ? "" : text).length;
671
671
  },
672
+ /** 折算列宽用的「显示宽度单位」:中文等宽字符 1,ASCII 约 0.6 */
673
+ textDisplayWidthUnits(text) {
674
+ var s = String(text == null ? "" : text);
675
+ var units = 0;
676
+ for (var i = 0; i < s.length; i++) {
677
+ units += s.charCodeAt(i) > 255 ? 1 : 0.6;
678
+ }
679
+ return units;
680
+ },
681
+ getColumnLabelText(col) {
682
+ return (col && (col.label || col.prop || col.slot)) || "";
683
+ },
672
684
  columnOverflowThreshold() {
673
685
  var n = Number(this.columnOverflowTooltipChars);
674
686
  return Number.isFinite(n) && n > 0 ? Math.floor(n) : 20;
675
687
  },
676
- /** 表头 + 当前页数据中最长展示文本的字符数(slot 列仅表头) */
688
+ getColumnAutoWidthMetrics() {
689
+ var charPx = Number(this.columnAutoWidthCharPx);
690
+ var pad = Number(this.columnAutoWidthPadding);
691
+ if (!Number.isFinite(charPx) || charPx <= 0) charPx = 14;
692
+ if (!Number.isFinite(pad) || pad < 0) pad = 24;
693
+ return {
694
+ charPx: charPx,
695
+ pad: pad,
696
+ headerCharPx: charPx * 1.08,
697
+ headerPad: Math.max(pad, 48)
698
+ };
699
+ },
700
+ estimateColumnWidthPx(units, charPx, paddingPx) {
701
+ var u = Number(units);
702
+ if (!Number.isFinite(u) || u <= 0) u = 1;
703
+ return Math.ceil(u * charPx + paddingPx);
704
+ },
705
+ /** 表头文案折算的最小列宽(不参与内容超长封顶) */
706
+ getColumnHeaderMinWidthPx(col) {
707
+ var metrics = this.getColumnAutoWidthMetrics();
708
+ var labelUnits = this.textDisplayWidthUnits(this.getColumnLabelText(col));
709
+ return this.estimateColumnWidthPx(labelUnits, metrics.headerCharPx, metrics.headerPad);
710
+ },
711
+ /** 当前页单元格内容折算的最小列宽(超长按 threshold 封顶,仅影响内容侧) */
712
+ getColumnContentMinWidthPx(col) {
713
+ if (!col || col.type === "slot" || this.isBuiltinCellColumn(col)) return 0;
714
+ var metrics = this.getColumnAutoWidthMetrics();
715
+ var maxCellUnits = 0;
716
+ var rows = this.innerTableData || [];
717
+ for (var i = 0; i < rows.length; i++) {
718
+ var text = this.resolveCellText(col, rows[i], i);
719
+ maxCellUnits = Math.max(maxCellUnits, this.textDisplayWidthUnits(text));
720
+ }
721
+ var threshold = this.columnOverflowThreshold();
722
+ var contentUnits =
723
+ maxCellUnits > threshold ? threshold : Math.max(maxCellUnits, 1);
724
+ return this.estimateColumnWidthPx(contentUnits, metrics.charPx, metrics.pad);
725
+ },
726
+ /** 表头 + 当前页数据中最长展示文本的字符数(slot 列仅表头;用于 tooltip 判断) */
677
727
  getColumnMaxContentLength(col) {
678
- var labelLen = this.textDisplayLength((col && (col.label || col.prop || col.slot)) || "");
728
+ var labelLen = this.textDisplayLength(this.getColumnLabelText(col));
679
729
  if (!col || col.type === "slot" || this.isBuiltinCellColumn(col)) {
680
730
  return labelLen;
681
731
  }
@@ -691,27 +741,30 @@ export default {
691
741
  if (!col) return {};
692
742
  var hasWidth = col.width != null && col.width !== "";
693
743
  var hasMinWidth = col.minWidth != null && col.minWidth !== "";
744
+ var headerMinWidth = this.getColumnHeaderMinWidthPx(col);
745
+ var layout = {};
746
+ if (hasMinWidth) {
747
+ var explicitMin = Number(col.minWidth);
748
+ if (Number.isFinite(explicitMin) && explicitMin < headerMinWidth) {
749
+ layout.minWidth = headerMinWidth;
750
+ }
751
+ }
694
752
  if (hasWidth || hasMinWidth) {
695
753
  if (col.showOverflowTooltip !== undefined && col.showOverflowTooltip !== null) {
696
- return {};
754
+ return layout;
697
755
  }
698
756
  var maxLenExplicit = this.getColumnMaxContentLength(col);
699
- return maxLenExplicit > this.columnOverflowThreshold()
700
- ? { showOverflowTooltip: true }
701
- : {};
757
+ if (maxLenExplicit > this.columnOverflowThreshold()) {
758
+ layout.showOverflowTooltip = true;
759
+ }
760
+ return layout;
702
761
  }
703
762
  var maxLen = this.getColumnMaxContentLength(col);
704
763
  var threshold = this.columnOverflowThreshold();
705
- var widthChars = maxLen > threshold ? threshold : Math.max(maxLen, 1);
706
- var charPx = Number(this.columnAutoWidthCharPx);
707
- var pad = Number(this.columnAutoWidthPadding);
708
- if (!Number.isFinite(charPx) || charPx <= 0) charPx = 14;
709
- if (!Number.isFinite(pad) || pad < 0) pad = 24;
764
+ var contentMinWidth = this.getColumnContentMinWidthPx(col);
710
765
  var minW = Number(this.columnAutoMinWidth);
711
766
  if (!Number.isFinite(minW) || minW <= 0) minW = 100;
712
- var layout = {
713
- minWidth: Math.max(minW, Math.ceil(widthChars * charPx + pad))
714
- };
767
+ layout.minWidth = Math.max(minW, headerMinWidth, contentMinWidth);
715
768
  if (maxLen > threshold) {
716
769
  layout.showOverflowTooltip = true;
717
770
  } else if (col.showOverflowTooltip === true) {
@@ -1684,21 +1737,21 @@ export default {
1684
1737
  color: #409eff;
1685
1738
  }
1686
1739
 
1687
- /* ---------- 列表表格(浅表头、细横线;空数据用极细外框,不用 border 网格) ---------- */
1740
+ /* ---------- 列表表格(极细外框兜底:空数据区不塌陷、无粗网格线) ---------- */
1688
1741
  .common-list-page /deep/ .el-table {
1689
1742
  overflow: hidden;
1690
1743
  font-size: 12px;
1691
1744
  color: #606266;
1692
- border: none;
1745
+ border: none !important;
1693
1746
  border-radius: 2px;
1694
1747
  outline: 1px solid #ebeef5;
1695
1748
  outline-offset: -1px;
1696
1749
  }
1697
1750
 
1698
1751
  .common-list-page /deep/ .el-table::before,
1699
- .common-list-page /deep/ .el-table--group::after,
1700
- .common-list-page /deep/ .el-table--border::after {
1701
- display: none;
1752
+ .common-list-page /deep/ .el-table.el-table--border::after,
1753
+ .common-list-page /deep/ .el-table.el-table--group::after {
1754
+ display: none !important;
1702
1755
  }
1703
1756
 
1704
1757
  .common-list-page /deep/ .el-table__empty-block {
@@ -1716,7 +1769,8 @@ export default {
1716
1769
  }
1717
1770
 
1718
1771
  .common-list-page /deep/ .el-table__fixed .el-table__body tr td.el-table__cell,
1719
- .common-list-page /deep/ .el-table__fixed-right .el-table__body tr td.el-table__cell {
1772
+ .common-list-page /deep/ .el-table__fixed-right .el-table__body tr td.el-table__cell,
1773
+ .common-list-page /deep/ .el-table__body tr:last-child td.el-table__cell {
1720
1774
  border-bottom: 1px solid #f0f2f5 !important;
1721
1775
  }
1722
1776
 
@@ -1740,10 +1794,6 @@ export default {
1740
1794
  vertical-align: middle;
1741
1795
  }
1742
1796
 
1743
- .common-list-page /deep/ .el-table__body tr:last-child td.el-table__cell {
1744
- border-bottom: 1px solid #f0f2f5 !important;
1745
- }
1746
-
1747
1797
  .common-list-page /deep/ .el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell {
1748
1798
  background: #fafbfc;
1749
1799
  }
@@ -1753,9 +1803,10 @@ export default {
1753
1803
  }
1754
1804
 
1755
1805
  .common-list-page /deep/ .el-table .cell {
1806
+ vertical-align: middle;
1756
1807
  line-height: 1.5;
1757
- padding-left: 0;
1758
- padding-right: 0;
1808
+ padding-left: 10px !important;
1809
+ padding-right: 10px !important;
1759
1810
  word-break: break-word;
1760
1811
  }
1761
1812