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.
- package/dist/style.css +1 -1
- package/dist/szld-components.es.js +32023 -20148
- package/dist/szld-components.umd.js +72 -60
- package/es/components/DynamicForm/index.js +3 -2
- package/es/components/DynamicForm/selectModelBackfillFormItem/index.js +8 -7
- package/es/components/DynamicFormMobile/func.d.ts +35 -0
- package/es/components/DynamicFormMobile/func.js +204 -0
- package/es/components/DynamicFormMobile/index.d.ts +116 -0
- package/es/components/DynamicFormMobile/index.js +134 -0
- package/es/components/DynamicFormMobile/myCascader/index.d.ts +17 -0
- package/es/components/DynamicFormMobile/myCascader/index.js +196 -0
- package/es/components/DynamicFormMobile/myCascader/vite.svg +1 -0
- package/es/components/DynamicFormMobile/myCheckbox/index.d.ts +19 -0
- package/es/components/DynamicFormMobile/myCheckbox/index.js +109 -0
- package/es/components/DynamicFormMobile/myCheckbox/vite.svg +1 -0
- package/es/components/DynamicFormMobile/myRadio/index.d.ts +20 -0
- package/es/components/DynamicFormMobile/myRadio/index.js +107 -0
- package/es/components/DynamicFormMobile/myRadio/vite.svg +1 -0
- package/es/components/DynamicFormMobile/mySelect/index.css +31 -0
- package/es/components/DynamicFormMobile/mySelect/index.d.ts +16 -0
- package/es/components/DynamicFormMobile/mySelect/index.js +147 -0
- package/es/components/DynamicFormMobile/mySelect/vite.svg +1 -0
- package/es/components/DynamicFormMobile/myUpload/index.css +3 -0
- package/es/components/DynamicFormMobile/myUpload/index.d.ts +16 -0
- package/es/components/DynamicFormMobile/myUpload/index.js +103 -0
- package/es/components/DynamicFormMobile/myUpload/vite.svg +1 -0
- package/es/components/DynamicFormMobile/radioCard/index.d.ts +12 -0
- package/es/components/DynamicFormMobile/radioCard/index.js +142 -0
- package/es/components/DynamicFormMobile/radioCard/vite.svg +1 -0
- package/es/components/DynamicFormMobile/selectModel/index.d.ts +22 -0
- package/es/components/DynamicFormMobile/selectModel/index.js +235 -0
- package/es/components/DynamicFormMobile/selectModel/vite.svg +1 -0
- package/es/components/DynamicFormMobile/selectModelBackfillFormItem/index.d.ts +27 -0
- package/es/components/DynamicFormMobile/selectModelBackfillFormItem/index.js +242 -0
- package/es/components/DynamicFormMobile/selectModelBackfillFormItem/vite.svg +1 -0
- package/es/components/DynamicFormMobile/useDynamicForm.d.ts +43 -0
- package/es/components/DynamicFormMobile/useDynamicForm.js +772 -0
- package/es/components/DynamicFormMobile/vite.svg +1 -0
- package/es/index.css +1 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +35 -29
- package/es/main.d.ts +2 -1
- package/es/main.js +22 -20
- package/es/mock/index.js +20 -59
- package/es/services/index.js +3 -5
- package/es/services/request.js +2 -2
- package/es/utils/method.d.ts +6 -1
- package/es/utils/method.js +60 -34
- package/lib/components/DynamicForm/index.js +3 -2
- package/lib/components/DynamicForm/selectModelBackfillFormItem/index.js +8 -7
- package/lib/components/DynamicFormMobile/func.d.ts +35 -0
- package/lib/components/DynamicFormMobile/func.js +204 -0
- package/lib/components/DynamicFormMobile/index.d.ts +116 -0
- package/lib/components/DynamicFormMobile/index.js +133 -0
- package/lib/components/DynamicFormMobile/myCascader/index.d.ts +17 -0
- package/lib/components/DynamicFormMobile/myCascader/index.js +195 -0
- package/lib/components/DynamicFormMobile/myCascader/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/myCheckbox/index.d.ts +19 -0
- package/lib/components/DynamicFormMobile/myCheckbox/index.js +108 -0
- package/lib/components/DynamicFormMobile/myCheckbox/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/myRadio/index.d.ts +20 -0
- package/lib/components/DynamicFormMobile/myRadio/index.js +106 -0
- package/lib/components/DynamicFormMobile/myRadio/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/mySelect/index.css +31 -0
- package/lib/components/DynamicFormMobile/mySelect/index.d.ts +16 -0
- package/lib/components/DynamicFormMobile/mySelect/index.js +146 -0
- package/lib/components/DynamicFormMobile/mySelect/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/myUpload/index.css +3 -0
- package/lib/components/DynamicFormMobile/myUpload/index.d.ts +16 -0
- package/lib/components/DynamicFormMobile/myUpload/index.js +102 -0
- package/lib/components/DynamicFormMobile/myUpload/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/radioCard/index.d.ts +12 -0
- package/lib/components/DynamicFormMobile/radioCard/index.js +141 -0
- package/lib/components/DynamicFormMobile/radioCard/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/selectModel/index.d.ts +22 -0
- package/lib/components/DynamicFormMobile/selectModel/index.js +235 -0
- package/lib/components/DynamicFormMobile/selectModel/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/index.d.ts +27 -0
- package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/index.js +242 -0
- package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/useDynamicForm.d.ts +43 -0
- package/lib/components/DynamicFormMobile/useDynamicForm.js +771 -0
- package/lib/components/DynamicFormMobile/vite.svg +1 -0
- package/lib/index.css +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +35 -29
- package/lib/main.d.ts +2 -1
- package/lib/main.js +2 -0
- package/lib/mock/index.js +20 -59
- package/lib/services/index.js +3 -5
- package/lib/services/request.js +2 -2
- package/lib/utils/method.d.ts +6 -1
- package/lib/utils/method.js +60 -34
- package/package.json +1 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const dayjs = require("dayjs");
|
|
4
|
+
const antd = require("antd");
|
|
5
|
+
const handleGetPlaceholder = (itemWithJson) => {
|
|
6
|
+
const { input = "" } = itemWithJson.json || {};
|
|
7
|
+
let placeholder = "请输入";
|
|
8
|
+
if ([
|
|
9
|
+
"radio",
|
|
10
|
+
"checkbox",
|
|
11
|
+
"select",
|
|
12
|
+
"mult-select",
|
|
13
|
+
"modal-select",
|
|
14
|
+
"date-picker",
|
|
15
|
+
"range-picker",
|
|
16
|
+
"multiple-date-picker",
|
|
17
|
+
"time-picker",
|
|
18
|
+
"week-picker",
|
|
19
|
+
"month-picker",
|
|
20
|
+
"quarter-picker",
|
|
21
|
+
"year-picker",
|
|
22
|
+
"second-picker"
|
|
23
|
+
].includes(input)) {
|
|
24
|
+
placeholder = "请选择";
|
|
25
|
+
}
|
|
26
|
+
if (["image", "file", "video", "audio"].includes(input)) {
|
|
27
|
+
placeholder = "请上传";
|
|
28
|
+
}
|
|
29
|
+
return placeholder;
|
|
30
|
+
};
|
|
31
|
+
const handleSetFormItemInitialValue = (itemWithJson) => {
|
|
32
|
+
var _a, _b, _c, _d;
|
|
33
|
+
const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
|
|
34
|
+
let initialValue = itemWithJson.attrvalue || ((_b = itemWithJson.json) == null ? void 0 : _b.default) || "";
|
|
35
|
+
if (inputType === "label" && initialValue) {
|
|
36
|
+
initialValue = ((_c = itemWithJson.json) == null ? void 0 : _c["label-value"]) ?? initialValue ?? "-";
|
|
37
|
+
}
|
|
38
|
+
if (inputType === "range-picker" && initialValue) {
|
|
39
|
+
try {
|
|
40
|
+
initialValue = initialValue == null ? void 0 : initialValue.split("~");
|
|
41
|
+
initialValue = initialValue.map((v) => v);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
initialValue = void 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (inputType === "multiple-date-picker" && initialValue) {
|
|
47
|
+
try {
|
|
48
|
+
initialValue = initialValue == null ? void 0 : initialValue.split(",");
|
|
49
|
+
initialValue = initialValue.map((v) => dayjs());
|
|
50
|
+
} catch (error) {
|
|
51
|
+
initialValue = void 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (inputType === "cascader" && initialValue && typeof initialValue === "string") {
|
|
55
|
+
const delimiter = (_d = itemWithJson.json) == null ? void 0 : _d["cascader-delimiter"];
|
|
56
|
+
if (delimiter) {
|
|
57
|
+
initialValue = initialValue.split(delimiter).filter(Boolean);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (["mult-select", "checkbox"].includes(inputType) && initialValue && typeof initialValue === "string") {
|
|
61
|
+
initialValue = initialValue.split(",").filter(Boolean);
|
|
62
|
+
}
|
|
63
|
+
if (["image", "video", "audio", "file"].includes(inputType) && initialValue) {
|
|
64
|
+
try {
|
|
65
|
+
const fileList = Array.isArray(initialValue) ? initialValue : JSON.parse(initialValue);
|
|
66
|
+
initialValue = fileList.map((file) => ({
|
|
67
|
+
...file,
|
|
68
|
+
url: file.FilePath,
|
|
69
|
+
name: file.FileName,
|
|
70
|
+
uid: file.FileId
|
|
71
|
+
}));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
initialValue = [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (itemWithJson.attrtype === 1) {
|
|
77
|
+
initialValue = handleGetSingleAttrListObj(itemWithJson.children || []);
|
|
78
|
+
}
|
|
79
|
+
return initialValue || void 0;
|
|
80
|
+
};
|
|
81
|
+
const disabledDate = (current) => {
|
|
82
|
+
return current && current < dayjs().startOf("day");
|
|
83
|
+
};
|
|
84
|
+
const handleUrlOptions = (val, delimiter, list) => {
|
|
85
|
+
let arr = [];
|
|
86
|
+
list.forEach((item) => {
|
|
87
|
+
arr.push(val == null ? void 0 : val[item]);
|
|
88
|
+
});
|
|
89
|
+
return arr.join(delimiter || "-");
|
|
90
|
+
};
|
|
91
|
+
const handleSelectOptions = async ({
|
|
92
|
+
commonRequestWidthParams,
|
|
93
|
+
commonRequest,
|
|
94
|
+
interfaceTypeDict = "YLZDDictList",
|
|
95
|
+
interfaceTypeSysDict = "YLZDSysConfigList",
|
|
96
|
+
actionUrlKey = "action-url",
|
|
97
|
+
actionUrlExtraParams = {},
|
|
98
|
+
item
|
|
99
|
+
}) => {
|
|
100
|
+
var _a;
|
|
101
|
+
let options = [];
|
|
102
|
+
const getDict = async (interfaceType) => {
|
|
103
|
+
var _a2;
|
|
104
|
+
let list = [];
|
|
105
|
+
if (item.classify) {
|
|
106
|
+
try {
|
|
107
|
+
const response = await commonRequest(interfaceType, {
|
|
108
|
+
asctypeid: item.classify
|
|
109
|
+
});
|
|
110
|
+
if (((_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.list) && Array.isArray(response.data.list)) {
|
|
111
|
+
list = response.data.list.map((dictItem) => ({
|
|
112
|
+
label: `${dictItem.dicid || ""}-${dictItem.info || ""}`,
|
|
113
|
+
value: `${dictItem.dicid || ""}-${dictItem.info || ""}`
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
} catch (error) {
|
|
117
|
+
antd.message.error("加载选项失败");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return list;
|
|
121
|
+
};
|
|
122
|
+
const getUrlOptions = async () => {
|
|
123
|
+
var _a2, _b;
|
|
124
|
+
try {
|
|
125
|
+
const keyFieldList = ((_a2 = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a2.list) || [];
|
|
126
|
+
const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "";
|
|
127
|
+
if (!keyFieldList.length) {
|
|
128
|
+
antd.message.error("请配置key-field");
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const response = await commonRequestWidthParams(
|
|
132
|
+
{
|
|
133
|
+
PageName: "dns_relay",
|
|
134
|
+
Controlname: "CallActionUrl",
|
|
135
|
+
InterfaceType: ""
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
[actionUrlKey]: item == null ? void 0 : item["action-url"],
|
|
139
|
+
...actionUrlExtraParams
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
if (response == null ? void 0 : response.data) {
|
|
143
|
+
const data = response == null ? void 0 : response.data;
|
|
144
|
+
const list = (data == null ? void 0 : data.list) || [];
|
|
145
|
+
let urlData = [];
|
|
146
|
+
if (Array.isArray(data)) {
|
|
147
|
+
urlData = data;
|
|
148
|
+
}
|
|
149
|
+
if (Array.isArray(list)) {
|
|
150
|
+
urlData = list;
|
|
151
|
+
}
|
|
152
|
+
options = urlData.map((val) => ({
|
|
153
|
+
label: handleUrlOptions(val, delimiter, keyFieldList),
|
|
154
|
+
value: handleUrlOptions(val, delimiter, keyFieldList)
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
} catch (error) {
|
|
158
|
+
antd.message.error("加载选项失败");
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
if (item.inputType === "local") {
|
|
162
|
+
options = ((_a = item.data) == null ? void 0 : _a.map((val) => ({
|
|
163
|
+
label: val,
|
|
164
|
+
value: val
|
|
165
|
+
}))) || [];
|
|
166
|
+
if (item.options && Array.isArray(item.options)) {
|
|
167
|
+
options = item.options;
|
|
168
|
+
}
|
|
169
|
+
} else if (item.inputType === "dictionary") {
|
|
170
|
+
options = await getDict(interfaceTypeDict);
|
|
171
|
+
} else if (item.inputType === "system-dictionary") {
|
|
172
|
+
options = await getDict(interfaceTypeSysDict);
|
|
173
|
+
}
|
|
174
|
+
if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
|
|
175
|
+
await getUrlOptions();
|
|
176
|
+
}
|
|
177
|
+
return options;
|
|
178
|
+
};
|
|
179
|
+
const handleGetSingleAttrListObj = (children) => {
|
|
180
|
+
if (!(children == null ? void 0 : children.length)) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
const dealList = (children2) => children2 == null ? void 0 : children2.map((v) => {
|
|
184
|
+
const obj = {};
|
|
185
|
+
if (Array.isArray(v)) {
|
|
186
|
+
v.forEach((x) => {
|
|
187
|
+
var _a;
|
|
188
|
+
if ((_a = x == null ? void 0 : x.children) == null ? void 0 : _a.length) {
|
|
189
|
+
obj[x.attrid] = dealList(x.children);
|
|
190
|
+
} else {
|
|
191
|
+
obj[x.attrid] = x.attrvalue;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return obj;
|
|
196
|
+
});
|
|
197
|
+
return dealList(children);
|
|
198
|
+
};
|
|
199
|
+
exports.disabledDate = disabledDate;
|
|
200
|
+
exports.handleGetPlaceholder = handleGetPlaceholder;
|
|
201
|
+
exports.handleGetSingleAttrListObj = handleGetSingleAttrListObj;
|
|
202
|
+
exports.handleSelectOptions = handleSelectOptions;
|
|
203
|
+
exports.handleSetFormItemInitialValue = handleSetFormItemInitialValue;
|
|
204
|
+
exports.handleUrlOptions = handleUrlOptions;
|
|
@@ -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,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const antd = require("antd");
|
|
5
|
+
const useDynamicForm = require("./useDynamicForm");
|
|
6
|
+
const reactVant = require("react-vant");
|
|
7
|
+
const icons = require("@react-vant/icons");
|
|
8
|
+
const DynamicForm = react.forwardRef((props, ref) => {
|
|
9
|
+
const [form] = reactVant.Form.useForm();
|
|
10
|
+
const {
|
|
11
|
+
formConfig,
|
|
12
|
+
setFormConfig,
|
|
13
|
+
setAttrList,
|
|
14
|
+
readonly = false,
|
|
15
|
+
relatedid,
|
|
16
|
+
colNum = 1,
|
|
17
|
+
colSpace = [0, 0],
|
|
18
|
+
instructionShowMode = "flex",
|
|
19
|
+
defaultWidth = "100%",
|
|
20
|
+
commonRequestWidthParams,
|
|
21
|
+
uploadAction,
|
|
22
|
+
commonRequest,
|
|
23
|
+
formItemStyle = [],
|
|
24
|
+
radioAlign = "horizontal",
|
|
25
|
+
interfaceTypeChildren = "YLLRDetailAttrlist",
|
|
26
|
+
interfaceTypeDict = "YLZDDictList",
|
|
27
|
+
interfaceTypeSysDict = "YLZDSysConfigList",
|
|
28
|
+
relatedidKey = "relatedid",
|
|
29
|
+
actionUrlKey = "action-url",
|
|
30
|
+
actionUrlExtraParams = {},
|
|
31
|
+
CustomModalComponent,
|
|
32
|
+
hideAttrList = [],
|
|
33
|
+
formShowType = "form",
|
|
34
|
+
formListItemWidth,
|
|
35
|
+
formListItemName
|
|
36
|
+
} = props;
|
|
37
|
+
const delFileListRef = react.useRef([]);
|
|
38
|
+
const updateDelFileList = (file) => {
|
|
39
|
+
delFileListRef.current.push(file);
|
|
40
|
+
};
|
|
41
|
+
const { handleRenderItem } = useDynamicForm({
|
|
42
|
+
commonRequestWidthParams,
|
|
43
|
+
uploadAction,
|
|
44
|
+
commonRequest,
|
|
45
|
+
setFormConfig,
|
|
46
|
+
setAttrList,
|
|
47
|
+
updateDelFileList,
|
|
48
|
+
formConfig,
|
|
49
|
+
interfaceTypeChildren,
|
|
50
|
+
interfaceTypeDict,
|
|
51
|
+
interfaceTypeSysDict,
|
|
52
|
+
relatedidKey,
|
|
53
|
+
actionUrlKey,
|
|
54
|
+
actionUrlExtraParams,
|
|
55
|
+
CustomModalComponent,
|
|
56
|
+
hideAttrList
|
|
57
|
+
});
|
|
58
|
+
react.useImperativeHandle(ref, () => ({
|
|
59
|
+
getDelFileList: () => {
|
|
60
|
+
return delFileListRef.current;
|
|
61
|
+
},
|
|
62
|
+
submitForm: async () => {
|
|
63
|
+
try {
|
|
64
|
+
const values = await form.validateFields();
|
|
65
|
+
return values;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactVant.Form, { layout: "vertical", form, children: formShowType === "table" ? /* @__PURE__ */ jsxRuntime.jsx(reactVant.Form.List, { name: formListItemName || "customFormList", initialValue: [{}], children: (fields, { add, remove }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
71
|
+
fields.map((field, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: "form-list-item",
|
|
75
|
+
style: {
|
|
76
|
+
borderRadius: 8,
|
|
77
|
+
marginBottom: 10
|
|
78
|
+
},
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
81
|
+
antd.Flex,
|
|
82
|
+
{
|
|
83
|
+
justify: "space-between",
|
|
84
|
+
style: {
|
|
85
|
+
height: 44,
|
|
86
|
+
width: "calc(100vw - 32px)",
|
|
87
|
+
marginLeft: 16,
|
|
88
|
+
borderBottom: "1px solid #E3E3E3"
|
|
89
|
+
},
|
|
90
|
+
align: "center",
|
|
91
|
+
children: [
|
|
92
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { color: "#555555" }, children: [
|
|
93
|
+
"第",
|
|
94
|
+
idx + 1,
|
|
95
|
+
"条"
|
|
96
|
+
] }),
|
|
97
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { style: { color: "#ff4d4f" }, onClick: () => remove(idx), children: "删除" })
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-list-item__control", children: formConfig == null ? void 0 : formConfig.map((child, index) => {
|
|
102
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: handleRenderItem({
|
|
103
|
+
item: child,
|
|
104
|
+
readonly,
|
|
105
|
+
colNum,
|
|
106
|
+
instructionShowMode,
|
|
107
|
+
relatedid,
|
|
108
|
+
form,
|
|
109
|
+
defaultWidth: (formListItemWidth == null ? void 0 : formListItemWidth[index]) || defaultWidth,
|
|
110
|
+
formItemStyle,
|
|
111
|
+
isFormListItem: true,
|
|
112
|
+
formListField: field,
|
|
113
|
+
isShowLabel: false
|
|
114
|
+
}) }, index);
|
|
115
|
+
}) })
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
idx
|
|
119
|
+
)),
|
|
120
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: 10 }, children: /* @__PURE__ */ jsxRuntime.jsx(reactVant.Button, { plain: true, icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}), style: { width: "100%" }, type: "primary", onClick: () => add({}), children: "新增" }) })
|
|
121
|
+
] }) }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { gutter: colSpace, children: formConfig.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: handleRenderItem({
|
|
122
|
+
item,
|
|
123
|
+
readonly,
|
|
124
|
+
colNum,
|
|
125
|
+
instructionShowMode,
|
|
126
|
+
relatedid,
|
|
127
|
+
form,
|
|
128
|
+
defaultWidth,
|
|
129
|
+
formItemStyle,
|
|
130
|
+
radioAlign
|
|
131
|
+
}) }, item.attrid || `form-item-${index}`)) }) });
|
|
132
|
+
});
|
|
133
|
+
module.exports = DynamicForm;
|
|
@@ -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;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const antd = require("antd");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const MyCascader = ({
|
|
6
|
+
item,
|
|
7
|
+
readonly,
|
|
8
|
+
value,
|
|
9
|
+
onChange,
|
|
10
|
+
style,
|
|
11
|
+
commonRequestWidthParams,
|
|
12
|
+
commonRequest,
|
|
13
|
+
interfaceTypeDict,
|
|
14
|
+
interfaceTypeSysDict,
|
|
15
|
+
actionUrlKey,
|
|
16
|
+
actionUrlExtraParams
|
|
17
|
+
}) => {
|
|
18
|
+
const [options, setOptions] = react.useState([]);
|
|
19
|
+
const [loading, setLoading] = react.useState(false);
|
|
20
|
+
const { message } = antd.App.useApp();
|
|
21
|
+
react.useEffect(() => {
|
|
22
|
+
handleLoadOptions();
|
|
23
|
+
}, [item.inputType, item.classify, item.data, item.options]);
|
|
24
|
+
const handleLoadOptions = async () => {
|
|
25
|
+
if (item.inputType === "local") {
|
|
26
|
+
let localOptions = [];
|
|
27
|
+
if (item.data && Array.isArray(item.data)) {
|
|
28
|
+
localOptions = item.data.map((val) => ({
|
|
29
|
+
label: val,
|
|
30
|
+
value: val
|
|
31
|
+
}));
|
|
32
|
+
} else if (item.options && Array.isArray(item.options)) {
|
|
33
|
+
localOptions = item.options;
|
|
34
|
+
}
|
|
35
|
+
setOptions(localOptions);
|
|
36
|
+
} else if (item.inputType === "dictionary") {
|
|
37
|
+
await getDict(interfaceTypeSysDict);
|
|
38
|
+
} else if (item.inputType === "system-dictionary") {
|
|
39
|
+
getDict(interfaceTypeSysDict);
|
|
40
|
+
} else if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
|
|
41
|
+
const res = await handleGetUrlData();
|
|
42
|
+
if (res && Array.isArray(res)) {
|
|
43
|
+
setOptions(res);
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
let defaultOptions = [];
|
|
47
|
+
if (item.data && Array.isArray(item.data)) {
|
|
48
|
+
defaultOptions = item.data.map((val) => ({
|
|
49
|
+
label: val,
|
|
50
|
+
value: val
|
|
51
|
+
}));
|
|
52
|
+
} else if (item.options && Array.isArray(item.options)) {
|
|
53
|
+
defaultOptions = item.options;
|
|
54
|
+
}
|
|
55
|
+
setOptions(defaultOptions);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const getDict = async (interfaceType) => {
|
|
59
|
+
var _a;
|
|
60
|
+
if (item.classify) {
|
|
61
|
+
setLoading(true);
|
|
62
|
+
try {
|
|
63
|
+
const response = await commonRequest(interfaceType, {
|
|
64
|
+
asctypeid: item.classify
|
|
65
|
+
});
|
|
66
|
+
if (((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.list) && Array.isArray(response.data.list)) {
|
|
67
|
+
const dictionaryOptions = response.data.list.map((dictItem) => ({
|
|
68
|
+
label: `${dictItem.dicid || ""}-${dictItem.info || ""}`,
|
|
69
|
+
value: `${dictItem.dicid || ""}-${dictItem.info || ""}`
|
|
70
|
+
}));
|
|
71
|
+
setOptions(dictionaryOptions);
|
|
72
|
+
}
|
|
73
|
+
} catch (error) {
|
|
74
|
+
message.error("加载选项失败");
|
|
75
|
+
} finally {
|
|
76
|
+
setLoading(false);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const handleChange = (value2, selectedOptions) => {
|
|
81
|
+
if (onChange) {
|
|
82
|
+
onChange(value2);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const handleGetUrlData = async (targetOption) => {
|
|
86
|
+
return new Promise(async (resolve, reject) => {
|
|
87
|
+
var _a, _b, _c;
|
|
88
|
+
const list = ((_a = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a.list) || [];
|
|
89
|
+
const searchFields = (item == null ? void 0 : item["search-field"]) || [];
|
|
90
|
+
const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "-";
|
|
91
|
+
if (!list.length) {
|
|
92
|
+
message.error("请配置key-field");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const params = {
|
|
96
|
+
[actionUrlKey]: item == null ? void 0 : item["action-url"],
|
|
97
|
+
...actionUrlExtraParams
|
|
98
|
+
};
|
|
99
|
+
if (targetOption) {
|
|
100
|
+
searchFields.forEach((field) => {
|
|
101
|
+
params[field] = targetOption[field] || "";
|
|
102
|
+
});
|
|
103
|
+
params["level"] = Number(targetOption.level || 0) + 1 || "";
|
|
104
|
+
}
|
|
105
|
+
setLoading(true);
|
|
106
|
+
try {
|
|
107
|
+
const response = await commonRequestWidthParams(
|
|
108
|
+
{
|
|
109
|
+
PageName: "dns_relay",
|
|
110
|
+
Controlname: "CallActionUrl",
|
|
111
|
+
InterfaceType: ""
|
|
112
|
+
},
|
|
113
|
+
params
|
|
114
|
+
);
|
|
115
|
+
if (((_c = response == null ? void 0 : response.data) == null ? void 0 : _c.list) && Array.isArray(response.data.list)) {
|
|
116
|
+
const dictionaryOptions = response.data.list.map((item2) => ({
|
|
117
|
+
...item2,
|
|
118
|
+
label: `${item2[list[0]] || ""}${delimiter}${item2[list[1]] || ""}`,
|
|
119
|
+
value: `${item2[list[0]] || ""}${delimiter}${item2[list[1]] || ""}`,
|
|
120
|
+
children: [],
|
|
121
|
+
isLeaf: (item2 == null ? void 0 : item2.subcount) === 0
|
|
122
|
+
}));
|
|
123
|
+
resolve(dictionaryOptions);
|
|
124
|
+
}
|
|
125
|
+
reject([]);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
message.error("加载选项失败");
|
|
128
|
+
reject([]);
|
|
129
|
+
} finally {
|
|
130
|
+
reject([]);
|
|
131
|
+
setLoading(false);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
const loadData = async (selectedOptions) => {
|
|
136
|
+
const targetOption = selectedOptions[selectedOptions.length - 1];
|
|
137
|
+
const children = await handleGetUrlData(targetOption) || [];
|
|
138
|
+
targetOption.children = children;
|
|
139
|
+
setOptions([...options]);
|
|
140
|
+
return children;
|
|
141
|
+
};
|
|
142
|
+
const filter = (inputValue, path) => path.some((option) => option.label.toLowerCase().includes(inputValue.toLowerCase()));
|
|
143
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
144
|
+
antd.Cascader,
|
|
145
|
+
{
|
|
146
|
+
showSearch: { filter },
|
|
147
|
+
loading,
|
|
148
|
+
placeholder: "请选择",
|
|
149
|
+
loadData,
|
|
150
|
+
disabled: readonly,
|
|
151
|
+
onChange: handleChange,
|
|
152
|
+
style: { ...style },
|
|
153
|
+
options,
|
|
154
|
+
value,
|
|
155
|
+
onOpenChange: async (visible) => {
|
|
156
|
+
var _a;
|
|
157
|
+
if (visible && (value == null ? void 0 : value.length)) {
|
|
158
|
+
const list = ((_a = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a.list) || [];
|
|
159
|
+
const searchFields = (item == null ? void 0 : item["search-field"]) || [];
|
|
160
|
+
if (!list.length || !searchFields.length) {
|
|
161
|
+
message.error("请配置key-field和search-field");
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const targetFieldIndex = list.findIndex((item2) => item2 === searchFields[0]);
|
|
165
|
+
if (targetFieldIndex === -1) {
|
|
166
|
+
message.error("key-field与search-field配置不匹配");
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const values = value.map((v) => {
|
|
170
|
+
const arr = v.split("-");
|
|
171
|
+
return arr[targetFieldIndex] || "";
|
|
172
|
+
}).filter(Boolean);
|
|
173
|
+
let children = options;
|
|
174
|
+
for (const [index, el] of values.entries()) {
|
|
175
|
+
if (index === values.length - 1) {
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
const selectedOptions = children.filter((item2) => item2[searchFields[0]] === el);
|
|
179
|
+
if (selectedOptions.length === 0) {
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
const targetOption = selectedOptions[0];
|
|
183
|
+
if (targetOption.children && targetOption.children.length > 0) {
|
|
184
|
+
children = targetOption.children;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const newChildren = await loadData(selectedOptions);
|
|
188
|
+
children = newChildren;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
module.exports = MyCascader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { Ijson } from '../index.d';
|
|
3
|
+
export interface IMYRadio {
|
|
4
|
+
value?: (string | number)[];
|
|
5
|
+
onChange?: (checkedValue: any[]) => void;
|
|
6
|
+
item: Ijson;
|
|
7
|
+
readonly?: boolean;
|
|
8
|
+
options?: any;
|
|
9
|
+
radioAlign?: 'vertical' | 'horizontal';
|
|
10
|
+
handleUrlOptions: (val: any, delimiter: string, list: any[]) => string;
|
|
11
|
+
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
12
|
+
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
13
|
+
interfaceTypeDict: string;
|
|
14
|
+
interfaceTypeSysDict: string;
|
|
15
|
+
actionUrlKey: string;
|
|
16
|
+
actionUrlExtraParams: object;
|
|
17
|
+
}
|
|
18
|
+
declare const MyCheckbox: (props: IMYRadio) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export default MyCheckbox;
|