szld-libs 0.2.52 → 0.2.54
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/style.css +1 -1
- package/dist/szld-components.es.js +17007 -15272
- package/dist/szld-components.umd.js +55 -55
- package/es/components/DynamicForm/index.d.ts +102 -0
- package/es/components/DynamicForm/index.js +55 -0
- package/es/components/DynamicForm/myCascader/index.d.ts +13 -0
- package/es/components/DynamicForm/myCascader/index.js +186 -0
- package/es/components/DynamicForm/myCascader/vite.svg +1 -0
- package/es/components/DynamicForm/myCheckbox/index.d.ts +15 -0
- package/es/components/DynamicForm/myCheckbox/index.js +102 -0
- package/es/components/DynamicForm/myCheckbox/vite.svg +1 -0
- package/es/components/DynamicForm/myRadio/index.d.ts +16 -0
- package/es/components/DynamicForm/myRadio/index.js +100 -0
- package/es/components/DynamicForm/myRadio/vite.svg +1 -0
- package/es/components/DynamicForm/mySelect/index.d.ts +13 -0
- package/es/components/DynamicForm/mySelect/index.js +126 -0
- package/es/components/DynamicForm/mySelect/vite.svg +1 -0
- package/es/components/DynamicForm/myUpload/index.css +3 -0
- package/es/components/DynamicForm/myUpload/index.d.ts +15 -0
- package/es/components/DynamicForm/myUpload/index.js +102 -0
- package/es/components/DynamicForm/myUpload/vite.svg +1 -0
- package/es/components/DynamicForm/radioCard/index.d.ts +12 -0
- package/es/components/DynamicForm/radioCard/index.js +142 -0
- package/es/components/DynamicForm/radioCard/vite.svg +1 -0
- package/es/components/DynamicForm/selectModel/index.d.ts +21 -0
- package/es/components/DynamicForm/selectModel/index.js +197 -0
- package/es/components/DynamicForm/selectModel/vite.svg +1 -0
- package/es/components/DynamicForm/useDynamicForm.d.ts +26 -0
- package/es/components/DynamicForm/useDynamicForm.js +554 -0
- package/es/components/DynamicForm/vite.svg +1 -0
- package/es/main.d.ts +3 -1
- package/es/main.js +22 -18
- package/es/utils/method.d.ts +21 -0
- package/es/utils/method.js +186 -0
- package/lib/components/DynamicForm/index.d.ts +102 -0
- package/lib/components/DynamicForm/index.js +54 -0
- package/lib/components/DynamicForm/myCascader/index.d.ts +13 -0
- package/lib/components/DynamicForm/myCascader/index.js +185 -0
- package/lib/components/DynamicForm/myCascader/vite.svg +1 -0
- package/lib/components/DynamicForm/myCheckbox/index.d.ts +15 -0
- package/lib/components/DynamicForm/myCheckbox/index.js +101 -0
- package/lib/components/DynamicForm/myCheckbox/vite.svg +1 -0
- package/lib/components/DynamicForm/myRadio/index.d.ts +16 -0
- package/lib/components/DynamicForm/myRadio/index.js +99 -0
- package/lib/components/DynamicForm/myRadio/vite.svg +1 -0
- package/lib/components/DynamicForm/mySelect/index.d.ts +13 -0
- package/lib/components/DynamicForm/mySelect/index.js +125 -0
- package/lib/components/DynamicForm/mySelect/vite.svg +1 -0
- package/lib/components/DynamicForm/myUpload/index.css +3 -0
- package/lib/components/DynamicForm/myUpload/index.d.ts +15 -0
- package/lib/components/DynamicForm/myUpload/index.js +101 -0
- package/lib/components/DynamicForm/myUpload/vite.svg +1 -0
- package/lib/components/DynamicForm/radioCard/index.d.ts +12 -0
- package/lib/components/DynamicForm/radioCard/index.js +141 -0
- package/lib/components/DynamicForm/radioCard/vite.svg +1 -0
- package/lib/components/DynamicForm/selectModel/index.d.ts +21 -0
- package/lib/components/DynamicForm/selectModel/index.js +197 -0
- package/lib/components/DynamicForm/selectModel/vite.svg +1 -0
- package/lib/components/DynamicForm/useDynamicForm.d.ts +26 -0
- package/lib/components/DynamicForm/useDynamicForm.js +553 -0
- package/lib/components/DynamicForm/vite.svg +1 -0
- package/lib/main.d.ts +3 -1
- package/lib/main.js +5 -0
- package/lib/utils/method.d.ts +21 -0
- package/lib/utils/method.js +186 -0
- package/package.json +3 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const dayjs = require("dayjs");
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
function getJson(jsonStr) {
|
|
6
|
+
try {
|
|
7
|
+
return JSON.parse(jsonStr);
|
|
8
|
+
} catch (error) {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function base64ToString(base64Str) {
|
|
13
|
+
if (!isBase64(base64Str)) {
|
|
14
|
+
return base64Str;
|
|
15
|
+
}
|
|
16
|
+
const binaryStr = atob(base64Str);
|
|
17
|
+
const bytes = new Uint8Array(binaryStr.length);
|
|
18
|
+
for (let i = 0; i < binaryStr.length; i++) {
|
|
19
|
+
bytes[i] = binaryStr.charCodeAt(i);
|
|
20
|
+
}
|
|
21
|
+
return new TextDecoder().decode(bytes);
|
|
22
|
+
}
|
|
23
|
+
function isBase64(str) {
|
|
24
|
+
if (!str)
|
|
25
|
+
return true;
|
|
26
|
+
if (str.length % 4 !== 0)
|
|
27
|
+
return false;
|
|
28
|
+
const base64Regex = /^[A-Za-z0-9+/]+(?:=?=?)$/;
|
|
29
|
+
return base64Regex.test(str);
|
|
30
|
+
}
|
|
31
|
+
const handleSubmitForm = (originalData, allValues) => {
|
|
32
|
+
let updatedData = _.cloneDeep(originalData);
|
|
33
|
+
let uploadedFiles = [];
|
|
34
|
+
const processAttrList = (attrList) => {
|
|
35
|
+
var _a, _b, _c;
|
|
36
|
+
const attrMap = new Map(attrList.map((item, index) => [item.attrid, index]));
|
|
37
|
+
try {
|
|
38
|
+
for (const [fieldName, formValue] of Object.entries(allValues)) {
|
|
39
|
+
const index = attrMap.get(fieldName);
|
|
40
|
+
if (index === void 0)
|
|
41
|
+
continue;
|
|
42
|
+
const attrItem = attrList[index];
|
|
43
|
+
const inputType = (_a = attrItem.json) == null ? void 0 : _a.input;
|
|
44
|
+
const format = (_b = attrItem.json) == null ? void 0 : _b["format"];
|
|
45
|
+
if (!formValue && formValue !== 0) {
|
|
46
|
+
attrItem.attrvalue = "";
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
switch (inputType) {
|
|
50
|
+
case "image":
|
|
51
|
+
case "file":
|
|
52
|
+
case "video":
|
|
53
|
+
case "audio":
|
|
54
|
+
const parsedValue = typeof formValue === "string" ? JSON.parse(formValue) : formValue;
|
|
55
|
+
if (!Array.isArray(parsedValue)) {
|
|
56
|
+
attrItem.attrvalue = JSON.stringify([]);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const existingFiles = parsedValue.filter((file) => file.FileId);
|
|
60
|
+
const uploadedFileList = parsedValue.filter((file) => {
|
|
61
|
+
var _a2;
|
|
62
|
+
return file.status === "done" && ((_a2 = file.response) == null ? void 0 : _a2.data);
|
|
63
|
+
}).map((file) => file.response.data);
|
|
64
|
+
const allFiles = [...existingFiles, ...uploadedFileList];
|
|
65
|
+
uploadedFiles = [...uploadedFiles, ...uploadedFileList];
|
|
66
|
+
attrItem.attrvalue = JSON.stringify(allFiles);
|
|
67
|
+
break;
|
|
68
|
+
case "cascader":
|
|
69
|
+
if (Array.isArray(formValue) && formValue.length > 0) {
|
|
70
|
+
const delimiter = ((_c = attrItem.json) == null ? void 0 : _c["cascader-delimiter"]) || "/";
|
|
71
|
+
attrItem.attrvalue = formValue.join(delimiter);
|
|
72
|
+
} else {
|
|
73
|
+
attrItem.attrvalue = "";
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case "checkbox":
|
|
77
|
+
case "mult-select":
|
|
78
|
+
if (Array.isArray(formValue) && formValue.length > 0) {
|
|
79
|
+
attrItem.attrvalue = formValue.join(",");
|
|
80
|
+
} else {
|
|
81
|
+
attrItem.attrvalue = formValue;
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case "date-picker":
|
|
85
|
+
if (formValue) {
|
|
86
|
+
attrItem.attrvalue = dayjs(formValue).format(format || "YYYY-MM-DD");
|
|
87
|
+
} else {
|
|
88
|
+
attrItem.attrvalue = "";
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case "time-picker":
|
|
92
|
+
if (formValue) {
|
|
93
|
+
attrItem.attrvalue = dayjs(formValue).format(format || "YYYY-MM-DD HH:mm:ss");
|
|
94
|
+
} else {
|
|
95
|
+
attrItem.attrvalue = "";
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
default:
|
|
99
|
+
attrItem.attrvalue = formValue;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
attrList.forEach((item) => {
|
|
104
|
+
if (item.children && Array.isArray(item.children) && item.children.length > 0) {
|
|
105
|
+
processAttrList(item.children);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
} catch (error) {
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
if (updatedData.attr_list && Array.isArray(updatedData.attr_list)) {
|
|
112
|
+
processAttrList(updatedData.attr_list);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
updatedData,
|
|
116
|
+
uploadedFiles
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
const handleAttrList = (attrList) => {
|
|
120
|
+
return attrList.map((item) => {
|
|
121
|
+
if (!item.json && item.info) {
|
|
122
|
+
try {
|
|
123
|
+
const json = item.info_base64 === 1 ? getJson(base64ToString(item.info)) : getJson(item.info);
|
|
124
|
+
item.json = json;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
item.json = {};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return item;
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
const handleFormConfig = async ({
|
|
133
|
+
number,
|
|
134
|
+
key,
|
|
135
|
+
sourceNumber,
|
|
136
|
+
guidInterfaceName,
|
|
137
|
+
SelPCParamInterfaceName,
|
|
138
|
+
attrListInterfaceName,
|
|
139
|
+
commonRequest
|
|
140
|
+
}) => {
|
|
141
|
+
return new Promise(async (resolve, reject) => {
|
|
142
|
+
var _a, _b, _c;
|
|
143
|
+
let newGUID = "", attrListConfigs = [], baseData = {};
|
|
144
|
+
const guidRes = await commonRequest(guidInterfaceName || "FWDXGLCreateGUID", {
|
|
145
|
+
"source-number": sourceNumber
|
|
146
|
+
});
|
|
147
|
+
if ((guidRes == null ? void 0 : guidRes.ReturnValue) === 1 && ((_a = guidRes == null ? void 0 : guidRes.data) == null ? void 0 : _a.GUID)) {
|
|
148
|
+
newGUID = guidRes.data.GUID;
|
|
149
|
+
} else {
|
|
150
|
+
reject("获取GUID失败");
|
|
151
|
+
}
|
|
152
|
+
const res = await commonRequest(SelPCParamInterfaceName || "FWDXGLSelPCParam", {
|
|
153
|
+
"source-number": sourceNumber
|
|
154
|
+
});
|
|
155
|
+
if ((res == null ? void 0 : res.ReturnValue) === 1) {
|
|
156
|
+
const asid = (_b = res.data[number]) == null ? void 0 : _b[key];
|
|
157
|
+
const res2 = await commonRequest(attrListInterfaceName || "SERATTALLList", {
|
|
158
|
+
asid,
|
|
159
|
+
"source-number": sourceNumber
|
|
160
|
+
});
|
|
161
|
+
if ((res2 == null ? void 0 : res2.ReturnValue) === 1 && res2.data) {
|
|
162
|
+
const attrList = ((_c = res2.data) == null ? void 0 : _c["attr_list"]) || [];
|
|
163
|
+
attrListConfigs = handleAttrList(attrList);
|
|
164
|
+
baseData = {
|
|
165
|
+
...res2.data,
|
|
166
|
+
attr_list: attrListConfigs
|
|
167
|
+
};
|
|
168
|
+
resolve({
|
|
169
|
+
baseData,
|
|
170
|
+
newGUID,
|
|
171
|
+
attrListConfigs
|
|
172
|
+
});
|
|
173
|
+
} else {
|
|
174
|
+
reject("请配置属性集");
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
reject("获取配置失败");
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
exports.base64ToString = base64ToString;
|
|
182
|
+
exports.getJson = getJson;
|
|
183
|
+
exports.handleAttrList = handleAttrList;
|
|
184
|
+
exports.handleFormConfig = handleFormConfig;
|
|
185
|
+
exports.handleSubmitForm = handleSubmitForm;
|
|
186
|
+
exports.isBase64 = isBase64;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "szld-libs",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.54",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"ahooks": "^3.7.4",
|
|
13
13
|
"antd": "^5.27.4",
|
|
14
|
+
"axios": "^1.13.2",
|
|
14
15
|
"crypto-js": "^4.2.0",
|
|
16
|
+
"dayjs": "^1.11.19",
|
|
15
17
|
"lodash": "^4.17.21",
|
|
16
18
|
"pako": "^2.1.0",
|
|
17
19
|
"react": "^18.2.0",
|