szld-libs 0.2.51 → 0.2.53
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 +17010 -15271
- package/dist/szld-components.umd.js +55 -55
- package/es/components/BackHeader/index.d.ts +2 -0
- package/es/components/BackHeader/index.js +5 -1
- package/es/components/DynamicForm/index.d.ts +102 -0
- package/es/components/DynamicForm/index.js +55 -0
- package/es/components/DynamicForm/myCascader/index.d.ts +13 -0
- package/es/components/DynamicForm/myCascader/index.js +186 -0
- package/es/components/DynamicForm/myCascader/vite.svg +1 -0
- package/es/components/DynamicForm/myCheckbox/index.d.ts +15 -0
- package/es/components/DynamicForm/myCheckbox/index.js +102 -0
- package/es/components/DynamicForm/myCheckbox/vite.svg +1 -0
- package/es/components/DynamicForm/myRadio/index.d.ts +16 -0
- package/es/components/DynamicForm/myRadio/index.js +100 -0
- package/es/components/DynamicForm/myRadio/vite.svg +1 -0
- package/es/components/DynamicForm/mySelect/index.d.ts +13 -0
- package/es/components/DynamicForm/mySelect/index.js +126 -0
- package/es/components/DynamicForm/mySelect/vite.svg +1 -0
- package/es/components/DynamicForm/myUpload/index.css +3 -0
- package/es/components/DynamicForm/myUpload/index.d.ts +15 -0
- package/es/components/DynamicForm/myUpload/index.js +102 -0
- package/es/components/DynamicForm/myUpload/vite.svg +1 -0
- package/es/components/DynamicForm/radioCard/index.d.ts +12 -0
- package/es/components/DynamicForm/radioCard/index.js +142 -0
- package/es/components/DynamicForm/radioCard/vite.svg +1 -0
- package/es/components/DynamicForm/selectModel/index.d.ts +21 -0
- package/es/components/DynamicForm/selectModel/index.js +197 -0
- package/es/components/DynamicForm/selectModel/vite.svg +1 -0
- package/es/components/DynamicForm/useDynamicForm.d.ts +26 -0
- package/es/components/DynamicForm/useDynamicForm.js +554 -0
- package/es/components/DynamicForm/vite.svg +1 -0
- package/es/main.d.ts +3 -1
- package/es/main.js +22 -18
- package/es/utils/method.d.ts +18 -0
- package/es/utils/method.js +186 -0
- package/lib/components/BackHeader/index.d.ts +2 -0
- package/lib/components/BackHeader/index.js +5 -1
- package/lib/components/DynamicForm/index.d.ts +102 -0
- package/lib/components/DynamicForm/index.js +54 -0
- package/lib/components/DynamicForm/myCascader/index.d.ts +13 -0
- package/lib/components/DynamicForm/myCascader/index.js +185 -0
- package/lib/components/DynamicForm/myCascader/vite.svg +1 -0
- package/lib/components/DynamicForm/myCheckbox/index.d.ts +15 -0
- package/lib/components/DynamicForm/myCheckbox/index.js +101 -0
- package/lib/components/DynamicForm/myCheckbox/vite.svg +1 -0
- package/lib/components/DynamicForm/myRadio/index.d.ts +16 -0
- package/lib/components/DynamicForm/myRadio/index.js +99 -0
- package/lib/components/DynamicForm/myRadio/vite.svg +1 -0
- package/lib/components/DynamicForm/mySelect/index.d.ts +13 -0
- package/lib/components/DynamicForm/mySelect/index.js +125 -0
- package/lib/components/DynamicForm/mySelect/vite.svg +1 -0
- package/lib/components/DynamicForm/myUpload/index.css +3 -0
- package/lib/components/DynamicForm/myUpload/index.d.ts +15 -0
- package/lib/components/DynamicForm/myUpload/index.js +101 -0
- package/lib/components/DynamicForm/myUpload/vite.svg +1 -0
- package/lib/components/DynamicForm/radioCard/index.d.ts +12 -0
- package/lib/components/DynamicForm/radioCard/index.js +141 -0
- package/lib/components/DynamicForm/radioCard/vite.svg +1 -0
- package/lib/components/DynamicForm/selectModel/index.d.ts +21 -0
- package/lib/components/DynamicForm/selectModel/index.js +197 -0
- package/lib/components/DynamicForm/selectModel/vite.svg +1 -0
- package/lib/components/DynamicForm/useDynamicForm.d.ts +26 -0
- package/lib/components/DynamicForm/useDynamicForm.js +553 -0
- package/lib/components/DynamicForm/vite.svg +1 -0
- package/lib/main.d.ts +3 -1
- package/lib/main.js +5 -0
- package/lib/utils/method.d.ts +18 -0
- package/lib/utils/method.js +186 -0
- package/package.json +3 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
function getJson(jsonStr) {
|
|
4
|
+
try {
|
|
5
|
+
return JSON.parse(jsonStr);
|
|
6
|
+
} catch (error) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function base64ToString(base64Str) {
|
|
11
|
+
if (!isBase64(base64Str)) {
|
|
12
|
+
return base64Str;
|
|
13
|
+
}
|
|
14
|
+
const binaryStr = atob(base64Str);
|
|
15
|
+
const bytes = new Uint8Array(binaryStr.length);
|
|
16
|
+
for (let i = 0; i < binaryStr.length; i++) {
|
|
17
|
+
bytes[i] = binaryStr.charCodeAt(i);
|
|
18
|
+
}
|
|
19
|
+
return new TextDecoder().decode(bytes);
|
|
20
|
+
}
|
|
21
|
+
function isBase64(str) {
|
|
22
|
+
if (!str)
|
|
23
|
+
return true;
|
|
24
|
+
if (str.length % 4 !== 0)
|
|
25
|
+
return false;
|
|
26
|
+
const base64Regex = /^[A-Za-z0-9+/]+(?:=?=?)$/;
|
|
27
|
+
return base64Regex.test(str);
|
|
28
|
+
}
|
|
29
|
+
const handleSubmitForm = (originalData, allValues) => {
|
|
30
|
+
let updatedData = _.cloneDeep(originalData);
|
|
31
|
+
let uploadedFiles = [];
|
|
32
|
+
const processAttrList = (attrList) => {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
const attrMap = new Map(attrList.map((item, index) => [item.attrid, index]));
|
|
35
|
+
try {
|
|
36
|
+
for (const [fieldName, formValue] of Object.entries(allValues)) {
|
|
37
|
+
const index = attrMap.get(fieldName);
|
|
38
|
+
if (index === void 0)
|
|
39
|
+
continue;
|
|
40
|
+
const attrItem = attrList[index];
|
|
41
|
+
const inputType = (_a = attrItem.json) == null ? void 0 : _a.input;
|
|
42
|
+
const format = (_b = attrItem.json) == null ? void 0 : _b["format"];
|
|
43
|
+
if (!formValue && formValue !== 0) {
|
|
44
|
+
attrItem.attrvalue = "";
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
switch (inputType) {
|
|
48
|
+
case "image":
|
|
49
|
+
case "file":
|
|
50
|
+
case "video":
|
|
51
|
+
case "audio":
|
|
52
|
+
const parsedValue = typeof formValue === "string" ? JSON.parse(formValue) : formValue;
|
|
53
|
+
if (!Array.isArray(parsedValue)) {
|
|
54
|
+
attrItem.attrvalue = JSON.stringify([]);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const existingFiles = parsedValue.filter((file) => file.FileId);
|
|
58
|
+
const uploadedFileList = parsedValue.filter((file) => {
|
|
59
|
+
var _a2;
|
|
60
|
+
return file.status === "done" && ((_a2 = file.response) == null ? void 0 : _a2.data);
|
|
61
|
+
}).map((file) => file.response.data);
|
|
62
|
+
const allFiles = [...existingFiles, ...uploadedFileList];
|
|
63
|
+
uploadedFiles = [...uploadedFiles, ...uploadedFileList];
|
|
64
|
+
attrItem.attrvalue = JSON.stringify(allFiles);
|
|
65
|
+
break;
|
|
66
|
+
case "cascader":
|
|
67
|
+
if (Array.isArray(formValue) && formValue.length > 0) {
|
|
68
|
+
const delimiter = ((_c = attrItem.json) == null ? void 0 : _c["cascader-delimiter"]) || "/";
|
|
69
|
+
attrItem.attrvalue = formValue.join(delimiter);
|
|
70
|
+
} else {
|
|
71
|
+
attrItem.attrvalue = "";
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case "checkbox":
|
|
75
|
+
case "mult-select":
|
|
76
|
+
if (Array.isArray(formValue) && formValue.length > 0) {
|
|
77
|
+
attrItem.attrvalue = formValue.join(",");
|
|
78
|
+
} else {
|
|
79
|
+
attrItem.attrvalue = formValue;
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
case "date-picker":
|
|
83
|
+
if (formValue) {
|
|
84
|
+
attrItem.attrvalue = dayjs(formValue).format(format || "YYYY-MM-DD");
|
|
85
|
+
} else {
|
|
86
|
+
attrItem.attrvalue = "";
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case "time-picker":
|
|
90
|
+
if (formValue) {
|
|
91
|
+
attrItem.attrvalue = dayjs(formValue).format(format || "YYYY-MM-DD HH:mm:ss");
|
|
92
|
+
} else {
|
|
93
|
+
attrItem.attrvalue = "";
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
attrItem.attrvalue = formValue;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
attrList.forEach((item) => {
|
|
102
|
+
if (item.children && Array.isArray(item.children) && item.children.length > 0) {
|
|
103
|
+
processAttrList(item.children);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
} catch (error) {
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
if (updatedData.attr_list && Array.isArray(updatedData.attr_list)) {
|
|
110
|
+
processAttrList(updatedData.attr_list);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
updatedData,
|
|
114
|
+
uploadedFiles
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
const handleAttrList = (attrList) => {
|
|
118
|
+
return attrList.map((item) => {
|
|
119
|
+
if (!item.json && item.info) {
|
|
120
|
+
try {
|
|
121
|
+
const json = item.info_base64 === 1 ? getJson(base64ToString(item.info)) : getJson(item.info);
|
|
122
|
+
item.json = json;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
item.json = {};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return item;
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
const handleFormConfig = async ({
|
|
131
|
+
number,
|
|
132
|
+
key,
|
|
133
|
+
sourceNumber,
|
|
134
|
+
guidInterfaceName,
|
|
135
|
+
SelPCParamInterfaceName,
|
|
136
|
+
attrListInterfaceName,
|
|
137
|
+
commonRequest
|
|
138
|
+
}) => {
|
|
139
|
+
return new Promise(async (resolve, reject) => {
|
|
140
|
+
var _a, _b, _c;
|
|
141
|
+
let newGUID = "", attrListConfigs = [], baseData = {};
|
|
142
|
+
const guidRes = await commonRequest(guidInterfaceName || "FWDXGLCreateGUID", {
|
|
143
|
+
"source-number": sourceNumber
|
|
144
|
+
});
|
|
145
|
+
if ((guidRes == null ? void 0 : guidRes.ReturnValue) === 1 && ((_a = guidRes == null ? void 0 : guidRes.data) == null ? void 0 : _a.GUID)) {
|
|
146
|
+
newGUID = guidRes.data.GUID;
|
|
147
|
+
} else {
|
|
148
|
+
reject("获取GUID失败");
|
|
149
|
+
}
|
|
150
|
+
const res = await commonRequest(SelPCParamInterfaceName || "FWDXGLSelPCParam", {
|
|
151
|
+
"source-number": sourceNumber
|
|
152
|
+
});
|
|
153
|
+
if ((res == null ? void 0 : res.ReturnValue) === 1) {
|
|
154
|
+
const asid = (_b = res.data[number]) == null ? void 0 : _b[key];
|
|
155
|
+
const res2 = await commonRequest(attrListInterfaceName || "SERATTALLList", {
|
|
156
|
+
asid,
|
|
157
|
+
"source-number": sourceNumber
|
|
158
|
+
});
|
|
159
|
+
if ((res2 == null ? void 0 : res2.ReturnValue) === 1 && res2.data) {
|
|
160
|
+
const attrList = ((_c = res2.data) == null ? void 0 : _c["attr_list"]) || [];
|
|
161
|
+
attrListConfigs = handleAttrList(attrList);
|
|
162
|
+
baseData = {
|
|
163
|
+
...res2.data,
|
|
164
|
+
attr_list: attrListConfigs
|
|
165
|
+
};
|
|
166
|
+
resolve({
|
|
167
|
+
baseData,
|
|
168
|
+
newGUID,
|
|
169
|
+
attrListConfigs
|
|
170
|
+
});
|
|
171
|
+
} else {
|
|
172
|
+
reject("请配置属性集");
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
reject("获取配置失败");
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
export {
|
|
180
|
+
base64ToString,
|
|
181
|
+
getJson,
|
|
182
|
+
handleAttrList,
|
|
183
|
+
handleFormConfig,
|
|
184
|
+
handleSubmitForm,
|
|
185
|
+
isBase64
|
|
186
|
+
};
|
|
@@ -18,6 +18,8 @@ interface BackHeaderProps {
|
|
|
18
18
|
level?: 1 | 2 | 3 | 4 | 5;
|
|
19
19
|
/** 自定义图标 */
|
|
20
20
|
icon?: React.ReactNode;
|
|
21
|
+
/** 自定义返回事件 */
|
|
22
|
+
onBack?: () => void;
|
|
21
23
|
}
|
|
22
24
|
declare const BackHeader: (props: BackHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
25
|
export default BackHeader;
|
|
@@ -16,7 +16,7 @@ const styles = {
|
|
|
16
16
|
};
|
|
17
17
|
const { Title, Text } = antd.Typography;
|
|
18
18
|
const BackHeader = (props) => {
|
|
19
|
-
const { isBack = true, title: title2, extra, subTitle = null, className, style, titleStyle, level = 2, icon } = props;
|
|
19
|
+
const { isBack = true, title: title2, extra, subTitle = null, className, style, titleStyle, level = 2, icon, onBack } = props;
|
|
20
20
|
const navigate = reactRouterDom.useNavigate();
|
|
21
21
|
const renderSubtitle = () => {
|
|
22
22
|
if (typeof subTitle === "string") {
|
|
@@ -25,6 +25,10 @@ const BackHeader = (props) => {
|
|
|
25
25
|
return subTitle;
|
|
26
26
|
};
|
|
27
27
|
const goBack = () => {
|
|
28
|
+
if (onBack) {
|
|
29
|
+
onBack == null ? void 0 : onBack();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
28
32
|
navigate(-1);
|
|
29
33
|
};
|
|
30
34
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames(styles.main, className), style, children: [
|
|
@@ -0,0 +1,102 @@
|
|
|
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: IformConfigItem[];
|
|
17
|
+
json: Ijson;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Ijson {
|
|
21
|
+
input: InputType;
|
|
22
|
+
length?: number;
|
|
23
|
+
'label-value'?: string; //代表属性固定取值,并且不可在实例化时修改
|
|
24
|
+
hide: true;
|
|
25
|
+
'upload-accept'?: string;
|
|
26
|
+
'upload-max-count'?: number;
|
|
27
|
+
'upload-size'?: number;
|
|
28
|
+
//代表弹窗标题
|
|
29
|
+
'modal-caption'?: string;
|
|
30
|
+
//代表弹窗宽度
|
|
31
|
+
'modal-width'?: number;
|
|
32
|
+
//代表弹窗高度
|
|
33
|
+
'modal-height'?: number;
|
|
34
|
+
//代表弹窗列表表头内容
|
|
35
|
+
'modal-field-list'?: { [key: string]: string }; // 键值对,键为属性名,值为属性显示的列表表头内容
|
|
36
|
+
inputType?: 'local' | 'dictionary' | 'url';
|
|
37
|
+
data?: string[];
|
|
38
|
+
//代表调用【字典管理系统】的值
|
|
39
|
+
classify?: number | string | undefined;
|
|
40
|
+
//代表调用字典对应的归类名 ID
|
|
41
|
+
//代表从"action-url"从获取选择的数据
|
|
42
|
+
'action-url'?: string;
|
|
43
|
+
//代表执行一个动作的 UCE 的 url
|
|
44
|
+
'key-field'?: { list: string[]; delimiter: string };
|
|
45
|
+
default?: string | number | boolean | null | undefined | dayjs.Dayjs;
|
|
46
|
+
//代表属性默认值,如果没配置或空着,则代表没有默认值
|
|
47
|
+
instruction?: '';
|
|
48
|
+
//代表在实例化时对属性的填写说明,会作为提示语显示在属性名称旁
|
|
49
|
+
'instruction-color'?: '#000000';
|
|
50
|
+
//代表在实例化时对属性的填写说明,字体颜色的配置,如果不配置默认#333333
|
|
51
|
+
must?: true;
|
|
52
|
+
//代表属性值是否必填,true 为必填、false 为非必填,如果没配置则默认为 false
|
|
53
|
+
'cascader-delimiter'?: string;
|
|
54
|
+
options?: { label: string; value: string | number }[];
|
|
55
|
+
format?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 定义支持的输入类型枚举
|
|
59
|
+
export type InputType =
|
|
60
|
+
| 'text'
|
|
61
|
+
| 'textarea'
|
|
62
|
+
| 'number'
|
|
63
|
+
| 'select'
|
|
64
|
+
| 'mult-select'
|
|
65
|
+
| 'modal-select'
|
|
66
|
+
| 'modal-mult-select'
|
|
67
|
+
| 'date-picker'
|
|
68
|
+
| 'time-picker'
|
|
69
|
+
| 'week-picker'
|
|
70
|
+
| 'month-picker'
|
|
71
|
+
| 'quarter-picker'
|
|
72
|
+
| 'year-picker'
|
|
73
|
+
| 'second-picker'
|
|
74
|
+
| 'image'
|
|
75
|
+
| 'file'
|
|
76
|
+
| 'video'
|
|
77
|
+
| 'audio'
|
|
78
|
+
| 'label'
|
|
79
|
+
| 'radio'
|
|
80
|
+
| 'checkbox'
|
|
81
|
+
| 'cascader'
|
|
82
|
+
| string;
|
|
83
|
+
|
|
84
|
+
// 定义文件上传值类型
|
|
85
|
+
export interface CustomUploadFile {
|
|
86
|
+
FilePath: string;
|
|
87
|
+
FileName: string;
|
|
88
|
+
FileId: string;
|
|
89
|
+
url?: string;
|
|
90
|
+
name?: string;
|
|
91
|
+
uid?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface IformItemStyle {
|
|
95
|
+
type: InputType;
|
|
96
|
+
style?: React.CSSProperties;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface Iselect {
|
|
100
|
+
label: string;
|
|
101
|
+
value: string | number;
|
|
102
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 DynamicForm = react.forwardRef((props, ref) => {
|
|
7
|
+
const {
|
|
8
|
+
formConfig,
|
|
9
|
+
setFormConfig,
|
|
10
|
+
form,
|
|
11
|
+
readonly = false,
|
|
12
|
+
relatedid,
|
|
13
|
+
colNum = 1,
|
|
14
|
+
colSpace = [0, 0],
|
|
15
|
+
instructionShowMode = "flex",
|
|
16
|
+
defaultWidth = 358,
|
|
17
|
+
commonRequestWidthParams,
|
|
18
|
+
uploadAction,
|
|
19
|
+
commonRequest,
|
|
20
|
+
formItemStyle = [],
|
|
21
|
+
radioAlign = "horizontal",
|
|
22
|
+
interfaceTypeChildren = "YLLRDetailAttrlist"
|
|
23
|
+
} = props;
|
|
24
|
+
const delFileListRef = react.useRef([]);
|
|
25
|
+
const updateDelFileList = (file) => {
|
|
26
|
+
delFileListRef.current.push(file);
|
|
27
|
+
};
|
|
28
|
+
const { handleRenderItem } = useDynamicForm({
|
|
29
|
+
commonRequestWidthParams,
|
|
30
|
+
uploadAction,
|
|
31
|
+
commonRequest,
|
|
32
|
+
setFormConfig,
|
|
33
|
+
updateDelFileList,
|
|
34
|
+
formConfig,
|
|
35
|
+
interfaceTypeChildren
|
|
36
|
+
});
|
|
37
|
+
react.useImperativeHandle(ref, () => ({
|
|
38
|
+
getDelFileList: () => {
|
|
39
|
+
return delFileListRef.current;
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
return /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { gutter: colSpace, children: formConfig.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: handleRenderItem({
|
|
43
|
+
item,
|
|
44
|
+
readonly,
|
|
45
|
+
colNum,
|
|
46
|
+
instructionShowMode,
|
|
47
|
+
relatedid,
|
|
48
|
+
form,
|
|
49
|
+
defaultWidth,
|
|
50
|
+
formItemStyle,
|
|
51
|
+
radioAlign
|
|
52
|
+
}) }, item.attrid || `form-item-${index}`)) });
|
|
53
|
+
});
|
|
54
|
+
module.exports = DynamicForm;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
12
|
+
declare const MyCascader: ({ item, readonly, value, onChange, style, commonRequestWidthParams, commonRequest, }: MyCascaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default MyCascader;
|
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
}) => {
|
|
14
|
+
const [options, setOptions] = react.useState([]);
|
|
15
|
+
const [loading, setLoading] = react.useState(false);
|
|
16
|
+
const { message } = antd.App.useApp();
|
|
17
|
+
react.useEffect(() => {
|
|
18
|
+
handleLoadOptions();
|
|
19
|
+
}, [item.inputType, item.classify, item.data, item.options]);
|
|
20
|
+
const handleLoadOptions = async () => {
|
|
21
|
+
var _a;
|
|
22
|
+
if (item.inputType === "local") {
|
|
23
|
+
let localOptions = [];
|
|
24
|
+
if (item.data && Array.isArray(item.data)) {
|
|
25
|
+
localOptions = item.data.map((val) => ({
|
|
26
|
+
label: val,
|
|
27
|
+
value: val
|
|
28
|
+
}));
|
|
29
|
+
} else if (item.options && Array.isArray(item.options)) {
|
|
30
|
+
localOptions = item.options;
|
|
31
|
+
}
|
|
32
|
+
setOptions(localOptions);
|
|
33
|
+
} else if (item.inputType === "dictionary") {
|
|
34
|
+
if (item.classify) {
|
|
35
|
+
setLoading(true);
|
|
36
|
+
try {
|
|
37
|
+
const response = await commonRequest("YLZDDictList", {
|
|
38
|
+
asctypeid: item.classify
|
|
39
|
+
});
|
|
40
|
+
if (((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.list) && Array.isArray(response.data.list)) {
|
|
41
|
+
const dictionaryOptions = response.data.list.map((dictItem) => ({
|
|
42
|
+
label: `${dictItem.dicid || ""}-${dictItem.info || ""}`,
|
|
43
|
+
value: `${dictItem.dicid || ""}-${dictItem.info || ""}`
|
|
44
|
+
}));
|
|
45
|
+
setOptions(dictionaryOptions);
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
message.error("加载选项失败");
|
|
49
|
+
} finally {
|
|
50
|
+
setLoading(false);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} else if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
|
|
54
|
+
const res = await handleGetUrlData();
|
|
55
|
+
if (res && Array.isArray(res)) {
|
|
56
|
+
setOptions(res);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
let defaultOptions = [];
|
|
60
|
+
if (item.data && Array.isArray(item.data)) {
|
|
61
|
+
defaultOptions = item.data.map((val) => ({
|
|
62
|
+
label: val,
|
|
63
|
+
value: val
|
|
64
|
+
}));
|
|
65
|
+
} else if (item.options && Array.isArray(item.options)) {
|
|
66
|
+
defaultOptions = item.options;
|
|
67
|
+
}
|
|
68
|
+
setOptions(defaultOptions);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const handleChange = (value2, selectedOptions) => {
|
|
72
|
+
if (onChange) {
|
|
73
|
+
onChange(value2);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const handleGetUrlData = async (targetOption) => {
|
|
77
|
+
return new Promise(async (resolve, reject) => {
|
|
78
|
+
var _a, _b, _c;
|
|
79
|
+
const list = ((_a = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a.list) || [];
|
|
80
|
+
const searchFields = (item == null ? void 0 : item["search-field"]) || [];
|
|
81
|
+
const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "-";
|
|
82
|
+
if (!list.length) {
|
|
83
|
+
message.error("请配置key-field");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const params = {
|
|
87
|
+
"action-url": item == null ? void 0 : item["action-url"]
|
|
88
|
+
};
|
|
89
|
+
if (targetOption) {
|
|
90
|
+
searchFields.forEach((field) => {
|
|
91
|
+
params[field] = targetOption[field] || "";
|
|
92
|
+
});
|
|
93
|
+
params["level"] = Number(targetOption.level || 0) + 1 || "";
|
|
94
|
+
}
|
|
95
|
+
setLoading(true);
|
|
96
|
+
try {
|
|
97
|
+
const response = await commonRequestWidthParams(
|
|
98
|
+
{
|
|
99
|
+
PageName: "dns_relay",
|
|
100
|
+
Controlname: "CallActionUrl",
|
|
101
|
+
InterfaceType: "DPGLSysemName"
|
|
102
|
+
},
|
|
103
|
+
params
|
|
104
|
+
);
|
|
105
|
+
if (((_c = response == null ? void 0 : response.data) == null ? void 0 : _c.list) && Array.isArray(response.data.list)) {
|
|
106
|
+
const dictionaryOptions = response.data.list.map((item2) => ({
|
|
107
|
+
...item2,
|
|
108
|
+
label: `${item2[list[0]] || ""}${delimiter}${item2[list[1]] || ""}`,
|
|
109
|
+
value: `${item2[list[0]] || ""}${delimiter}${item2[list[1]] || ""}`,
|
|
110
|
+
children: [],
|
|
111
|
+
isLeaf: (item2 == null ? void 0 : item2.subcount) === 0
|
|
112
|
+
}));
|
|
113
|
+
resolve(dictionaryOptions);
|
|
114
|
+
}
|
|
115
|
+
reject([]);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
message.error("加载选项失败");
|
|
118
|
+
reject([]);
|
|
119
|
+
} finally {
|
|
120
|
+
reject([]);
|
|
121
|
+
setLoading(false);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
const loadData = async (selectedOptions) => {
|
|
126
|
+
const targetOption = selectedOptions[selectedOptions.length - 1];
|
|
127
|
+
const children = await handleGetUrlData(targetOption) || [];
|
|
128
|
+
targetOption.children = children;
|
|
129
|
+
setOptions([...options]);
|
|
130
|
+
return children;
|
|
131
|
+
};
|
|
132
|
+
const filter = (inputValue, path) => path.some((option) => option.label.toLowerCase().includes(inputValue.toLowerCase()));
|
|
133
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
134
|
+
antd.Cascader,
|
|
135
|
+
{
|
|
136
|
+
showSearch: { filter },
|
|
137
|
+
loading,
|
|
138
|
+
placeholder: "请选择",
|
|
139
|
+
loadData,
|
|
140
|
+
disabled: readonly,
|
|
141
|
+
onChange: handleChange,
|
|
142
|
+
style: { ...style },
|
|
143
|
+
options,
|
|
144
|
+
value,
|
|
145
|
+
onOpenChange: async (visible) => {
|
|
146
|
+
var _a;
|
|
147
|
+
if (visible && (value == null ? void 0 : value.length)) {
|
|
148
|
+
const list = ((_a = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a.list) || [];
|
|
149
|
+
const searchFields = (item == null ? void 0 : item["search-field"]) || [];
|
|
150
|
+
if (!list.length || !searchFields.length) {
|
|
151
|
+
message.error("请配置key-field和search-field");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const targetFieldIndex = list.findIndex((item2) => item2 === searchFields[0]);
|
|
155
|
+
if (targetFieldIndex === -1) {
|
|
156
|
+
message.error("key-field与search-field配置不匹配");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const values = value.map((v) => {
|
|
160
|
+
const arr = v.split("-");
|
|
161
|
+
return arr[targetFieldIndex] || "";
|
|
162
|
+
}).filter(Boolean);
|
|
163
|
+
let children = options;
|
|
164
|
+
for (const [index, el] of values.entries()) {
|
|
165
|
+
if (index === values.length - 1) {
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
const selectedOptions = children.filter((item2) => item2[searchFields[0]] === el);
|
|
169
|
+
if (selectedOptions.length === 0) {
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
const targetOption = selectedOptions[0];
|
|
173
|
+
if (targetOption.children && targetOption.children.length > 0) {
|
|
174
|
+
children = targetOption.children;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const newChildren = await loadData(selectedOptions);
|
|
178
|
+
children = newChildren;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
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,15 @@
|
|
|
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
|
+
}
|
|
14
|
+
declare const MyCheckbox: (props: IMYRadio) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export default MyCheckbox;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const antd = require("antd");
|
|
5
|
+
const MyCheckbox = (props) => {
|
|
6
|
+
const {
|
|
7
|
+
item,
|
|
8
|
+
onChange,
|
|
9
|
+
readonly = false,
|
|
10
|
+
options,
|
|
11
|
+
radioAlign = "horizontal",
|
|
12
|
+
commonRequestWidthParams,
|
|
13
|
+
commonRequest,
|
|
14
|
+
handleUrlOptions,
|
|
15
|
+
value
|
|
16
|
+
} = props;
|
|
17
|
+
const { message } = antd.App.useApp();
|
|
18
|
+
const [list, setList] = react.useState([]);
|
|
19
|
+
const [val, setVal] = react.useState(value || []);
|
|
20
|
+
react.useEffect(() => {
|
|
21
|
+
if ((item == null ? void 0 : item.inputType) === "local") {
|
|
22
|
+
const arr = (item == null ? void 0 : item.data) || [];
|
|
23
|
+
setList(arr.map((v) => ({ value: v, label: v })));
|
|
24
|
+
} else if ((item == null ? void 0 : item.inputType) === "dictionary") {
|
|
25
|
+
getList(item.classify);
|
|
26
|
+
} else if ((item == null ? void 0 : item.inputType) === "url") {
|
|
27
|
+
getUrlList();
|
|
28
|
+
}
|
|
29
|
+
}, [item == null ? void 0 : item.inputType]);
|
|
30
|
+
const getList = async (id) => {
|
|
31
|
+
var _a;
|
|
32
|
+
if (!id) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const res = await commonRequest("YLZDDictList", { asctypeid: id });
|
|
36
|
+
if ((res == null ? void 0 : res.ReturnValue) === 1) {
|
|
37
|
+
const arr = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || [];
|
|
38
|
+
setList(
|
|
39
|
+
arr.map((v) => {
|
|
40
|
+
const value2 = v.dicid + "-" + v.info;
|
|
41
|
+
return { value: value2, label: value2 };
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const getUrlList = async () => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
try {
|
|
49
|
+
const keyFieldList = ((_a = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a.list) || [];
|
|
50
|
+
const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "";
|
|
51
|
+
if (!keyFieldList.length) {
|
|
52
|
+
message.error("请配置key-field");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const response = await commonRequestWidthParams(
|
|
56
|
+
{
|
|
57
|
+
PageName: "dns_relay",
|
|
58
|
+
Controlname: "CallActionUrl",
|
|
59
|
+
InterfaceType: "DPGLSysemName"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"action-url": item == null ? void 0 : item["action-url"]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
if (response == null ? void 0 : response.data) {
|
|
66
|
+
const data = response == null ? void 0 : response.data;
|
|
67
|
+
const list2 = data == null ? void 0 : data.list;
|
|
68
|
+
let urlData = [];
|
|
69
|
+
if (Array.isArray(data)) {
|
|
70
|
+
urlData = data;
|
|
71
|
+
}
|
|
72
|
+
if (Array.isArray(list2)) {
|
|
73
|
+
urlData = list2;
|
|
74
|
+
}
|
|
75
|
+
const urlOptions = urlData.map((val2) => ({
|
|
76
|
+
label: handleUrlOptions(val2, delimiter, keyFieldList),
|
|
77
|
+
value: handleUrlOptions(val2, delimiter, keyFieldList)
|
|
78
|
+
}));
|
|
79
|
+
setList([...urlOptions]);
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
message.error("加载选项失败");
|
|
83
|
+
} finally {
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
87
|
+
antd.Checkbox.Group,
|
|
88
|
+
{
|
|
89
|
+
...options,
|
|
90
|
+
options: list,
|
|
91
|
+
value: val,
|
|
92
|
+
style: radioAlign === "vertical" ? { display: "flex", flexDirection: "column", gap: "8px", width: "100%" } : { width: "100%" },
|
|
93
|
+
onChange: (val2) => {
|
|
94
|
+
setVal(val2);
|
|
95
|
+
onChange == null ? void 0 : onChange(val2);
|
|
96
|
+
},
|
|
97
|
+
disabled: readonly
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
module.exports = MyCheckbox;
|