wkjp-list-page 1.0.37 → 1.0.39

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.37",
3
+ "version": "1.0.39",
4
4
  "description": "Vue2 + ElementUI CommonListPage component",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -447,12 +447,6 @@ export default {
447
447
  exportBefore: { type: Function, default: null },
448
448
  /** 与列表当前 `total` 比较,超出则提示不导出;不传则不限制 */
449
449
  exportMaxLimit: { type: Number, default: null },
450
- /**
451
- * 未在列上写 `width` / `minWidth` 时,按表头与当前页单元格内容估算列宽;
452
- * 内容最长超过该字符宽度单位数则固定按该宽度算宽并开启 `showOverflowTooltip`。
453
- * 注:中文字符宽度为2,英文字母和数字宽度为1。
454
- */
455
- columnOverflowTooltipChars: { type: Number, default: 20 },
456
450
  /** 自动列宽:每字符宽度单位折算像素(12px 字号下,半角字符约8px,全角字符约16px) */
457
451
  columnAutoWidthCharPx: { type: Number, default: 8 },
458
452
  /** 自动列宽:单元格左右内边距等额外宽度 */
@@ -766,80 +760,17 @@ export default {
766
760
  return length;
767
761
  },
768
762
  // 判断文本是否需要显示省略号
769
- // 中文字符:超过20个字符宽度单位(约10个中文字)
770
- // 英文字母/数字:超过40个字符宽度单位(约40个英文字母/数字)
763
+ // 现在只通过列配置中的 showOverflowTooltip 属性来控制
764
+ // 不再根据字符长度自动判断
771
765
  shouldShowOverflowTooltip(text) {
772
- var str = String(text == null ? "" : text);
773
-
774
- // 如果字符串为空,不显示省略号
775
- if (str.length === 0) {
776
- return false;
777
- }
778
-
779
- var fullWidthCount = 0; // 全角字符计数
780
- var halfWidthCount = 0; // 半角字符计数
781
- var isPureNumberOrLetter = true; // 标记是否为纯数字或字母
782
-
783
- for (var i = 0; i < str.length; i++) {
784
- var charCode = str.charCodeAt(i);
785
- var char = str.charAt(i);
786
-
787
- // 检查是否为全角字符
788
- if (
789
- (charCode >= 0x4E00 && charCode <= 0x9FFF) || // 中文
790
- (charCode >= 0x3000 && charCode <= 0x303F) || // CJK符号和标点
791
- (charCode >= 0xFF00 && charCode <= 0xFFEF) // 全角字符
792
- ) {
793
- fullWidthCount++;
794
- isPureNumberOrLetter = false; // 包含全角字符,不是纯数字/字母
795
- } else {
796
- halfWidthCount++;
797
- // 检查是否为数字或字母(半角)
798
- if (!((charCode >= 48 && charCode <= 57) || // 数字 0-9
799
- (charCode >= 65 && charCode <= 90) || // 大写字母 A-Z
800
- (charCode >= 97 && charCode <= 122))) { // 小写字母 a-z
801
- isPureNumberOrLetter = false; // 包含非数字字母字符
802
- }
803
- }
804
- }
805
-
806
- // 纯数字或字母内容不显示省略号
807
- if (isPureNumberOrLetter && halfWidthCount > 0 && fullWidthCount === 0) {
808
- return false;
809
- }
810
-
811
- // 计算总宽度单位:全角字符*2 + 半角字符*1
812
- var totalWidth = fullWidthCount * 2 + halfWidthCount;
813
-
814
- // 如果包含全角字符,使用20个宽度单位的阈值
815
- // 如果只有半角字符,使用40个宽度单位的阈值
816
- var threshold = fullWidthCount > 0 ? 20 : 40;
817
-
818
- return totalWidth > threshold;
766
+ // 永远返回 false,不自动显示省略号
767
+ // 省略号显示完全由列配置中的 showOverflowTooltip 属性控制
768
+ return false;
819
769
  },
820
770
  // 根据字符类型获取动态阈值
771
+ // 现在不再使用,但保留方法避免错误
821
772
  getDynamicThreshold(text) {
822
- var str = String(text == null ? "" : text);
823
- var fullWidthCount = 0; // 全角字符计数
824
-
825
- for (var i = 0; i < str.length; i++) {
826
- var charCode = str.charCodeAt(i);
827
- if (
828
- (charCode >= 0x4E00 && charCode <= 0x9FFF) || // 中文
829
- (charCode >= 0x3000 && charCode <= 0x303F) || // CJK符号和标点
830
- (charCode >= 0xFF00 && charCode <= 0xFFEF) // 全角字符
831
- ) {
832
- fullWidthCount++;
833
- }
834
- }
835
-
836
- // 如果包含全角字符,使用20个宽度单位的阈值
837
- // 如果只有半角字符,使用40个宽度单位的阈值
838
- return fullWidthCount > 0 ? 20 : 40;
839
- },
840
- columnOverflowThreshold() {
841
- var n = Number(this.columnOverflowTooltipChars);
842
- return Number.isFinite(n) && n > 0 ? Math.floor(n) : 20;
773
+ return 20; // 返回默认值
843
774
  },
844
775
  /** 表头 + 当前页数据中最长展示文本的字符数(slot 列仅表头) */
845
776
  getColumnMaxContentLength(col) {
@@ -929,33 +860,13 @@ export default {
929
860
  // slot 列可以设置 showOverflowTooltip
930
861
  // 对于 slot 列,我们只检查用户是否显式设置了 showOverflowTooltip
931
862
  // 因为 slot 列的内容是自定义的,无法自动判断是否需要省略号
863
+ // 注意:slot列无法自动判断内容是否为纯数字字母,所以这里保留用户设置
932
864
  if (col.showOverflowTooltip === true) {
933
865
  slotLayout.showOverflowTooltip = true;
934
866
  }
935
867
  return slotLayout;
936
868
  }
937
869
 
938
- // 获取表头和内容的最大字符长度
939
- var maxLen = this.getColumnMaxContentLength(col);
940
- var threshold = this.columnOverflowThreshold();
941
-
942
- // 计算基于内容的宽度(字符数转像素)
943
- var charPx = Number(this.columnAutoWidthCharPx);
944
- var pad = Number(this.columnAutoWidthPadding);
945
- if (!Number.isFinite(charPx) || charPx <= 0) charPx = 16;
946
- if (!Number.isFinite(pad) || pad < 0) pad = 32;
947
-
948
- // 计算内容宽度(像素)
949
- // 获取最长内容的字符串来判断应该使用哪个阈值
950
- var maxContentText = this.getColumnMaxContentText(col);
951
- var shouldShowTooltip = this.shouldShowOverflowTooltip(maxContentText);
952
-
953
- // 根据字符类型动态调整阈值
954
- // 如果应该显示省略号,使用动态阈值计算宽度
955
- var dynamicThreshold = this.getDynamicThreshold(maxContentText);
956
- var widthChars = shouldShowTooltip ? dynamicThreshold : Math.max(maxLen, 1);
957
- var contentWidthPx = Math.ceil(widthChars * charPx + pad);
958
-
959
870
  // 获取用户设置的 minWidth(如果有)
960
871
  var userMinWidth = null;
961
872
  if (col.minWidth != null && col.minWidth !== "") {
@@ -969,11 +880,8 @@ export default {
969
880
  var defaultMinW = Number(this.columnAutoMinWidth);
970
881
  if (!Number.isFinite(defaultMinW) || defaultMinW <= 0) defaultMinW = 120;
971
882
 
972
- // 计算最终的最小宽度:max(用户设置的minWidth, 默认minWidth, 内容宽度)
973
- var finalMinWidth = Math.max(
974
- defaultMinW,
975
- contentWidthPx
976
- );
883
+ // 计算最终的最小宽度:max(用户设置的minWidth, 默认minWidth)
884
+ var finalMinWidth = defaultMinW;
977
885
  if (userMinWidth !== null) {
978
886
  finalMinWidth = Math.max(finalMinWidth, userMinWidth);
979
887
  }
@@ -982,12 +890,15 @@ export default {
982
890
  if (col.width != null && col.width !== "") {
983
891
  var userWidth = Number(col.width);
984
892
  if (Number.isFinite(userWidth) && userWidth > 0) {
985
- // 获取最长内容的字符串来判断是否需要显示省略号
986
- var maxContentText = this.getColumnMaxContentText(col);
987
- var shouldShowTooltip = this.shouldShowOverflowTooltip(maxContentText) || col.showOverflowTooltip === true;
893
+ // 只根据列配置中的 showOverflowTooltip 属性决定是否显示省略号
894
+ if (col.showOverflowTooltip === true) {
895
+ return {
896
+ width: userWidth,
897
+ showOverflowTooltip: true
898
+ };
899
+ }
988
900
  return {
989
- width: userWidth,
990
- showOverflowTooltip: shouldShowTooltip
901
+ width: userWidth
991
902
  };
992
903
  }
993
904
  }
@@ -996,11 +907,8 @@ export default {
996
907
  minWidth: finalMinWidth
997
908
  };
998
909
 
999
- // 判断是否需要显示 tooltip
1000
- // 获取最长内容的字符串来判断是否需要显示省略号
1001
- var maxContentText = this.getColumnMaxContentText(col);
1002
- var shouldShowTooltip = this.shouldShowOverflowTooltip(maxContentText) || col.showOverflowTooltip === true;
1003
- if (shouldShowTooltip) {
910
+ // 只根据列配置中的 showOverflowTooltip 属性决定是否显示省略号
911
+ if (col.showOverflowTooltip === true) {
1004
912
  layout.showOverflowTooltip = true;
1005
913
  }
1006
914