szld-libs 0.2.99 → 0.3.2

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 (94) hide show
  1. package/dist/style.css +1 -1
  2. package/dist/szld-components.es.js +32023 -20148
  3. package/dist/szld-components.umd.js +72 -60
  4. package/es/components/DynamicForm/index.js +3 -2
  5. package/es/components/DynamicForm/selectModelBackfillFormItem/index.js +8 -7
  6. package/es/components/DynamicFormMobile/func.d.ts +35 -0
  7. package/es/components/DynamicFormMobile/func.js +204 -0
  8. package/es/components/DynamicFormMobile/index.d.ts +116 -0
  9. package/es/components/DynamicFormMobile/index.js +134 -0
  10. package/es/components/DynamicFormMobile/myCascader/index.d.ts +17 -0
  11. package/es/components/DynamicFormMobile/myCascader/index.js +196 -0
  12. package/es/components/DynamicFormMobile/myCascader/vite.svg +1 -0
  13. package/es/components/DynamicFormMobile/myCheckbox/index.d.ts +19 -0
  14. package/es/components/DynamicFormMobile/myCheckbox/index.js +109 -0
  15. package/es/components/DynamicFormMobile/myCheckbox/vite.svg +1 -0
  16. package/es/components/DynamicFormMobile/myRadio/index.d.ts +20 -0
  17. package/es/components/DynamicFormMobile/myRadio/index.js +107 -0
  18. package/es/components/DynamicFormMobile/myRadio/vite.svg +1 -0
  19. package/es/components/DynamicFormMobile/mySelect/index.css +31 -0
  20. package/es/components/DynamicFormMobile/mySelect/index.d.ts +16 -0
  21. package/es/components/DynamicFormMobile/mySelect/index.js +147 -0
  22. package/es/components/DynamicFormMobile/mySelect/vite.svg +1 -0
  23. package/es/components/DynamicFormMobile/myUpload/index.css +3 -0
  24. package/es/components/DynamicFormMobile/myUpload/index.d.ts +16 -0
  25. package/es/components/DynamicFormMobile/myUpload/index.js +103 -0
  26. package/es/components/DynamicFormMobile/myUpload/vite.svg +1 -0
  27. package/es/components/DynamicFormMobile/radioCard/index.d.ts +12 -0
  28. package/es/components/DynamicFormMobile/radioCard/index.js +142 -0
  29. package/es/components/DynamicFormMobile/radioCard/vite.svg +1 -0
  30. package/es/components/DynamicFormMobile/selectModel/index.d.ts +22 -0
  31. package/es/components/DynamicFormMobile/selectModel/index.js +235 -0
  32. package/es/components/DynamicFormMobile/selectModel/vite.svg +1 -0
  33. package/es/components/DynamicFormMobile/selectModelBackfillFormItem/index.d.ts +27 -0
  34. package/es/components/DynamicFormMobile/selectModelBackfillFormItem/index.js +242 -0
  35. package/es/components/DynamicFormMobile/selectModelBackfillFormItem/vite.svg +1 -0
  36. package/es/components/DynamicFormMobile/useDynamicForm.d.ts +43 -0
  37. package/es/components/DynamicFormMobile/useDynamicForm.js +772 -0
  38. package/es/components/DynamicFormMobile/vite.svg +1 -0
  39. package/es/index.css +1 -0
  40. package/es/index.d.ts +1 -1
  41. package/es/index.js +35 -29
  42. package/es/main.d.ts +2 -1
  43. package/es/main.js +22 -20
  44. package/es/mock/index.js +20 -59
  45. package/es/services/index.js +3 -5
  46. package/es/services/request.js +2 -2
  47. package/es/utils/method.d.ts +6 -1
  48. package/es/utils/method.js +60 -34
  49. package/lib/components/DynamicForm/index.js +3 -2
  50. package/lib/components/DynamicForm/selectModelBackfillFormItem/index.js +8 -7
  51. package/lib/components/DynamicFormMobile/func.d.ts +35 -0
  52. package/lib/components/DynamicFormMobile/func.js +204 -0
  53. package/lib/components/DynamicFormMobile/index.d.ts +116 -0
  54. package/lib/components/DynamicFormMobile/index.js +133 -0
  55. package/lib/components/DynamicFormMobile/myCascader/index.d.ts +17 -0
  56. package/lib/components/DynamicFormMobile/myCascader/index.js +195 -0
  57. package/lib/components/DynamicFormMobile/myCascader/vite.svg +1 -0
  58. package/lib/components/DynamicFormMobile/myCheckbox/index.d.ts +19 -0
  59. package/lib/components/DynamicFormMobile/myCheckbox/index.js +108 -0
  60. package/lib/components/DynamicFormMobile/myCheckbox/vite.svg +1 -0
  61. package/lib/components/DynamicFormMobile/myRadio/index.d.ts +20 -0
  62. package/lib/components/DynamicFormMobile/myRadio/index.js +106 -0
  63. package/lib/components/DynamicFormMobile/myRadio/vite.svg +1 -0
  64. package/lib/components/DynamicFormMobile/mySelect/index.css +31 -0
  65. package/lib/components/DynamicFormMobile/mySelect/index.d.ts +16 -0
  66. package/lib/components/DynamicFormMobile/mySelect/index.js +146 -0
  67. package/lib/components/DynamicFormMobile/mySelect/vite.svg +1 -0
  68. package/lib/components/DynamicFormMobile/myUpload/index.css +3 -0
  69. package/lib/components/DynamicFormMobile/myUpload/index.d.ts +16 -0
  70. package/lib/components/DynamicFormMobile/myUpload/index.js +102 -0
  71. package/lib/components/DynamicFormMobile/myUpload/vite.svg +1 -0
  72. package/lib/components/DynamicFormMobile/radioCard/index.d.ts +12 -0
  73. package/lib/components/DynamicFormMobile/radioCard/index.js +141 -0
  74. package/lib/components/DynamicFormMobile/radioCard/vite.svg +1 -0
  75. package/lib/components/DynamicFormMobile/selectModel/index.d.ts +22 -0
  76. package/lib/components/DynamicFormMobile/selectModel/index.js +235 -0
  77. package/lib/components/DynamicFormMobile/selectModel/vite.svg +1 -0
  78. package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/index.d.ts +27 -0
  79. package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/index.js +242 -0
  80. package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/vite.svg +1 -0
  81. package/lib/components/DynamicFormMobile/useDynamicForm.d.ts +43 -0
  82. package/lib/components/DynamicFormMobile/useDynamicForm.js +771 -0
  83. package/lib/components/DynamicFormMobile/vite.svg +1 -0
  84. package/lib/index.css +1 -0
  85. package/lib/index.d.ts +1 -1
  86. package/lib/index.js +35 -29
  87. package/lib/main.d.ts +2 -1
  88. package/lib/main.js +2 -0
  89. package/lib/mock/index.js +20 -59
  90. package/lib/services/index.js +3 -5
  91. package/lib/services/request.js +2 -2
  92. package/lib/utils/method.d.ts +6 -1
  93. package/lib/utils/method.js +60 -34
  94. package/package.json +1 -1
