szld-libs 0.4.54 → 0.4.56
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/szld-components.es.js +10 -5
- package/dist/szld-components.umd.js +1 -1
- package/es/hooks/useUniversalTable.d.ts +3 -1
- package/es/hooks/useUniversalTable.js +6 -2
- package/es/mock/index.js +56 -567
- package/es/utils/method.js +3 -2
- package/lib/hooks/useUniversalTable.d.ts +3 -1
- package/lib/hooks/useUniversalTable.js +6 -2
- package/lib/mock/index.js +56 -567
- package/lib/utils/method.js +3 -2
- package/package.json +1 -1
package/es/utils/method.js
CHANGED
|
@@ -5,7 +5,8 @@ function getJson(jsonStr) {
|
|
|
5
5
|
try {
|
|
6
6
|
return JSON.parse(jsonStr);
|
|
7
7
|
} catch (error) {
|
|
8
|
-
|
|
8
|
+
const fixedData = jsonStr.replace(/\\_/g, "_");
|
|
9
|
+
return fixedData ? JSON.parse(fixedData) : {};
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
function base64ToString(base64Str) {
|
|
@@ -225,7 +226,7 @@ const processItem = (item, extraAttrs, notDisplay) => {
|
|
|
225
226
|
if (!item.json && item.info) {
|
|
226
227
|
try {
|
|
227
228
|
const infoStr = item.info_base64 === 1 ? base64ToString(item.info) : item.info;
|
|
228
|
-
const json = getJson(infoStr);
|
|
229
|
+
const json = typeof infoStr === "string" ? getJson(infoStr) : infoStr;
|
|
229
230
|
const _extraAttrs = _.cloneDeep(extraAttrs) || {};
|
|
230
231
|
const { langConfig = [], attrLangConfig = [] } = _extraAttrs || {};
|
|
231
232
|
_extraAttrs == null ? true : delete _extraAttrs.langConfig;
|
|
@@ -3,7 +3,9 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
declare function useUniversalTable(): {
|
|
4
4
|
handleUniversalHeaderToColumns: ({ universalHeader, extraBtn, operationColumnConfig, attributeSetId, getTitle, downloadText, isDefaultWidth, otherLangPageId, objDefaultLangPageId, }: {
|
|
5
5
|
universalHeader: any[];
|
|
6
|
-
extraBtn?:
|
|
6
|
+
extraBtn?: {
|
|
7
|
+
[key: string]: (record: any, content: string, item: any) => ReactNode;
|
|
8
|
+
} | ((record: any, content: string, item: any) => ReactNode) | undefined;
|
|
7
9
|
operationColumnConfig?: any;
|
|
8
10
|
attributeSetId?: string | undefined;
|
|
9
11
|
getTitle?: ((pageID: string, dataID: string) => string) | undefined;
|
|
@@ -276,6 +276,7 @@ function useUniversalTable() {
|
|
|
276
276
|
const showBtn = item == null ? void 0 : item["show-btn"];
|
|
277
277
|
if (mulAttrConfig && mulAttrConfig.list && Array.isArray(mulAttrConfig.list)) {
|
|
278
278
|
column.render = (_, record) => {
|
|
279
|
+
var _a;
|
|
279
280
|
const { list: list2, delimiter = "," } = mulAttrConfig;
|
|
280
281
|
const values = list2.map((attrId) => {
|
|
281
282
|
if (!attrId)
|
|
@@ -286,17 +287,20 @@ function useUniversalTable() {
|
|
|
286
287
|
if (showBtn && extraBtn) {
|
|
287
288
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
288
289
|
content ?? "-",
|
|
289
|
-
extraBtn
|
|
290
|
+
typeof extraBtn === "function" ? extraBtn(record, content, item) : null,
|
|
291
|
+
typeof extraBtn === "object" ? (_a = extraBtn == null ? void 0 : extraBtn[item == null ? void 0 : item["header-attribute-id"]]) == null ? void 0 : _a.call(extraBtn, record, content, item) : null
|
|
290
292
|
] });
|
|
291
293
|
}
|
|
292
294
|
return content || "-";
|
|
293
295
|
};
|
|
294
296
|
} else if (showBtn && extraBtn) {
|
|
295
297
|
column.render = (_, record) => {
|
|
298
|
+
var _a;
|
|
296
299
|
const content = record[column.dataIndex] || "";
|
|
297
300
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
298
301
|
content || "-",
|
|
299
|
-
extraBtn(record, content, item)
|
|
302
|
+
typeof extraBtn === "function" ? extraBtn(record, content, item) : null,
|
|
303
|
+
typeof extraBtn === "object" ? (_a = extraBtn == null ? void 0 : extraBtn[item == null ? void 0 : item["header-attribute-id"]]) == null ? void 0 : _a.call(extraBtn, record, content, item) : null
|
|
300
304
|
] });
|
|
301
305
|
};
|
|
302
306
|
}
|