bl-common-vue3 3.8.118 → 3.8.119
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
package/src/common/utils/util.js
CHANGED
|
@@ -18,6 +18,7 @@ const utils = {
|
|
|
18
18
|
basicConfigI18n: {}, // config 接口返回的i18n 配置信息
|
|
19
19
|
dictData: {}, // 字典
|
|
20
20
|
dictMenuData: {}, // 菜单字典
|
|
21
|
+
preferences: {}, // 用户使用偏好
|
|
21
22
|
/**
|
|
22
23
|
* 表单验证为数字
|
|
23
24
|
*/
|
|
@@ -91,6 +92,12 @@ const utils = {
|
|
|
91
92
|
}else {
|
|
92
93
|
localData[key] = value;
|
|
93
94
|
}
|
|
95
|
+
if (key == 'preferences') {
|
|
96
|
+
utils.preferences = localData[key];
|
|
97
|
+
let setBLPreferences = new Event('setBLPreferences');
|
|
98
|
+
setBLPreferences.newValue = utils.preferences;
|
|
99
|
+
window.dispatchEvent(setBLPreferences);
|
|
100
|
+
}
|
|
94
101
|
localStorage.setItem(utils.blCommonKey, JSON.stringify(localData));
|
|
95
102
|
if (key && key.includes('locale_')) {
|
|
96
103
|
// 修改的语言
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div ref="tableWarpRef" class="table-warp">
|
|
2
|
+
<div ref="tableWarpRef" class="table-warp" :class="{'antd-pagination-no-mb': useUserPreferences}">
|
|
3
3
|
<template v-if="displayTitleCollapsed && filterList?.length">
|
|
4
4
|
<div
|
|
5
5
|
ref="titleHeaderRef"
|
|
@@ -659,6 +659,7 @@
|
|
|
659
659
|
? { x: 'max-content', y: tableScrollHeight }
|
|
660
660
|
: { x: 'max-content' },
|
|
661
661
|
...$attrs,
|
|
662
|
+
sticky: resolvedSticky,
|
|
662
663
|
}"
|
|
663
664
|
:dataSource="newDataSource"
|
|
664
665
|
:size="$attrs?.size || isInDrawer ? 'small' : tableConfig?.size"
|
|
@@ -1615,14 +1616,14 @@ export default defineComponent({
|
|
|
1615
1616
|
};
|
|
1616
1617
|
},
|
|
1617
1618
|
},
|
|
1618
|
-
|
|
1619
|
-
type: Number,
|
|
1620
|
-
default: 0,
|
|
1621
|
-
},
|
|
1622
|
-
autoTableHeight: {
|
|
1619
|
+
useUserPreferences: {
|
|
1623
1620
|
type: Boolean,
|
|
1624
1621
|
default: false,
|
|
1625
1622
|
},
|
|
1623
|
+
autoTableHeightBottomOffset: {
|
|
1624
|
+
type: Number,
|
|
1625
|
+
default: 11,
|
|
1626
|
+
},
|
|
1626
1627
|
maximized: {
|
|
1627
1628
|
type: Boolean,
|
|
1628
1629
|
default: false,
|
|
@@ -1928,9 +1929,25 @@ export default defineComponent({
|
|
|
1928
1929
|
const autoTableHeightRaf = ref(0);
|
|
1929
1930
|
const tableHeightTimer = ref(0);
|
|
1930
1931
|
const autoTableHeightObserver = ref(null);
|
|
1931
|
-
const autoTableHeightBottomOffset = 11;
|
|
1932
1932
|
const autoTableHeightMinBody = 80;
|
|
1933
1933
|
const showTableMaximizedButton = computed(() => props.showMaximizeButton);
|
|
1934
|
+
const getUserTableHeightMode = () => {
|
|
1935
|
+
return (
|
|
1936
|
+
utils.preferences?.table?.heightMode ||
|
|
1937
|
+
utils.getCommonLocal("preferences")?.table?.heightMode ||
|
|
1938
|
+
""
|
|
1939
|
+
);
|
|
1940
|
+
};
|
|
1941
|
+
const userTableHeightMode = ref(getUserTableHeightMode());
|
|
1942
|
+
const shouldUseAutoTableHeight = computed(() => {
|
|
1943
|
+
return props.useUserPreferences && userTableHeightMode.value === "fixed";
|
|
1944
|
+
});
|
|
1945
|
+
const resolvedSticky = computed(() => {
|
|
1946
|
+
if (props.useUserPreferences && userTableHeightMode.value !== "fixed") {
|
|
1947
|
+
return true;
|
|
1948
|
+
}
|
|
1949
|
+
return attrs.sticky;
|
|
1950
|
+
});
|
|
1934
1951
|
const tableMaximizedText = computed(() =>
|
|
1935
1952
|
isTableMaximized.value
|
|
1936
1953
|
? t("CustomTable.index.074786-34")
|
|
@@ -1948,6 +1965,17 @@ export default defineComponent({
|
|
|
1948
1965
|
scheduleTableHeightRecalc();
|
|
1949
1966
|
});
|
|
1950
1967
|
};
|
|
1968
|
+
const handleLangChange = (event) => {
|
|
1969
|
+
const newLang = event.newValue;
|
|
1970
|
+
loadLanguageAsync(newLang);
|
|
1971
|
+
};
|
|
1972
|
+
const handlePreferencesChange = () => {
|
|
1973
|
+
userTableHeightMode.value = getUserTableHeightMode();
|
|
1974
|
+
nextTick(() => {
|
|
1975
|
+
setupAutoTableHeightObserver();
|
|
1976
|
+
scheduleTableHeightRecalc();
|
|
1977
|
+
});
|
|
1978
|
+
};
|
|
1951
1979
|
|
|
1952
1980
|
const isVisibleFlowElement = (el) => {
|
|
1953
1981
|
if (!el || el.nodeType !== 1) {
|
|
@@ -2004,7 +2032,7 @@ export default defineComponent({
|
|
|
2004
2032
|
};
|
|
2005
2033
|
|
|
2006
2034
|
const isAutoTableHeightSafe = () => {
|
|
2007
|
-
if (!
|
|
2035
|
+
if (!shouldUseAutoTableHeight.value) {
|
|
2008
2036
|
return false;
|
|
2009
2037
|
}
|
|
2010
2038
|
const rootEl = tableWarpRef.value;
|
|
@@ -2080,13 +2108,17 @@ export default defineComponent({
|
|
|
2080
2108
|
};
|
|
2081
2109
|
|
|
2082
2110
|
const getTablePaginationHeight = () => {
|
|
2083
|
-
|
|
2084
|
-
tableRef.value?.$el.getElementsByClassName("ant-pagination")[0]
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
pagHeight += 32;
|
|
2111
|
+
const paginationEl =
|
|
2112
|
+
tableRef.value?.$el.getElementsByClassName("ant-pagination")[0];
|
|
2113
|
+
if (!paginationEl) {
|
|
2114
|
+
return 0;
|
|
2088
2115
|
}
|
|
2089
|
-
|
|
2116
|
+
const style = window.getComputedStyle(paginationEl);
|
|
2117
|
+
return (
|
|
2118
|
+
paginationEl.offsetHeight +
|
|
2119
|
+
parseFloat(style.marginTop || 0) +
|
|
2120
|
+
parseFloat(style.marginBottom || 0)
|
|
2121
|
+
);
|
|
2090
2122
|
};
|
|
2091
2123
|
|
|
2092
2124
|
const getFilterHeight = () => {
|
|
@@ -3036,34 +3068,7 @@ export default defineComponent({
|
|
|
3036
3068
|
if (!tableEl) {
|
|
3037
3069
|
return;
|
|
3038
3070
|
}
|
|
3039
|
-
if (
|
|
3040
|
-
let tTitleHeight = getTableTitleHeight();
|
|
3041
|
-
let tHeaderHeight = getTableHeaderHeight();
|
|
3042
|
-
let tPagHeight = getTablePaginationHeight();
|
|
3043
|
-
let filterHeight = getFilterHeight();
|
|
3044
|
-
if (utils.isEnv()) {
|
|
3045
|
-
console.log(
|
|
3046
|
-
props.tableHeight,
|
|
3047
|
-
tTitleHeight,
|
|
3048
|
-
tHeaderHeight,
|
|
3049
|
-
tPagHeight,
|
|
3050
|
-
tableEl.getElementsByClassName("ant-table-thead")[0],
|
|
3051
|
-
"0000000000000000000"
|
|
3052
|
-
);
|
|
3053
|
-
}
|
|
3054
|
-
let tableScrollHeight =
|
|
3055
|
-
props.tableHeight -
|
|
3056
|
-
tTitleHeight -
|
|
3057
|
-
tHeaderHeight -
|
|
3058
|
-
tPagHeight -
|
|
3059
|
-
filterHeight;
|
|
3060
|
-
tableScrollHeight = Math.max(0, Math.floor(tableScrollHeight));
|
|
3061
|
-
if (state.tableScrollHeight !== tableScrollHeight) {
|
|
3062
|
-
state.tableScrollHeight = tableScrollHeight;
|
|
3063
|
-
}
|
|
3064
|
-
return;
|
|
3065
|
-
}
|
|
3066
|
-
if (props.autoTableHeight && isAutoTableHeightSafe()) {
|
|
3071
|
+
if (shouldUseAutoTableHeight.value && isAutoTableHeightSafe()) {
|
|
3067
3072
|
const tableTop = tableEl.getBoundingClientRect()?.top || 0;
|
|
3068
3073
|
const boundaryBottom = getAutoTableHeightBoundaryBottom(tableEl);
|
|
3069
3074
|
let tableScrollHeight =
|
|
@@ -3072,7 +3077,7 @@ export default defineComponent({
|
|
|
3072
3077
|
getTableTitleHeight() -
|
|
3073
3078
|
getTableHeaderHeight() -
|
|
3074
3079
|
getTablePaginationHeight() -
|
|
3075
|
-
autoTableHeightBottomOffset;
|
|
3080
|
+
props.autoTableHeightBottomOffset;
|
|
3076
3081
|
tableScrollHeight = Math.max(
|
|
3077
3082
|
autoTableHeightMinBody,
|
|
3078
3083
|
Math.ceil(tableScrollHeight)
|
|
@@ -4044,22 +4049,6 @@ export default defineComponent({
|
|
|
4044
4049
|
return utils.i18nMapShow;
|
|
4045
4050
|
});
|
|
4046
4051
|
|
|
4047
|
-
watch(
|
|
4048
|
-
() => props.tableHeight,
|
|
4049
|
-
() => {
|
|
4050
|
-
setupAutoTableHeightObserver();
|
|
4051
|
-
getTableHeight();
|
|
4052
|
-
}
|
|
4053
|
-
);
|
|
4054
|
-
|
|
4055
|
-
watch(
|
|
4056
|
-
() => props.autoTableHeight,
|
|
4057
|
-
() => {
|
|
4058
|
-
setupAutoTableHeightObserver();
|
|
4059
|
-
scheduleTableHeightRecalc();
|
|
4060
|
-
}
|
|
4061
|
-
);
|
|
4062
|
-
|
|
4063
4052
|
watch(
|
|
4064
4053
|
() => [state.filterList.length, isTitleCollapsed.value],
|
|
4065
4054
|
() => {
|
|
@@ -4074,6 +4063,8 @@ export default defineComponent({
|
|
|
4074
4063
|
createColumnSlots();
|
|
4075
4064
|
createButtonIconSlots();
|
|
4076
4065
|
window.addEventListener("resize", handleResize);
|
|
4066
|
+
window.addEventListener("setBLLang", handleLangChange);
|
|
4067
|
+
window.addEventListener("setBLPreferences", handlePreferencesChange);
|
|
4077
4068
|
handleResize();
|
|
4078
4069
|
setupAutoTableHeightObserver();
|
|
4079
4070
|
scheduleTableHeightRecalc();
|
|
@@ -4082,6 +4073,8 @@ export default defineComponent({
|
|
|
4082
4073
|
|
|
4083
4074
|
onBeforeUnmount(() => {
|
|
4084
4075
|
window.removeEventListener("resize", handleResize);
|
|
4076
|
+
window.removeEventListener("setBLLang", handleLangChange);
|
|
4077
|
+
window.removeEventListener("setBLPreferences", handlePreferencesChange);
|
|
4085
4078
|
clearAutoTableHeightObserver();
|
|
4086
4079
|
if (autoTableHeightRaf.value) {
|
|
4087
4080
|
cancelAnimationFrame(autoTableHeightRaf.value);
|
|
@@ -4147,11 +4140,6 @@ export default defineComponent({
|
|
|
4147
4140
|
};*/
|
|
4148
4141
|
loadLanguageAsync(utils.getLang());
|
|
4149
4142
|
|
|
4150
|
-
window.addEventListener("setBLLang", (event) => {
|
|
4151
|
-
const newLang = event.newValue; // 获取新的语言值
|
|
4152
|
-
loadLanguageAsync(newLang);
|
|
4153
|
-
});
|
|
4154
|
-
|
|
4155
4143
|
const checkOverflow = (e) => {
|
|
4156
4144
|
const ev = window.event || e;
|
|
4157
4145
|
const textContent = ev.target;
|
|
@@ -4440,6 +4428,7 @@ export default defineComponent({
|
|
|
4440
4428
|
shouldShowSecurityHeaderBtn,
|
|
4441
4429
|
formatFilterTagValueShow,
|
|
4442
4430
|
isFormatFilterTagValueShow,
|
|
4431
|
+
resolvedSticky,
|
|
4443
4432
|
};
|
|
4444
4433
|
},
|
|
4445
4434
|
});
|
|
@@ -4538,4 +4527,12 @@ export default defineComponent({
|
|
|
4538
4527
|
text-align: right;
|
|
4539
4528
|
}
|
|
4540
4529
|
}
|
|
4530
|
+
|
|
4531
|
+
.table-warp {
|
|
4532
|
+
&.antd-pagination-no-mb {
|
|
4533
|
+
:deep(.ant-table-pagination.ant-pagination) {
|
|
4534
|
+
margin-bottom: 0 !important;
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
}
|
|
4541
4538
|
</style>
|