szld-libs 0.2.51 → 0.2.53
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 +17010 -15271
- package/dist/szld-components.umd.js +55 -55
- package/es/components/BackHeader/index.d.ts +2 -0
- package/es/components/BackHeader/index.js +5 -1
- 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 +18 -0
- package/es/utils/method.js +186 -0
- package/lib/components/BackHeader/index.d.ts +2 -0
- package/lib/components/BackHeader/index.js +5 -1
- 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 +18 -0
- package/lib/utils/method.js +186 -0
- package/package.json +3 -1
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const icons = require("@ant-design/icons");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const method = require("../../utils/method");
|
|
6
|
+
const isoWeek = require("dayjs/plugin/isoWeek");
|
|
7
|
+
const SelectModel = require("./selectModel");
|
|
8
|
+
const MyCheckbox = require("./myCheckbox");
|
|
9
|
+
const MyCascader = require("./myCascader");
|
|
10
|
+
const dayjs = require("dayjs");
|
|
11
|
+
const RadioCard = require("./radioCard");
|
|
12
|
+
const MySelect = require("./mySelect");
|
|
13
|
+
const MyUpload = require("./myUpload");
|
|
14
|
+
const MyRadio = require("./myRadio");
|
|
15
|
+
const _ = require("lodash");
|
|
16
|
+
const antd = require("antd");
|
|
17
|
+
dayjs.extend(isoWeek);
|
|
18
|
+
function useDynamicForm(props) {
|
|
19
|
+
const {
|
|
20
|
+
commonRequestWidthParams,
|
|
21
|
+
uploadAction,
|
|
22
|
+
commonRequest,
|
|
23
|
+
formConfig,
|
|
24
|
+
setFormConfig,
|
|
25
|
+
interfaceTypeChildren,
|
|
26
|
+
updateDelFileList
|
|
27
|
+
} = props;
|
|
28
|
+
const formConfigRef = react.useRef([]);
|
|
29
|
+
const { message } = antd.App.useApp();
|
|
30
|
+
react.useEffect(() => {
|
|
31
|
+
if (!formConfig) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
formConfigRef.current = formConfig;
|
|
35
|
+
}, [formConfig]);
|
|
36
|
+
const handleUrlOptions = (val, delimiter, list) => {
|
|
37
|
+
let arr = [];
|
|
38
|
+
list.forEach((item) => {
|
|
39
|
+
arr.push(val == null ? void 0 : val[item]);
|
|
40
|
+
});
|
|
41
|
+
return arr.join(delimiter || "-");
|
|
42
|
+
};
|
|
43
|
+
const handleNormFile = react.useCallback((e) => {
|
|
44
|
+
if (Array.isArray(e)) {
|
|
45
|
+
return e;
|
|
46
|
+
}
|
|
47
|
+
return (e == null ? void 0 : e.fileList) ?? [];
|
|
48
|
+
}, []);
|
|
49
|
+
const handleDealFile = (file) => {
|
|
50
|
+
updateDelFileList(file);
|
|
51
|
+
};
|
|
52
|
+
const handleSetFormItemProps = react.useCallback(
|
|
53
|
+
(itemWithJson) => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
|
|
56
|
+
const format = (_b = itemWithJson.json) == null ? void 0 : _b.format;
|
|
57
|
+
const baseProps = {};
|
|
58
|
+
switch (inputType) {
|
|
59
|
+
case "image":
|
|
60
|
+
case "file":
|
|
61
|
+
case "video":
|
|
62
|
+
case "audio":
|
|
63
|
+
baseProps.getValueFromEvent = handleNormFile;
|
|
64
|
+
break;
|
|
65
|
+
case "date-picker":
|
|
66
|
+
baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.format(format || "YYYY-MM-DD");
|
|
67
|
+
baseProps.getValueProps = (value) => ({
|
|
68
|
+
value: value ? dayjs(value) : null
|
|
69
|
+
});
|
|
70
|
+
break;
|
|
71
|
+
case "time-picker":
|
|
72
|
+
baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.format(format || "YYYY-MM-DD HH:mm:ss");
|
|
73
|
+
baseProps.getValueProps = (value) => ({
|
|
74
|
+
value: value ? dayjs(value) : null
|
|
75
|
+
});
|
|
76
|
+
break;
|
|
77
|
+
case "week-picker":
|
|
78
|
+
baseProps.getValueFromEvent = (date) => {
|
|
79
|
+
return `${date == null ? void 0 : date.year()}-${dayjs(date).isoWeek()}周`;
|
|
80
|
+
};
|
|
81
|
+
baseProps.getValueProps = (value) => {
|
|
82
|
+
if (!value)
|
|
83
|
+
return { value: null };
|
|
84
|
+
const [yearStr, weekStr] = value.split("-");
|
|
85
|
+
const year = Number(yearStr);
|
|
86
|
+
const week = Number(weekStr.replace("周", ""));
|
|
87
|
+
return {
|
|
88
|
+
value: dayjs().year(year).isoWeek(week)
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
break;
|
|
92
|
+
case "month-picker":
|
|
93
|
+
baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.format(format || "YYYY-MM");
|
|
94
|
+
baseProps.getValueProps = (value) => ({
|
|
95
|
+
value: value ? dayjs(value) : null
|
|
96
|
+
});
|
|
97
|
+
break;
|
|
98
|
+
case "quarter-picker":
|
|
99
|
+
baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.format(format || "YYYY年第Q季度");
|
|
100
|
+
baseProps.getValueProps = (value) => ({
|
|
101
|
+
value: value ? dayjs(value, format || "YYYY年第Q季度") : null
|
|
102
|
+
});
|
|
103
|
+
break;
|
|
104
|
+
case "year-picker":
|
|
105
|
+
baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.format(format || "YYYY");
|
|
106
|
+
baseProps.getValueProps = (value) => ({
|
|
107
|
+
value: value ? dayjs(value) : null
|
|
108
|
+
});
|
|
109
|
+
break;
|
|
110
|
+
case "second-picker":
|
|
111
|
+
baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.format(format || "HH:mm:ss");
|
|
112
|
+
baseProps.getValueProps = (value) => ({
|
|
113
|
+
value: value ? dayjs(value, format || "HH:mm:ss") : null
|
|
114
|
+
});
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
return baseProps;
|
|
118
|
+
},
|
|
119
|
+
[handleNormFile]
|
|
120
|
+
);
|
|
121
|
+
const handleSetFormItemInitialValue = react.useCallback((itemWithJson) => {
|
|
122
|
+
var _a, _b, _c, _d;
|
|
123
|
+
const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
|
|
124
|
+
let initialValue = itemWithJson.attrvalue ?? ((_b = itemWithJson.json) == null ? void 0 : _b.default);
|
|
125
|
+
if (inputType === "label" && initialValue) {
|
|
126
|
+
initialValue = ((_c = itemWithJson.json) == null ? void 0 : _c["label-value"]) ?? initialValue ?? "-";
|
|
127
|
+
}
|
|
128
|
+
if ((inputType === "date-picker" || inputType === "time-picker") && initialValue) {
|
|
129
|
+
try {
|
|
130
|
+
const date = dayjs(initialValue);
|
|
131
|
+
initialValue = date.isValid() ? date : void 0;
|
|
132
|
+
} catch (error) {
|
|
133
|
+
initialValue = void 0;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (inputType === "cascader" && initialValue && typeof initialValue === "string") {
|
|
137
|
+
const delimiter = (_d = itemWithJson.json) == null ? void 0 : _d["cascader-delimiter"];
|
|
138
|
+
if (delimiter) {
|
|
139
|
+
initialValue = initialValue.split(delimiter).filter(Boolean);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (["mult-select", "checkbox"].includes(inputType) && initialValue && typeof initialValue === "string") {
|
|
143
|
+
initialValue = initialValue.split(",").filter(Boolean);
|
|
144
|
+
}
|
|
145
|
+
if (["image", "video", "audio", "file"].includes(inputType) && initialValue) {
|
|
146
|
+
try {
|
|
147
|
+
const fileList = Array.isArray(initialValue) ? initialValue : JSON.parse(initialValue);
|
|
148
|
+
initialValue = fileList.map((file) => ({
|
|
149
|
+
...file,
|
|
150
|
+
url: file.FilePath,
|
|
151
|
+
name: file.FileName,
|
|
152
|
+
uid: file.FileId
|
|
153
|
+
}));
|
|
154
|
+
} catch (error) {
|
|
155
|
+
initialValue = [];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return initialValue || null;
|
|
159
|
+
}, []);
|
|
160
|
+
const handleCollapseIcon = react.useCallback(
|
|
161
|
+
({ isActive }) => isActive ? /* @__PURE__ */ jsxRuntime.jsx(icons.MinusSquareOutlined, { style: { fontSize: 18, color: "#999" } }) : /* @__PURE__ */ jsxRuntime.jsx(icons.PlusSquareOutlined, { style: { fontSize: 18, color: "#999" } }),
|
|
162
|
+
[]
|
|
163
|
+
);
|
|
164
|
+
const handleDealInstruction = (itemWithJson, instructionShowMode) => {
|
|
165
|
+
var _a, _b, _c, _d, _e;
|
|
166
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 10, vertical: instructionShowMode === "flex", align: "center", children: [
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: itemWithJson.attrname }),
|
|
168
|
+
((_a = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _a.instruction) && instructionShowMode === "icon" && /* @__PURE__ */ jsxRuntime.jsx(antd.Tooltip, { title: (_b = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _b.instruction, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
169
|
+
icons.InfoCircleOutlined,
|
|
170
|
+
{
|
|
171
|
+
style: {
|
|
172
|
+
color: ((_c = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _c["instruction-color"]) ?? "#888888",
|
|
173
|
+
fontSize: 16,
|
|
174
|
+
cursor: "pointer"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
) }) || /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: ((_d = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _d["instruction-color"]) ?? "red" }, children: (_e = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _e.instruction })
|
|
178
|
+
] });
|
|
179
|
+
};
|
|
180
|
+
const handleRenderFunc = react.useCallback(
|
|
181
|
+
({
|
|
182
|
+
itemWithJson,
|
|
183
|
+
colNum = 1,
|
|
184
|
+
readonly = false,
|
|
185
|
+
instructionShowMode = "icon",
|
|
186
|
+
radioAlign = "horizontal",
|
|
187
|
+
formItemStyle,
|
|
188
|
+
relatedid,
|
|
189
|
+
form,
|
|
190
|
+
defaultWidth = 358
|
|
191
|
+
}) => {
|
|
192
|
+
var _a, _b;
|
|
193
|
+
if (((_a = itemWithJson.json) == null ? void 0 : _a.hide) === true) {
|
|
194
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
195
|
+
}
|
|
196
|
+
if (itemWithJson.attrtype === 1) {
|
|
197
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
198
|
+
antd.Collapse,
|
|
199
|
+
{
|
|
200
|
+
bordered: false,
|
|
201
|
+
style: { backgroundColor: "transparent" },
|
|
202
|
+
expandIcon: ({ isActive }) => handleCollapseIcon({ isActive }),
|
|
203
|
+
onChange: async (key) => {
|
|
204
|
+
var _a2;
|
|
205
|
+
try {
|
|
206
|
+
const { children = [] } = itemWithJson;
|
|
207
|
+
if (key && (key == null ? void 0 : key.length) && setFormConfig && formConfigRef.current && interfaceTypeChildren && !(children == null ? void 0 : children.length)) {
|
|
208
|
+
const res = await commonRequest(interfaceTypeChildren, {
|
|
209
|
+
instanceid: relatedid,
|
|
210
|
+
asid: itemWithJson.asid,
|
|
211
|
+
tname: itemWithJson.tname
|
|
212
|
+
});
|
|
213
|
+
if ((res == null ? void 0 : res.ReturnValue) === 1) {
|
|
214
|
+
const arr = ((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.list) || [];
|
|
215
|
+
const _formConfig = _.cloneDeep(formConfigRef.current);
|
|
216
|
+
const _item = _formConfig.find((item) => item.attrid === itemWithJson.attrid);
|
|
217
|
+
if (_item) {
|
|
218
|
+
_item.children = [...arr];
|
|
219
|
+
}
|
|
220
|
+
setFormConfig(_formConfig);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
} catch (error) {
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
items: [
|
|
227
|
+
{
|
|
228
|
+
key: itemWithJson.attrid,
|
|
229
|
+
label: itemWithJson.attrname,
|
|
230
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: (itemWithJson.children || []).map((child, index) => {
|
|
231
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: handleRenderItem({
|
|
232
|
+
item: child,
|
|
233
|
+
readonly,
|
|
234
|
+
colNum,
|
|
235
|
+
instructionShowMode,
|
|
236
|
+
relatedid,
|
|
237
|
+
form,
|
|
238
|
+
defaultWidth,
|
|
239
|
+
formItemStyle
|
|
240
|
+
}) }, child.attrid || `child-${index}`);
|
|
241
|
+
}) })
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
},
|
|
245
|
+
itemWithJson.attrid
|
|
246
|
+
) });
|
|
247
|
+
}
|
|
248
|
+
if (itemWithJson.attrtype === 2) {
|
|
249
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: "实例信息" });
|
|
250
|
+
}
|
|
251
|
+
if (itemWithJson.attrtype === 0) {
|
|
252
|
+
let initialValue = handleSetFormItemInitialValue(itemWithJson);
|
|
253
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24 / colNum, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
254
|
+
antd.Form.Item,
|
|
255
|
+
{
|
|
256
|
+
name: itemWithJson.attrid,
|
|
257
|
+
label: handleDealInstruction(itemWithJson, instructionShowMode),
|
|
258
|
+
initialValue,
|
|
259
|
+
rules: [
|
|
260
|
+
...((_b = itemWithJson.json) == null ? void 0 : _b.must) ? [
|
|
261
|
+
{
|
|
262
|
+
required: true,
|
|
263
|
+
message: `请输入${itemWithJson.attrname}`
|
|
264
|
+
}
|
|
265
|
+
] : []
|
|
266
|
+
],
|
|
267
|
+
...handleSetFormItemProps(itemWithJson),
|
|
268
|
+
children: handleRenderItemInputMode({
|
|
269
|
+
item: itemWithJson,
|
|
270
|
+
readonly,
|
|
271
|
+
formItemStyle,
|
|
272
|
+
radioAlign,
|
|
273
|
+
relatedid,
|
|
274
|
+
form,
|
|
275
|
+
defaultWidth
|
|
276
|
+
})
|
|
277
|
+
},
|
|
278
|
+
itemWithJson.attrid
|
|
279
|
+
) });
|
|
280
|
+
}
|
|
281
|
+
return null;
|
|
282
|
+
},
|
|
283
|
+
[handleCollapseIcon]
|
|
284
|
+
);
|
|
285
|
+
const handleOnRemove = async (file) => {
|
|
286
|
+
var _a;
|
|
287
|
+
try {
|
|
288
|
+
const data = (_a = file == null ? void 0 : file.response) == null ? void 0 : _a.data;
|
|
289
|
+
if (data) {
|
|
290
|
+
if (!commonRequestWidthParams)
|
|
291
|
+
return;
|
|
292
|
+
const result = await commonRequestWidthParams(
|
|
293
|
+
{ Controlname: "DelFile", PageName: "initializationfile" },
|
|
294
|
+
data
|
|
295
|
+
);
|
|
296
|
+
if ((result == null ? void 0 : result.ReturnValue) !== 1) {
|
|
297
|
+
message.error((result == null ? void 0 : result.msg) || "删除文件失败");
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
handleDealFile(file);
|
|
302
|
+
}
|
|
303
|
+
return true;
|
|
304
|
+
} catch (error) {
|
|
305
|
+
message.error("删除文件失败,请重试");
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
const handleRenderItemInputMode = ({
|
|
310
|
+
item,
|
|
311
|
+
readonly = false,
|
|
312
|
+
formItemStyle = [],
|
|
313
|
+
radioAlign = "horizontal",
|
|
314
|
+
relatedid,
|
|
315
|
+
form,
|
|
316
|
+
defaultWidth = 358
|
|
317
|
+
}) => {
|
|
318
|
+
var _a, _b;
|
|
319
|
+
const mode = item.json.input || "text";
|
|
320
|
+
const formatValue = handleSetFormItemInitialValue(item);
|
|
321
|
+
const params = item.json.length && {
|
|
322
|
+
maxLength: item.json.length
|
|
323
|
+
} || {};
|
|
324
|
+
const itemStyle = formItemStyle.find((v) => v.type === mode);
|
|
325
|
+
switch (mode) {
|
|
326
|
+
case "label":
|
|
327
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
328
|
+
antd.Input,
|
|
329
|
+
{
|
|
330
|
+
disabled: true,
|
|
331
|
+
value: ((_a = item.json) == null ? void 0 : _a["label-value"]) || item.attrvalue || ((_b = item.json) == null ? void 0 : _b.default) || "-",
|
|
332
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
case "text":
|
|
336
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
337
|
+
antd.Input,
|
|
338
|
+
{
|
|
339
|
+
placeholder: "请输入",
|
|
340
|
+
...params,
|
|
341
|
+
disabled: readonly,
|
|
342
|
+
allowClear: true,
|
|
343
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
|
|
344
|
+
}
|
|
345
|
+
);
|
|
346
|
+
case "textarea":
|
|
347
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
348
|
+
antd.Input.TextArea,
|
|
349
|
+
{
|
|
350
|
+
allowClear: true,
|
|
351
|
+
placeholder: "请输入",
|
|
352
|
+
rows: 5,
|
|
353
|
+
...params,
|
|
354
|
+
disabled: readonly,
|
|
355
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
case "number":
|
|
359
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
360
|
+
antd.InputNumber,
|
|
361
|
+
{
|
|
362
|
+
controls: false,
|
|
363
|
+
placeholder: "请输入",
|
|
364
|
+
...params,
|
|
365
|
+
disabled: readonly,
|
|
366
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
case "select":
|
|
370
|
+
case "mult-select": {
|
|
371
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
372
|
+
MySelect,
|
|
373
|
+
{
|
|
374
|
+
handleUrlOptions,
|
|
375
|
+
item: item.json,
|
|
376
|
+
readonly,
|
|
377
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style },
|
|
378
|
+
commonRequestWidthParams,
|
|
379
|
+
commonRequest,
|
|
380
|
+
value: formatValue,
|
|
381
|
+
onChange: (val) => {
|
|
382
|
+
form.setFieldValue(item.attrid, val);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
case "modal-mult-select":
|
|
388
|
+
case "modal-select": {
|
|
389
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
390
|
+
SelectModel,
|
|
391
|
+
{
|
|
392
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style },
|
|
393
|
+
item: item.json,
|
|
394
|
+
value: item.attrvalue || item.json.default || "",
|
|
395
|
+
commonRequestWidthParams,
|
|
396
|
+
commonRequest,
|
|
397
|
+
onSure: async (value) => {
|
|
398
|
+
form.setFieldValue(item.attrid, value);
|
|
399
|
+
},
|
|
400
|
+
disabled: readonly
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
case "date-picker":
|
|
405
|
+
case "time-picker":
|
|
406
|
+
case "week-picker":
|
|
407
|
+
case "month-picker":
|
|
408
|
+
case "quarter-picker":
|
|
409
|
+
case "year-picker":
|
|
410
|
+
case "second-picker": {
|
|
411
|
+
const pickerObj = {
|
|
412
|
+
"date-picker": "date",
|
|
413
|
+
"time-picker": "date",
|
|
414
|
+
"week-picker": "week",
|
|
415
|
+
"month-picker": "month",
|
|
416
|
+
"quarter-picker": "quarter",
|
|
417
|
+
"year-picker": "year",
|
|
418
|
+
"second-picker": "time"
|
|
419
|
+
};
|
|
420
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
421
|
+
antd.DatePicker,
|
|
422
|
+
{
|
|
423
|
+
showTime: mode === "time-picker",
|
|
424
|
+
picker: pickerObj[mode] || "date",
|
|
425
|
+
disabled: readonly,
|
|
426
|
+
placement: "bottomLeft",
|
|
427
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
case "radio":
|
|
432
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
433
|
+
MyRadio,
|
|
434
|
+
{
|
|
435
|
+
radioAlign,
|
|
436
|
+
commonRequest,
|
|
437
|
+
commonRequestWidthParams,
|
|
438
|
+
item: item.json,
|
|
439
|
+
readonly,
|
|
440
|
+
options: params,
|
|
441
|
+
handleUrlOptions,
|
|
442
|
+
value: formatValue,
|
|
443
|
+
onChange: (e) => {
|
|
444
|
+
form.setFieldValue(item.attrid, e.target.value);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
);
|
|
448
|
+
case "checkbox":
|
|
449
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
450
|
+
MyCheckbox,
|
|
451
|
+
{
|
|
452
|
+
radioAlign,
|
|
453
|
+
commonRequest,
|
|
454
|
+
commonRequestWidthParams,
|
|
455
|
+
item: item.json,
|
|
456
|
+
readonly,
|
|
457
|
+
options: params,
|
|
458
|
+
value: formatValue,
|
|
459
|
+
handleUrlOptions,
|
|
460
|
+
onChange: (val) => {
|
|
461
|
+
form.setFieldValue(item.attrid, val.join(","));
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
);
|
|
465
|
+
case "audio":
|
|
466
|
+
case "file":
|
|
467
|
+
case "image":
|
|
468
|
+
case "video":
|
|
469
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
470
|
+
MyUpload,
|
|
471
|
+
{
|
|
472
|
+
action: uploadAction && uploadAction("initializationfile"),
|
|
473
|
+
item: item.json,
|
|
474
|
+
uploadType: mode,
|
|
475
|
+
list: formatValue,
|
|
476
|
+
readonly,
|
|
477
|
+
relatedid,
|
|
478
|
+
onRemove: (file) => handleOnRemove(file)
|
|
479
|
+
}
|
|
480
|
+
);
|
|
481
|
+
case "cascader":
|
|
482
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
483
|
+
MyCascader,
|
|
484
|
+
{
|
|
485
|
+
commonRequestWidthParams,
|
|
486
|
+
commonRequest,
|
|
487
|
+
item: item.json,
|
|
488
|
+
value: item.attrvalue,
|
|
489
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
|
|
490
|
+
}
|
|
491
|
+
);
|
|
492
|
+
case "radio-card":
|
|
493
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
494
|
+
RadioCard,
|
|
495
|
+
{
|
|
496
|
+
item: item.json,
|
|
497
|
+
readonly,
|
|
498
|
+
onChange: (value) => {
|
|
499
|
+
form.setFieldValue(item.attrid, value);
|
|
500
|
+
},
|
|
501
|
+
commonRequestWidthParams
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
default:
|
|
505
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "请输入", ...params, showCount: true, disabled: readonly, style: { ...itemStyle == null ? void 0 : itemStyle.style } });
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
const handleRenderItem = ({
|
|
509
|
+
item,
|
|
510
|
+
readonly = false,
|
|
511
|
+
colNum = 1,
|
|
512
|
+
instructionShowMode = "icon",
|
|
513
|
+
relatedid,
|
|
514
|
+
form,
|
|
515
|
+
defaultWidth = 358,
|
|
516
|
+
formItemStyle,
|
|
517
|
+
radioAlign = "horizontal"
|
|
518
|
+
}) => {
|
|
519
|
+
var _a;
|
|
520
|
+
const json = item.info_base64 === 1 ? method.getJson(method.base64ToString(item.info)) : method.getJson(item.info);
|
|
521
|
+
const itemWithJson = { ...item, json };
|
|
522
|
+
if (((_a = itemWithJson.json) == null ? void 0 : _a.hide) === true) {
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
526
|
+
handleRenderFunc({
|
|
527
|
+
itemWithJson,
|
|
528
|
+
readonly,
|
|
529
|
+
colNum,
|
|
530
|
+
instructionShowMode,
|
|
531
|
+
relatedid,
|
|
532
|
+
form,
|
|
533
|
+
defaultWidth,
|
|
534
|
+
formItemStyle,
|
|
535
|
+
radioAlign
|
|
536
|
+
}),
|
|
537
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
538
|
+
antd.Form.Item,
|
|
539
|
+
{
|
|
540
|
+
name: itemWithJson.attrid + "_objs",
|
|
541
|
+
style: { display: "none" },
|
|
542
|
+
initialValue: itemWithJson,
|
|
543
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { type: "hidden" })
|
|
544
|
+
},
|
|
545
|
+
itemWithJson.attrid + "_objs"
|
|
546
|
+
)
|
|
547
|
+
] }, itemWithJson.attrid);
|
|
548
|
+
};
|
|
549
|
+
return {
|
|
550
|
+
handleRenderItem
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
module.exports = useDynamicForm;
|
|
@@ -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/lib/main.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import CoralButton from './components/CoralButton';
|
|
|
8
8
|
import LoopSlide from './components/LoopSlide';
|
|
9
9
|
import showWorkFlow, { WorkFlowNode } from './components/WorkFlowNode';
|
|
10
10
|
import CustomPagination from './components/CustomPagination';
|
|
11
|
+
import DynamicForm from './components/DynamicForm';
|
|
11
12
|
import * as download from './utils/download';
|
|
12
13
|
import * as fileType from './utils/filetype';
|
|
13
14
|
import * as FormRules from './utils/formRules';
|
|
@@ -17,9 +18,10 @@ import * as verfyCode from './utils/verify-code';
|
|
|
17
18
|
import AES from './utils/aes';
|
|
18
19
|
import HmacSHA512 from './utils/hmacSHA512';
|
|
19
20
|
import HmacSM3 from './utils/hmacSM3';
|
|
21
|
+
import * as method from './utils/method';
|
|
20
22
|
import useCaptcha from './hooks/useCaptcha';
|
|
21
23
|
import useChangePwd from './hooks/useChangePwd';
|
|
22
24
|
import useConfig from './hooks/useConfig';
|
|
23
25
|
import useRemember from './hooks/useRemember';
|
|
24
26
|
import useRowSelection from './hooks/useRowSelection';
|
|
25
|
-
export { AES, AuthButton, BackHeader, compressionImage, CoralButton, CreateForm,
|
|
27
|
+
export { AES, AuthButton, BackHeader, compressionImage, CoralButton, CreateForm, EditTable, HmacSHA512, HmacSM3, LoopSlide, SearchTable, showWorkFlow, UploadFile, DynamicForm, useCaptcha, useChangePwd, useConfig, useRemember, useRowSelection, WorkFlowNode, CustomPagination, utils, download, fileType, FormRules, verfyCode, method, };
|
package/lib/main.js
CHANGED
|
@@ -10,6 +10,7 @@ const CoralButton = require("./components/CoralButton");
|
|
|
10
10
|
const LoopSlide = require("./components/LoopSlide");
|
|
11
11
|
const WorkFlowNode = require("./components/WorkFlowNode");
|
|
12
12
|
const CustomPagination = require("./components/CustomPagination");
|
|
13
|
+
const DynamicForm = require("./components/DynamicForm");
|
|
13
14
|
const download = require("./utils/download");
|
|
14
15
|
const filetype = require("./utils/filetype");
|
|
15
16
|
const formRules = require("./utils/formRules");
|
|
@@ -19,6 +20,7 @@ const verifyCode = require("./utils/verify-code");
|
|
|
19
20
|
const aes = require("./utils/aes");
|
|
20
21
|
const hmacSHA512 = require("./utils/hmacSHA512");
|
|
21
22
|
const hmacSM3 = require("./utils/hmacSM3");
|
|
23
|
+
const method = require("./utils/method");
|
|
22
24
|
const useCaptcha = require("./hooks/useCaptcha");
|
|
23
25
|
const useChangePwd = require("./hooks/useChangePwd");
|
|
24
26
|
const useConfig = require("./hooks/useConfig");
|
|
@@ -45,6 +47,7 @@ const filetype__namespace = /* @__PURE__ */ _interopNamespaceDefault(filetype);
|
|
|
45
47
|
const formRules__namespace = /* @__PURE__ */ _interopNamespaceDefault(formRules);
|
|
46
48
|
const index__namespace = /* @__PURE__ */ _interopNamespaceDefault(index);
|
|
47
49
|
const verifyCode__namespace = /* @__PURE__ */ _interopNamespaceDefault(verifyCode);
|
|
50
|
+
const method__namespace = /* @__PURE__ */ _interopNamespaceDefault(method);
|
|
48
51
|
exports.BackHeader = BackHeader;
|
|
49
52
|
exports.CreateForm = CreateForm;
|
|
50
53
|
exports.SearchTable = SearchTable;
|
|
@@ -59,6 +62,7 @@ Object.defineProperty(exports, "WorkFlowNode", {
|
|
|
59
62
|
});
|
|
60
63
|
exports.showWorkFlow = WorkFlowNode;
|
|
61
64
|
exports.CustomPagination = CustomPagination;
|
|
65
|
+
exports.DynamicForm = DynamicForm;
|
|
62
66
|
exports.download = download__namespace;
|
|
63
67
|
exports.fileType = filetype__namespace;
|
|
64
68
|
exports.FormRules = formRules__namespace;
|
|
@@ -68,6 +72,7 @@ exports.verfyCode = verifyCode__namespace;
|
|
|
68
72
|
exports.AES = aes;
|
|
69
73
|
exports.HmacSHA512 = hmacSHA512;
|
|
70
74
|
exports.HmacSM3 = hmacSM3;
|
|
75
|
+
exports.method = method__namespace;
|
|
71
76
|
exports.useCaptcha = useCaptcha;
|
|
72
77
|
exports.useChangePwd = useChangePwd;
|
|
73
78
|
exports.useConfig = useConfig;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
export declare function getJson(jsonStr: string): any;
|
|
3
|
+
export declare function base64ToString(base64Str: string): string;
|
|
4
|
+
export declare function isBase64(str: string): boolean;
|
|
5
|
+
export declare const handleSubmitForm: (originalData: any, allValues: any) => {
|
|
6
|
+
updatedData: any;
|
|
7
|
+
uploadedFiles: any[];
|
|
8
|
+
};
|
|
9
|
+
export declare const handleAttrList: (attrList: any[]) => any[];
|
|
10
|
+
export declare const handleFormConfig: ({ number, key, sourceNumber, guidInterfaceName, SelPCParamInterfaceName, attrListInterfaceName, commonRequest, }: {
|
|
11
|
+
number: string | number;
|
|
12
|
+
key: string;
|
|
13
|
+
guidInterfaceName: string;
|
|
14
|
+
SelPCParamInterfaceName: string;
|
|
15
|
+
attrListInterfaceName: string;
|
|
16
|
+
sourceNumber?: string | number | undefined;
|
|
17
|
+
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
18
|
+
}) => Promise<unknown>;
|