gxxc-util 1.0.0 → 1.0.1
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/cjs/modules/other.js +29 -27
- package/dist/esm/modules/other.js +29 -27
- package/dist/types/tsdoc-metadata.json +1 -1
- package/dist/umd/index.js +5 -12
- package/package.json +1 -1
|
@@ -90,41 +90,43 @@ const tem_compare_version = (version1, version2) => {
|
|
|
90
90
|
* @param {TableHeaderItem} initial 默认
|
|
91
91
|
*/
|
|
92
92
|
const tem_get_tableHeader = (keyVal, cache, initial) => {
|
|
93
|
+
/// 原始 map
|
|
94
|
+
const _initialMap = {};
|
|
95
|
+
initial.map(item => {
|
|
96
|
+
_initialMap[item.key ?? ""] = { ...item };
|
|
97
|
+
});
|
|
98
|
+
/// 缓存 map
|
|
99
|
+
const _cacheMap = {};
|
|
100
|
+
cache.map(item => {
|
|
101
|
+
_cacheMap[item.key ?? ""] = { ...item };
|
|
102
|
+
});
|
|
93
103
|
const returnList = [];
|
|
94
|
-
|
|
104
|
+
/// 通过服务端返回 key 筛选选显示项
|
|
95
105
|
if (keyVal) {
|
|
96
106
|
Object.keys(keyVal)?.forEach((key) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
i = { ...i, ...j, ...k };
|
|
109
|
-
i.width = j?.width;
|
|
110
|
-
i.sort = k?.sort ? k?.sort : j.sort;
|
|
111
|
-
i.selected = k?.selected === undefined ? true : k?.selected;
|
|
112
|
-
returnList.push(i);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
107
|
+
let _item = _initialMap[key];
|
|
108
|
+
const _cacheItem = _cacheMap[key ?? ""];
|
|
109
|
+
const name = keyVal[key];
|
|
110
|
+
/// 有缓冲并且 服务端 返回表头
|
|
111
|
+
if (_item && _cacheItem) {
|
|
112
|
+
_cacheItem.name = name;
|
|
113
|
+
returnList.push(_cacheItem);
|
|
114
|
+
}
|
|
115
|
+
else if (_item) {
|
|
116
|
+
_item.name = name;
|
|
117
|
+
returnList.push(_item);
|
|
115
118
|
}
|
|
116
119
|
else {
|
|
117
|
-
|
|
118
|
-
i = { ...i, ...j };
|
|
119
|
-
i.selected = true;
|
|
120
|
-
returnList.push(i);
|
|
121
|
-
}
|
|
120
|
+
console.warn("列表服务端返回" + key + "未配置");
|
|
122
121
|
}
|
|
123
122
|
});
|
|
124
|
-
});
|
|
125
|
-
if (initial[initial.length - 1]?.key === "operate") {
|
|
126
|
-
returnList.push(initial[initial.length - 1]);
|
|
127
123
|
}
|
|
124
|
+
/// 添加 操作项
|
|
125
|
+
const operateItem = _initialMap["operate"];
|
|
126
|
+
if (operateItem) {
|
|
127
|
+
returnList.push(operateItem);
|
|
128
|
+
}
|
|
129
|
+
/// 排序
|
|
128
130
|
returnList.sort((a, b) => {
|
|
129
131
|
return (a?.sort ?? 1) - (b?.sort ?? 2);
|
|
130
132
|
});
|
|
@@ -69,41 +69,43 @@ const tem_compare_version = (version1, version2) => {
|
|
|
69
69
|
* @param {TableHeaderItem} initial 默认
|
|
70
70
|
*/
|
|
71
71
|
const tem_get_tableHeader = (keyVal, cache, initial) => {
|
|
72
|
+
/// 原始 map
|
|
73
|
+
const _initialMap = {};
|
|
74
|
+
initial.map(item => {
|
|
75
|
+
_initialMap[item.key ?? ""] = { ...item };
|
|
76
|
+
});
|
|
77
|
+
/// 缓存 map
|
|
78
|
+
const _cacheMap = {};
|
|
79
|
+
cache.map(item => {
|
|
80
|
+
_cacheMap[item.key ?? ""] = { ...item };
|
|
81
|
+
});
|
|
72
82
|
const returnList = [];
|
|
73
|
-
|
|
83
|
+
/// 通过服务端返回 key 筛选选显示项
|
|
74
84
|
if (keyVal) {
|
|
75
85
|
Object.keys(keyVal)?.forEach((key) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
i = { ...i, ...j, ...k };
|
|
88
|
-
i.width = j?.width;
|
|
89
|
-
i.sort = k?.sort ? k?.sort : j.sort;
|
|
90
|
-
i.selected = k?.selected === undefined ? true : k?.selected;
|
|
91
|
-
returnList.push(i);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
86
|
+
let _item = _initialMap[key];
|
|
87
|
+
const _cacheItem = _cacheMap[key ?? ""];
|
|
88
|
+
const name = keyVal[key];
|
|
89
|
+
/// 有缓冲并且 服务端 返回表头
|
|
90
|
+
if (_item && _cacheItem) {
|
|
91
|
+
_cacheItem.name = name;
|
|
92
|
+
returnList.push(_cacheItem);
|
|
93
|
+
}
|
|
94
|
+
else if (_item) {
|
|
95
|
+
_item.name = name;
|
|
96
|
+
returnList.push(_item);
|
|
94
97
|
}
|
|
95
98
|
else {
|
|
96
|
-
|
|
97
|
-
i = { ...i, ...j };
|
|
98
|
-
i.selected = true;
|
|
99
|
-
returnList.push(i);
|
|
100
|
-
}
|
|
99
|
+
console.warn("列表服务端返回" + key + "未配置");
|
|
101
100
|
}
|
|
102
101
|
});
|
|
103
|
-
});
|
|
104
|
-
if (initial[initial.length - 1]?.key === "operate") {
|
|
105
|
-
returnList.push(initial[initial.length - 1]);
|
|
106
102
|
}
|
|
103
|
+
/// 添加 操作项
|
|
104
|
+
const operateItem = _initialMap["operate"];
|
|
105
|
+
if (operateItem) {
|
|
106
|
+
returnList.push(operateItem);
|
|
107
|
+
}
|
|
108
|
+
/// 排序
|
|
107
109
|
returnList.sort((a, b) => {
|
|
108
110
|
return (a?.sort ?? 1) - (b?.sort ?? 2);
|
|
109
111
|
});
|