wkjp-list-page 1.0.32 → 1.0.34
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
|
@@ -451,11 +451,11 @@ export default {
|
|
|
451
451
|
*/
|
|
452
452
|
columnOverflowTooltipChars: { type: Number, default: 20 },
|
|
453
453
|
/** 自动列宽:每字符折算像素(12px 字号下约 12~14) */
|
|
454
|
-
columnAutoWidthCharPx: { type: Number, default:
|
|
454
|
+
columnAutoWidthCharPx: { type: Number, default: 16 },
|
|
455
455
|
/** 自动列宽:单元格左右内边距等额外宽度 */
|
|
456
|
-
columnAutoWidthPadding: { type: Number, default:
|
|
456
|
+
columnAutoWidthPadding: { type: Number, default: 32 },
|
|
457
457
|
/** 自动列宽:未写 width / minWidth 时的默认最小宽度(px) */
|
|
458
|
-
columnAutoMinWidth: { type: Number, default:
|
|
458
|
+
columnAutoMinWidth: { type: Number, default: 120 }
|
|
459
459
|
},
|
|
460
460
|
data() {
|
|
461
461
|
return {
|
|
@@ -764,34 +764,64 @@ export default {
|
|
|
764
764
|
if (col.minWidth != null && col.minWidth !== "") nestedLayout.minWidth = col.minWidth;
|
|
765
765
|
return nestedLayout;
|
|
766
766
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
if (hasWidth || hasMinWidth) {
|
|
770
|
-
if (col.showOverflowTooltip !== undefined && col.showOverflowTooltip !== null) {
|
|
771
|
-
return {};
|
|
772
|
-
}
|
|
773
|
-
var maxLenExplicit = this.getColumnMaxContentLength(col);
|
|
774
|
-
return maxLenExplicit > this.columnOverflowThreshold()
|
|
775
|
-
? { showOverflowTooltip: true }
|
|
776
|
-
: {};
|
|
777
|
-
}
|
|
767
|
+
|
|
768
|
+
// 获取表头和内容的最大字符长度
|
|
778
769
|
var maxLen = this.getColumnMaxContentLength(col);
|
|
779
770
|
var threshold = this.columnOverflowThreshold();
|
|
780
|
-
|
|
771
|
+
|
|
772
|
+
// 计算基于内容的宽度(字符数转像素)
|
|
781
773
|
var charPx = Number(this.columnAutoWidthCharPx);
|
|
782
774
|
var pad = Number(this.columnAutoWidthPadding);
|
|
783
|
-
if (!Number.isFinite(charPx) || charPx <= 0) charPx =
|
|
784
|
-
if (!Number.isFinite(pad) || pad < 0) pad =
|
|
785
|
-
|
|
786
|
-
|
|
775
|
+
if (!Number.isFinite(charPx) || charPx <= 0) charPx = 16;
|
|
776
|
+
if (!Number.isFinite(pad) || pad < 0) pad = 32;
|
|
777
|
+
|
|
778
|
+
// 计算内容宽度(像素)
|
|
779
|
+
// 如果内容超过阈值,使用阈值计算宽度(显示省略号)
|
|
780
|
+
var widthChars = maxLen > threshold ? threshold : Math.max(maxLen, 1);
|
|
781
|
+
var contentWidthPx = Math.ceil(widthChars * charPx + pad);
|
|
782
|
+
|
|
783
|
+
// 获取用户设置的 minWidth(如果有)
|
|
784
|
+
var userMinWidth = null;
|
|
785
|
+
if (col.minWidth != null && col.minWidth !== "") {
|
|
786
|
+
userMinWidth = Number(col.minWidth);
|
|
787
|
+
if (!Number.isFinite(userMinWidth) || userMinWidth <= 0) {
|
|
788
|
+
userMinWidth = null;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// 获取默认的最小宽度
|
|
793
|
+
var defaultMinW = Number(this.columnAutoMinWidth);
|
|
794
|
+
if (!Number.isFinite(defaultMinW) || defaultMinW <= 0) defaultMinW = 120;
|
|
795
|
+
|
|
796
|
+
// 计算最终的最小宽度:max(用户设置的minWidth, 默认minWidth, 内容宽度)
|
|
797
|
+
var finalMinWidth = Math.max(
|
|
798
|
+
defaultMinW,
|
|
799
|
+
contentWidthPx
|
|
800
|
+
);
|
|
801
|
+
if (userMinWidth !== null) {
|
|
802
|
+
finalMinWidth = Math.max(finalMinWidth, userMinWidth);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// 如果用户设置了 width,则使用 width(优先级最高)
|
|
806
|
+
if (col.width != null && col.width !== "") {
|
|
807
|
+
var userWidth = Number(col.width);
|
|
808
|
+
if (Number.isFinite(userWidth) && userWidth > 0) {
|
|
809
|
+
return {
|
|
810
|
+
width: userWidth,
|
|
811
|
+
showOverflowTooltip: maxLen > threshold || col.showOverflowTooltip === true
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
787
816
|
var layout = {
|
|
788
|
-
minWidth:
|
|
817
|
+
minWidth: finalMinWidth
|
|
789
818
|
};
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
819
|
+
|
|
820
|
+
// 判断是否需要显示 tooltip
|
|
821
|
+
if (maxLen > threshold || col.showOverflowTooltip === true) {
|
|
793
822
|
layout.showOverflowTooltip = true;
|
|
794
823
|
}
|
|
824
|
+
|
|
795
825
|
return layout;
|
|
796
826
|
},
|
|
797
827
|
tableColumnBind(col) {
|
|
@@ -1962,7 +1992,9 @@ export default {
|
|
|
1962
1992
|
line-height: 1.5;
|
|
1963
1993
|
padding-left: 10px !important;
|
|
1964
1994
|
padding-right: 10px !important;
|
|
1965
|
-
|
|
1995
|
+
white-space: nowrap;
|
|
1996
|
+
overflow: hidden;
|
|
1997
|
+
text-overflow: ellipsis;
|
|
1966
1998
|
}
|
|
1967
1999
|
|
|
1968
2000
|
/* 操作列:多个文字按钮拉开间距(详情 / 推送 / 删除 等) */
|
|
@@ -8,10 +8,12 @@ export default {
|
|
|
8
8
|
column: { type: Object, required: true },
|
|
9
9
|
resolveCellText: { type: Function, default: null },
|
|
10
10
|
columnBind: { type: Function, default: null },
|
|
11
|
+
parentScopedSlots: { type: Object, default: null }, // 新增:接收父组件传递的插槽
|
|
11
12
|
},
|
|
12
13
|
render(h) {
|
|
13
14
|
const col = this.column;
|
|
14
|
-
|
|
15
|
+
// 优先使用 parentScopedSlots,否则使用 $scopedSlots
|
|
16
|
+
const slots = this.parentScopedSlots || this.$scopedSlots;
|
|
15
17
|
const resolveCellText = this.resolveCellText;
|
|
16
18
|
const columnBind = this.columnBind;
|
|
17
19
|
|
|
@@ -26,6 +28,7 @@ export default {
|
|
|
26
28
|
minWidth: parentBind.minWidth != null ? parentBind.minWidth : col.minWidth,
|
|
27
29
|
headerAlign: parentBind.headerAlign,
|
|
28
30
|
};
|
|
31
|
+
|
|
29
32
|
return h(
|
|
30
33
|
"el-table-column",
|
|
31
34
|
{ props: parentProps },
|
|
@@ -36,26 +39,64 @@ export default {
|
|
|
36
39
|
column: child,
|
|
37
40
|
resolveCellText,
|
|
38
41
|
columnBind,
|
|
42
|
+
parentScopedSlots: slots, // 关键:继续向下传递插槽
|
|
39
43
|
},
|
|
40
|
-
scopedSlots: slots,
|
|
44
|
+
scopedSlots: slots, // 也传递 scopedSlots 作为备选
|
|
41
45
|
}),
|
|
42
46
|
),
|
|
43
47
|
);
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
const bind = typeof columnBind === "function" ? columnBind(col) || {} : {};
|
|
47
|
-
|
|
51
|
+
|
|
52
|
+
// 构建 columnProps
|
|
53
|
+
const columnProps = Object.assign(
|
|
54
|
+
{
|
|
55
|
+
prop: col.prop,
|
|
56
|
+
label: col.label,
|
|
57
|
+
slot: col.slot,
|
|
58
|
+
type: col.type,
|
|
59
|
+
align: col.align,
|
|
60
|
+
fixed: col.fixed,
|
|
61
|
+
width: col.width,
|
|
62
|
+
minWidth: col.minWidth,
|
|
63
|
+
sortable: col.sortable,
|
|
64
|
+
sortMethod: col.sortMethod,
|
|
65
|
+
sortBy: col.sortBy,
|
|
66
|
+
sortOrders: col.sortOrders,
|
|
67
|
+
resizable: col.resizable,
|
|
68
|
+
formatter: col.formatter,
|
|
69
|
+
showOverflowTooltip: col.showOverflowTooltip,
|
|
70
|
+
inlineTemplate: col.inlineTemplate,
|
|
71
|
+
headerAlign: col.headerAlign,
|
|
72
|
+
className: col.className,
|
|
73
|
+
labelClassName: col.labelClassName,
|
|
74
|
+
selectable: col.selectable,
|
|
75
|
+
reserveSelection: col.reserveSelection,
|
|
76
|
+
filters: col.filters,
|
|
77
|
+
filterMultiple: col.filterMultiple,
|
|
78
|
+
filterMethod: col.filterMethod,
|
|
79
|
+
filteredValue: col.filteredValue,
|
|
80
|
+
},
|
|
81
|
+
bind,
|
|
82
|
+
);
|
|
83
|
+
|
|
48
84
|
delete columnProps.children;
|
|
49
85
|
|
|
86
|
+
// 处理自定义 slot
|
|
50
87
|
if (col.slot && slots[col.slot]) {
|
|
51
88
|
return h("el-table-column", {
|
|
52
89
|
props: columnProps,
|
|
53
90
|
scopedSlots: {
|
|
54
|
-
default: (scope) =>
|
|
91
|
+
default: (scope) => {
|
|
92
|
+
const slotFn = slots[col.slot];
|
|
93
|
+
return slotFn(scope);
|
|
94
|
+
},
|
|
55
95
|
},
|
|
56
96
|
});
|
|
57
97
|
}
|
|
58
98
|
|
|
99
|
+
// 处理普通文本渲染
|
|
59
100
|
return h("el-table-column", {
|
|
60
101
|
props: columnProps,
|
|
61
102
|
scopedSlots: {
|
|
@@ -70,4 +111,4 @@ export default {
|
|
|
70
111
|
});
|
|
71
112
|
},
|
|
72
113
|
};
|
|
73
|
-
</script>
|
|
114
|
+
</script>
|