szld-libs 0.2.90 → 0.2.92
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 +12467 -12424
- package/dist/szld-components.umd.js +52 -52
- package/es/components/DynamicForm/func.d.ts +27 -1
- package/es/components/DynamicForm/func.js +126 -28
- package/es/components/DynamicForm/index.d.ts +1 -1
- package/es/components/DynamicForm/mySelect/index.js +1 -1
- package/es/components/DynamicForm/useDynamicForm.d.ts +4 -1
- package/es/components/DynamicForm/useDynamicForm.js +110 -132
- package/es/utils/method.d.ts +8 -3
- package/es/utils/method.js +54 -42
- package/es/utils/szxkFunc.d.ts +7 -1
- package/lib/components/DynamicForm/func.d.ts +27 -1
- package/lib/components/DynamicForm/func.js +125 -27
- package/lib/components/DynamicForm/index.d.ts +1 -1
- package/lib/components/DynamicForm/mySelect/index.js +2 -2
- package/lib/components/DynamicForm/useDynamicForm.d.ts +4 -1
- package/lib/components/DynamicForm/useDynamicForm.js +104 -126
- package/lib/utils/method.d.ts +8 -3
- package/lib/utils/method.js +54 -42
- package/lib/utils/szxkFunc.d.ts +7 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IformConfigItem } from './index.d';
|
|
1
|
+
import { IformConfigItem, Ijson } from './index.d';
|
|
2
2
|
import { RangePickerProps } from 'antd/es/date-picker';
|
|
3
|
+
import { AxiosResponse } from 'axios';
|
|
3
4
|
export declare const handleGetPlaceholder: (itemWithJson: IformConfigItem) => string;
|
|
4
5
|
/**
|
|
5
6
|
* 处理表单项目初始值
|
|
@@ -7,3 +8,28 @@ export declare const handleGetPlaceholder: (itemWithJson: IformConfigItem) => st
|
|
|
7
8
|
*/
|
|
8
9
|
export declare const handleSetFormItemInitialValue: (itemWithJson: IformConfigItem) => any;
|
|
9
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
|
+
}[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import dayjs from "dayjs";
|
|
2
|
+
import { message } from "antd";
|
|
2
3
|
const handleGetPlaceholder = (itemWithJson) => {
|
|
3
4
|
const { input = "" } = itemWithJson.json || {};
|
|
4
5
|
let placeholder = "请输入";
|
|
@@ -26,25 +27,16 @@ const handleGetPlaceholder = (itemWithJson) => {
|
|
|
26
27
|
return placeholder;
|
|
27
28
|
};
|
|
28
29
|
const handleSetFormItemInitialValue = (itemWithJson) => {
|
|
29
|
-
var _a, _b, _c, _d
|
|
30
|
+
var _a, _b, _c, _d;
|
|
30
31
|
const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
|
|
31
|
-
|
|
32
|
-
let initialValue = itemWithJson.attrvalue || ((_c = itemWithJson.json) == null ? void 0 : _c.default);
|
|
32
|
+
let initialValue = itemWithJson.attrvalue || ((_b = itemWithJson.json) == null ? void 0 : _b.default);
|
|
33
33
|
if (inputType === "label" && initialValue) {
|
|
34
|
-
initialValue = ((
|
|
35
|
-
}
|
|
36
|
-
if ((inputType === "date-picker" || inputType === "time-picker") && initialValue) {
|
|
37
|
-
try {
|
|
38
|
-
const date = dayjs(initialValue);
|
|
39
|
-
initialValue = date.isValid() ? date : void 0;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
initialValue = void 0;
|
|
42
|
-
}
|
|
34
|
+
initialValue = ((_c = itemWithJson.json) == null ? void 0 : _c["label-value"]) ?? initialValue ?? "-";
|
|
43
35
|
}
|
|
44
36
|
if (inputType === "range-picker" && initialValue) {
|
|
45
37
|
try {
|
|
46
38
|
initialValue = initialValue == null ? void 0 : initialValue.split("~");
|
|
47
|
-
initialValue = initialValue.map((v) =>
|
|
39
|
+
initialValue = initialValue.map((v) => v);
|
|
48
40
|
} catch (error) {
|
|
49
41
|
initialValue = void 0;
|
|
50
42
|
}
|
|
@@ -52,13 +44,13 @@ const handleSetFormItemInitialValue = (itemWithJson) => {
|
|
|
52
44
|
if (inputType === "multiple-date-picker" && initialValue) {
|
|
53
45
|
try {
|
|
54
46
|
initialValue = initialValue == null ? void 0 : initialValue.split(",");
|
|
55
|
-
initialValue = initialValue.map((v) => dayjs(
|
|
47
|
+
initialValue = initialValue.map((v) => dayjs());
|
|
56
48
|
} catch (error) {
|
|
57
49
|
initialValue = void 0;
|
|
58
50
|
}
|
|
59
51
|
}
|
|
60
52
|
if (inputType === "cascader" && initialValue && typeof initialValue === "string") {
|
|
61
|
-
const delimiter = (
|
|
53
|
+
const delimiter = (_d = itemWithJson.json) == null ? void 0 : _d["cascader-delimiter"];
|
|
62
54
|
if (delimiter) {
|
|
63
55
|
initialValue = initialValue.split(delimiter).filter(Boolean);
|
|
64
56
|
}
|
|
@@ -79,26 +71,132 @@ const handleSetFormItemInitialValue = (itemWithJson) => {
|
|
|
79
71
|
initialValue = [];
|
|
80
72
|
}
|
|
81
73
|
}
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
if (Array.isArray(children)) {
|
|
85
|
-
initialValue = [
|
|
86
|
-
Object.assign(
|
|
87
|
-
{},
|
|
88
|
-
...children == null ? void 0 : children.map((child) => ({
|
|
89
|
-
[child.attrid]: handleSetFormItemInitialValue(child)
|
|
90
|
-
}))
|
|
91
|
-
)
|
|
92
|
-
];
|
|
93
|
-
}
|
|
74
|
+
if (itemWithJson.attrtype === 1) {
|
|
75
|
+
initialValue = handleGetSingleAttrListObj(itemWithJson.children || []);
|
|
94
76
|
}
|
|
95
77
|
return initialValue || null;
|
|
96
78
|
};
|
|
97
79
|
const disabledDate = (current) => {
|
|
98
80
|
return current && current < dayjs().startOf("day");
|
|
99
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
|
+
v.forEach((x) => {
|
|
184
|
+
var _a;
|
|
185
|
+
if ((_a = x == null ? void 0 : x.children) == null ? void 0 : _a.length) {
|
|
186
|
+
obj[x.attrid] = dealList(x.children);
|
|
187
|
+
} else {
|
|
188
|
+
obj[x.attrid] = x.attrvalue;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return obj;
|
|
192
|
+
});
|
|
193
|
+
return dealList(children);
|
|
194
|
+
};
|
|
100
195
|
export {
|
|
101
196
|
disabledDate,
|
|
102
197
|
handleGetPlaceholder,
|
|
103
|
-
|
|
198
|
+
handleGetSingleAttrListObj,
|
|
199
|
+
handleSelectOptions,
|
|
200
|
+
handleSetFormItemInitialValue,
|
|
201
|
+
handleUrlOptions
|
|
104
202
|
};
|
|
@@ -19,6 +19,9 @@ interface IDynamicFormProps {
|
|
|
19
19
|
setAttrList?: (config: IformConfigItem[]) => void;
|
|
20
20
|
hideAttrList?: string[];
|
|
21
21
|
}
|
|
22
|
+
type NestedFormListFieldData = FormListFieldData & {
|
|
23
|
+
parentName?: (string | number)[];
|
|
24
|
+
};
|
|
22
25
|
declare function useDynamicForm(props: IDynamicFormProps): {
|
|
23
26
|
handleRenderItem: ({ item, readonly, colNum, instructionShowMode, relatedid, form, defaultWidth, formItemStyle, radioAlign, isFormListItem, formListField, isShowLabel, }: {
|
|
24
27
|
item: IformConfigItem;
|
|
@@ -31,7 +34,7 @@ declare function useDynamicForm(props: IDynamicFormProps): {
|
|
|
31
34
|
formItemStyle: IformItemStyle[] | undefined;
|
|
32
35
|
radioAlign?: "horizontal" | "vertical" | undefined;
|
|
33
36
|
isFormListItem?: boolean | undefined;
|
|
34
|
-
formListField?:
|
|
37
|
+
formListField?: NestedFormListFieldData | undefined;
|
|
35
38
|
isShowLabel?: boolean | undefined;
|
|
36
39
|
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
37
40
|
handleSetFormItemInitialValue: (itemWithJson: IformConfigItem) => any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx,
|
|
1
|
+
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
2
2
|
import { handleSetFormItemInitialValue, handleGetPlaceholder, disabledDate } from "./func";
|
|
3
|
-
import {
|
|
4
|
-
import { useRef, useEffect, useCallback, Fragment
|
|
3
|
+
import { handleUrlOptions, getJson, base64ToString } from "../../utils/method";
|
|
4
|
+
import { useRef, useEffect, useCallback, Fragment } from "react";
|
|
5
5
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
6
6
|
import SelectModel from "./selectModel";
|
|
7
7
|
import MyCheckbox from "./myCheckbox";
|
|
@@ -11,7 +11,6 @@ import RadioCard from "./radioCard";
|
|
|
11
11
|
import MySelect from "./mySelect";
|
|
12
12
|
import MyUpload from "./myUpload";
|
|
13
13
|
import MyRadio from "./myRadio";
|
|
14
|
-
import _ from "lodash";
|
|
15
14
|
import { MinusSquareOutlined, PlusSquareOutlined, CloseOutlined, InfoCircleOutlined } from "@ant-design/icons";
|
|
16
15
|
import { App, Col, Collapse, Form, Card, Flex, Button, Space, Input, DatePicker, InputNumber, Tooltip } from "antd";
|
|
17
16
|
dayjs.extend(isoWeek);
|
|
@@ -151,7 +150,7 @@ function useDynamicForm(props) {
|
|
|
151
150
|
) }) || /* @__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 })
|
|
152
151
|
] });
|
|
153
152
|
};
|
|
154
|
-
const
|
|
153
|
+
const renderNestedFormList = useCallback(
|
|
155
154
|
({
|
|
156
155
|
itemWithJson,
|
|
157
156
|
colNum = 1,
|
|
@@ -162,81 +161,68 @@ function useDynamicForm(props) {
|
|
|
162
161
|
relatedid,
|
|
163
162
|
form,
|
|
164
163
|
defaultWidth = 358,
|
|
165
|
-
|
|
166
|
-
formListField,
|
|
164
|
+
parentFormListField,
|
|
167
165
|
isShowLabel = true
|
|
168
166
|
}) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
formListInitValue = handleSetFormItemInitialValue(itemWithJson);
|
|
167
|
+
const formListInitValue = handleSetFormItemInitialValue(itemWithJson);
|
|
168
|
+
let children = itemWithJson.children || [];
|
|
169
|
+
if (Array.isArray(children == null ? void 0 : children[0]) && children.length) {
|
|
170
|
+
children = children[0];
|
|
174
171
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const list = ((_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.list) || [];
|
|
197
|
-
const arr = handleAttrList(list, { instanceid: relatedid, tname: itemWithJson.tname });
|
|
198
|
-
const _formConfig = _.cloneDeep(formConfigRef.current);
|
|
199
|
-
const _item = _formConfig.find((item) => item.attrid === itemWithJson.attrid);
|
|
200
|
-
if (_item) {
|
|
201
|
-
_item.children = [...arr];
|
|
202
|
-
}
|
|
203
|
-
setFormConfig == null ? void 0 : setFormConfig(_formConfig);
|
|
204
|
-
setAttrList == null ? void 0 : setAttrList(_formConfig);
|
|
205
|
-
}
|
|
172
|
+
const getFormListName = (field) => {
|
|
173
|
+
const parentPath = (parentFormListField == null ? void 0 : parentFormListField.parentName) || (parentFormListField == null ? void 0 : parentFormListField.name);
|
|
174
|
+
if (parentPath) {
|
|
175
|
+
return Array.isArray(parentPath) ? [...parentPath, itemWithJson.attrid, field.name] : [parentPath, itemWithJson.attrid, field.name];
|
|
176
|
+
}
|
|
177
|
+
return [itemWithJson.attrid, field.name];
|
|
178
|
+
};
|
|
179
|
+
return /* @__PURE__ */ jsx(Col, { span: 24 / colNum, children: /* @__PURE__ */ jsx(
|
|
180
|
+
Collapse,
|
|
181
|
+
{
|
|
182
|
+
bordered: false,
|
|
183
|
+
defaultActiveKey: [itemWithJson.attrid],
|
|
184
|
+
style: { backgroundColor: "transparent" },
|
|
185
|
+
expandIcon: ({ isActive }) => handleCollapseIcon({ isActive }),
|
|
186
|
+
items: [
|
|
187
|
+
{
|
|
188
|
+
key: itemWithJson.attrid,
|
|
189
|
+
label: itemWithJson.attrname,
|
|
190
|
+
styles: {
|
|
191
|
+
header: {
|
|
192
|
+
paddingLeft: 0
|
|
206
193
|
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
styles: {
|
|
215
|
-
header: {
|
|
216
|
-
paddingLeft: 0
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
children: isFormList ? /* @__PURE__ */ jsx(Form.List, { name: itemWithJson.attrid, initialValue: formListInitValue, children: (fields, { add, remove }) => {
|
|
220
|
-
var _a2;
|
|
221
|
-
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", rowGap: 16, flexDirection: "column" }, children: [
|
|
194
|
+
},
|
|
195
|
+
children: /* @__PURE__ */ jsx(
|
|
196
|
+
Form.List,
|
|
197
|
+
{
|
|
198
|
+
name: parentFormListField ? Array.isArray(parentFormListField.name) ? [...parentFormListField.name, itemWithJson.attrid] : [parentFormListField.name, itemWithJson.attrid] : itemWithJson.attrid,
|
|
199
|
+
initialValue: formListInitValue,
|
|
200
|
+
children: (fields, { add, remove }) => /* @__PURE__ */ jsxs("div", { style: { display: "flex", rowGap: 16, flexDirection: "column" }, children: [
|
|
222
201
|
fields.map((field) => {
|
|
223
|
-
|
|
202
|
+
const nestedField = {
|
|
203
|
+
...field,
|
|
204
|
+
parentName: getFormListName(field)
|
|
205
|
+
};
|
|
224
206
|
return /* @__PURE__ */ jsx(
|
|
225
207
|
Card,
|
|
226
208
|
{
|
|
227
|
-
style: { width:
|
|
209
|
+
style: { width: defaultWidth + 100 },
|
|
228
210
|
size: "small",
|
|
229
211
|
title: `${itemWithJson.attrname} ${field.name + 1}`,
|
|
230
212
|
extra: /* @__PURE__ */ jsx(
|
|
231
213
|
CloseOutlined,
|
|
232
214
|
{
|
|
233
215
|
onClick: () => {
|
|
234
|
-
|
|
216
|
+
if (fields.length > 1) {
|
|
217
|
+
remove(field.name);
|
|
218
|
+
} else {
|
|
219
|
+
message.warning("至少需要保留一个!");
|
|
220
|
+
}
|
|
235
221
|
}
|
|
236
222
|
}
|
|
237
223
|
),
|
|
238
|
-
children: (
|
|
239
|
-
return /* @__PURE__ */ jsx(Fragment
|
|
224
|
+
children: (children || []).map((child, index) => {
|
|
225
|
+
return /* @__PURE__ */ jsx(Fragment, { children: handleRenderItem({
|
|
240
226
|
item: child,
|
|
241
227
|
readonly,
|
|
242
228
|
colNum,
|
|
@@ -245,8 +231,9 @@ function useDynamicForm(props) {
|
|
|
245
231
|
form,
|
|
246
232
|
defaultWidth,
|
|
247
233
|
formItemStyle,
|
|
234
|
+
radioAlign,
|
|
248
235
|
isFormListItem: true,
|
|
249
|
-
formListField:
|
|
236
|
+
formListField: nestedField,
|
|
250
237
|
isShowLabel: true
|
|
251
238
|
}) }, child.attrid || `child-${index}`);
|
|
252
239
|
})
|
|
@@ -254,40 +241,66 @@ function useDynamicForm(props) {
|
|
|
254
241
|
field.key
|
|
255
242
|
);
|
|
256
243
|
}),
|
|
257
|
-
/* @__PURE__ */ jsx(Flex, { style: { width:
|
|
258
|
-
] })
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
244
|
+
/* @__PURE__ */ jsx(Flex, { style: { width: 200 }, children: /* @__PURE__ */ jsx(Button, { type: "dashed", onClick: () => add(), block: true, children: "+ 新增" }) })
|
|
245
|
+
] })
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
]
|
|
250
|
+
},
|
|
251
|
+
itemWithJson.attrid
|
|
252
|
+
) });
|
|
253
|
+
},
|
|
254
|
+
[handleCollapseIcon, handleSetFormItemInitialValue]
|
|
255
|
+
);
|
|
256
|
+
const handleRenderFunc = useCallback(
|
|
257
|
+
({
|
|
258
|
+
itemWithJson,
|
|
259
|
+
colNum = 1,
|
|
260
|
+
readonly = false,
|
|
261
|
+
instructionShowMode = "icon",
|
|
262
|
+
radioAlign = "horizontal",
|
|
263
|
+
formItemStyle,
|
|
264
|
+
relatedid,
|
|
265
|
+
form,
|
|
266
|
+
defaultWidth = 358,
|
|
267
|
+
isFormListItem = false,
|
|
268
|
+
formListField,
|
|
269
|
+
isShowLabel = true
|
|
270
|
+
}) => {
|
|
271
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
272
|
+
if (((_a = itemWithJson.json) == null ? void 0 : _a.hide) === true || (hideAttrList == null ? void 0 : hideAttrList.includes(itemWithJson.attrid))) {
|
|
273
|
+
return /* @__PURE__ */ jsx(Fragment$1, {});
|
|
274
|
+
}
|
|
275
|
+
if (itemWithJson.attrtype === 1) {
|
|
276
|
+
return renderNestedFormList({
|
|
277
|
+
itemWithJson,
|
|
278
|
+
colNum,
|
|
279
|
+
readonly,
|
|
280
|
+
instructionShowMode,
|
|
281
|
+
radioAlign,
|
|
282
|
+
formItemStyle,
|
|
283
|
+
relatedid,
|
|
284
|
+
form,
|
|
285
|
+
defaultWidth,
|
|
286
|
+
parentFormListField: formListField,
|
|
287
|
+
isShowLabel
|
|
288
|
+
});
|
|
276
289
|
}
|
|
277
290
|
if (itemWithJson.attrtype === 2) {
|
|
278
|
-
return /* @__PURE__ */ jsx(Fragment, { children: "实例信息" });
|
|
291
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: "实例信息" });
|
|
279
292
|
}
|
|
280
293
|
if (itemWithJson.attrtype === 0) {
|
|
281
|
-
|
|
282
|
-
const message2 = (
|
|
294
|
+
const initialValue = handleSetFormItemInitialValue(itemWithJson);
|
|
295
|
+
const message2 = (_b = itemWithJson.json) == null ? void 0 : _b["default-prompt"];
|
|
283
296
|
const placeholder = handleGetPlaceholder(itemWithJson);
|
|
284
297
|
const { combinations = [] } = itemWithJson.json || {};
|
|
285
298
|
if (combinations == null ? void 0 : combinations.length) {
|
|
286
299
|
return /* @__PURE__ */ jsx(Col, { span: 24 / colNum, children: /* @__PURE__ */ jsx(
|
|
287
300
|
Form.Item,
|
|
288
301
|
{
|
|
289
|
-
label: (
|
|
290
|
-
required: (
|
|
302
|
+
label: (_c = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _c["combination-name"],
|
|
303
|
+
required: (_d = itemWithJson.json) == null ? void 0 : _d.must,
|
|
291
304
|
children: /* @__PURE__ */ jsx(Space.Compact, { children: combinations.map((item, index) => {
|
|
292
305
|
var _a2, _b2, _c2, _d2;
|
|
293
306
|
let initValue = handleSetFormItemInitialValue(item);
|
|
@@ -302,21 +315,20 @@ function useDynamicForm(props) {
|
|
|
302
315
|
}
|
|
303
316
|
}
|
|
304
317
|
const widthRatio = (_a2 = item == null ? void 0 : item.json) == null ? void 0 : _a2["combination-width-ratio"];
|
|
305
|
-
const placeholder2 = handleGetPlaceholder(item);
|
|
306
318
|
if (widthRatio) {
|
|
307
319
|
width = defaultWidth * widthRatio;
|
|
308
320
|
}
|
|
309
321
|
return /* @__PURE__ */ jsx(
|
|
310
322
|
Form.Item,
|
|
311
323
|
{
|
|
312
|
-
name: item.attrid,
|
|
324
|
+
name: formListField ? Array.isArray(formListField.name) ? [...formListField.name, item.attrid] : [formListField.name, item.attrid] : item.attrid,
|
|
313
325
|
noStyle: true,
|
|
314
326
|
initialValue: initValue,
|
|
315
327
|
rules: [
|
|
316
328
|
...((_b2 = item.json) == null ? void 0 : _b2.must) ? [
|
|
317
329
|
{
|
|
318
330
|
required: true,
|
|
319
|
-
message: message2 || `${
|
|
331
|
+
message: message2 || `${placeholder}${item.attrname}`
|
|
320
332
|
}
|
|
321
333
|
] : [],
|
|
322
334
|
...((_c2 = itemWithJson.json) == null ? void 0 : _c2.regexp) ? [
|
|
@@ -345,58 +357,24 @@ function useDynamicForm(props) {
|
|
|
345
357
|
`${itemWithJson.attrid}+1`
|
|
346
358
|
) });
|
|
347
359
|
}
|
|
348
|
-
|
|
349
|
-
return /* @__PURE__ */ jsx(Col, { span: 24 / colNum, children: /* @__PURE__ */ jsx(
|
|
350
|
-
Form.Item,
|
|
351
|
-
{
|
|
352
|
-
name: [formListField == null ? void 0 : formListField.name, itemWithJson.attrid],
|
|
353
|
-
label: isShowLabel && handleDealInstruction(itemWithJson, instructionShowMode) || null,
|
|
354
|
-
initialValue,
|
|
355
|
-
rules: [
|
|
356
|
-
...((_f = itemWithJson.json) == null ? void 0 : _f.must) ? [
|
|
357
|
-
{
|
|
358
|
-
required: true,
|
|
359
|
-
message: `${placeholder}${itemWithJson.attrname}`
|
|
360
|
-
}
|
|
361
|
-
] : [],
|
|
362
|
-
...((_g = itemWithJson.json) == null ? void 0 : _g.regexp) ? [
|
|
363
|
-
{
|
|
364
|
-
pattern: new RegExp(itemWithJson.json.regexp.replace(/^\/|\/$/g, "")),
|
|
365
|
-
message: ((_h = itemWithJson.json) == null ? void 0 : _h["regexp-message"]) || `${itemWithJson.attrname}格式不正确`
|
|
366
|
-
}
|
|
367
|
-
] : []
|
|
368
|
-
],
|
|
369
|
-
...handleSetFormItemProps(itemWithJson),
|
|
370
|
-
children: handleRenderItemInputMode({
|
|
371
|
-
item: itemWithJson,
|
|
372
|
-
readonly,
|
|
373
|
-
formItemStyle,
|
|
374
|
-
radioAlign,
|
|
375
|
-
relatedid,
|
|
376
|
-
form,
|
|
377
|
-
defaultWidth
|
|
378
|
-
})
|
|
379
|
-
},
|
|
380
|
-
itemWithJson.attrid
|
|
381
|
-
) });
|
|
382
|
-
}
|
|
360
|
+
const formItemName = isFormListItem && formListField ? Array.isArray(formListField.name) ? [...formListField.name, itemWithJson.attrid] : [formListField.name, itemWithJson.attrid] : itemWithJson.attrid;
|
|
383
361
|
return /* @__PURE__ */ jsx(Col, { span: 24 / colNum, children: /* @__PURE__ */ jsx(
|
|
384
362
|
Form.Item,
|
|
385
363
|
{
|
|
386
|
-
name:
|
|
364
|
+
name: formItemName,
|
|
387
365
|
label: isShowLabel && handleDealInstruction(itemWithJson, instructionShowMode) || null,
|
|
388
366
|
initialValue,
|
|
389
367
|
rules: [
|
|
390
|
-
...((
|
|
368
|
+
...((_e = itemWithJson.json) == null ? void 0 : _e.must) ? [
|
|
391
369
|
{
|
|
392
370
|
required: true,
|
|
393
371
|
message: `${placeholder}${itemWithJson.attrname}`
|
|
394
372
|
}
|
|
395
373
|
] : [],
|
|
396
|
-
...((
|
|
374
|
+
...((_f = itemWithJson.json) == null ? void 0 : _f.regexp) ? [
|
|
397
375
|
{
|
|
398
376
|
pattern: new RegExp(itemWithJson.json.regexp.replace(/^\/|\/$/g, "")),
|
|
399
|
-
message: ((
|
|
377
|
+
message: ((_g = itemWithJson.json) == null ? void 0 : _g["regexp-message"]) || `${itemWithJson.attrname}格式不正确`
|
|
400
378
|
}
|
|
401
379
|
] : []
|
|
402
380
|
],
|
|
@@ -416,7 +394,7 @@ function useDynamicForm(props) {
|
|
|
416
394
|
}
|
|
417
395
|
return null;
|
|
418
396
|
},
|
|
419
|
-
[
|
|
397
|
+
[handleDealInstruction, handleSetFormItemInitialValue, handleSetFormItemProps, hideAttrList, renderNestedFormList]
|
|
420
398
|
);
|
|
421
399
|
const handleOnRemove = async (file) => {
|
|
422
400
|
var _a;
|
|
@@ -730,7 +708,7 @@ function useDynamicForm(props) {
|
|
|
730
708
|
if (((_a = itemWithJson.json) == null ? void 0 : _a.hide) === true) {
|
|
731
709
|
return null;
|
|
732
710
|
}
|
|
733
|
-
return /* @__PURE__ */ jsx(Fragment
|
|
711
|
+
return /* @__PURE__ */ jsx(Fragment, { children: handleRenderFunc({
|
|
734
712
|
itemWithJson,
|
|
735
713
|
readonly,
|
|
736
714
|
colNum,
|
package/es/utils/method.d.ts
CHANGED
|
@@ -10,7 +10,12 @@ export declare function isBase64(str: string): boolean;
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
export declare const handleSubmitForm: (originalData: any, allValues: any) => {
|
|
13
|
-
updatedData:
|
|
13
|
+
updatedData: {
|
|
14
|
+
data: {
|
|
15
|
+
asid: any;
|
|
16
|
+
data_list: any[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
14
19
|
uploadedFiles: any[];
|
|
15
20
|
};
|
|
16
21
|
/**
|
|
@@ -69,7 +74,7 @@ export declare const handleOperationFile: (params: any, data: any, commonRequest
|
|
|
69
74
|
*/
|
|
70
75
|
export declare function handleKebabToCamel(str: string): string;
|
|
71
76
|
/**
|
|
72
|
-
*
|
|
77
|
+
* 处理属性列表为接口提交格式(修复children的data_list为空问题)
|
|
73
78
|
* @param {Array} attrList 原始属性列表
|
|
74
79
|
* @returns {Object} 目标格式的data对象
|
|
75
80
|
*/
|
|
@@ -94,7 +99,7 @@ export declare const handleAttrListToObjDetail: ({ attrList, params, extra, comm
|
|
|
94
99
|
[key: string]: any;
|
|
95
100
|
} | undefined;
|
|
96
101
|
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
97
|
-
}) => Promise<any>;
|
|
102
|
+
}) => Promise<any[]>;
|
|
98
103
|
/**
|
|
99
104
|
* 处理URL选项 根据远程接口获取下拉、单选、多选数据
|
|
100
105
|
* 将URL中的指定字段拼接为字符串
|