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