szld-libs 0.2.96 → 0.2.98
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 +67 -59
- package/dist/szld-components.umd.js +3 -3
- package/es/components/DynamicForm/func.js +10 -8
- package/es/components/DynamicForm/useDynamicForm.d.ts +1 -1
- package/es/hooks/useRenderAttrSetDetail.d.ts +24 -0
- package/es/hooks/useRenderAttrSetDetail.js +186 -0
- package/es/index.js +32 -263
- package/es/mock/index.d.ts +306 -0
- package/es/mock/index.js +387 -0
- package/es/mock/vite.svg +1 -0
- package/es/services/index.d.ts +6 -0
- package/es/services/index.js +85 -0
- package/es/services/request.d.ts +6 -0
- package/es/services/request.js +140 -0
- package/es/services/status.d.ts +1 -0
- package/es/services/status.js +44 -0
- package/es/services/vite.svg +1 -0
- package/es/utils/enum.d.ts +4 -0
- package/es/utils/enum.js +10 -0
- package/es/utils/method.js +14 -10
- package/es/utils/szxkFunc.d.ts +8 -0
- package/es/utils/szxkFunc.js +7 -1
- package/es/vite-env.d.ts +11 -0
- package/lib/components/DynamicForm/func.js +10 -8
- package/lib/components/DynamicForm/useDynamicForm.d.ts +1 -1
- package/lib/hooks/useRenderAttrSetDetail.d.ts +24 -0
- package/lib/hooks/useRenderAttrSetDetail.js +185 -0
- package/lib/index.js +29 -260
- package/lib/mock/index.d.ts +306 -0
- package/lib/mock/index.js +387 -0
- package/lib/mock/vite.svg +1 -0
- package/lib/services/index.d.ts +6 -0
- package/lib/services/index.js +85 -0
- package/lib/services/request.d.ts +6 -0
- package/lib/services/request.js +140 -0
- package/lib/services/status.d.ts +1 -0
- package/lib/services/status.js +44 -0
- package/lib/services/vite.svg +1 -0
- package/lib/utils/enum.d.ts +4 -0
- package/lib/utils/enum.js +10 -0
- package/lib/utils/method.js +14 -10
- package/lib/utils/szxkFunc.d.ts +8 -0
- package/lib/utils/szxkFunc.js +6 -0
- package/lib/vite-env.d.ts +11 -0
- package/package.json +3 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import queryString from "query-string";
|
|
2
|
+
import request, { domainSetting } from "./request";
|
|
3
|
+
import { TOKEN, encryptParamStrings } from "../utils/enum";
|
|
4
|
+
import { HmacSHA512 } from "szld-libs";
|
|
5
|
+
const commonRequest = async (InterfaceType, data) => {
|
|
6
|
+
return request.post("", data, {
|
|
7
|
+
params: {
|
|
8
|
+
PageName: "dns_relay",
|
|
9
|
+
Controlname: "Connon_Control",
|
|
10
|
+
InterfaceType
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const commonRequestDic = async (data) => {
|
|
15
|
+
return request.post("", data, {
|
|
16
|
+
params: {
|
|
17
|
+
PageName: "DicInterface",
|
|
18
|
+
Controlname: "SelectDic"
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const commonRequestWidthParams = async (params, data) => {
|
|
23
|
+
return request.post("", data, {
|
|
24
|
+
params
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const commonRequestActionUrl = async (data) => {
|
|
28
|
+
return request.post("", data, {
|
|
29
|
+
params: {
|
|
30
|
+
PageName: "dns_relay",
|
|
31
|
+
Controlname: "CallActionUrl",
|
|
32
|
+
InterfaceType: "DPGLSysemName"
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const uploadAction = () => {
|
|
37
|
+
var _a;
|
|
38
|
+
const SessionID = sessionStorage.getItem(TOKEN);
|
|
39
|
+
const params = {
|
|
40
|
+
...domainSetting.baseParams,
|
|
41
|
+
PageName: "dns_relay",
|
|
42
|
+
return: true,
|
|
43
|
+
Controlname: "UpSingleFile",
|
|
44
|
+
InterfaceType: "",
|
|
45
|
+
udmfile: "file",
|
|
46
|
+
SessionID
|
|
47
|
+
};
|
|
48
|
+
const obj = {};
|
|
49
|
+
encryptParamStrings.forEach((key) => {
|
|
50
|
+
obj[key] = params[key] || "";
|
|
51
|
+
});
|
|
52
|
+
const encryptParams = queryString.stringify(obj, { sort: false });
|
|
53
|
+
const sha = new HmacSHA512((_a = window == null ? void 0 : window.CONFIG) == null ? void 0 : _a.Salt);
|
|
54
|
+
params["TokenId"] = sha.encrypt(encryptParams);
|
|
55
|
+
return domainSetting.baseUrl + "?" + queryString.stringify(params);
|
|
56
|
+
};
|
|
57
|
+
const uploadFormAction = () => {
|
|
58
|
+
var _a;
|
|
59
|
+
const SessionID = sessionStorage.getItem(TOKEN);
|
|
60
|
+
const params = {
|
|
61
|
+
...domainSetting.baseParams,
|
|
62
|
+
PageName: "initializationfile",
|
|
63
|
+
return: true,
|
|
64
|
+
Controlname: "UpSingleFile",
|
|
65
|
+
InterfaceType: "",
|
|
66
|
+
udmfile: "file",
|
|
67
|
+
SessionID
|
|
68
|
+
};
|
|
69
|
+
const obj = {};
|
|
70
|
+
encryptParamStrings.forEach((key) => {
|
|
71
|
+
obj[key] = params[key] || "";
|
|
72
|
+
});
|
|
73
|
+
const encryptParams = queryString.stringify(obj, { sort: false });
|
|
74
|
+
const sha = new HmacSHA512((_a = window == null ? void 0 : window.CONFIG) == null ? void 0 : _a.Salt);
|
|
75
|
+
params["TokenId"] = sha.encrypt(encryptParams);
|
|
76
|
+
return domainSetting.baseUrl + "?" + queryString.stringify(params);
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
commonRequest,
|
|
80
|
+
commonRequestActionUrl,
|
|
81
|
+
commonRequestDic,
|
|
82
|
+
commonRequestWidthParams,
|
|
83
|
+
uploadAction,
|
|
84
|
+
uploadFormAction
|
|
85
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var _a, _b;
|
|
2
|
+
import { OEID, TOKEN, encryptParamStrings, USERINFO } from "../utils/enum";
|
|
3
|
+
import { message } from "antd";
|
|
4
|
+
import axios from "axios";
|
|
5
|
+
import _ from "lodash";
|
|
6
|
+
import queryString from "query-string";
|
|
7
|
+
import { HmacSHA512, utils } from "szld-libs";
|
|
8
|
+
import { showStatus } from "./status";
|
|
9
|
+
const { removeSessionStorage, getSessionStorage } = utils;
|
|
10
|
+
const env = {}.VITE_BUILD_ENV;
|
|
11
|
+
const domainSetting = {
|
|
12
|
+
baseUrl: "",
|
|
13
|
+
baseParams: {}
|
|
14
|
+
};
|
|
15
|
+
if (env === "test" || env === "dev") {
|
|
16
|
+
domainSetting.baseUrl = "/ucc";
|
|
17
|
+
domainSetting.baseParams = {
|
|
18
|
+
AppID: "KF_SZLD_YLFWLR",
|
|
19
|
+
Password: "KF_SZLD_YLFWLR2557013"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (env === "dev") {
|
|
23
|
+
domainSetting.baseUrl = "/api";
|
|
24
|
+
}
|
|
25
|
+
if (env === "production") {
|
|
26
|
+
domainSetting.baseUrl = "/ucc";
|
|
27
|
+
domainSetting.baseParams = {
|
|
28
|
+
AppID: (_a = window == null ? void 0 : window.CONFIG) == null ? void 0 : _a.AppID,
|
|
29
|
+
Password: (_b = window == null ? void 0 : window.CONFIG) == null ? void 0 : _b.Password
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const request = axios.create({
|
|
33
|
+
baseURL: domainSetting.baseUrl,
|
|
34
|
+
headers: { "Content-Type": "application/json;charset=utf-8" },
|
|
35
|
+
withCredentials: true,
|
|
36
|
+
timeout: 3e5,
|
|
37
|
+
params: {
|
|
38
|
+
return: true,
|
|
39
|
+
...domainSetting.baseParams
|
|
40
|
+
},
|
|
41
|
+
transformRequest: [
|
|
42
|
+
(data) => {
|
|
43
|
+
data = JSON.stringify(data);
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
request.interceptors.request.use(
|
|
49
|
+
function(config) {
|
|
50
|
+
var _a2;
|
|
51
|
+
const oeid = sessionStorage.getItem(OEID);
|
|
52
|
+
if (oeid) {
|
|
53
|
+
config.data = {
|
|
54
|
+
...(config == null ? void 0 : config.data) || {},
|
|
55
|
+
oeid
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const token = sessionStorage.getItem(TOKEN);
|
|
59
|
+
if (token) {
|
|
60
|
+
const types = ["GetVCode", "FirstLoginUpdateMM", "DPGLSystemName"];
|
|
61
|
+
const names = ["Login"];
|
|
62
|
+
if (!names.includes(config.params["Controlname"]) && !types.includes(config.params["InterfaceType"])) {
|
|
63
|
+
config.params["SessionID"] = token;
|
|
64
|
+
config.params["InterfaceType"] = config.params["InterfaceType"] || "";
|
|
65
|
+
const obj = {};
|
|
66
|
+
encryptParamStrings.forEach((key) => {
|
|
67
|
+
obj[key] = config.params[key] || "";
|
|
68
|
+
});
|
|
69
|
+
const encryptParams = queryString.stringify(obj, { sort: false });
|
|
70
|
+
const sha = new HmacSHA512((_a2 = window == null ? void 0 : window.CONFIG) == null ? void 0 : _a2.Salt);
|
|
71
|
+
config.params["TokenId"] = sha.encrypt(encryptParams);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return config;
|
|
75
|
+
},
|
|
76
|
+
function(error) {
|
|
77
|
+
return Promise.reject(error);
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
request.interceptors.response.use(
|
|
81
|
+
function(response) {
|
|
82
|
+
var _a2;
|
|
83
|
+
const status = response.status;
|
|
84
|
+
if (status < 200 || status >= 300) {
|
|
85
|
+
const msg = showStatus(status);
|
|
86
|
+
if (typeof response.data === "string") {
|
|
87
|
+
response.data = { msg };
|
|
88
|
+
} else {
|
|
89
|
+
response.data = {
|
|
90
|
+
data: response.data,
|
|
91
|
+
msg
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
msgError(response.data.msg);
|
|
95
|
+
Promise.reject(response);
|
|
96
|
+
return {
|
|
97
|
+
ReturnValue: 0,
|
|
98
|
+
...response.data
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (typeof response.data === "string" && response.data.includes("Invalid")) {
|
|
102
|
+
msgError("登录已失效,请重新登录");
|
|
103
|
+
removeSessionStorage(USERINFO);
|
|
104
|
+
removeSessionStorage(TOKEN);
|
|
105
|
+
Promise.reject(response);
|
|
106
|
+
return {
|
|
107
|
+
ReturnValue: 0,
|
|
108
|
+
msg: "登录已失效,请重新登录",
|
|
109
|
+
data: response.data
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const result = response.data;
|
|
113
|
+
const noHitControlList = [];
|
|
114
|
+
if (_.isNumber(result == null ? void 0 : result.ReturnValue) && result.ReturnValue !== 1) {
|
|
115
|
+
if (!noHitControlList.includes((_a2 = response.config) == null ? void 0 : _a2.params["Controlname"])) {
|
|
116
|
+
msgError(result.msg);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
},
|
|
121
|
+
function(error) {
|
|
122
|
+
msgError("请求出错");
|
|
123
|
+
Promise.reject(error);
|
|
124
|
+
return {
|
|
125
|
+
ReturnValue: 0,
|
|
126
|
+
msg: "请求出错",
|
|
127
|
+
data: error
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
const msgError = (content) => {
|
|
132
|
+
message.error({
|
|
133
|
+
content,
|
|
134
|
+
key: "globalError"
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
export {
|
|
138
|
+
request as default,
|
|
139
|
+
domainSetting
|
|
140
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const showStatus: (status: number) => string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const showStatus = (status) => {
|
|
2
|
+
let message = "";
|
|
3
|
+
switch (status) {
|
|
4
|
+
case 400:
|
|
5
|
+
message = "请求错误(400)";
|
|
6
|
+
break;
|
|
7
|
+
case 401:
|
|
8
|
+
message = "未授权,请重新登录(401)";
|
|
9
|
+
break;
|
|
10
|
+
case 403:
|
|
11
|
+
message = "拒绝访问(403)";
|
|
12
|
+
break;
|
|
13
|
+
case 404:
|
|
14
|
+
message = "请求出错(404)";
|
|
15
|
+
break;
|
|
16
|
+
case 408:
|
|
17
|
+
message = "请求超时(408)";
|
|
18
|
+
break;
|
|
19
|
+
case 500:
|
|
20
|
+
message = "服务器错误(500)";
|
|
21
|
+
break;
|
|
22
|
+
case 501:
|
|
23
|
+
message = "服务未实现(501)";
|
|
24
|
+
break;
|
|
25
|
+
case 502:
|
|
26
|
+
message = "网络错误(502)";
|
|
27
|
+
break;
|
|
28
|
+
case 503:
|
|
29
|
+
message = "服务不可用(503)";
|
|
30
|
+
break;
|
|
31
|
+
case 504:
|
|
32
|
+
message = "网络超时(504)";
|
|
33
|
+
break;
|
|
34
|
+
case 505:
|
|
35
|
+
message = "HTTP版本不受支持(505)";
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
message = `连接出错(${status})!`;
|
|
39
|
+
}
|
|
40
|
+
return `${message},请检查网络或联系管理员!`;
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
showStatus
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/es/utils/enum.js
ADDED
package/es/utils/method.js
CHANGED
|
@@ -176,16 +176,19 @@ const handleAttrList = (attrList, extraAttrs) => {
|
|
|
176
176
|
const combinationGroups = parsedAttrList.filter((item) => {
|
|
177
177
|
var _a;
|
|
178
178
|
return (_a = item.json) == null ? void 0 : _a.combination;
|
|
179
|
-
}).reduce(
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
}).reduce(
|
|
180
|
+
(groups, item) => {
|
|
181
|
+
const combinationId = item.json["combination-id"];
|
|
182
|
+
if (!combinationId)
|
|
183
|
+
return groups;
|
|
184
|
+
if (!groups[combinationId]) {
|
|
185
|
+
groups[combinationId] = [];
|
|
186
|
+
}
|
|
187
|
+
groups[combinationId].push(item);
|
|
182
188
|
return groups;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
groups[combinationId].push(item);
|
|
187
|
-
return groups;
|
|
188
|
-
}, {});
|
|
189
|
+
},
|
|
190
|
+
{}
|
|
191
|
+
);
|
|
189
192
|
const excludeAttrIds = /* @__PURE__ */ new Set();
|
|
190
193
|
Object.values(combinationGroups).forEach((group) => {
|
|
191
194
|
if ((group == null ? void 0 : group.length) === 0)
|
|
@@ -310,7 +313,8 @@ const handleAttrListToObj = (attrList) => {
|
|
|
310
313
|
data_list: [processLevel(item.children)]
|
|
311
314
|
};
|
|
312
315
|
} else if (item.attrtype === 1 && item.children.length > 0 && Array.isArray(item.children)) {
|
|
313
|
-
|
|
316
|
+
let { attrvalue = [], children = [] } = item || {};
|
|
317
|
+
attrvalue = Array.isArray(attrvalue) ? attrvalue : [attrvalue];
|
|
314
318
|
if (Array.isArray(attrvalue) && (attrvalue == null ? void 0 : attrvalue.length)) {
|
|
315
319
|
item.children = attrvalue.map((v) => {
|
|
316
320
|
return handleObjDetailToSignleAttrList((children == null ? void 0 : children[0]) || [], v);
|
package/es/utils/szxkFunc.d.ts
CHANGED
|
@@ -28,3 +28,11 @@ export declare const handleGetAttrDetail: (params: {
|
|
|
28
28
|
* @returns 处理后的属性集列表,每个属性项包含attrvalue
|
|
29
29
|
*/
|
|
30
30
|
export declare const handleObjDetailToSignleAttrList: (attrList: any[], detail: any) => any[];
|
|
31
|
+
/**
|
|
32
|
+
* 设置表格行的颜色
|
|
33
|
+
*/
|
|
34
|
+
export declare const handleSetTableRowColor: (record: any, index: number | undefined) => {
|
|
35
|
+
style: {
|
|
36
|
+
backgroundColor: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
package/es/utils/szxkFunc.js
CHANGED
|
@@ -26,8 +26,14 @@ const handleObjDetailToSignleAttrList = (attrList, detail) => {
|
|
|
26
26
|
attrvalue: detail[item.attrid] || ""
|
|
27
27
|
}));
|
|
28
28
|
};
|
|
29
|
+
const handleSetTableRowColor = (record, index) => ({
|
|
30
|
+
style: {
|
|
31
|
+
backgroundColor: index !== void 0 && index % 2 === 1 ? "var(--bg-color-2)" : "var(--bg-color-3)"
|
|
32
|
+
}
|
|
33
|
+
});
|
|
29
34
|
export {
|
|
30
35
|
handleGetAttrDetail,
|
|
31
36
|
handleGetAttrList,
|
|
32
|
-
handleObjDetailToSignleAttrList
|
|
37
|
+
handleObjDetailToSignleAttrList,
|
|
38
|
+
handleSetTableRowColor
|
|
33
39
|
};
|
package/es/vite-env.d.ts
CHANGED
|
@@ -12,3 +12,14 @@ interface ICustomModal {
|
|
|
12
12
|
footer?: React.ReactNode;
|
|
13
13
|
modalStyle?: React.CSSProperties;
|
|
14
14
|
}
|
|
15
|
+
interface IFileRes {
|
|
16
|
+
FileId: string;
|
|
17
|
+
FileName: string;
|
|
18
|
+
FileExt: string;
|
|
19
|
+
FilePath: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface Window {
|
|
23
|
+
CONFIG: any;
|
|
24
|
+
CONFIG_STR: string;
|
|
25
|
+
}
|
|
@@ -182,14 +182,16 @@ const handleGetSingleAttrListObj = (children) => {
|
|
|
182
182
|
}
|
|
183
183
|
const dealList = (children2) => children2 == null ? void 0 : children2.map((v) => {
|
|
184
184
|
const obj = {};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
185
|
+
if (Array.isArray(v)) {
|
|
186
|
+
v.forEach((x) => {
|
|
187
|
+
var _a;
|
|
188
|
+
if ((_a = x == null ? void 0 : x.children) == null ? void 0 : _a.length) {
|
|
189
|
+
obj[x.attrid] = dealList(x.children);
|
|
190
|
+
} else {
|
|
191
|
+
obj[x.attrid] = x.attrvalue;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
193
195
|
return obj;
|
|
194
196
|
});
|
|
195
197
|
return dealList(children);
|
|
@@ -27,7 +27,7 @@ declare function useDynamicForm(props: IDynamicFormProps): {
|
|
|
27
27
|
item: IformConfigItem;
|
|
28
28
|
readonly: boolean;
|
|
29
29
|
colNum: number;
|
|
30
|
-
instructionShowMode?: "
|
|
30
|
+
instructionShowMode?: "icon" | "flex" | undefined;
|
|
31
31
|
relatedid?: string | undefined;
|
|
32
32
|
form: FormInstance;
|
|
33
33
|
defaultWidth?: number | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 宠物详情渲染 Hook
|
|
3
|
+
* @param attrList 属性列表数据
|
|
4
|
+
* @param config 配置信息(用于文件预览地址)
|
|
5
|
+
* @returns 渲染函数
|
|
6
|
+
*/
|
|
7
|
+
interface IAttrSetDetailRendererProps {
|
|
8
|
+
labelSpan?: number;
|
|
9
|
+
valueSpan?: number;
|
|
10
|
+
imgWidth?: number;
|
|
11
|
+
imgHeight?: number;
|
|
12
|
+
layoutType?: 'row' | 'flex';
|
|
13
|
+
}
|
|
14
|
+
export default function useAttrSetDetailRenderer({ labelSpan, valueSpan, imgWidth, imgHeight, layoutType, }: IAttrSetDetailRendererProps): {
|
|
15
|
+
renderDetail: ({ attrList, span, type, servicesUniversalHeader, beforeExtraValue, operationColumn, }: {
|
|
16
|
+
attrList: any[];
|
|
17
|
+
span?: number | undefined;
|
|
18
|
+
type?: "form" | "table" | undefined;
|
|
19
|
+
servicesUniversalHeader?: any[] | undefined;
|
|
20
|
+
beforeExtraValue?: string | undefined;
|
|
21
|
+
operationColumn?: any;
|
|
22
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const antd = require("antd");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const ahooks = require("ahooks");
|
|
6
|
+
const szxkFunc = require("../utils/szxkFunc");
|
|
7
|
+
function useAttrSetDetailRenderer({
|
|
8
|
+
labelSpan = 3,
|
|
9
|
+
valueSpan = 9,
|
|
10
|
+
imgWidth = 93,
|
|
11
|
+
imgHeight = 93,
|
|
12
|
+
layoutType = "row"
|
|
13
|
+
}) {
|
|
14
|
+
const { message } = antd.App.useApp();
|
|
15
|
+
const renderRadioCardAttr = (item, span) => {
|
|
16
|
+
try {
|
|
17
|
+
const attrvalue = JSON.parse((item == null ? void 0 : item.attrvalue) || "{}") || "";
|
|
18
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
19
|
+
layoutType === "flex" && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
20
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
21
|
+
item == null ? void 0 : item.attrname,
|
|
22
|
+
":"
|
|
23
|
+
] }),
|
|
24
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { wordWrap: "break-word" }, children: attrvalue == null ? void 0 : attrvalue.typename })
|
|
25
|
+
] }) }),
|
|
26
|
+
layoutType === "row" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
27
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
28
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: item == null ? void 0 : item.attrvalue })
|
|
29
|
+
] })
|
|
30
|
+
] }, item == null ? void 0 : item.attrid);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
message.error("房型数据格式错误,转json失败");
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const renderImageAttr = (item, span) => {
|
|
37
|
+
if (typeof (item == null ? void 0 : item.attrvalue) !== "string")
|
|
38
|
+
return;
|
|
39
|
+
const attrvalues = JSON.parse((item == null ? void 0 : item.attrvalue) || "[]");
|
|
40
|
+
const valueNode = () => /* @__PURE__ */ jsxRuntime.jsx(antd.Space, { wrap: true, children: attrvalues.map((el, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
style: {
|
|
44
|
+
border: "1px solid rgba(0, 0, 0, 0.15)",
|
|
45
|
+
borderRadius: 4
|
|
46
|
+
},
|
|
47
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
48
|
+
antd.Image,
|
|
49
|
+
{
|
|
50
|
+
style: { objectFit: "cover", padding: 5 },
|
|
51
|
+
width: imgWidth,
|
|
52
|
+
height: imgHeight,
|
|
53
|
+
src: el == null ? void 0 : el.FilePath,
|
|
54
|
+
alt: (item == null ? void 0 : item.attrname) || "-"
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
},
|
|
58
|
+
index
|
|
59
|
+
)) });
|
|
60
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
61
|
+
layoutType === "flex" && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
62
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
63
|
+
item == null ? void 0 : item.attrname,
|
|
64
|
+
":"
|
|
65
|
+
] }),
|
|
66
|
+
valueNode()
|
|
67
|
+
] }) }),
|
|
68
|
+
layoutType === "row" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
69
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
70
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: valueNode() })
|
|
71
|
+
] })
|
|
72
|
+
] }, item == null ? void 0 : item.attrid);
|
|
73
|
+
};
|
|
74
|
+
const renderFileAttr = (item, span) => {
|
|
75
|
+
const attrvalues = JSON.parse((item == null ? void 0 : item.attrvalue) || "[]");
|
|
76
|
+
const valueNode = () => /* @__PURE__ */ jsxRuntime.jsx(antd.Space, { wrap: true, children: attrvalues.map((el, index) => /* @__PURE__ */ jsxRuntime.jsx("a", { onClick: () => window.open(el == null ? void 0 : el.FilePath), children: (el == null ? void 0 : el.FileName) || "-" }, index)) });
|
|
77
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
78
|
+
layoutType === "flex" && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
79
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
80
|
+
item == null ? void 0 : item.attrname,
|
|
81
|
+
":"
|
|
82
|
+
] }),
|
|
83
|
+
valueNode()
|
|
84
|
+
] }) }),
|
|
85
|
+
layoutType === "row" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
86
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
87
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: valueNode() })
|
|
88
|
+
] })
|
|
89
|
+
] }, item == null ? void 0 : item.attrid);
|
|
90
|
+
};
|
|
91
|
+
const renderTextAttr = (item, span, beforeExtraValue) => {
|
|
92
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
93
|
+
layoutType === "flex" && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
|
|
94
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { flexShrink: 0 }, children: [
|
|
95
|
+
item == null ? void 0 : item.attrname,
|
|
96
|
+
":"
|
|
97
|
+
] }),
|
|
98
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { wordWrap: "break-word" }, children: [
|
|
99
|
+
beforeExtraValue || "",
|
|
100
|
+
" ",
|
|
101
|
+
(item == null ? void 0 : item.attrvalue) || "-",
|
|
102
|
+
" "
|
|
103
|
+
] })
|
|
104
|
+
] }) }),
|
|
105
|
+
layoutType === "row" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
106
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: labelSpan, children: item == null ? void 0 : item.attrname }),
|
|
107
|
+
/* @__PURE__ */ jsxRuntime.jsxs(antd.Col, { span: valueSpan, style: { wordWrap: "break-word" }, children: [
|
|
108
|
+
beforeExtraValue || "",
|
|
109
|
+
(item == null ? void 0 : item.attrvalue) || "-"
|
|
110
|
+
] })
|
|
111
|
+
] })
|
|
112
|
+
] }, item == null ? void 0 : item.attrid);
|
|
113
|
+
};
|
|
114
|
+
const renderTableDetail = ({
|
|
115
|
+
attrList = [],
|
|
116
|
+
servicesUniversalHeader = [],
|
|
117
|
+
operationColumn
|
|
118
|
+
}) => {
|
|
119
|
+
const columns = servicesUniversalHeader == null ? void 0 : servicesUniversalHeader.map((item) => ({
|
|
120
|
+
title: item == null ? void 0 : item["header-name"],
|
|
121
|
+
dataIndex: item == null ? void 0 : item["header-attribute-id"],
|
|
122
|
+
key: item == null ? void 0 : item["header-attribute-id"],
|
|
123
|
+
width: item == null ? void 0 : item["header-width"]
|
|
124
|
+
}));
|
|
125
|
+
if (operationColumn) {
|
|
126
|
+
columns.push(operationColumn);
|
|
127
|
+
}
|
|
128
|
+
const dataSource = attrList == null ? void 0 : attrList.map((v, i) => ({
|
|
129
|
+
key: i,
|
|
130
|
+
...handleDealAttrList(v)
|
|
131
|
+
}));
|
|
132
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
+
antd.Table,
|
|
134
|
+
{
|
|
135
|
+
style: { width: "100%" },
|
|
136
|
+
columns,
|
|
137
|
+
scroll: { x: "max-content" },
|
|
138
|
+
size: "small",
|
|
139
|
+
rowKey: "key",
|
|
140
|
+
onRow: szxkFunc.handleSetTableRowColor,
|
|
141
|
+
dataSource,
|
|
142
|
+
pagination: false
|
|
143
|
+
}
|
|
144
|
+
) });
|
|
145
|
+
};
|
|
146
|
+
const handleDealAttrList = (attrList) => {
|
|
147
|
+
return attrList == null ? void 0 : attrList.reduce((pre, cur) => {
|
|
148
|
+
pre[cur == null ? void 0 : cur.attrid] = cur == null ? void 0 : cur.attrvalue;
|
|
149
|
+
return pre;
|
|
150
|
+
}, {});
|
|
151
|
+
};
|
|
152
|
+
const renderDetail = ahooks.useMemoizedFn(
|
|
153
|
+
({
|
|
154
|
+
attrList = [],
|
|
155
|
+
span = 24,
|
|
156
|
+
type = "form",
|
|
157
|
+
servicesUniversalHeader = [],
|
|
158
|
+
beforeExtraValue = "",
|
|
159
|
+
operationColumn
|
|
160
|
+
}) => {
|
|
161
|
+
if (!(attrList == null ? void 0 : attrList.length))
|
|
162
|
+
return null;
|
|
163
|
+
if (type === "table") {
|
|
164
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderTableDetail({ attrList, servicesUniversalHeader, operationColumn }) });
|
|
165
|
+
}
|
|
166
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { gutter: [10, 8], children: attrList == null ? void 0 : attrList.map((item) => {
|
|
167
|
+
if ((item == null ? void 0 : item.attrtype) !== 0)
|
|
168
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, {}, item == null ? void 0 : item.attrid);
|
|
169
|
+
const info = (item == null ? void 0 : item.json) || (item == null ? void 0 : item.info) && JSON.parse(item.info);
|
|
170
|
+
if ((info == null ? void 0 : info.input) === "image") {
|
|
171
|
+
return renderImageAttr(item, span);
|
|
172
|
+
}
|
|
173
|
+
if (["file", "audio", "video"].includes(info == null ? void 0 : info.input)) {
|
|
174
|
+
return renderFileAttr(item, span);
|
|
175
|
+
}
|
|
176
|
+
if ((info == null ? void 0 : info.input) === "radio-card") {
|
|
177
|
+
return renderRadioCardAttr(item, span);
|
|
178
|
+
}
|
|
179
|
+
return renderTextAttr(item, span, beforeExtraValue);
|
|
180
|
+
}) });
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
return { renderDetail };
|
|
184
|
+
}
|
|
185
|
+
module.exports = useAttrSetDetailRenderer;
|