szld-libs 0.2.98 → 0.3.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.
Files changed (106) hide show
  1. package/dist/style.css +1 -1
  2. package/dist/szld-components.es.js +32089 -20004
  3. package/dist/szld-components.umd.js +72 -60
  4. package/es/components/DynamicForm/index.d.ts +2 -0
  5. package/es/components/DynamicForm/index.js +3 -2
  6. package/es/components/DynamicForm/selectModel/index.js +1 -1
  7. package/es/components/DynamicForm/selectModelBackfillFormItem/index.d.ts +27 -0
  8. package/es/components/DynamicForm/selectModelBackfillFormItem/index.js +242 -0
  9. package/es/components/DynamicForm/selectModelBackfillFormItem/vite.svg +1 -0
  10. package/es/components/DynamicForm/useDynamicForm.js +22 -1
  11. package/es/components/DynamicFormMobile/func.d.ts +35 -0
  12. package/es/components/DynamicFormMobile/func.js +204 -0
  13. package/es/components/DynamicFormMobile/index.d.ts +116 -0
  14. package/es/components/DynamicFormMobile/index.js +134 -0
  15. package/es/components/DynamicFormMobile/myCascader/index.d.ts +17 -0
  16. package/es/components/DynamicFormMobile/myCascader/index.js +196 -0
  17. package/es/components/DynamicFormMobile/myCascader/vite.svg +1 -0
  18. package/es/components/DynamicFormMobile/myCheckbox/index.d.ts +19 -0
  19. package/es/components/DynamicFormMobile/myCheckbox/index.js +109 -0
  20. package/es/components/DynamicFormMobile/myCheckbox/vite.svg +1 -0
  21. package/es/components/DynamicFormMobile/myRadio/index.d.ts +20 -0
  22. package/es/components/DynamicFormMobile/myRadio/index.js +107 -0
  23. package/es/components/DynamicFormMobile/myRadio/vite.svg +1 -0
  24. package/es/components/DynamicFormMobile/mySelect/index.css +31 -0
  25. package/es/components/DynamicFormMobile/mySelect/index.d.ts +16 -0
  26. package/es/components/DynamicFormMobile/mySelect/index.js +147 -0
  27. package/es/components/DynamicFormMobile/mySelect/vite.svg +1 -0
  28. package/es/components/DynamicFormMobile/myUpload/index.css +3 -0
  29. package/es/components/DynamicFormMobile/myUpload/index.d.ts +16 -0
  30. package/es/components/DynamicFormMobile/myUpload/index.js +103 -0
  31. package/es/components/DynamicFormMobile/myUpload/vite.svg +1 -0
  32. package/es/components/DynamicFormMobile/radioCard/index.d.ts +12 -0
  33. package/es/components/DynamicFormMobile/radioCard/index.js +142 -0
  34. package/es/components/DynamicFormMobile/radioCard/vite.svg +1 -0
  35. package/es/components/DynamicFormMobile/selectModel/index.d.ts +22 -0
  36. package/es/components/DynamicFormMobile/selectModel/index.js +235 -0
  37. package/es/components/DynamicFormMobile/selectModel/vite.svg +1 -0
  38. package/es/components/DynamicFormMobile/selectModelBackfillFormItem/index.d.ts +27 -0
  39. package/es/components/DynamicFormMobile/selectModelBackfillFormItem/index.js +242 -0
  40. package/es/components/DynamicFormMobile/selectModelBackfillFormItem/vite.svg +1 -0
  41. package/es/components/DynamicFormMobile/useDynamicForm.d.ts +43 -0
  42. package/es/components/DynamicFormMobile/useDynamicForm.js +772 -0
  43. package/es/components/DynamicFormMobile/vite.svg +1 -0
  44. package/es/index.css +1 -0
  45. package/es/index.d.ts +1 -1
  46. package/es/index.js +36 -30
  47. package/es/main.d.ts +2 -1
  48. package/es/main.js +22 -20
  49. package/es/mock/index.d.ts +1 -305
  50. package/es/mock/index.js +20 -364
  51. package/es/services/index.js +3 -5
  52. package/es/services/request.js +2 -2
  53. package/es/utils/method.d.ts +4 -1
  54. package/es/utils/method.js +25 -8
  55. package/lib/components/DynamicForm/index.d.ts +2 -0
  56. package/lib/components/DynamicForm/index.js +3 -2
  57. package/lib/components/DynamicForm/selectModel/index.js +1 -1
  58. package/lib/components/DynamicForm/selectModelBackfillFormItem/index.d.ts +27 -0
  59. package/lib/components/DynamicForm/selectModelBackfillFormItem/index.js +242 -0
  60. package/lib/components/DynamicForm/selectModelBackfillFormItem/vite.svg +1 -0
  61. package/lib/components/DynamicForm/useDynamicForm.js +22 -1
  62. package/lib/components/DynamicFormMobile/func.d.ts +35 -0
  63. package/lib/components/DynamicFormMobile/func.js +204 -0
  64. package/lib/components/DynamicFormMobile/index.d.ts +116 -0
  65. package/lib/components/DynamicFormMobile/index.js +133 -0
  66. package/lib/components/DynamicFormMobile/myCascader/index.d.ts +17 -0
  67. package/lib/components/DynamicFormMobile/myCascader/index.js +195 -0
  68. package/lib/components/DynamicFormMobile/myCascader/vite.svg +1 -0
  69. package/lib/components/DynamicFormMobile/myCheckbox/index.d.ts +19 -0
  70. package/lib/components/DynamicFormMobile/myCheckbox/index.js +108 -0
  71. package/lib/components/DynamicFormMobile/myCheckbox/vite.svg +1 -0
  72. package/lib/components/DynamicFormMobile/myRadio/index.d.ts +20 -0
  73. package/lib/components/DynamicFormMobile/myRadio/index.js +106 -0
  74. package/lib/components/DynamicFormMobile/myRadio/vite.svg +1 -0
  75. package/lib/components/DynamicFormMobile/mySelect/index.css +31 -0
  76. package/lib/components/DynamicFormMobile/mySelect/index.d.ts +16 -0
  77. package/lib/components/DynamicFormMobile/mySelect/index.js +146 -0
  78. package/lib/components/DynamicFormMobile/mySelect/vite.svg +1 -0
  79. package/lib/components/DynamicFormMobile/myUpload/index.css +3 -0
  80. package/lib/components/DynamicFormMobile/myUpload/index.d.ts +16 -0
  81. package/lib/components/DynamicFormMobile/myUpload/index.js +102 -0
  82. package/lib/components/DynamicFormMobile/myUpload/vite.svg +1 -0
  83. package/lib/components/DynamicFormMobile/radioCard/index.d.ts +12 -0
  84. package/lib/components/DynamicFormMobile/radioCard/index.js +141 -0
  85. package/lib/components/DynamicFormMobile/radioCard/vite.svg +1 -0
  86. package/lib/components/DynamicFormMobile/selectModel/index.d.ts +22 -0
  87. package/lib/components/DynamicFormMobile/selectModel/index.js +235 -0
  88. package/lib/components/DynamicFormMobile/selectModel/vite.svg +1 -0
  89. package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/index.d.ts +27 -0
  90. package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/index.js +242 -0
  91. package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/vite.svg +1 -0
  92. package/lib/components/DynamicFormMobile/useDynamicForm.d.ts +43 -0
  93. package/lib/components/DynamicFormMobile/useDynamicForm.js +771 -0
  94. package/lib/components/DynamicFormMobile/vite.svg +1 -0
  95. package/lib/index.css +1 -0
  96. package/lib/index.d.ts +1 -1
  97. package/lib/index.js +36 -30
  98. package/lib/main.d.ts +2 -1
  99. package/lib/main.js +2 -0
  100. package/lib/mock/index.d.ts +1 -305
  101. package/lib/mock/index.js +19 -363
  102. package/lib/services/index.js +3 -5
  103. package/lib/services/request.js +2 -2
  104. package/lib/utils/method.d.ts +4 -1
  105. package/lib/utils/method.js +25 -8
  106. package/package.json +1 -1
