@weitutech/by-components-v3 1.1.5 → 1.1.7
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/dist/by-component-v3.mjs
CHANGED
|
@@ -36802,14 +36802,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
36802
36802
|
const CustomColumn = /* @__PURE__ */ _export_sfc$1(_sfc_main, [["__scopeId", "data-v-0dadba78"]]);
|
|
36803
36803
|
const isCachedTableColumns = (name) => {
|
|
36804
36804
|
if (!name) return false;
|
|
36805
|
-
|
|
36806
|
-
if (!cachedData) return false;
|
|
36807
|
-
try {
|
|
36808
|
-
const parsedData = JSON.parse(cachedData);
|
|
36809
|
-
return Array.isArray(parsedData) && parsedData.length > 0;
|
|
36810
|
-
} catch (e) {
|
|
36811
|
-
return false;
|
|
36812
|
-
}
|
|
36805
|
+
return !!localStorage.getItem(name);
|
|
36813
36806
|
};
|
|
36814
36807
|
const removeCachedTableColumns = (name) => {
|
|
36815
36808
|
localStorage.removeItem(name);
|
|
@@ -36890,6 +36883,27 @@ const replaceColumnWidthToColumns = (name, columns) => {
|
|
|
36890
36883
|
};
|
|
36891
36884
|
return processColumnWidth(columns, cacheColumns);
|
|
36892
36885
|
};
|
|
36886
|
+
const rewriteWidthColumns = (fromColumns, toColumns) => {
|
|
36887
|
+
if (!fromColumns || !toColumns) return [];
|
|
36888
|
+
if (!fromColumns || fromColumns.length === 0) return toColumns;
|
|
36889
|
+
const result = [];
|
|
36890
|
+
for (const col of toColumns) {
|
|
36891
|
+
const fromCol = fromColumns.find((from2) => from2.field === col.field);
|
|
36892
|
+
if (col.children) {
|
|
36893
|
+
result.push({
|
|
36894
|
+
...col,
|
|
36895
|
+
...(fromCol == null ? void 0 : fromCol.width) && { width: fromCol.width },
|
|
36896
|
+
children: rewriteWidthColumns((fromCol == null ? void 0 : fromCol.children) || [], col.children)
|
|
36897
|
+
});
|
|
36898
|
+
} else {
|
|
36899
|
+
result.push({
|
|
36900
|
+
...col,
|
|
36901
|
+
...(fromCol == null ? void 0 : fromCol.width) && { width: fromCol.width }
|
|
36902
|
+
});
|
|
36903
|
+
}
|
|
36904
|
+
}
|
|
36905
|
+
return result;
|
|
36906
|
+
};
|
|
36893
36907
|
const events = ["keydown", "current-change", "radio-change", "checkbox-change", "checkbox-all", "checkbox-range-start", "checkbox-range-change", "checkbox-range-end", "cell-dblclick", "cell-menu", "cell-mouseenter", "cell-mouseleave", "cell-delete-value", "header-cell-click", "header-cell-dblclick", "header-cell-menu", "footer-cell-click", "footer-cell-dblclick", "footer-cell-menu", "clear-merge", "sort-change", "clear-sort", "filter-visible", "filter-change", "clear-filter", "toggle-row-expand", "toggle-tree-expand", "menu-click", "cell-selected", "edit-closed", "edit-activated", "edit-disabled", "valid-error", "scroll", "custom", "page-change", "form-submit", "form-submit-invalid", "form-reset", "form-collapse", "proxy-query", "proxy-delete", "proxy-save", "toolbar-button-click", "toolbar-tool-click", "zoom", "cell-click"];
|
|
36894
36908
|
const capitalizeFirstLetter = (str) => {
|
|
36895
36909
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
@@ -36964,6 +36978,13 @@ const ByTable = /* @__PURE__ */ defineComponent({
|
|
|
36964
36978
|
const showResetCache = ref(false);
|
|
36965
36979
|
const hasCache = ref(false);
|
|
36966
36980
|
const originColumns = ref([]);
|
|
36981
|
+
const tempColumns = ref([]);
|
|
36982
|
+
watch(() => props.gridOptions.columns, (newColumns) => {
|
|
36983
|
+
const result = rewriteWidthColumns(tempColumns.value, newColumns);
|
|
36984
|
+
originColumns.value = result;
|
|
36985
|
+
}, {
|
|
36986
|
+
deep: true
|
|
36987
|
+
});
|
|
36967
36988
|
onMounted(() => {
|
|
36968
36989
|
showResetCache.value = !!props.name;
|
|
36969
36990
|
originColumns.value = deepClone(props.gridOptions.columns);
|
|
@@ -37057,7 +37078,7 @@ const ByTable = /* @__PURE__ */ defineComponent({
|
|
|
37057
37078
|
}
|
|
37058
37079
|
}
|
|
37059
37080
|
}
|
|
37060
|
-
|
|
37081
|
+
tempColumns.value = deepClone(result);
|
|
37061
37082
|
const newColumns = replaceColumnWidthToColumns(props.name, result);
|
|
37062
37083
|
setHasCache();
|
|
37063
37084
|
emit("setColumns", newColumns);
|