wkjp-list-page 1.0.38 → 1.0.40
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
|
@@ -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
|
-
//
|
|
770
|
-
//
|
|
763
|
+
// 现在只通过列配置中的 showOverflowTooltip 属性来控制
|
|
764
|
+
// 不再根据字符长度自动判断
|
|
771
765
|
shouldShowOverflowTooltip(text) {
|
|
772
|
-
|
|
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
|
-
|
|
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) {
|
|
@@ -938,7 +869,6 @@ export default {
|
|
|
938
869
|
|
|
939
870
|
// 获取表头和内容的最大字符长度
|
|
940
871
|
var maxLen = this.getColumnMaxContentLength(col);
|
|
941
|
-
var threshold = this.columnOverflowThreshold();
|
|
942
872
|
|
|
943
873
|
// 计算基于内容的宽度(字符数转像素)
|
|
944
874
|
var charPx = Number(this.columnAutoWidthCharPx);
|
|
@@ -947,14 +877,7 @@ export default {
|
|
|
947
877
|
if (!Number.isFinite(pad) || pad < 0) pad = 32;
|
|
948
878
|
|
|
949
879
|
// 计算内容宽度(像素)
|
|
950
|
-
|
|
951
|
-
var maxContentText = this.getColumnMaxContentText(col);
|
|
952
|
-
var shouldShowTooltip = this.shouldShowOverflowTooltip(maxContentText);
|
|
953
|
-
|
|
954
|
-
// 根据字符类型动态调整阈值
|
|
955
|
-
// 如果应该显示省略号,使用动态阈值计算宽度
|
|
956
|
-
var dynamicThreshold = this.getDynamicThreshold(maxContentText);
|
|
957
|
-
var widthChars = shouldShowTooltip ? dynamicThreshold : Math.max(maxLen, 1);
|
|
880
|
+
var widthChars = Math.max(maxLen, 1);
|
|
958
881
|
var contentWidthPx = Math.ceil(widthChars * charPx + pad);
|
|
959
882
|
|
|
960
883
|
// 获取用户设置的 minWidth(如果有)
|
|
@@ -983,11 +906,8 @@ export default {
|
|
|
983
906
|
if (col.width != null && col.width !== "") {
|
|
984
907
|
var userWidth = Number(col.width);
|
|
985
908
|
if (Number.isFinite(userWidth) && userWidth > 0) {
|
|
986
|
-
//
|
|
987
|
-
|
|
988
|
-
var shouldShowTooltip = this.shouldShowOverflowTooltip(maxContentText);
|
|
989
|
-
// 纯数字字母内容不显示省略号,即使设置了 showOverflowTooltip: true
|
|
990
|
-
if (shouldShowTooltip) {
|
|
909
|
+
// 只根据列配置中的 showOverflowTooltip 属性决定是否显示省略号
|
|
910
|
+
if (col.showOverflowTooltip === true) {
|
|
991
911
|
return {
|
|
992
912
|
width: userWidth,
|
|
993
913
|
showOverflowTooltip: true
|
|
@@ -1003,12 +923,8 @@ export default {
|
|
|
1003
923
|
minWidth: finalMinWidth
|
|
1004
924
|
};
|
|
1005
925
|
|
|
1006
|
-
//
|
|
1007
|
-
|
|
1008
|
-
var maxContentText = this.getColumnMaxContentText(col);
|
|
1009
|
-
var shouldShowTooltip = this.shouldShowOverflowTooltip(maxContentText);
|
|
1010
|
-
// 纯数字字母内容不显示省略号,即使设置了 showOverflowTooltip: true
|
|
1011
|
-
if (shouldShowTooltip) {
|
|
926
|
+
// 只根据列配置中的 showOverflowTooltip 属性决定是否显示省略号
|
|
927
|
+
if (col.showOverflowTooltip === true) {
|
|
1012
928
|
layout.showOverflowTooltip = true;
|
|
1013
929
|
}
|
|
1014
930
|
|