@@ -29,7 +29,8 @@ const DynamicForm = forwardRef((props, ref) => {
29
29
  hideAttrList = [],
30
30
  formShowType = "form",
31
31
  headerWidth,
32
- formListItemWidth
32
+ formListItemWidth,
33
+ formListItemName
33
34
  } = props;
34
35
  const delFileListRef = useRef([]);
35
36
  const updateDelFileList = (file) => {
@@ -57,7 +58,7 @@ const DynamicForm = forwardRef((props, ref) => {
57
58
  return delFileListRef.current;
58
59
  }
59
60
  }));
60
- return /* @__PURE__ */ jsx(Fragment, { children: formShowType === "table" ? /* @__PURE__ */ jsx(Form.List, { name: "customFormList", initialValue: [{}], children: (fields, { add, remove }) => /* @__PURE__ */ jsxs("div", { className: "custom-form-list", children: [
61
+ return /* @__PURE__ */ jsx(Fragment, { children: formShowType === "table" ? /* @__PURE__ */ jsx(Form.List, { name: formListItemName || "customFormList", initialValue: [{}], children: (fields, { add, remove }) => /* @__PURE__ */ jsxs("div", { className: "custom-form-list", children: [
61
62
  /* @__PURE__ */ jsxs(Flex, { align: "center", children: [
62
63
  /* @__PURE__ */ jsx(Flex, { className: "custom-form-list-header", align: "center", children: formConfig == null ? void 0 : formConfig.map((child, index) => {
63
64
  return /* @__PURE__ */ jsxs(Flex, { style: { width: (headerWidth == null ? void 0 : headerWidth[index]) || defaultWidth }, align: "center", children: [
@@ -72,21 +72,22 @@ function SelectModel(props) {
72
72
  message.error("请配置action-url");
73
73
  };
74
74
  const openModal = () => {
75
- var _a, _b;
75
+ var _a;
76
76
  if (disabled) {
77
77
  return;
78
78
  }
79
79
  if (value) {
80
- const keyFieldList = ((_a = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a.list) ?? [];
81
- const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) ?? "-";
82
- if (!keyFieldList.length) {
80
+ const keyField = item == null ? void 0 : item["key-field"];
81
+ const el = keyField == null ? void 0 : keyField[attrid];
82
+ const { delimiter = "-", list = [] } = el || {};
83
+ if (!keyField) {
83
84
  message.error("请配置key-field");
84
85
  return;
85
86
  }
86
87
  switch (mode) {
87
- case "modal-select":
88
- const id = value == null ? void 0 : value.split("-");
89
- const index = dataSource == null ? void 0 : dataSource.findIndex((item2) => id.includes((item2 == null ? void 0 : item2.typeid) || (item2 == null ? void 0 : item2.instanceid)));
88
+ case "mul-field-modal-select":
89
+ const id = (_a = value == null ? void 0 : value.split(delimiter)) == null ? void 0 : _a[0];
90
+ const index = dataSource == null ? void 0 : dataSource.findIndex((item2) => Object.values(item2).includes(id));
90
91
  setSelectedRowKeys([index]);
91
92
  break;
92
93
  case "modal-mult-select":
@@ -0,0 +1,35 @@
1
+ import { IformConfigItem, Ijson } from './index.d';
2
+ import { RangePickerProps } from 'antd/es/date-picker';
3
+ import { AxiosResponse } from 'axios';
4
+ export declare const handleGetPlaceholder: (itemWithJson: IformConfigItem) => string;
5
+ /**
6
+ * 处理表单项目初始值
7
+ * 根据输入类型转换初始值为组件所需格式
8
+ */
9
+ export declare const handleSetFormItemInitialValue: (itemWithJson: IformConfigItem) => any;
10
+ export declare const disabledDate: RangePickerProps['disabledDate'];
11
+ /**
12
+ * 处理URL选项
13
+ * 将URL中的指定字段拼接为字符串
14
+ */
15
+ export declare const handleUrlOptions: (val: any, delimiter: string, list: any[]) => string;
16
+ /**
17
+ * 根据配置处理成下拉数据
18
+ * @param param0
19
+ * @returns
20
+ */
21
+ export declare const handleSelectOptions: ({ commonRequestWidthParams, commonRequest, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, item, }: {
22
+ commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
23
+ commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
24
+ interfaceTypeDict?: string | undefined;
25
+ interfaceTypeSysDict?: string | undefined;
26
+ actionUrlKey?: string | undefined;
27
+ actionUrlExtraParams?: object | undefined;
28
+ item: Ijson;
29
+ }) => Promise<any[]>;
30
+ /**
31
+ * attrList 格式的单层数组 处理成对象{attrid:attrname}
32
+ */
33
+ export declare const handleGetSingleAttrListObj: (children: any[]) => {
34
+ [key: string]: any;
35
+ }[];
@@ -0,0 +1,204 @@
1
+ import dayjs from "dayjs";
2
+ import { message } from "antd";
3
+ const handleGetPlaceholder = (itemWithJson) => {
4
+ const { input = "" } = itemWithJson.json || {};
5
+ let placeholder = "请输入";
6
+ if ([
7
+ "radio",
8
+ "checkbox",
9
+ "select",
10
+ "mult-select",
11
+ "modal-select",
12
+ "date-picker",
13
+ "range-picker",
14
+ "multiple-date-picker",
15
+ "time-picker",
16
+ "week-picker",
17
+ "month-picker",
18
+ "quarter-picker",
19
+ "year-picker",
20
+ "second-picker"
21
+ ].includes(input)) {
22
+ placeholder = "请选择";
23
+ }
24
+ if (["image", "file", "video", "audio"].includes(input)) {
25
+ placeholder = "请上传";
26
+ }
27
+ return placeholder;
28
+ };
29
+ const handleSetFormItemInitialValue = (itemWithJson) => {
30
+ var _a, _b, _c, _d;
31
+ const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
32
+ let initialValue = itemWithJson.attrvalue || ((_b = itemWithJson.json) == null ? void 0 : _b.default) || "";
33
+ if (inputType === "label" && initialValue) {
34
+ initialValue = ((_c = itemWithJson.json) == null ? void 0 : _c["label-value"]) ?? initialValue ?? "-";
35
+ }
36
+ if (inputType === "range-picker" && initialValue) {
37
+ try {
38
+ initialValue = initialValue == null ? void 0 : initialValue.split("~");
39
+ initialValue = initialValue.map((v) => v);
40
+ } catch (error) {
41
+ initialValue = void 0;
42
+ }
43
+ }
44
+ if (inputType === "multiple-date-picker" && initialValue) {
45
+ try {
46
+ initialValue = initialValue == null ? void 0 : initialValue.split(",");
47
+ initialValue = initialValue.map((v) => dayjs());
48
+ } catch (error) {
49
+ initialValue = void 0;
50
+ }
51
+ }
52
+ if (inputType === "cascader" && initialValue && typeof initialValue === "string") {
53
+ const delimiter = (_d = itemWithJson.json) == null ? void 0 : _d["cascader-delimiter"];
54
+ if (delimiter) {
55
+ initialValue = initialValue.split(delimiter).filter(Boolean);
56
+ }
57
+ }
58
+ if (["mult-select", "checkbox"].includes(inputType) && initialValue && typeof initialValue === "string") {
59
+ initialValue = initialValue.split(",").filter(Boolean);
60
+ }
61
+ if (["image", "video", "audio", "file"].includes(inputType) && initialValue) {
62
+ try {
63
+ const fileList = Array.isArray(initialValue) ? initialValue : JSON.parse(initialValue);
64
+ initialValue = fileList.map((file) => ({
65
+ ...file,
66
+ url: file.FilePath,
67
+ name: file.FileName,
68
+ uid: file.FileId
69
+ }));
70
+ } catch (error) {
71
+ initialValue = [];
72
+ }
73
+ }
74
+ if (itemWithJson.attrtype === 1) {
75
+ initialValue = handleGetSingleAttrListObj(itemWithJson.children || []);
76
+ }
77
+ return initialValue || void 0;
78
+ };
79
+ const disabledDate = (current) => {
80
+ return current && current < dayjs().startOf("day");
81
+ };
82
+ const handleUrlOptions = (val, delimiter, list) => {
83
+ let arr = [];
84
+ list.forEach((item) => {
85
+ arr.push(val == null ? void 0 : val[item]);
86
+ });
87
+ return arr.join(delimiter || "-");
88
+ };
89
+ const handleSelectOptions = async ({
90
+ commonRequestWidthParams,
91
+ commonRequest,
92
+ interfaceTypeDict = "YLZDDictList",
93
+ interfaceTypeSysDict = "YLZDSysConfigList",
94
+ actionUrlKey = "action-url",
95
+ actionUrlExtraParams = {},
96
+ item
97
+ }) => {
98
+ var _a;
99
+ let options = [];
100
+ const getDict = async (interfaceType) => {
101
+ var _a2;
102
+ let list = [];
103
+ if (item.classify) {
104
+ try {
105
+ const response = await commonRequest(interfaceType, {
106
+ asctypeid: item.classify
107
+ });
108
+ if (((_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.list) && Array.isArray(response.data.list)) {
109
+ list = response.data.list.map((dictItem) => ({
110
+ label: `${dictItem.dicid || ""}-${dictItem.info || ""}`,
111
+ value: `${dictItem.dicid || ""}-${dictItem.info || ""}`
112
+ }));
113
+ }
114
+ } catch (error) {
115
+ message.error("加载选项失败");
116
+ }
117
+ }
118
+ return list;
119
+ };
120
+ const getUrlOptions = async () => {
121
+ var _a2, _b;
122
+ try {
123
+ const keyFieldList = ((_a2 = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a2.list) || [];
124
+ const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "";
125
+ if (!keyFieldList.length) {
126
+ message.error("请配置key-field");
127
+ return;
128
+ }
129
+ const response = await commonRequestWidthParams(
130
+ {
131
+ PageName: "dns_relay",
132
+ Controlname: "CallActionUrl",
133
+ InterfaceType: ""
134
+ },
135
+ {
136
+ [actionUrlKey]: item == null ? void 0 : item["action-url"],
137
+ ...actionUrlExtraParams
138
+ }
139
+ );
140
+ if (response == null ? void 0 : response.data) {
141
+ const data = response == null ? void 0 : response.data;
142
+ const list = (data == null ? void 0 : data.list) || [];
143
+ let urlData = [];
144
+ if (Array.isArray(data)) {
145
+ urlData = data;
146
+ }
147
+ if (Array.isArray(list)) {
148
+ urlData = list;
149
+ }
150
+ options = urlData.map((val) => ({
151
+ label: handleUrlOptions(val, delimiter, keyFieldList),
152
+ value: handleUrlOptions(val, delimiter, keyFieldList)
153
+ }));
154
+ }
155
+ } catch (error) {
156
+ message.error("加载选项失败");
157
+ }
158
+ };
159
+ if (item.inputType === "local") {
160
+ options = ((_a = item.data) == null ? void 0 : _a.map((val) => ({
161
+ label: val,
162
+ value: val
163
+ }))) || [];
164
+ if (item.options && Array.isArray(item.options)) {
165
+ options = item.options;
166
+ }
167
+ } else if (item.inputType === "dictionary") {
168
+ options = await getDict(interfaceTypeDict);
169
+ } else if (item.inputType === "system-dictionary") {
170
+ options = await getDict(interfaceTypeSysDict);
171
+ }
172
+ if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
173
+ await getUrlOptions();
174
+ }
175
+ return options;
176
+ };
177
+ const handleGetSingleAttrListObj = (children) => {
178
+ if (!(children == null ? void 0 : children.length)) {
179
+ return [];
180
+ }
181
+ const dealList = (children2) => children2 == null ? void 0 : children2.map((v) => {
182
+ const obj = {};
183
+ if (Array.isArray(v)) {
184
+ v.forEach((x) => {
185
+ var _a;
186
+ if ((_a = x == null ? void 0 : x.children) == null ? void 0 : _a.length) {
187
+ obj[x.attrid] = dealList(x.children);
188
+ } else {
189
+ obj[x.attrid] = x.attrvalue;
190
+ }
191
+ });
192
+ }
193
+ return obj;
194
+ });
195
+ return dealList(children);
196
+ };
197
+ export {
198
+ disabledDate,
199
+ handleGetPlaceholder,
200
+ handleGetSingleAttrListObj,
201
+ handleSelectOptions,
202
+ handleSetFormItemInitialValue,
203
+ handleUrlOptions
204
+ };
@@ -0,0 +1,116 @@
1
+ import dayjs from 'dayjs';
2
+
3
+ export interface IformConfigItem {
4
+ xh: number;
5
+ asid: string;
6
+ astype: number;
7
+ tname: string;
8
+ attrid: string;
9
+ attrname: string;
10
+ attrtype: number;
11
+ info: string;
12
+ info_base64: number;
13
+ createtime: string;
14
+ attrvalue: any;
15
+ serialnum: number;
16
+ children: any[];
17
+ json: Ijson;
18
+ }
19
+
20
+ export interface Ijson {
21
+ 'action-url-extra-params'?: { [key: string]: any }; // 弹窗选择对应多个表单字段时,额外的参数
22
+ 'disable-date-goover'?: boolean; // 禁用日期选择器超出当前日期
23
+ 'default-prompt'?: string; // 提示信息
24
+ 'regexp-message'?: string; // 正则表达式提示信息
25
+ regexp: any; // 正则表达式
26
+ 'properties-width'?: number; // 属性集表单宽度
27
+ 'properties-multiple'?: boolean; // 是否支持可增减的表单列表
28
+ propertiesID: string;
29
+ 'combination-name'?: string; // 组合表单名称
30
+ combinations: any; // 组合表单配置
31
+ input: InputType;
32
+ length?: number;
33
+ 'label-value'?: string; //代表属性固定取值,并且不可在实例化时修改
34
+ hide: true;
35
+ 'upload-accept'?: string;
36
+ 'upload-max-count'?: number;
37
+ 'upload-size'?: number;
38
+ //代表弹窗标题
39
+ 'modal-caption'?: string;
40
+ //代表弹窗宽度
41
+ 'modal-width'?: number;
42
+ //代表弹窗高度
43
+ 'modal-height'?: number;
44
+ //代表弹窗列表表头内容
45
+ 'modal-field-list'?: { [key: string]: string }; // 键值对,键为属性名,值为属性显示的列表表头内容
46
+ inputType?: 'local' | 'dictionary' | 'url' | 'system-dictionary';
47
+ data?: string[];
48
+ //代表调用【字典管理系统】的值
49
+ classify?: number | string | undefined;
50
+ //代表调用字典对应的归类名 ID
51
+ //代表从"action-url"从获取选择的数据
52
+ 'action-url'?: string;
53
+ //代表执行一个动作的 UCE 的 url
54
+ 'key-field'?: { list: string[]; delimiter: string };
55
+ default?: string | number | boolean | null | undefined | dayjs.Dayjs;
56
+ //代表属性默认值,如果没配置或空着,则代表没有默认值
57
+ instruction?: '';
58
+ //代表在实例化时对属性的填写说明,会作为提示语显示在属性名称旁
59
+ 'instruction-color'?: '#000000';
60
+ //代表在实例化时对属性的填写说明,字体颜色的配置,如果不配置默认#333333
61
+ must?: true;
62
+ //代表属性值是否必填,true 为必填、false 为非必填,如果没配置则默认为 false
63
+ 'cascader-delimiter'?: string;
64
+ options?: { label: string; value: string | number }[];
65
+ format?: string;
66
+ }
67
+
68
+ // 定义支持的输入类型枚举
69
+ export type InputType =
70
+ | 'text'
71
+ | 'password'
72
+ | 'textarea'
73
+ | 'number'
74
+ | 'select'
75
+ | 'mult-select'
76
+ | 'modal-select'
77
+ | 'modal-mult-select'
78
+ | 'date-picker'
79
+ | 'time-picker'
80
+ | 'week-picker'
81
+ | 'month-picker'
82
+ | 'quarter-picker'
83
+ | 'range-picker'
84
+ | 'multiple-date-picker'
85
+ | 'year-picker'
86
+ | 'second-picker'
87
+ | 'image'
88
+ | 'file'
89
+ | 'video'
90
+ | 'audio'
91
+ | 'label'
92
+ | 'radio'
93
+ | 'checkbox'
94
+ | 'cascader'
95
+ | 'mult-field-modal-select' // 弹窗选择对应多个表单字段
96
+ | string;
97
+
98
+ // 定义文件上传值类型
99
+ export interface CustomUploadFile {
100
+ FilePath: string;
101
+ FileName: string;
102
+ FileId: string;
103
+ url?: string;
104
+ name?: string;
105
+ uid?: string;
106
+ }
107
+
108
+ export interface IformItemStyle {
109
+ type: InputType;
110
+ style?: React.CSSProperties;
111
+ }
112
+
113
+ export interface Iselect {
114
+ label: string;
115
+ value: string | number;
116
+ }
@@ -0,0 +1,134 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { forwardRef, useRef, useImperativeHandle, Fragment as Fragment$1 } from "react";
3
+ import { Flex, Row } from "antd";
4
+ import useDynamicForm from "./useDynamicForm";
5
+ import { Form, Button } from "react-vant";
6
+ import { Plus } from "@react-vant/icons";
7
+ const DynamicForm = forwardRef((props, ref) => {
8
+ const [form] = Form.useForm();
9
+ const {
10
+ formConfig,
11
+ setFormConfig,
12
+ setAttrList,
13
+ readonly = false,
14
+ relatedid,
15
+ colNum = 1,
16
+ colSpace = [0, 0],
17
+ instructionShowMode = "flex",
18
+ defaultWidth = "100%",
19
+ commonRequestWidthParams,
20
+ uploadAction,
21
+ commonRequest,
22
+ formItemStyle = [],
23
+ radioAlign = "horizontal",
24
+ interfaceTypeChildren = "YLLRDetailAttrlist",
25
+ interfaceTypeDict = "YLZDDictList",
26
+ interfaceTypeSysDict = "YLZDSysConfigList",
27
+ relatedidKey = "relatedid",
28
+ actionUrlKey = "action-url",
29
+ actionUrlExtraParams = {},
30
+ CustomModalComponent,
31
+ hideAttrList = [],
32
+ formShowType = "form",
33
+ formListItemWidth,
34
+ formListItemName
35
+ } = props;
36
+ const delFileListRef = useRef([]);
37
+ const updateDelFileList = (file) => {
38
+ delFileListRef.current.push(file);
39
+ };
40
+ const { handleRenderItem } = useDynamicForm({
41
+ commonRequestWidthParams,
42
+ uploadAction,
43
+ commonRequest,
44
+ setFormConfig,
45
+ setAttrList,
46
+ updateDelFileList,
47
+ formConfig,
48
+ interfaceTypeChildren,
49
+ interfaceTypeDict,
50
+ interfaceTypeSysDict,
51
+ relatedidKey,
52
+ actionUrlKey,
53
+ actionUrlExtraParams,
54
+ CustomModalComponent,
55
+ hideAttrList
56
+ });
57
+ useImperativeHandle(ref, () => ({
58
+ getDelFileList: () => {
59
+ return delFileListRef.current;
60
+ },
61
+ submitForm: async () => {
62
+ try {
63
+ const values = await form.validateFields();
64
+ return values;
65
+ } catch (error) {
66
+ }
67
+ }
68
+ }));
69
+ return /* @__PURE__ */ jsx(Form, { layout: "vertical", form, children: formShowType === "table" ? /* @__PURE__ */ jsx(Form.List, { name: formListItemName || "customFormList", initialValue: [{}], children: (fields, { add, remove }) => /* @__PURE__ */ jsxs(Fragment, { children: [
70
+ fields.map((field, idx) => /* @__PURE__ */ jsxs(
71
+ "div",
72
+ {
73
+ className: "form-list-item",
74
+ style: {
75
+ borderRadius: 8,
76
+ marginBottom: 10
77
+ },
78
+ children: [
79
+ /* @__PURE__ */ jsxs(
80
+ Flex,
81
+ {
82
+ justify: "space-between",
83
+ style: {
84
+ height: 44,
85
+ width: "calc(100vw - 32px)",
86
+ marginLeft: 16,
87
+ borderBottom: "1px solid #E3E3E3"
88
+ },
89
+ align: "center",
90
+ children: [
91
+ /* @__PURE__ */ jsxs("span", { style: { color: "#555555" }, children: [
92
+ "第",
93
+ idx + 1,
94
+ "条"
95
+ ] }),
96
+ /* @__PURE__ */ jsx("a", { style: { color: "#ff4d4f" }, onClick: () => remove(idx), children: "删除" })
97
+ ]
98
+ }
99
+ ),
100
+ /* @__PURE__ */ jsx("div", { className: "form-list-item__control", children: formConfig == null ? void 0 : formConfig.map((child, index) => {
101
+ return /* @__PURE__ */ jsx(Fragment$1, { children: handleRenderItem({
102
+ item: child,
103
+ readonly,
104
+ colNum,
105
+ instructionShowMode,
106
+ relatedid,
107
+ form,
108
+ defaultWidth: (formListItemWidth == null ? void 0 : formListItemWidth[index]) || defaultWidth,
109
+ formItemStyle,
110
+ isFormListItem: true,
111
+ formListField: field,
112
+ isShowLabel: false
113
+ }) }, index);
114
+ }) })
115
+ ]
116
+ },
117
+ idx
118
+ )),
119
+ /* @__PURE__ */ jsx("div", { style: { padding: 10 }, children: /* @__PURE__ */ jsx(Button, { plain: true, icon: /* @__PURE__ */ jsx(Plus, {}), style: { width: "100%" }, type: "primary", onClick: () => add({}), children: "新增" }) })
120
+ ] }) }) : /* @__PURE__ */ jsx(Row, { gutter: colSpace, children: formConfig.map((item, index) => /* @__PURE__ */ jsx(Fragment$1, { children: handleRenderItem({
121
+ item,
122
+ readonly,
123
+ colNum,
124
+ instructionShowMode,
125
+ relatedid,
126
+ form,
127
+ defaultWidth,
128
+ formItemStyle,
129
+ radioAlign
130
+ }) }, item.attrid || `form-item-${index}`)) }) });
131
+ });
132
+ export {
133
+ DynamicForm as default
134
+ };
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { AxiosResponse } from 'axios';
3
+ interface MyCascaderProps {
4
+ item: any;
5
+ readonly?: boolean;
6
+ value?: string[];
7
+ onChange?: (value: any) => void;
8
+ style?: React.CSSProperties;
9
+ commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
10
+ commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
11
+ interfaceTypeDict: string;
12
+ interfaceTypeSysDict: string;
13
+ actionUrlKey: string;
14
+ actionUrlExtraParams: object;
15
+ }
16
+ declare const MyCascader: ({ item, readonly, value, onChange, style, commonRequestWidthParams, commonRequest, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, }: MyCascaderProps) => import("react/jsx-runtime").JSX.Element;
17
+ export default MyCascader;