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
|
@@ -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
|
-
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useRef, useImperativeHandle, Fragment } from "react";
|
|
3
|
-
import { Row } from "antd";
|
|
1
|
+
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useRef, useImperativeHandle, Fragment as Fragment$1 } from "react";
|
|
3
|
+
import { Form, Flex, Row } from "antd";
|
|
4
4
|
import useDynamicForm from "./useDynamicForm";
|
|
5
5
|
const DynamicForm = forwardRef((props, ref) => {
|
|
6
6
|
const {
|
|
7
7
|
formConfig,
|
|
8
8
|
setFormConfig,
|
|
9
|
+
setAttrList,
|
|
9
10
|
form,
|
|
10
11
|
readonly = false,
|
|
11
12
|
relatedid,
|
|
@@ -24,7 +25,11 @@ const DynamicForm = forwardRef((props, ref) => {
|
|
|
24
25
|
relatedidKey = "relatedid",
|
|
25
26
|
actionUrlKey = "action-url",
|
|
26
27
|
actionUrlExtraParams = {},
|
|
27
|
-
CustomModalComponent
|
|
28
|
+
CustomModalComponent,
|
|
29
|
+
hideAttrList = [],
|
|
30
|
+
formShowType = "form",
|
|
31
|
+
headerWidth,
|
|
32
|
+
formListItemWidth
|
|
28
33
|
} = props;
|
|
29
34
|
const delFileListRef = useRef([]);
|
|
30
35
|
const updateDelFileList = (file) => {
|
|
@@ -35,6 +40,7 @@ const DynamicForm = forwardRef((props, ref) => {
|
|
|
35
40
|
uploadAction,
|
|
36
41
|
commonRequest,
|
|
37
42
|
setFormConfig,
|
|
43
|
+
setAttrList,
|
|
38
44
|
updateDelFileList,
|
|
39
45
|
formConfig,
|
|
40
46
|
interfaceTypeChildren,
|
|
@@ -43,14 +49,53 @@ const DynamicForm = forwardRef((props, ref) => {
|
|
|
43
49
|
relatedidKey,
|
|
44
50
|
actionUrlKey,
|
|
45
51
|
actionUrlExtraParams,
|
|
46
|
-
CustomModalComponent
|
|
52
|
+
CustomModalComponent,
|
|
53
|
+
hideAttrList
|
|
47
54
|
});
|
|
48
55
|
useImperativeHandle(ref, () => ({
|
|
49
56
|
getDelFileList: () => {
|
|
50
57
|
return delFileListRef.current;
|
|
51
58
|
}
|
|
52
59
|
}));
|
|
53
|
-
return /* @__PURE__ */ jsx(
|
|
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
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", children: [
|
|
62
|
+
/* @__PURE__ */ jsx(Flex, { className: "custom-form-list-header", align: "center", children: formConfig == null ? void 0 : formConfig.map((child, index) => {
|
|
63
|
+
return /* @__PURE__ */ jsxs(Flex, { style: { width: (headerWidth == null ? void 0 : headerWidth[index]) || defaultWidth }, align: "center", children: [
|
|
64
|
+
index !== 0 && /* @__PURE__ */ jsx("div", { className: "line" }),
|
|
65
|
+
/* @__PURE__ */ jsx("div", { className: "custom-form-list-header-item", children: child.attrname })
|
|
66
|
+
] }, index);
|
|
67
|
+
}) }),
|
|
68
|
+
/* @__PURE__ */ jsx("a", { className: "custom-form-list-add-btn", onClick: () => add(), children: "新增" })
|
|
69
|
+
] }),
|
|
70
|
+
fields.map((field) => /* @__PURE__ */ jsxs(Flex, { align: "center", className: "custom-form-list-item-container", children: [
|
|
71
|
+
/* @__PURE__ */ jsx(Flex, { className: "custom-form-list-item", align: "center", children: formConfig == null ? void 0 : formConfig.map((child, index) => {
|
|
72
|
+
return /* @__PURE__ */ jsx(
|
|
73
|
+
Flex,
|
|
74
|
+
{
|
|
75
|
+
align: "center",
|
|
76
|
+
className: "custom-form-list-item-content",
|
|
77
|
+
justify: "center",
|
|
78
|
+
style: { width: (headerWidth == null ? void 0 : headerWidth[index]) || defaultWidth },
|
|
79
|
+
children: handleRenderItem({
|
|
80
|
+
item: child,
|
|
81
|
+
readonly,
|
|
82
|
+
colNum,
|
|
83
|
+
instructionShowMode,
|
|
84
|
+
relatedid,
|
|
85
|
+
form,
|
|
86
|
+
defaultWidth: (formListItemWidth == null ? void 0 : formListItemWidth[index]) || defaultWidth,
|
|
87
|
+
formItemStyle,
|
|
88
|
+
isFormListItem: true,
|
|
89
|
+
formListField: field,
|
|
90
|
+
isShowLabel: false
|
|
91
|
+
})
|
|
92
|
+
},
|
|
93
|
+
child.attrid || `child-${index}`
|
|
94
|
+
);
|
|
95
|
+
}) }),
|
|
96
|
+
/* @__PURE__ */ jsx("a", { className: "custom-form-list-del-btn", onClick: () => remove(field.key), children: "删除" })
|
|
97
|
+
] }, field.key))
|
|
98
|
+
] }) }) : /* @__PURE__ */ jsx(Row, { gutter: colSpace, children: formConfig.map((item, index) => /* @__PURE__ */ jsx(Fragment$1, { children: handleRenderItem({
|
|
54
99
|
item,
|
|
55
100
|
readonly,
|
|
56
101
|
colNum,
|
|
@@ -60,7 +105,7 @@ const DynamicForm = forwardRef((props, ref) => {
|
|
|
60
105
|
defaultWidth,
|
|
61
106
|
formItemStyle,
|
|
62
107
|
radioAlign
|
|
63
|
-
}) }, item.attrid || `form-item-${index}`)) });
|
|
108
|
+
}) }, item.attrid || `form-item-${index}`)) }) });
|
|
64
109
|
});
|
|
65
110
|
export {
|
|
66
111
|
DynamicForm as default
|
|
@@ -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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { MinusSquareOutlined, PlusSquareOutlined, InfoCircleOutlined } from "@ant-design/icons";
|
|
2
|
+
import { MinusSquareOutlined, PlusSquareOutlined, CloseOutlined, InfoCircleOutlined } from "@ant-design/icons";
|
|
3
3
|
import { useRef, useEffect, useCallback, Fragment as Fragment$1 } from "react";
|
|
4
|
-
import { getJson, base64ToString } from "../../utils/method";
|
|
4
|
+
import { handleAttrList, getJson, base64ToString } from "../../utils/method";
|
|
5
5
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
6
6
|
import SelectModel from "./selectModel";
|
|
7
7
|
import MyCheckbox from "./myCheckbox";
|
|
@@ -12,7 +12,7 @@ import MySelect from "./mySelect";
|
|
|
12
12
|
import MyUpload from "./myUpload";
|
|
13
13
|
import MyRadio from "./myRadio";
|
|
14
14
|
import _ from "lodash";
|
|
15
|
-
import { App, Col, Collapse, Form, Input, DatePicker, InputNumber,
|
|
15
|
+
import { App, Col, Collapse, Form, Card, Flex, Button, Space, Input, DatePicker, InputNumber, Tooltip } from "antd";
|
|
16
16
|
dayjs.extend(isoWeek);
|
|
17
17
|
function useDynamicForm(props) {
|
|
18
18
|
const {
|
|
@@ -28,7 +28,9 @@ function useDynamicForm(props) {
|
|
|
28
28
|
relatedidKey,
|
|
29
29
|
actionUrlKey,
|
|
30
30
|
actionUrlExtraParams,
|
|
31
|
-
CustomModalComponent
|
|
31
|
+
CustomModalComponent,
|
|
32
|
+
setAttrList,
|
|
33
|
+
hideAttrList = []
|
|
32
34
|
} = props;
|
|
33
35
|
const formConfigRef = useRef([]);
|
|
34
36
|
const { message } = App.useApp();
|
|
@@ -118,17 +120,24 @@ function useDynamicForm(props) {
|
|
|
118
120
|
value: value ? dayjs(value, format || "HH:mm:ss") : null
|
|
119
121
|
});
|
|
120
122
|
break;
|
|
123
|
+
case "range-picker":
|
|
124
|
+
baseProps.getValueFromEvent = (date) => date == null ? void 0 : date.map((d) => d == null ? void 0 : d.format(format || "YYYY-MM-DD"));
|
|
125
|
+
baseProps.getValueProps = (value) => ({
|
|
126
|
+
value: (value == null ? void 0 : value.map((v) => dayjs(v))) || null
|
|
127
|
+
});
|
|
128
|
+
break;
|
|
121
129
|
}
|
|
122
130
|
return baseProps;
|
|
123
131
|
},
|
|
124
132
|
[handleNormFile]
|
|
125
133
|
);
|
|
126
134
|
const handleSetFormItemInitialValue = useCallback((itemWithJson) => {
|
|
127
|
-
var _a, _b, _c, _d;
|
|
135
|
+
var _a, _b, _c, _d, _e;
|
|
128
136
|
const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
|
|
129
|
-
|
|
137
|
+
const isFormList = (_b = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _b["properties-multiple"];
|
|
138
|
+
let initialValue = itemWithJson.attrvalue ?? ((_c = itemWithJson.json) == null ? void 0 : _c.default);
|
|
130
139
|
if (inputType === "label" && initialValue) {
|
|
131
|
-
initialValue = ((
|
|
140
|
+
initialValue = ((_d = itemWithJson.json) == null ? void 0 : _d["label-value"]) ?? initialValue ?? "-";
|
|
132
141
|
}
|
|
133
142
|
if ((inputType === "date-picker" || inputType === "time-picker") && initialValue) {
|
|
134
143
|
try {
|
|
@@ -138,8 +147,16 @@ function useDynamicForm(props) {
|
|
|
138
147
|
initialValue = void 0;
|
|
139
148
|
}
|
|
140
149
|
}
|
|
150
|
+
if (inputType === "range-picker" && initialValue) {
|
|
151
|
+
try {
|
|
152
|
+
initialValue = initialValue == null ? void 0 : initialValue.split("~");
|
|
153
|
+
initialValue = initialValue.map((v) => dayjs(v));
|
|
154
|
+
} catch (error) {
|
|
155
|
+
initialValue = void 0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
141
158
|
if (inputType === "cascader" && initialValue && typeof initialValue === "string") {
|
|
142
|
-
const delimiter = (
|
|
159
|
+
const delimiter = (_e = itemWithJson.json) == null ? void 0 : _e["cascader-delimiter"];
|
|
143
160
|
if (delimiter) {
|
|
144
161
|
initialValue = initialValue.split(delimiter).filter(Boolean);
|
|
145
162
|
}
|
|
@@ -160,6 +177,19 @@ function useDynamicForm(props) {
|
|
|
160
177
|
initialValue = [];
|
|
161
178
|
}
|
|
162
179
|
}
|
|
180
|
+
if (isFormList && itemWithJson.attrtype === 1) {
|
|
181
|
+
const children = itemWithJson.children || [];
|
|
182
|
+
if (Array.isArray(children)) {
|
|
183
|
+
initialValue = [
|
|
184
|
+
Object.assign(
|
|
185
|
+
{},
|
|
186
|
+
...children == null ? void 0 : children.map((child) => ({
|
|
187
|
+
[child.attrid]: handleSetFormItemInitialValue(child)
|
|
188
|
+
}))
|
|
189
|
+
)
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
}
|
|
163
193
|
return initialValue || null;
|
|
164
194
|
}, []);
|
|
165
195
|
const handleCollapseIcon = useCallback(
|
|
@@ -192,10 +222,18 @@ function useDynamicForm(props) {
|
|
|
192
222
|
formItemStyle,
|
|
193
223
|
relatedid,
|
|
194
224
|
form,
|
|
195
|
-
defaultWidth = 358
|
|
225
|
+
defaultWidth = 358,
|
|
226
|
+
isFormListItem = false,
|
|
227
|
+
formListField,
|
|
228
|
+
isShowLabel = true
|
|
196
229
|
}) => {
|
|
197
|
-
var _a, _b;
|
|
198
|
-
|
|
230
|
+
var _a, _b, _c, _d, _e;
|
|
231
|
+
const isFormList = (_a = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _a["properties-multiple"];
|
|
232
|
+
let formListInitValue = [];
|
|
233
|
+
if (isFormList) {
|
|
234
|
+
formListInitValue = handleSetFormItemInitialValue(itemWithJson);
|
|
235
|
+
}
|
|
236
|
+
if (((_b = itemWithJson.json) == null ? void 0 : _b.hide) === true || (hideAttrList == null ? void 0 : hideAttrList.includes(itemWithJson.attrid))) {
|
|
199
237
|
return /* @__PURE__ */ jsx(Fragment, {});
|
|
200
238
|
}
|
|
201
239
|
if (itemWithJson.attrtype === 1) {
|
|
@@ -206,23 +244,25 @@ function useDynamicForm(props) {
|
|
|
206
244
|
style: { backgroundColor: "transparent" },
|
|
207
245
|
expandIcon: ({ isActive }) => handleCollapseIcon({ isActive }),
|
|
208
246
|
onChange: async (key) => {
|
|
209
|
-
var _a2;
|
|
247
|
+
var _a2, _b2;
|
|
210
248
|
try {
|
|
211
249
|
const { children = [] } = itemWithJson;
|
|
212
|
-
if (key && (key == null ? void 0 : key.length) &&
|
|
250
|
+
if (key && (key == null ? void 0 : key.length) && formConfigRef.current && interfaceTypeChildren && !(children == null ? void 0 : children.length)) {
|
|
213
251
|
const res = await commonRequest(interfaceTypeChildren, {
|
|
214
252
|
instanceid: relatedid,
|
|
215
|
-
asid: itemWithJson.
|
|
216
|
-
tname: itemWithJson.
|
|
253
|
+
asid: (_a2 = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _a2.propertiesID,
|
|
254
|
+
tname: itemWithJson.attrvalue
|
|
217
255
|
});
|
|
218
256
|
if ((res == null ? void 0 : res.ReturnValue) === 1) {
|
|
219
|
-
const
|
|
257
|
+
const list = ((_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.list) || [];
|
|
258
|
+
const arr = handleAttrList(list, { instanceid: relatedid, tname: itemWithJson.tname });
|
|
220
259
|
const _formConfig = _.cloneDeep(formConfigRef.current);
|
|
221
260
|
const _item = _formConfig.find((item) => item.attrid === itemWithJson.attrid);
|
|
222
261
|
if (_item) {
|
|
223
262
|
_item.children = [...arr];
|
|
224
263
|
}
|
|
225
|
-
setFormConfig(_formConfig);
|
|
264
|
+
setFormConfig == null ? void 0 : setFormConfig(_formConfig);
|
|
265
|
+
setAttrList == null ? void 0 : setAttrList(_formConfig);
|
|
226
266
|
}
|
|
227
267
|
}
|
|
228
268
|
} catch (error) {
|
|
@@ -232,7 +272,52 @@ function useDynamicForm(props) {
|
|
|
232
272
|
{
|
|
233
273
|
key: itemWithJson.attrid,
|
|
234
274
|
label: itemWithJson.attrname,
|
|
235
|
-
|
|
275
|
+
styles: {
|
|
276
|
+
header: {
|
|
277
|
+
paddingLeft: 0
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
children: isFormList ? /* @__PURE__ */ jsx(Form.List, { name: itemWithJson.attrid, initialValue: formListInitValue, children: (fields, { add, remove }) => {
|
|
281
|
+
var _a2;
|
|
282
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", rowGap: 16, flexDirection: "column" }, children: [
|
|
283
|
+
fields.map((field) => {
|
|
284
|
+
var _a3;
|
|
285
|
+
return /* @__PURE__ */ jsx(
|
|
286
|
+
Card,
|
|
287
|
+
{
|
|
288
|
+
style: { width: ((_a3 = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _a3["properties-width"]) || defaultWidth + 100 },
|
|
289
|
+
size: "small",
|
|
290
|
+
title: `${itemWithJson.attrname} ${field.name + 1}`,
|
|
291
|
+
extra: /* @__PURE__ */ jsx(
|
|
292
|
+
CloseOutlined,
|
|
293
|
+
{
|
|
294
|
+
onClick: () => {
|
|
295
|
+
remove(field.name);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
),
|
|
299
|
+
children: (itemWithJson.children || []).map((child, index) => {
|
|
300
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: handleRenderItem({
|
|
301
|
+
item: child,
|
|
302
|
+
readonly,
|
|
303
|
+
colNum,
|
|
304
|
+
instructionShowMode,
|
|
305
|
+
relatedid,
|
|
306
|
+
form,
|
|
307
|
+
defaultWidth,
|
|
308
|
+
formItemStyle,
|
|
309
|
+
isFormListItem: true,
|
|
310
|
+
formListField: field,
|
|
311
|
+
isShowLabel: true
|
|
312
|
+
}) }, child.attrid || `child-${index}`);
|
|
313
|
+
})
|
|
314
|
+
},
|
|
315
|
+
field.key
|
|
316
|
+
);
|
|
317
|
+
}),
|
|
318
|
+
/* @__PURE__ */ jsx(Flex, { style: { width: ((_a2 = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _a2["properties-width"]) || defaultWidth + 100 }, children: /* @__PURE__ */ jsx(Button, { type: "dashed", onClick: () => add(), block: true, children: "+ 新增" }) })
|
|
319
|
+
] });
|
|
320
|
+
} }) : /* @__PURE__ */ jsx("div", { children: (itemWithJson.children || []).map((child, index) => {
|
|
236
321
|
return /* @__PURE__ */ jsx(Fragment$1, { children: handleRenderItem({
|
|
237
322
|
item: child,
|
|
238
323
|
readonly,
|
|
@@ -264,6 +349,8 @@ function useDynamicForm(props) {
|
|
|
264
349
|
"mult-select",
|
|
265
350
|
"modal-select",
|
|
266
351
|
"date-picker",
|
|
352
|
+
"range-picker",
|
|
353
|
+
"multiple-date-picker",
|
|
267
354
|
"time-picker",
|
|
268
355
|
"week-picker",
|
|
269
356
|
"month-picker",
|
|
@@ -276,14 +363,92 @@ function useDynamicForm(props) {
|
|
|
276
363
|
if (["image", "file", "video", "audio"].includes(input)) {
|
|
277
364
|
placeholder = "请上传";
|
|
278
365
|
}
|
|
366
|
+
const { combinations = [] } = itemWithJson.json || {};
|
|
367
|
+
if (combinations == null ? void 0 : combinations.length) {
|
|
368
|
+
return /* @__PURE__ */ jsx(Col, { span: 24 / colNum, children: /* @__PURE__ */ jsx(Form.Item, { label: (_c = itemWithJson == null ? void 0 : itemWithJson.json) == null ? void 0 : _c["combination-name"], children: /* @__PURE__ */ jsx(Space.Compact, { children: combinations.map((item, index) => {
|
|
369
|
+
var _a2, _b2;
|
|
370
|
+
let initValue = handleSetFormItemInitialValue(item);
|
|
371
|
+
let width = defaultWidth;
|
|
372
|
+
const customWidth = {};
|
|
373
|
+
const mode = item.json.input || "text";
|
|
374
|
+
const itemStyle = formItemStyle == null ? void 0 : formItemStyle.find((v) => v.type === mode);
|
|
375
|
+
if (itemStyle) {
|
|
376
|
+
const { width: width2 } = (itemStyle == null ? void 0 : itemStyle.style) || {};
|
|
377
|
+
if (width2) {
|
|
378
|
+
customWidth["width"] = width2;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
const widthRatio = (_a2 = item == null ? void 0 : item.json) == null ? void 0 : _a2["combination-width-ratio"];
|
|
382
|
+
if (widthRatio) {
|
|
383
|
+
width = defaultWidth * widthRatio;
|
|
384
|
+
}
|
|
385
|
+
return /* @__PURE__ */ jsx(
|
|
386
|
+
Form.Item,
|
|
387
|
+
{
|
|
388
|
+
name: item.attrid,
|
|
389
|
+
noStyle: true,
|
|
390
|
+
initialValue: initValue,
|
|
391
|
+
rules: [
|
|
392
|
+
...((_b2 = item.json) == null ? void 0 : _b2.must) ? [
|
|
393
|
+
{
|
|
394
|
+
required: true,
|
|
395
|
+
message: `${placeholder}${item.attrname}`
|
|
396
|
+
}
|
|
397
|
+
] : []
|
|
398
|
+
],
|
|
399
|
+
...handleSetFormItemProps(item),
|
|
400
|
+
children: handleRenderItemInputMode({
|
|
401
|
+
item,
|
|
402
|
+
readonly,
|
|
403
|
+
formItemStyle,
|
|
404
|
+
radioAlign,
|
|
405
|
+
relatedid,
|
|
406
|
+
form,
|
|
407
|
+
defaultWidth: width,
|
|
408
|
+
customWidth
|
|
409
|
+
})
|
|
410
|
+
},
|
|
411
|
+
index
|
|
412
|
+
);
|
|
413
|
+
}) }) }, `${itemWithJson.attrid}+1`) });
|
|
414
|
+
}
|
|
415
|
+
if (isFormListItem && formListField) {
|
|
416
|
+
return /* @__PURE__ */ jsx(Col, { span: 24 / colNum, children: /* @__PURE__ */ jsx(
|
|
417
|
+
Form.Item,
|
|
418
|
+
{
|
|
419
|
+
name: [formListField == null ? void 0 : formListField.name, itemWithJson.attrid],
|
|
420
|
+
label: isShowLabel && handleDealInstruction(itemWithJson, instructionShowMode) || null,
|
|
421
|
+
initialValue,
|
|
422
|
+
rules: [
|
|
423
|
+
...((_d = itemWithJson.json) == null ? void 0 : _d.must) ? [
|
|
424
|
+
{
|
|
425
|
+
required: true,
|
|
426
|
+
message: `${placeholder}${itemWithJson.attrname}`
|
|
427
|
+
}
|
|
428
|
+
] : []
|
|
429
|
+
],
|
|
430
|
+
...handleSetFormItemProps(itemWithJson),
|
|
431
|
+
children: handleRenderItemInputMode({
|
|
432
|
+
item: itemWithJson,
|
|
433
|
+
readonly,
|
|
434
|
+
formItemStyle,
|
|
435
|
+
radioAlign,
|
|
436
|
+
relatedid,
|
|
437
|
+
form,
|
|
438
|
+
defaultWidth
|
|
439
|
+
})
|
|
440
|
+
},
|
|
441
|
+
itemWithJson.attrid
|
|
442
|
+
) });
|
|
443
|
+
}
|
|
279
444
|
return /* @__PURE__ */ jsx(Col, { span: 24 / colNum, children: /* @__PURE__ */ jsx(
|
|
280
445
|
Form.Item,
|
|
281
446
|
{
|
|
282
447
|
name: itemWithJson.attrid,
|
|
283
|
-
label: handleDealInstruction(itemWithJson, instructionShowMode),
|
|
448
|
+
label: isShowLabel && handleDealInstruction(itemWithJson, instructionShowMode) || null,
|
|
284
449
|
initialValue,
|
|
285
450
|
rules: [
|
|
286
|
-
...((
|
|
451
|
+
...((_e = itemWithJson.json) == null ? void 0 : _e.must) ? [
|
|
287
452
|
{
|
|
288
453
|
required: true,
|
|
289
454
|
message: `${placeholder}${itemWithJson.attrname}`
|
|
@@ -339,7 +504,8 @@ function useDynamicForm(props) {
|
|
|
339
504
|
radioAlign = "horizontal",
|
|
340
505
|
relatedid,
|
|
341
506
|
form,
|
|
342
|
-
defaultWidth = 358
|
|
507
|
+
defaultWidth = 358,
|
|
508
|
+
customWidth = {}
|
|
343
509
|
}) => {
|
|
344
510
|
var _a, _b;
|
|
345
511
|
const mode = item.json.input || "text";
|
|
@@ -355,7 +521,7 @@ function useDynamicForm(props) {
|
|
|
355
521
|
{
|
|
356
522
|
disabled: true,
|
|
357
523
|
value: ((_a = item.json) == null ? void 0 : _a["label-value"]) || item.attrvalue || ((_b = item.json) == null ? void 0 : _b.default) || "-",
|
|
358
|
-
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
|
|
524
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
|
|
359
525
|
}
|
|
360
526
|
);
|
|
361
527
|
case "text":
|
|
@@ -366,7 +532,7 @@ function useDynamicForm(props) {
|
|
|
366
532
|
...params,
|
|
367
533
|
disabled: readonly,
|
|
368
534
|
allowClear: true,
|
|
369
|
-
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
|
|
535
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
|
|
370
536
|
}
|
|
371
537
|
);
|
|
372
538
|
case "textarea":
|
|
@@ -378,7 +544,7 @@ function useDynamicForm(props) {
|
|
|
378
544
|
rows: 5,
|
|
379
545
|
...params,
|
|
380
546
|
disabled: readonly,
|
|
381
|
-
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
|
|
547
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
|
|
382
548
|
}
|
|
383
549
|
);
|
|
384
550
|
case "number":
|
|
@@ -389,7 +555,7 @@ function useDynamicForm(props) {
|
|
|
389
555
|
placeholder: "请输入",
|
|
390
556
|
...params,
|
|
391
557
|
disabled: readonly,
|
|
392
|
-
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
|
|
558
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
|
|
393
559
|
}
|
|
394
560
|
);
|
|
395
561
|
case "select":
|
|
@@ -400,7 +566,7 @@ function useDynamicForm(props) {
|
|
|
400
566
|
handleUrlOptions,
|
|
401
567
|
item: item.json,
|
|
402
568
|
readonly,
|
|
403
|
-
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style },
|
|
569
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
|
|
404
570
|
commonRequestWidthParams,
|
|
405
571
|
commonRequest,
|
|
406
572
|
value: formatValue,
|
|
@@ -419,7 +585,7 @@ function useDynamicForm(props) {
|
|
|
419
585
|
return /* @__PURE__ */ jsx(
|
|
420
586
|
SelectModel,
|
|
421
587
|
{
|
|
422
|
-
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style },
|
|
588
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
|
|
423
589
|
item: item.json,
|
|
424
590
|
value: item.attrvalue || item.json.default || "",
|
|
425
591
|
commonRequestWidthParams,
|
|
@@ -455,10 +621,18 @@ function useDynamicForm(props) {
|
|
|
455
621
|
picker: pickerObj[mode] || "date",
|
|
456
622
|
disabled: readonly,
|
|
457
623
|
placement: "bottomLeft",
|
|
458
|
-
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style }
|
|
624
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
|
|
459
625
|
}
|
|
460
626
|
);
|
|
461
627
|
}
|
|
628
|
+
case "range-picker":
|
|
629
|
+
return /* @__PURE__ */ jsx(
|
|
630
|
+
DatePicker.RangePicker,
|
|
631
|
+
{
|
|
632
|
+
disabled: readonly,
|
|
633
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
|
|
634
|
+
}
|
|
635
|
+
);
|
|
462
636
|
case "radio":
|
|
463
637
|
return /* @__PURE__ */ jsx(
|
|
464
638
|
MyRadio,
|
|
@@ -526,7 +700,7 @@ function useDynamicForm(props) {
|
|
|
526
700
|
commonRequest,
|
|
527
701
|
item: item.json,
|
|
528
702
|
value: item.attrvalue,
|
|
529
|
-
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style },
|
|
703
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
|
|
530
704
|
interfaceTypeDict,
|
|
531
705
|
interfaceTypeSysDict,
|
|
532
706
|
actionUrlKey,
|
|
@@ -546,7 +720,16 @@ function useDynamicForm(props) {
|
|
|
546
720
|
}
|
|
547
721
|
);
|
|
548
722
|
default:
|
|
549
|
-
return /* @__PURE__ */ jsx(
|
|
723
|
+
return /* @__PURE__ */ jsx(
|
|
724
|
+
Input,
|
|
725
|
+
{
|
|
726
|
+
placeholder: "请输入",
|
|
727
|
+
...params,
|
|
728
|
+
showCount: true,
|
|
729
|
+
disabled: readonly,
|
|
730
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth }
|
|
731
|
+
}
|
|
732
|
+
);
|
|
550
733
|
}
|
|
551
734
|
};
|
|
552
735
|
const handleRenderItem = ({
|
|
@@ -558,40 +741,41 @@ function useDynamicForm(props) {
|
|
|
558
741
|
form,
|
|
559
742
|
defaultWidth = 358,
|
|
560
743
|
formItemStyle,
|
|
561
|
-
radioAlign = "horizontal"
|
|
744
|
+
radioAlign = "horizontal",
|
|
745
|
+
isFormListItem = false,
|
|
746
|
+
formListField,
|
|
747
|
+
isShowLabel = true
|
|
562
748
|
}) => {
|
|
563
749
|
var _a;
|
|
564
750
|
const json = item.info_base64 === 1 ? getJson(base64ToString(item.info)) : getJson(item.info);
|
|
565
|
-
const itemWithJson = {
|
|
751
|
+
const itemWithJson = {
|
|
752
|
+
...item,
|
|
753
|
+
json: {
|
|
754
|
+
...item == null ? void 0 : item.json,
|
|
755
|
+
...json
|
|
756
|
+
}
|
|
757
|
+
};
|
|
566
758
|
if (((_a = itemWithJson.json) == null ? void 0 : _a.hide) === true) {
|
|
567
759
|
return null;
|
|
568
760
|
}
|
|
569
|
-
return /* @__PURE__ */
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
{
|
|
584
|
-
name: itemWithJson.attrid + "_objs",
|
|
585
|
-
style: { display: "none" },
|
|
586
|
-
initialValue: itemWithJson,
|
|
587
|
-
children: /* @__PURE__ */ jsx(Input, { type: "hidden" })
|
|
588
|
-
},
|
|
589
|
-
itemWithJson.attrid + "_objs"
|
|
590
|
-
)
|
|
591
|
-
] }, itemWithJson.attrid);
|
|
761
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: handleRenderFunc({
|
|
762
|
+
itemWithJson,
|
|
763
|
+
readonly,
|
|
764
|
+
colNum,
|
|
765
|
+
instructionShowMode,
|
|
766
|
+
relatedid,
|
|
767
|
+
form,
|
|
768
|
+
defaultWidth,
|
|
769
|
+
formItemStyle,
|
|
770
|
+
radioAlign,
|
|
771
|
+
isFormListItem,
|
|
772
|
+
formListField,
|
|
773
|
+
isShowLabel
|
|
774
|
+
}) }, itemWithJson.attrid);
|
|
592
775
|
};
|
|
593
776
|
return {
|
|
594
|
-
handleRenderItem
|
|
777
|
+
handleRenderItem,
|
|
778
|
+
handleSetFormItemInitialValue
|
|
595
779
|
};
|
|
596
780
|
}
|
|
597
781
|
export {
|