@@ -0,0 +1,772 @@
1
+ import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
2
+ import { MinusSquareOutlined, PlusSquareOutlined, CloseOutlined, InfoCircleOutlined } from "@ant-design/icons";
3
+ import { handleSetFormItemInitialValue, handleGetPlaceholder } from "./func";
4
+ import { handleUrlOptions, getJson, base64ToString } from "../../utils/method";
5
+ import SelectModelBackfillFormItem from "./selectModelBackfillFormItem";
6
+ import { useRef, useEffect, useCallback, Fragment } from "react";
7
+ import isoWeek from "dayjs/plugin/isoWeek";
8
+ import SelectModel from "./selectModel";
9
+ import MyCheckbox from "./myCheckbox";
10
+ import MyCascader from "./myCascader";
11
+ import dayjs from "dayjs";
12
+ import RadioCard from "./radioCard";
13
+ import MySelect from "./mySelect";
14
+ import MyUpload from "./myUpload";
15
+ import MyRadio from "./myRadio";
16
+ import { App, Col, Collapse, Card, Flex, Button, DatePicker, Tooltip } from "antd";
17
+ import { Form, Input, Calendar, Cell, DatetimePicker } from "react-vant";
18
+ dayjs.extend(isoWeek);
19
+ function useDynamicForm(props) {
20
+ const {
21
+ commonRequestWidthParams,
22
+ uploadAction,
23
+ commonRequest,
24
+ formConfig,
25
+ setFormConfig,
26
+ updateDelFileList,
27
+ interfaceTypeChildren,
28
+ interfaceTypeDict,
29
+ interfaceTypeSysDict,
30
+ relatedidKey,
31
+ actionUrlKey,
32
+ actionUrlExtraParams,
33
+ CustomModalComponent,
34
+ setAttrList,
35
+ hideAttrList = []
36
+ } = props;
37
+ const formConfigRef = useRef([]);
38
+ const { message } = App.useApp();
39
+ useEffect(() => {
40
+ if (!formConfig) {
41
+ return;
42
+ }
43
+ formConfigRef.current = formConfig;
44
+ }, [formConfig]);
45
+ const handleNormFile = useCallback((e) => {
46
+ if (Array.isArray(e)) {
47
+ return e;
48
+ }
49
+ return (e == null ? void 0 : e.fileList) ?? [];
50
+ }, []);
51
+ const handleDealFile = (file) => {
52
+ updateDelFileList(file);
53
+ };
54
+ const handleSetFormItemProps = useCallback(
55
+ (itemWithJson) => {
56
+ var _a, _b;
57
+ const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
58
+ const format = (_b = itemWithJson.json) == null ? void 0 : _b.format;
59
+ const baseProps = {};
60
+ switch (inputType) {
61
+ case "date-picker":
62
+ case "range-picker":
63
+ case "second-picker":
64
+ case "multiple-date-picker":
65
+ case "time-picker":
66
+ baseProps.onClick = (_2, action) => {
67
+ var _a2;
68
+ (_a2 = action.current) == null ? void 0 : _a2.open();
69
+ };
70
+ baseProps.isLink = true;
71
+ baseProps.trigger = "onConfirm";
72
+ break;
73
+ case "image":
74
+ case "file":
75
+ case "video":
76
+ case "audio":
77
+ baseProps.getValueFromEvent = handleNormFile;
78
+ break;
79
+ case "week-picker":
80
+ baseProps.getValueFromEvent = (date) => {
81
+ return `${date == null ? void 0 : date.year()}-${dayjs(date).isoWeek()}周`;
82
+ };
83
+ baseProps.getValueProps = (value) => {
84
+ if (!value)
85
+ return { value: null };
86
+ const [yearStr, weekStr] = value.split("-");
87
+ const year = Number(yearStr);
88
+ const week = Number(weekStr.replace("周", ""));
89
+ return {
90
+ value: dayjs().year(year).isoWeek(week)
91
+ };
92
+ };
93
+ break;
94
+ case "month-picker":
95
+ baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.format(format || "YYYY-MM");
96
+ baseProps.getValueProps = (value) => ({
97
+ value: value ? dayjs(value) : null
98
+ });
99
+ break;
100
+ case "quarter-picker":
101
+ baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.format(format || "YYYY年第Q季度");
102
+ baseProps.getValueProps = (value) => ({
103
+ value: value ? dayjs(value, format || "YYYY年第Q季度") : null
104
+ });
105
+ break;
106
+ case "year-picker":
107
+ baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.format(format || "YYYY");
108
+ baseProps.getValueProps = (value) => ({
109
+ value: value ? dayjs(value) : null
110
+ });
111
+ break;
112
+ case "second-picker":
113
+ baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.format(format || "HH:mm:ss");
114
+ baseProps.getValueProps = (value) => ({
115
+ value: value ? dayjs(value, format || "HH:mm:ss") : null
116
+ });
117
+ break;
118
+ }
119
+ return baseProps;
120
+ },
121
+ [handleNormFile]
122
+ );
123
+ const handleCollapseIcon = useCallback(
124
+ ({ isActive }) => isActive ? /* @__PURE__ */ jsx(MinusSquareOutlined, { style: { fontSize: 18, color: "#999" } }) : /* @__PURE__ */ jsx(PlusSquareOutlined, { style: { fontSize: 18, color: "#999" } }),
125
+ []
126
+ );
127
+ const handleDealInstruction = (itemWithJson, instructionShowMode) => {
128
+ var _a, _b, _c, _d, _e;
129
+ return /* @__PURE__ */ jsxs(Flex, { gap: 10, vertical: instructionShowMode === "flex", align: "center", children: [
130
+ /* @__PURE__ */ jsx("span", { children: itemWithJson.attrname }),
131
+ ((_a = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _a.instruction) && instructionShowMode === "icon" && /* @__PURE__ */ jsx(Tooltip, { title: (_b = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _b.instruction, children: /* @__PURE__ */ jsx(
132
+ InfoCircleOutlined,
133
+ {
134
+ style: {
135
+ color: ((_c = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _c["instruction-color"]) ?? "#888888",
136
+ fontSize: 16,
137
+ cursor: "pointer"
138
+ }
139
+ }
140
+ ) }) || /* @__PURE__ */ 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 })
141
+ ] });
142
+ };
143
+ const renderNestedFormList = useCallback(
144
+ ({
145
+ itemWithJson,
146
+ colNum = 1,
147
+ readonly = false,
148
+ instructionShowMode = "icon",
149
+ radioAlign = "horizontal",
150
+ formItemStyle,
151
+ relatedid,
152
+ form,
153
+ defaultWidth = 358,
154
+ parentFormListField,
155
+ isShowLabel = true
156
+ }) => {
157
+ const formListInitValue = handleSetFormItemInitialValue(itemWithJson);
158
+ let children = itemWithJson.children || [];
159
+ if (Array.isArray(children == null ? void 0 : children[0]) && children.length) {
160
+ children = children[0];
161
+ }
162
+ const getFormListName = (field) => {
163
+ const parentPath = (parentFormListField == null ? void 0 : parentFormListField.parentName) || (parentFormListField == null ? void 0 : parentFormListField.name);
164
+ if (parentPath) {
165
+ return Array.isArray(parentPath) ? [...parentPath, itemWithJson.attrid, field.name] : [parentPath, itemWithJson.attrid, field.name];
166
+ }
167
+ return [itemWithJson.attrid, field.name];
168
+ };
169
+ return /* @__PURE__ */ jsx(Col, { span: 24 / colNum, children: /* @__PURE__ */ jsx(
170
+ Collapse,
171
+ {
172
+ bordered: false,
173
+ defaultActiveKey: [itemWithJson.attrid],
174
+ style: { backgroundColor: "transparent" },
175
+ expandIcon: ({ isActive }) => handleCollapseIcon({ isActive }),
176
+ items: [
177
+ {
178
+ key: itemWithJson.attrid,
179
+ label: itemWithJson.attrname,
180
+ styles: {
181
+ header: {
182
+ paddingLeft: 0
183
+ }
184
+ },
185
+ children: /* @__PURE__ */ jsx(
186
+ Form.List,
187
+ {
188
+ name: parentFormListField ? Array.isArray(parentFormListField.name) ? [...parentFormListField.name, itemWithJson.attrid] : [parentFormListField.name, itemWithJson.attrid] : itemWithJson.attrid,
189
+ initialValue: formListInitValue,
190
+ children: (fields, { add, remove }) => /* @__PURE__ */ jsxs("div", { style: { display: "flex", rowGap: 16, flexDirection: "column" }, children: [
191
+ fields.map((field) => {
192
+ const nestedField = {
193
+ ...field,
194
+ parentName: getFormListName(field)
195
+ };
196
+ return /* @__PURE__ */ jsx(
197
+ Card,
198
+ {
199
+ style: { width: typeof defaultWidth === "number" ? defaultWidth + 100 : defaultWidth },
200
+ size: "small",
201
+ title: `${itemWithJson.attrname} ${field.name + 1}`,
202
+ extra: /* @__PURE__ */ jsx(
203
+ CloseOutlined,
204
+ {
205
+ onClick: () => {
206
+ if (fields.length > 1) {
207
+ remove(field.name);
208
+ } else {
209
+ message.warning("至少需要保留一个!");
210
+ }
211
+ }
212
+ }
213
+ ),
214
+ children: (children || []).map((child, index) => {
215
+ return /* @__PURE__ */ jsx(Fragment, { children: handleRenderItem({
216
+ item: child,
217
+ readonly,
218
+ colNum,
219
+ instructionShowMode,
220
+ relatedid,
221
+ form,
222
+ defaultWidth,
223
+ formItemStyle,
224
+ radioAlign,
225
+ isFormListItem: true,
226
+ formListField: nestedField,
227
+ isShowLabel: true
228
+ }) }, child.attrid || `child-${index}`);
229
+ })
230
+ },
231
+ field.key
232
+ );
233
+ }),
234
+ /* @__PURE__ */ jsx(Flex, { style: { width: 200 }, children: /* @__PURE__ */ jsx(Button, { type: "dashed", onClick: () => add(), block: true, children: "+ 新增" }) })
235
+ ] })
236
+ }
237
+ )
238
+ }
239
+ ]
240
+ },
241
+ itemWithJson.attrid
242
+ ) });
243
+ },
244
+ [handleCollapseIcon, handleSetFormItemInitialValue]
245
+ );
246
+ const handleRenderFunc = useCallback(
247
+ ({
248
+ itemWithJson,
249
+ colNum = 1,
250
+ readonly = false,
251
+ instructionShowMode = "icon",
252
+ radioAlign = "horizontal",
253
+ formItemStyle,
254
+ relatedid,
255
+ form,
256
+ defaultWidth = 358,
257
+ isFormListItem = false,
258
+ formListField,
259
+ isShowLabel = true
260
+ }) => {
261
+ var _a, _b, _c, _d, _e;
262
+ if (((_a = itemWithJson.json) == null ? void 0 : _a.hide) === true || (hideAttrList == null ? void 0 : hideAttrList.includes(itemWithJson.attrid))) {
263
+ return /* @__PURE__ */ jsx(Fragment$1, {});
264
+ }
265
+ if (itemWithJson.attrtype === 1) {
266
+ return renderNestedFormList({
267
+ itemWithJson,
268
+ colNum,
269
+ readonly,
270
+ instructionShowMode,
271
+ radioAlign,
272
+ formItemStyle,
273
+ relatedid,
274
+ form,
275
+ defaultWidth,
276
+ parentFormListField: formListField,
277
+ isShowLabel
278
+ });
279
+ }
280
+ if (itemWithJson.attrtype === 2) {
281
+ return /* @__PURE__ */ jsx(Fragment$1, { children: "实例信息" });
282
+ }
283
+ if (itemWithJson.attrtype === 0) {
284
+ const initialValue = handleSetFormItemInitialValue(itemWithJson);
285
+ const message2 = (_b = itemWithJson.json) == null ? void 0 : _b["default-prompt"];
286
+ const placeholder = handleGetPlaceholder(itemWithJson);
287
+ const { combinations = [] } = itemWithJson.json || {};
288
+ if (combinations == null ? void 0 : combinations.length) {
289
+ return /* @__PURE__ */ jsx(Flex, { children: combinations.map((item, index) => {
290
+ var _a2, _b2, _c2, _d2, _e2, _f, _g;
291
+ let initValue = handleSetFormItemInitialValue(item);
292
+ let width = defaultWidth;
293
+ const mode = item.json.input || "text";
294
+ const itemStyle = formItemStyle == null ? void 0 : formItemStyle.find((v) => v.type === mode);
295
+ if (itemStyle) {
296
+ (itemStyle == null ? void 0 : itemStyle.style) || {};
297
+ }
298
+ const widthRatio = (_a2 = item == null ? void 0 : item.json) == null ? void 0 : _a2["combination-width-ratio"];
299
+ if (widthRatio) {
300
+ width = 10 * widthRatio;
301
+ }
302
+ return /* @__PURE__ */ jsx(
303
+ Form.Item,
304
+ {
305
+ style: { flex: width },
306
+ label: index === 0 ? (_b2 = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _b2["combination-name"] : /* @__PURE__ */ jsx("div", { style: { visibility: "hidden" }, children: (_c2 = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _c2["combination-name"] }),
307
+ required: index === 0 ? (_d2 = item.json) == null ? void 0 : _d2.must : false,
308
+ name: formListField ? Array.isArray(formListField.name) ? [...formListField.name, item.attrid] : [formListField.name, item.attrid] : item.attrid,
309
+ initialValue: initValue,
310
+ rules: [
311
+ ...((_e2 = item.json) == null ? void 0 : _e2.must) ? [
312
+ {
313
+ required: true,
314
+ message: message2 || `${placeholder}${item.attrname}`
315
+ }
316
+ ] : [],
317
+ ...((_f = itemWithJson.json) == null ? void 0 : _f.regexp) ? [
318
+ {
319
+ pattern: new RegExp(itemWithJson.json.regexp.replace(/^\/|\/$/g, "")),
320
+ message: ((_g = itemWithJson.json) == null ? void 0 : _g["regexp-message"]) || `${itemWithJson.attrname}格式不正确`
321
+ }
322
+ ] : []
323
+ ],
324
+ ...handleSetFormItemProps(item),
325
+ children: handleRenderItemInputMode({
326
+ item,
327
+ readonly,
328
+ formItemStyle,
329
+ radioAlign,
330
+ relatedid,
331
+ form,
332
+ defaultWidth: width,
333
+ customWidth: { width: "100%" }
334
+ })
335
+ },
336
+ index
337
+ );
338
+ }) });
339
+ }
340
+ const formItemName = isFormListItem && formListField ? Array.isArray(formListField.name) ? [...formListField.name, itemWithJson.attrid] : [formListField.name, itemWithJson.attrid] : itemWithJson.attrid;
341
+ return /* @__PURE__ */ jsx(
342
+ Form.Item,
343
+ {
344
+ border: true,
345
+ name: formItemName,
346
+ label: isShowLabel && handleDealInstruction(itemWithJson, instructionShowMode) || null,
347
+ initialValue,
348
+ rules: [
349
+ ...((_c = itemWithJson.json) == null ? void 0 : _c.must) ? [
350
+ {
351
+ required: true,
352
+ message: `${placeholder}${itemWithJson.attrname}`
353
+ }
354
+ ] : [],
355
+ ...((_d = itemWithJson.json) == null ? void 0 : _d.regexp) ? [
356
+ {
357
+ pattern: new RegExp(itemWithJson.json.regexp.replace(/^\/|\/$/g, "")),
358
+ message: ((_e = itemWithJson.json) == null ? void 0 : _e["regexp-message"]) || `${itemWithJson.attrname}格式不正确`
359
+ }
360
+ ] : []
361
+ ],
362
+ ...handleSetFormItemProps(itemWithJson),
363
+ children: handleRenderItemInputMode({
364
+ item: itemWithJson,
365
+ readonly,
366
+ formItemStyle,
367
+ radioAlign,
368
+ relatedid,
369
+ form,
370
+ defaultWidth
371
+ })
372
+ },
373
+ itemWithJson.attrid
374
+ );
375
+ }
376
+ return null;
377
+ },
378
+ [handleDealInstruction, handleSetFormItemInitialValue, handleSetFormItemProps, hideAttrList, renderNestedFormList]
379
+ );
380
+ const handleOnRemove = async (file) => {
381
+ var _a;
382
+ try {
383
+ const data = (_a = file == null ? void 0 : file.response) == null ? void 0 : _a.data;
384
+ if (data) {
385
+ if (!commonRequestWidthParams)
386
+ return;
387
+ const result = await commonRequestWidthParams(
388
+ { Controlname: "DelFile", PageName: "initializationfile" },
389
+ data
390
+ );
391
+ if ((result == null ? void 0 : result.ReturnValue) !== 1) {
392
+ message.error((result == null ? void 0 : result.msg) || "删除文件失败");
393
+ return false;
394
+ }
395
+ } else {
396
+ handleDealFile(file);
397
+ }
398
+ return true;
399
+ } catch (error) {
400
+ message.error("删除文件失败,请重试");
401
+ return false;
402
+ }
403
+ };
404
+ const handleRenderItemInputMode = ({
405
+ item,
406
+ readonly = false,
407
+ formItemStyle = [],
408
+ radioAlign = "horizontal",
409
+ relatedid,
410
+ form,
411
+ defaultWidth = 358,
412
+ customWidth = {}
413
+ }) => {
414
+ var _a, _b, _c, _d;
415
+ const mode = item.json.input || "text";
416
+ const attrid = item.attrid;
417
+ const formatValue = handleSetFormItemInitialValue(item);
418
+ const message2 = ((_a = item.json) == null ? void 0 : _a["default-prompt"]) || "";
419
+ ((_b = item.json) == null ? void 0 : _b["disable-date-goover"]) || false;
420
+ const params = item.json.length && {
421
+ maxLength: item.json.length
422
+ } || {};
423
+ const itemStyle = formItemStyle.find((v) => v.type === mode);
424
+ switch (mode) {
425
+ case "label":
426
+ return /* @__PURE__ */ jsx(
427
+ Input,
428
+ {
429
+ disabled: true,
430
+ value: ((_c = item.json) == null ? void 0 : _c["label-value"]) || item.attrvalue || ((_d = item.json) == null ? void 0 : _d.default) || "-",
431
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
432
+ }
433
+ );
434
+ case "text":
435
+ return /* @__PURE__ */ jsx(
436
+ Input,
437
+ {
438
+ placeholder: message2 || "请输入",
439
+ ...params,
440
+ disabled: readonly,
441
+ clearable: true,
442
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
443
+ }
444
+ );
445
+ case "password":
446
+ return /* @__PURE__ */ jsx(
447
+ Input,
448
+ {
449
+ placeholder: message2 || "请输入",
450
+ ...params,
451
+ disabled: readonly,
452
+ type: "password",
453
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
454
+ }
455
+ );
456
+ case "textarea":
457
+ return /* @__PURE__ */ jsx(
458
+ Input.TextArea,
459
+ {
460
+ placeholder: message2 || "请输入",
461
+ autoSize: { minHeight: 80, maxHeight: 120 },
462
+ ...params,
463
+ disabled: readonly,
464
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
465
+ }
466
+ );
467
+ case "number":
468
+ return /* @__PURE__ */ jsx(
469
+ Input,
470
+ {
471
+ placeholder: message2 || "请输入",
472
+ ...params,
473
+ type: "number",
474
+ disabled: readonly,
475
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
476
+ }
477
+ );
478
+ case "mult-select":
479
+ case "select": {
480
+ return /* @__PURE__ */ jsx(
481
+ MySelect,
482
+ {
483
+ item: item.json,
484
+ readonly,
485
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
486
+ commonRequestWidthParams,
487
+ commonRequest,
488
+ value: formatValue,
489
+ interfaceTypeDict,
490
+ interfaceTypeSysDict,
491
+ actionUrlKey,
492
+ actionUrlExtraParams,
493
+ onChange: (val) => {
494
+ form.setFieldValue(item.attrid, val);
495
+ }
496
+ }
497
+ );
498
+ }
499
+ case "modal-mult-select":
500
+ case "modal-select": {
501
+ return /* @__PURE__ */ jsx(
502
+ SelectModel,
503
+ {
504
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
505
+ item: item.json,
506
+ value: item.attrvalue || item.json.default || "",
507
+ commonRequestWidthParams,
508
+ commonRequest,
509
+ onSure: async (value) => {
510
+ form.setFieldValue(item.attrid, value);
511
+ },
512
+ disabled: readonly,
513
+ CustomModalComponent
514
+ }
515
+ );
516
+ }
517
+ case "mul-field-modal-select": {
518
+ return /* @__PURE__ */ jsx(
519
+ SelectModelBackfillFormItem,
520
+ {
521
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
522
+ item: item.json,
523
+ form,
524
+ attrid,
525
+ value: item.attrvalue || item.json.default || "",
526
+ commonRequestWidthParams,
527
+ commonRequest,
528
+ onSure: async (value) => {
529
+ form.setFieldsValue(value);
530
+ },
531
+ disabled: readonly,
532
+ CustomModalComponent
533
+ }
534
+ );
535
+ }
536
+ case "date-picker":
537
+ return /* @__PURE__ */ jsx(DatetimePicker, { popup: true, type: "date", children: (val) => val ? dayjs(val).format("YYYY-MM-DD") : "请选择日期" });
538
+ case "week-picker":
539
+ case "month-picker":
540
+ case "quarter-picker":
541
+ case "year-picker": {
542
+ const pickerObj = {
543
+ "date-picker": "date",
544
+ "time-picker": "date",
545
+ "week-picker": "week",
546
+ "month-picker": "month",
547
+ "quarter-picker": "quarter",
548
+ "year-picker": "year",
549
+ "second-picker": "time"
550
+ };
551
+ return /* @__PURE__ */ jsx(
552
+ DatePicker,
553
+ {
554
+ picker: pickerObj[mode] || "date",
555
+ disabled: readonly,
556
+ placement: "bottomLeft",
557
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
558
+ }
559
+ );
560
+ }
561
+ case "time-picker": {
562
+ return /* @__PURE__ */ jsx(
563
+ DatetimePicker,
564
+ {
565
+ popup: {
566
+ round: true
567
+ },
568
+ type: "datetime",
569
+ title: "选择年月日时分",
570
+ onConfirm: (val) => {
571
+ form.setFieldValue(item.attrid, val);
572
+ },
573
+ children: (val) => {
574
+ return val ? /* @__PURE__ */ jsx("span", { style: { color: "#333333" }, children: dayjs(val).format("YYYY-MM-DD HH:mm") }) : "请选择时间";
575
+ }
576
+ }
577
+ );
578
+ }
579
+ case "second-picker": {
580
+ return /* @__PURE__ */ jsx(
581
+ DatetimePicker,
582
+ {
583
+ popup: {
584
+ round: true
585
+ },
586
+ type: "time",
587
+ title: "选择年月日",
588
+ onConfirm: (val) => {
589
+ form.setFieldValue(item.attrid, val);
590
+ },
591
+ children: (val) => {
592
+ return val ? /* @__PURE__ */ jsx("span", { style: { color: "#333333" }, children: val }) : "请选择时间";
593
+ }
594
+ }
595
+ );
596
+ }
597
+ case "range-picker":
598
+ return /* @__PURE__ */ jsx(Calendar, { type: "range", children: (val, actions) => {
599
+ form.setFieldValue(item.attrid, val);
600
+ return /* @__PURE__ */ jsx(
601
+ Cell,
602
+ {
603
+ style: { padding: 0 },
604
+ value: val ? val.map(
605
+ (el) => dayjs(el).format("YYYY-MM-DD")
606
+ ).join("~") : /* @__PURE__ */ jsx("span", { style: { color: "#969799" }, children: "请选择日期" }),
607
+ onClick: () => actions.open()
608
+ }
609
+ );
610
+ } });
611
+ case "multiple-date-picker":
612
+ return /* @__PURE__ */ jsx(Calendar, { type: "multiple", children: (val, actions) => {
613
+ form.setFieldValue(item.attrid, val);
614
+ return /* @__PURE__ */ jsx(
615
+ Cell,
616
+ {
617
+ style: { padding: 0 },
618
+ value: val ? val.map(
619
+ (el) => dayjs(el).format("YYYY-MM-DD")
620
+ ).join(",") : /* @__PURE__ */ jsx("span", { style: { color: "#969799" }, children: "请选择日期" }),
621
+ onClick: () => actions.open()
622
+ }
623
+ );
624
+ } });
625
+ case "radio":
626
+ return /* @__PURE__ */ jsx(
627
+ MyRadio,
628
+ {
629
+ radioAlign,
630
+ commonRequest,
631
+ commonRequestWidthParams,
632
+ item: item.json,
633
+ readonly,
634
+ options: params,
635
+ handleUrlOptions,
636
+ value: formatValue,
637
+ interfaceTypeDict,
638
+ interfaceTypeSysDict,
639
+ actionUrlKey,
640
+ actionUrlExtraParams,
641
+ onChange: (e) => {
642
+ form.setFieldValue(item.attrid, e.target.value);
643
+ }
644
+ }
645
+ );
646
+ case "checkbox":
647
+ return /* @__PURE__ */ jsx(
648
+ MyCheckbox,
649
+ {
650
+ radioAlign,
651
+ commonRequest,
652
+ commonRequestWidthParams,
653
+ item: item.json,
654
+ readonly,
655
+ options: params,
656
+ value: formatValue,
657
+ handleUrlOptions,
658
+ interfaceTypeDict,
659
+ interfaceTypeSysDict,
660
+ actionUrlKey,
661
+ actionUrlExtraParams,
662
+ onChange: (val) => {
663
+ form.setFieldValue(item.attrid, val.join(","));
664
+ }
665
+ }
666
+ );
667
+ case "audio":
668
+ case "file":
669
+ case "image":
670
+ case "video":
671
+ return /* @__PURE__ */ jsx(
672
+ MyUpload,
673
+ {
674
+ action: uploadAction && uploadAction("initializationfile"),
675
+ item: item.json,
676
+ uploadType: mode,
677
+ list: formatValue,
678
+ readonly,
679
+ relatedid,
680
+ relatedidKey,
681
+ onRemove: (file) => handleOnRemove(file)
682
+ }
683
+ );
684
+ case "cascader":
685
+ return /* @__PURE__ */ jsx(
686
+ MyCascader,
687
+ {
688
+ commonRequestWidthParams,
689
+ commonRequest,
690
+ item: item.json,
691
+ value: item.attrvalue,
692
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
693
+ interfaceTypeDict,
694
+ interfaceTypeSysDict,
695
+ actionUrlKey,
696
+ actionUrlExtraParams
697
+ }
698
+ );
699
+ case "radio-card":
700
+ return /* @__PURE__ */ jsx(
701
+ RadioCard,
702
+ {
703
+ item: item.json,
704
+ readonly,
705
+ onChange: (value) => {
706
+ form.setFieldValue(item.attrid, value);
707
+ },
708
+ commonRequestWidthParams
709
+ }
710
+ );
711
+ default:
712
+ return /* @__PURE__ */ jsx(
713
+ Input,
714
+ {
715
+ placeholder: "请输入",
716
+ ...params,
717
+ clearable: true,
718
+ disabled: readonly,
719
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
720
+ }
721
+ );
722
+ }
723
+ };
724
+ const handleRenderItem = ({
725
+ item,
726
+ readonly = false,
727
+ colNum = 1,
728
+ instructionShowMode = "icon",
729
+ relatedid,
730
+ form,
731
+ defaultWidth = 358,
732
+ formItemStyle,
733
+ radioAlign = "horizontal",
734
+ isFormListItem = false,
735
+ formListField,
736
+ isShowLabel = true
737
+ }) => {
738
+ var _a;
739
+ const json = item.info_base64 === 1 ? getJson(base64ToString(item.info)) : getJson(item.info);
740
+ const itemWithJson = {
741
+ ...item,
742
+ json: {
743
+ ...item == null ? void 0 : item.json,
744
+ ...json
745
+ }
746
+ };
747
+ if (((_a = itemWithJson.json) == null ? void 0 : _a.hide) === true) {
748
+ return null;
749
+ }
750
+ return /* @__PURE__ */ jsx(Fragment, { children: handleRenderFunc({
751
+ itemWithJson,
752
+ readonly,
753
+ colNum,
754
+ instructionShowMode,
755
+ relatedid,
756
+ form,
757
+ defaultWidth,
758
+ formItemStyle,
759
+ radioAlign,
760
+ isFormListItem,
761
+ formListField,
762
+ isShowLabel
763
+ }) }, itemWithJson.attrid);
764
+ };
765
+ return {
766
+ handleRenderItem,
767
+ handleSetFormItemInitialValue
768
+ };
769
+ }
770
+ export {
771
+ useDynamicForm as default
772
+ };