szld-libs 0.2.69 → 0.2.71
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/szld-components.es.js +12770 -12501
- package/dist/szld-components.umd.js +53 -53
- package/es/components/DynamicForm/index.d.ts +7 -30
- package/es/components/DynamicForm/index.js +52 -7
- package/es/components/DynamicForm/useDynamicForm.d.ts +8 -2
- package/es/components/DynamicForm/useDynamicForm.js +240 -56
- package/es/utils/method.d.ts +21 -1
- package/es/utils/method.js +173 -80
- package/lib/components/DynamicForm/index.d.ts +7 -30
- package/lib/components/DynamicForm/index.js +49 -4
- package/lib/components/DynamicForm/useDynamicForm.d.ts +8 -2
- package/lib/components/DynamicForm/useDynamicForm.js +237 -53
- package/lib/utils/method.d.ts +21 -1
- package/lib/utils/method.js +173 -80
- package/package.json +1 -1
package/es/utils/method.d.ts
CHANGED
|
@@ -11,7 +11,21 @@ export declare const handleSubmitForm: (originalData: any, allValues: any) => {
|
|
|
11
11
|
updatedData: any;
|
|
12
12
|
uploadedFiles: any[];
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* 处理基础属性数组
|
|
16
|
+
*/
|
|
17
|
+
export declare const handleBaseAttrList: (attrList: any[], extraAttrs?: {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
} | undefined) => any[];
|
|
20
|
+
/**
|
|
21
|
+
* 处理属性列表,合并组合属性
|
|
22
|
+
* @param attrList 属性列表
|
|
23
|
+
* @param extraAttrs 额外属性
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
export declare const handleAttrList: (attrList: any[], extraAttrs?: {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
} | undefined) => any[];
|
|
15
29
|
export declare const handleFormConfig: ({ number, key, sourceNumber, guidInterfaceName, SelPCParamInterfaceName, servicerAttrListInterfaceName, accepterAttrListInterfaceName, defaultAttrListInterfaceName, commonRequest, guidParams, pcParam, attrReqKey, attrListExtraParams, }: {
|
|
16
30
|
number: string | number;
|
|
17
31
|
key: string;
|
|
@@ -46,3 +60,9 @@ export declare const handleFormConfig: ({ number, key, sourceNumber, guidInterfa
|
|
|
46
60
|
* @returns
|
|
47
61
|
*/
|
|
48
62
|
export declare const handleOperationFile: (params: any, data: any, commonRequestWidthParams: any) => Promise<any>;
|
|
63
|
+
/**
|
|
64
|
+
* 命名转换为驼峰命名
|
|
65
|
+
* @param str 烤肉串命名
|
|
66
|
+
* @returns 驼峰命名
|
|
67
|
+
*/
|
|
68
|
+
export declare function handleKebabToCamel(str: string): string;
|
package/es/utils/method.js
CHANGED
|
@@ -29,83 +29,112 @@ function isBase64(str) {
|
|
|
29
29
|
const handleSubmitForm = (originalData, allValues) => {
|
|
30
30
|
let updatedData = _.cloneDeep(originalData);
|
|
31
31
|
let uploadedFiles = [];
|
|
32
|
-
const processAttrList = (attrList) => {
|
|
33
|
-
var _a
|
|
34
|
-
const attrMap = new Map(attrList.map((item, index) => [item.attrid, index]));
|
|
32
|
+
const processAttrList = (attrList, item) => {
|
|
33
|
+
var _a;
|
|
35
34
|
try {
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
switch (inputType) {
|
|
48
|
-
case "image":
|
|
49
|
-
case "file":
|
|
50
|
-
case "video":
|
|
51
|
-
case "audio":
|
|
52
|
-
const parsedValue = typeof formValue === "string" ? JSON.parse(formValue) : formValue;
|
|
53
|
-
if (!Array.isArray(parsedValue)) {
|
|
54
|
-
attrItem.attrvalue = JSON.stringify([]);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const existingFiles = parsedValue.filter((file) => file.FileId);
|
|
58
|
-
const uploadedFileList = parsedValue.filter((file) => {
|
|
59
|
-
var _a2;
|
|
60
|
-
return file.status === "done" && ((_a2 = file.response) == null ? void 0 : _a2.data);
|
|
61
|
-
}).map((file) => file.response.data);
|
|
62
|
-
const allFiles = [...existingFiles, ...uploadedFileList];
|
|
63
|
-
uploadedFiles = [...uploadedFiles, ...uploadedFileList];
|
|
64
|
-
attrItem.attrvalue = JSON.stringify(allFiles);
|
|
65
|
-
break;
|
|
66
|
-
case "cascader":
|
|
67
|
-
if (Array.isArray(formValue) && formValue.length > 0) {
|
|
68
|
-
const delimiter = ((_c = attrItem.json) == null ? void 0 : _c["cascader-delimiter"]) || "/";
|
|
69
|
-
attrItem.attrvalue = formValue.join(delimiter);
|
|
70
|
-
} else {
|
|
71
|
-
attrItem.attrvalue = "";
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
case "checkbox":
|
|
75
|
-
case "mult-select":
|
|
76
|
-
if (Array.isArray(formValue) && formValue.length > 0) {
|
|
77
|
-
attrItem.attrvalue = formValue.join(",");
|
|
78
|
-
} else {
|
|
79
|
-
attrItem.attrvalue = formValue;
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
case "date-picker":
|
|
83
|
-
if (formValue) {
|
|
84
|
-
attrItem.attrvalue = dayjs(formValue).format(format || "YYYY-MM-DD");
|
|
85
|
-
} else {
|
|
86
|
-
attrItem.attrvalue = "";
|
|
87
|
-
}
|
|
88
|
-
break;
|
|
89
|
-
case "time-picker":
|
|
90
|
-
if (formValue) {
|
|
91
|
-
attrItem.attrvalue = dayjs(formValue).format(format || "YYYY-MM-DD HH:mm:ss");
|
|
92
|
-
} else {
|
|
93
|
-
attrItem.attrvalue = "";
|
|
35
|
+
if ((_a = item == null ? void 0 : item.json) == null ? void 0 : _a["properties-multiple"]) {
|
|
36
|
+
const attrValue = allValues[item.attrid];
|
|
37
|
+
if (Array.isArray(attrValue)) {
|
|
38
|
+
const childrenObj = {};
|
|
39
|
+
attrValue.forEach((item2, index) => {
|
|
40
|
+
var _a2;
|
|
41
|
+
childrenObj[index] = _.cloneDeep(attrList);
|
|
42
|
+
for (const [fieldName, formValue] of Object.entries(item2)) {
|
|
43
|
+
const attrItem = (_a2 = childrenObj[index]) == null ? void 0 : _a2.find((item3) => item3.attrid === fieldName);
|
|
44
|
+
handleDealValue(attrItem, formValue);
|
|
94
45
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
attrItem.attrvalue = formValue;
|
|
98
|
-
break;
|
|
46
|
+
});
|
|
47
|
+
item.children = childrenObj;
|
|
99
48
|
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
49
|
+
} else {
|
|
50
|
+
const attrMap = new Map(attrList.map((item2, index) => [item2.attrid, index]));
|
|
51
|
+
for (const [fieldName, formValue] of Object.entries(allValues)) {
|
|
52
|
+
const index = attrMap.get(fieldName);
|
|
53
|
+
if (index === void 0)
|
|
54
|
+
continue;
|
|
55
|
+
const attrItem = attrList[index];
|
|
56
|
+
if (!formValue && formValue !== 0) {
|
|
57
|
+
attrItem.attrvalue = "";
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
handleDealValue(attrItem, formValue);
|
|
104
61
|
}
|
|
105
|
-
|
|
62
|
+
attrList.forEach((item2) => {
|
|
63
|
+
if (item2.children && Array.isArray(item2.children) && item2.children.length > 0) {
|
|
64
|
+
processAttrList(item2.children, item2);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
106
68
|
} catch (error) {
|
|
107
69
|
}
|
|
108
70
|
};
|
|
71
|
+
const handleDealValue = (attrItem, formValue) => {
|
|
72
|
+
var _a, _b, _c, _d;
|
|
73
|
+
const inputType = (_a = attrItem.json) == null ? void 0 : _a.input;
|
|
74
|
+
const format = (_b = attrItem.json) == null ? void 0 : _b["format"];
|
|
75
|
+
switch (inputType) {
|
|
76
|
+
case "image":
|
|
77
|
+
case "file":
|
|
78
|
+
case "video":
|
|
79
|
+
case "audio":
|
|
80
|
+
const parsedValue = typeof formValue === "string" ? JSON.parse(formValue) : formValue;
|
|
81
|
+
if (!Array.isArray(parsedValue)) {
|
|
82
|
+
attrItem.attrvalue = JSON.stringify([]);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const existingFiles = parsedValue.filter((file) => file.FileId);
|
|
86
|
+
const uploadedFileList = parsedValue.filter((file) => {
|
|
87
|
+
var _a2;
|
|
88
|
+
return file.status === "done" && ((_a2 = file.response) == null ? void 0 : _a2.data);
|
|
89
|
+
}).map((file) => file.response.data);
|
|
90
|
+
const allFiles = [...existingFiles, ...uploadedFileList];
|
|
91
|
+
uploadedFiles = [...uploadedFiles, ...uploadedFileList];
|
|
92
|
+
attrItem.attrvalue = JSON.stringify(allFiles);
|
|
93
|
+
break;
|
|
94
|
+
case "cascader":
|
|
95
|
+
if (Array.isArray(formValue) && formValue.length > 0) {
|
|
96
|
+
const delimiter = ((_c = attrItem.json) == null ? void 0 : _c["cascader-delimiter"]) || "/";
|
|
97
|
+
attrItem.attrvalue = formValue.join(delimiter);
|
|
98
|
+
} else {
|
|
99
|
+
attrItem.attrvalue = "";
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case "range-picker":
|
|
103
|
+
if (Array.isArray(formValue) && formValue.length > 0) {
|
|
104
|
+
attrItem.attrvalue = formValue.join("~");
|
|
105
|
+
} else {
|
|
106
|
+
attrItem.attrvalue = "";
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
case "checkbox":
|
|
110
|
+
case "mult-select":
|
|
111
|
+
if (Array.isArray(formValue) && formValue.length > 0) {
|
|
112
|
+
attrItem.attrvalue = formValue.join(",");
|
|
113
|
+
} else {
|
|
114
|
+
attrItem.attrvalue = formValue;
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
case "date-picker":
|
|
118
|
+
if (formValue) {
|
|
119
|
+
attrItem.attrvalue = dayjs(formValue).format(format || "YYYY-MM-DD");
|
|
120
|
+
} else {
|
|
121
|
+
attrItem.attrvalue = "";
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
case "time-picker":
|
|
125
|
+
if (formValue) {
|
|
126
|
+
attrItem.attrvalue = dayjs(formValue).format(format || "YYYY-MM-DD HH:mm:ss");
|
|
127
|
+
} else {
|
|
128
|
+
attrItem.attrvalue = "";
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
default:
|
|
132
|
+
if (!((_d = attrItem == null ? void 0 : attrItem.json) == null ? void 0 : _d["properties-multiple"])) {
|
|
133
|
+
attrItem.attrvalue = formValue;
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
109
138
|
if (updatedData.attr_list && Array.isArray(updatedData.attr_list)) {
|
|
110
139
|
processAttrList(updatedData.attr_list);
|
|
111
140
|
}
|
|
@@ -114,19 +143,76 @@ const handleSubmitForm = (originalData, allValues) => {
|
|
|
114
143
|
uploadedFiles
|
|
115
144
|
};
|
|
116
145
|
};
|
|
117
|
-
const
|
|
118
|
-
return
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
item.json = json;
|
|
123
|
-
} catch (error) {
|
|
124
|
-
item.json = {};
|
|
125
|
-
}
|
|
146
|
+
const processChildren = (items, extraAttrs) => {
|
|
147
|
+
return items.map((item) => {
|
|
148
|
+
const processedItem = processItem(item, extraAttrs);
|
|
149
|
+
if (processedItem.children && Array.isArray(processedItem.children)) {
|
|
150
|
+
processedItem.children = processChildren(processedItem.children);
|
|
126
151
|
}
|
|
127
|
-
return
|
|
152
|
+
return processedItem;
|
|
128
153
|
});
|
|
129
154
|
};
|
|
155
|
+
const processItem = (item, extraAttrs) => {
|
|
156
|
+
if (!item.json && item.info) {
|
|
157
|
+
try {
|
|
158
|
+
const infoStr = item.info_base64 === 1 ? base64ToString(item.info) : item.info;
|
|
159
|
+
const json = getJson(infoStr);
|
|
160
|
+
return { ...item, json, ...extraAttrs };
|
|
161
|
+
} catch (error) {
|
|
162
|
+
return { ...item, json: {}, ...extraAttrs };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return { ...item, ...extraAttrs };
|
|
166
|
+
};
|
|
167
|
+
const handleBaseAttrList = (attrList, extraAttrs) => {
|
|
168
|
+
return processChildren(attrList, extraAttrs);
|
|
169
|
+
};
|
|
170
|
+
const handleAttrList = (attrList, extraAttrs) => {
|
|
171
|
+
const parsedAttrList = processChildren(attrList, extraAttrs);
|
|
172
|
+
const combinationGroups = parsedAttrList.filter((item) => {
|
|
173
|
+
var _a;
|
|
174
|
+
return (_a = item.json) == null ? void 0 : _a.combination;
|
|
175
|
+
}).reduce((groups, item) => {
|
|
176
|
+
const combinationId = item.json["combination-id"];
|
|
177
|
+
if (!combinationId)
|
|
178
|
+
return groups;
|
|
179
|
+
if (!groups[combinationId]) {
|
|
180
|
+
groups[combinationId] = [];
|
|
181
|
+
}
|
|
182
|
+
groups[combinationId].push(item);
|
|
183
|
+
return groups;
|
|
184
|
+
}, {});
|
|
185
|
+
const excludeAttrIds = /* @__PURE__ */ new Set();
|
|
186
|
+
Object.values(combinationGroups).forEach((group) => {
|
|
187
|
+
if ((group == null ? void 0 : group.length) === 0)
|
|
188
|
+
return;
|
|
189
|
+
group.slice(1).forEach((item) => excludeAttrIds.add(item.attrid));
|
|
190
|
+
});
|
|
191
|
+
const filterAndCombine = (items) => {
|
|
192
|
+
return items.filter((item) => !excludeAttrIds.has(item.attrid)).map((item) => {
|
|
193
|
+
var _a;
|
|
194
|
+
const combinationId = (_a = item.json) == null ? void 0 : _a["combination-id"];
|
|
195
|
+
if (combinationId && combinationGroups[combinationId]) {
|
|
196
|
+
const processedItem = {
|
|
197
|
+
...item,
|
|
198
|
+
json: {
|
|
199
|
+
...item.json,
|
|
200
|
+
combinations: combinationGroups[combinationId]
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
if (processedItem.children && Array.isArray(processedItem.children)) {
|
|
204
|
+
processedItem.children = filterAndCombine(processedItem.children);
|
|
205
|
+
}
|
|
206
|
+
return processedItem;
|
|
207
|
+
}
|
|
208
|
+
if (item.children && Array.isArray(item.children)) {
|
|
209
|
+
item.children = filterAndCombine(item.children);
|
|
210
|
+
}
|
|
211
|
+
return item;
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
return filterAndCombine(parsedAttrList);
|
|
215
|
+
};
|
|
130
216
|
const handleFormConfig = async ({
|
|
131
217
|
number,
|
|
132
218
|
key,
|
|
@@ -200,11 +286,18 @@ const handleOperationFile = async (params, data, commonRequestWidthParams) => {
|
|
|
200
286
|
const response = await commonRequestWidthParams(params, data);
|
|
201
287
|
return response;
|
|
202
288
|
};
|
|
289
|
+
function handleKebabToCamel(str) {
|
|
290
|
+
return str.replace(/-([a-z])/g, function(match, letter) {
|
|
291
|
+
return letter.toUpperCase();
|
|
292
|
+
});
|
|
293
|
+
}
|
|
203
294
|
export {
|
|
204
295
|
base64ToString,
|
|
205
296
|
getJson,
|
|
206
297
|
handleAttrList,
|
|
298
|
+
handleBaseAttrList,
|
|
207
299
|
handleFormConfig,
|
|
300
|
+
handleKebabToCamel,
|
|
208
301
|
handleOperationFile,
|
|
209
302
|
handleSubmitForm,
|
|
210
303
|
isBase64
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
-
import { AxiosResponse } from 'axios';
|
|
3
2
|
|
|
4
3
|
export interface IformConfigItem {
|
|
5
4
|
xh: number;
|
|
@@ -19,6 +18,11 @@ export interface IformConfigItem {
|
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
export interface Ijson {
|
|
21
|
+
'properties-width'?: number; // 属性集表单宽度
|
|
22
|
+
'properties-multiple'?: boolean; // 是否支持可增减的表单列表
|
|
23
|
+
propertiesID: string;
|
|
24
|
+
'combination-name'?: string; // 组合表单名称
|
|
25
|
+
combinations: any; // 组合表单配置
|
|
22
26
|
input: InputType;
|
|
23
27
|
length?: number;
|
|
24
28
|
'label-value'?: string; //代表属性固定取值,并且不可在实例化时修改
|
|
@@ -70,6 +74,8 @@ export type InputType =
|
|
|
70
74
|
| 'week-picker'
|
|
71
75
|
| 'month-picker'
|
|
72
76
|
| 'quarter-picker'
|
|
77
|
+
| 'range-picker'
|
|
78
|
+
| 'multiple-date-picker'
|
|
73
79
|
| 'year-picker'
|
|
74
80
|
| 'second-picker'
|
|
75
81
|
| 'image'
|
|
@@ -101,32 +107,3 @@ export interface Iselect {
|
|
|
101
107
|
label: string;
|
|
102
108
|
value: string | number;
|
|
103
109
|
}
|
|
104
|
-
|
|
105
|
-
export interface DynamicFormProps {
|
|
106
|
-
formConfig: IformConfigItem[]; // 表单配置项
|
|
107
|
-
form: FormInstance; // 表单实例
|
|
108
|
-
readonly?: boolean; // 是否只读,默认false
|
|
109
|
-
relatedid?: string; // GuId实例id
|
|
110
|
-
colNum?: number; // 新增:列数,默认1列
|
|
111
|
-
colSpace?: [number, number]; // 新增:列间距,默认[15,15]
|
|
112
|
-
instructionShowMode?: 'icon' | 'flex'; // icon 图标展示,flex 文字展示
|
|
113
|
-
formItemStyle?: IformItemStyle[]; // 新增:表单项样式,默认[]
|
|
114
|
-
radioAlign?: 'horizontal' | 'vertical'; // 'horizontal': 横向展示(默认), 'vertical': 垂直展示
|
|
115
|
-
defaultWidth?: number; // 新增:默认宽度,默认358px
|
|
116
|
-
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>; // 用于请求url类型的数据
|
|
117
|
-
uploadAction: (PageName?: string | undefined) => string; // 用于上传文件地址
|
|
118
|
-
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>; // 用于请求字典类型的数据
|
|
119
|
-
ref?: React.Ref<{ getDelFileList: () => any[] }>; // 新增:用于获取删除文件列表的ref
|
|
120
|
-
setFormConfig?: (config: IformConfigItem[]) => void; // 新增:用于设置表单配置项的函数
|
|
121
|
-
interfaceTypeChildren?: string; // 新增:接口类型子项,默认YLLRDetailAttrlist
|
|
122
|
-
interfaceTypeDict?: string; // 新增:接口类型字典,默认YLZDDictList
|
|
123
|
-
interfaceTypeSysDict?: string; // 新增:接口系统类型字典,默认YLZDSysConfigList
|
|
124
|
-
relatedidKey?: string; // 新增:关联id键名,默认relatedid
|
|
125
|
-
actionUrlKey?: string; // 新增:配置第三方接口参数取action-url的键名,默认action-url
|
|
126
|
-
actionUrlExtraParams?: object; // 新增:配置第三方接口参数取action-url的额外参数,默认{}
|
|
127
|
-
CustomModalComponent?: React.FC<ICustomModal>;
|
|
128
|
-
}
|
|
129
|
-
// 定义DynamicForm的Ref类型(包含暴露的方法)
|
|
130
|
-
export interface DynamicFormRef {
|
|
131
|
-
getDelFileList: () => UploadFile<any>[];
|
|
132
|
-
}
|
|
@@ -7,6 +7,7 @@ const DynamicForm = react.forwardRef((props, ref) => {
|
|
|
7
7
|
const {
|
|
8
8
|
formConfig,
|
|
9
9
|
setFormConfig,
|
|
10
|
+
setAttrList,
|
|
10
11
|
form,
|
|
11
12
|
readonly = false,
|
|
12
13
|
relatedid,
|
|
@@ -25,7 +26,11 @@ const DynamicForm = react.forwardRef((props, ref) => {
|
|
|
25
26
|
relatedidKey = "relatedid",
|
|
26
27
|
actionUrlKey = "action-url",
|
|
27
28
|
actionUrlExtraParams = {},
|
|
28
|
-
CustomModalComponent
|
|
29
|
+
CustomModalComponent,
|
|
30
|
+
hideAttrList = [],
|
|
31
|
+
formShowType = "form",
|
|
32
|
+
headerWidth,
|
|
33
|
+
formListItemWidth
|
|
29
34
|
} = props;
|
|
30
35
|
const delFileListRef = react.useRef([]);
|
|
31
36
|
const updateDelFileList = (file) => {
|
|
@@ -36,6 +41,7 @@ const DynamicForm = react.forwardRef((props, ref) => {
|
|
|
36
41
|
uploadAction,
|
|
37
42
|
commonRequest,
|
|
38
43
|
setFormConfig,
|
|
44
|
+
setAttrList,
|
|
39
45
|
updateDelFileList,
|
|
40
46
|
formConfig,
|
|
41
47
|
interfaceTypeChildren,
|
|
@@ -44,14 +50,53 @@ const DynamicForm = react.forwardRef((props, ref) => {
|
|
|
44
50
|
relatedidKey,
|
|
45
51
|
actionUrlKey,
|
|
46
52
|
actionUrlExtraParams,
|
|
47
|
-
CustomModalComponent
|
|
53
|
+
CustomModalComponent,
|
|
54
|
+
hideAttrList
|
|
48
55
|
});
|
|
49
56
|
react.useImperativeHandle(ref, () => ({
|
|
50
57
|
getDelFileList: () => {
|
|
51
58
|
return delFileListRef.current;
|
|
52
59
|
}
|
|
53
60
|
}));
|
|
54
|
-
return /* @__PURE__ */ jsxRuntime.jsx(antd.
|
|
61
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formShowType === "table" ? /* @__PURE__ */ jsxRuntime.jsx(antd.Form.List, { name: "customFormList", initialValue: [{}], children: (fields, { add, remove }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "custom-form-list", children: [
|
|
62
|
+
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", children: [
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { className: "custom-form-list-header", align: "center", children: formConfig == null ? void 0 : formConfig.map((child, index) => {
|
|
64
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { style: { width: (headerWidth == null ? void 0 : headerWidth[index]) || defaultWidth }, align: "center", children: [
|
|
65
|
+
index !== 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line" }),
|
|
66
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "custom-form-list-header-item", children: child.attrname })
|
|
67
|
+
] }, index);
|
|
68
|
+
}) }),
|
|
69
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { className: "custom-form-list-add-btn", onClick: () => add(), children: "新增" })
|
|
70
|
+
] }),
|
|
71
|
+
fields.map((field) => /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { align: "center", className: "custom-form-list-item-container", children: [
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { className: "custom-form-list-item", align: "center", children: formConfig == null ? void 0 : formConfig.map((child, index) => {
|
|
73
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
74
|
+
antd.Flex,
|
|
75
|
+
{
|
|
76
|
+
align: "center",
|
|
77
|
+
className: "custom-form-list-item-content",
|
|
78
|
+
justify: "center",
|
|
79
|
+
style: { width: (headerWidth == null ? void 0 : headerWidth[index]) || defaultWidth },
|
|
80
|
+
children: handleRenderItem({
|
|
81
|
+
item: child,
|
|
82
|
+
readonly,
|
|
83
|
+
colNum,
|
|
84
|
+
instructionShowMode,
|
|
85
|
+
relatedid,
|
|
86
|
+
form,
|
|
87
|
+
defaultWidth: (formListItemWidth == null ? void 0 : formListItemWidth[index]) || defaultWidth,
|
|
88
|
+
formItemStyle,
|
|
89
|
+
isFormListItem: true,
|
|
90
|
+
formListField: field,
|
|
91
|
+
isShowLabel: false
|
|
92
|
+
})
|
|
93
|
+
},
|
|
94
|
+
child.attrid || `child-${index}`
|
|
95
|
+
);
|
|
96
|
+
}) }),
|
|
97
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { className: "custom-form-list-del-btn", onClick: () => remove(field.key), children: "删除" })
|
|
98
|
+
] }, field.key))
|
|
99
|
+
] }) }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { gutter: colSpace, children: formConfig.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: handleRenderItem({
|
|
55
100
|
item,
|
|
56
101
|
readonly,
|
|
57
102
|
colNum,
|
|
@@ -61,6 +106,6 @@ const DynamicForm = react.forwardRef((props, ref) => {
|
|
|
61
106
|
defaultWidth,
|
|
62
107
|
formItemStyle,
|
|
63
108
|
radioAlign
|
|
64
|
-
}) }, item.attrid || `form-item-${index}`)) });
|
|
109
|
+
}) }, item.attrid || `form-item-${index}`)) }) });
|
|
65
110
|
});
|
|
66
111
|
module.exports = DynamicForm;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IformConfigItem, IformItemStyle } from './index.d';
|
|
3
3
|
import { AxiosResponse } from 'axios';
|
|
4
|
-
import { FormInstance, UploadFile } from 'antd';
|
|
4
|
+
import { FormInstance, FormListFieldData, UploadFile } from 'antd';
|
|
5
5
|
interface IDynamicFormProps {
|
|
6
6
|
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
7
7
|
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
@@ -16,9 +16,11 @@ interface IDynamicFormProps {
|
|
|
16
16
|
actionUrlKey: string;
|
|
17
17
|
actionUrlExtraParams: object;
|
|
18
18
|
CustomModalComponent?: React.FC<ICustomModal>;
|
|
19
|
+
setAttrList?: (config: IformConfigItem[]) => void;
|
|
20
|
+
hideAttrList?: string[];
|
|
19
21
|
}
|
|
20
22
|
declare function useDynamicForm(props: IDynamicFormProps): {
|
|
21
|
-
handleRenderItem: ({ item, readonly, colNum, instructionShowMode, relatedid, form, defaultWidth, formItemStyle, radioAlign, }: {
|
|
23
|
+
handleRenderItem: ({ item, readonly, colNum, instructionShowMode, relatedid, form, defaultWidth, formItemStyle, radioAlign, isFormListItem, formListField, isShowLabel, }: {
|
|
22
24
|
item: IformConfigItem;
|
|
23
25
|
readonly: boolean;
|
|
24
26
|
colNum: number;
|
|
@@ -28,6 +30,10 @@ declare function useDynamicForm(props: IDynamicFormProps): {
|
|
|
28
30
|
defaultWidth?: number | undefined;
|
|
29
31
|
formItemStyle: IformItemStyle[] | undefined;
|
|
30
32
|
radioAlign?: "horizontal" | "vertical" | undefined;
|
|
33
|
+
isFormListItem?: boolean | undefined;
|
|
34
|
+
formListField?: FormListFieldData | undefined;
|
|
35
|
+
isShowLabel?: boolean | undefined;
|
|
31
36
|
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
37
|
+
handleSetFormItemInitialValue: (itemWithJson: IformConfigItem) => any;
|
|
32
38
|
};
|
|
33
39
|
export default useDynamicForm;
|