szld-libs 0.2.78 → 0.2.81
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 +11274 -11260
- package/dist/szld-components.umd.js +53 -53
- package/es/components/DynamicForm/mySelect/index.d.ts +1 -2
- package/es/components/DynamicForm/mySelect/index.js +14 -90
- package/es/components/DynamicForm/useDynamicForm.js +2 -10
- package/es/utils/method.d.ts +41 -2
- package/es/utils/method.js +139 -28
- package/lib/components/DynamicForm/mySelect/index.d.ts +1 -2
- package/lib/components/DynamicForm/mySelect/index.js +13 -89
- package/lib/components/DynamicForm/useDynamicForm.js +3 -11
- package/lib/utils/method.d.ts +41 -2
- package/lib/utils/method.js +139 -28
- package/package.json +1 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Ijson } from '../index.d';
|
|
2
2
|
import { AxiosResponse } from 'axios';
|
|
3
|
-
declare const MySelect: ({ item, readonly, style,
|
|
3
|
+
declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, commonRequest, value, onChange, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, }: {
|
|
4
4
|
item: Ijson;
|
|
5
5
|
readonly?: boolean | undefined;
|
|
6
6
|
style?: any;
|
|
7
|
-
handleUrlOptions: (val: any, delimiter: string, list: any[]) => string;
|
|
8
7
|
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
9
8
|
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
10
9
|
value: string | number | (string | number)[];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { handleSelectOptions } from "../../../utils/method";
|
|
2
3
|
import { useState, useEffect } from "react";
|
|
3
|
-
import {
|
|
4
|
+
import { Select } from "antd";
|
|
4
5
|
const MySelect = ({
|
|
5
6
|
item,
|
|
6
7
|
readonly,
|
|
7
8
|
style,
|
|
8
|
-
handleUrlOptions,
|
|
9
9
|
commonRequestWidthParams,
|
|
10
10
|
commonRequest,
|
|
11
11
|
value,
|
|
@@ -15,100 +15,24 @@ const MySelect = ({
|
|
|
15
15
|
actionUrlKey,
|
|
16
16
|
actionUrlExtraParams
|
|
17
17
|
}) => {
|
|
18
|
-
const { message } = App.useApp();
|
|
19
18
|
const [options, setOptions] = useState([]);
|
|
20
19
|
const [loading, setLoading] = useState(false);
|
|
21
20
|
useEffect(() => {
|
|
22
21
|
handleLoadOptions();
|
|
23
22
|
}, [item.inputType, item.classify, item.data, item.options]);
|
|
24
23
|
const handleLoadOptions = async () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} else if (item.inputType === "dictionary") {
|
|
38
|
-
getDict(interfaceTypeDict);
|
|
39
|
-
} else if (item.inputType === "system-dictionary") {
|
|
40
|
-
getDict(interfaceTypeSysDict);
|
|
41
|
-
} else if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
|
|
42
|
-
try {
|
|
43
|
-
const keyFieldList = ((_a = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a.list) || [];
|
|
44
|
-
const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "";
|
|
45
|
-
if (!keyFieldList.length) {
|
|
46
|
-
message.error("请配置key-field");
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const response = await commonRequestWidthParams(
|
|
50
|
-
{
|
|
51
|
-
PageName: "dns_relay",
|
|
52
|
-
Controlname: "CallActionUrl",
|
|
53
|
-
InterfaceType: ""
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
[actionUrlKey]: item == null ? void 0 : item["action-url"],
|
|
57
|
-
...actionUrlExtraParams
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
if (response == null ? void 0 : response.data) {
|
|
61
|
-
const data = response == null ? void 0 : response.data;
|
|
62
|
-
const list = data == null ? void 0 : data.list;
|
|
63
|
-
let urlData = [];
|
|
64
|
-
if (Array.isArray(data)) {
|
|
65
|
-
urlData = data;
|
|
66
|
-
}
|
|
67
|
-
if (Array.isArray(list)) {
|
|
68
|
-
urlData = list;
|
|
69
|
-
}
|
|
70
|
-
const urlOptions = urlData.map((val) => ({
|
|
71
|
-
label: handleUrlOptions(val, delimiter, keyFieldList),
|
|
72
|
-
value: handleUrlOptions(val, delimiter, keyFieldList)
|
|
73
|
-
}));
|
|
74
|
-
setOptions([...urlOptions]);
|
|
75
|
-
}
|
|
76
|
-
} catch (error) {
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
let defaultOptions = [];
|
|
80
|
-
if (item.data && Array.isArray(item.data)) {
|
|
81
|
-
defaultOptions = item.data.map((val) => ({
|
|
82
|
-
label: val,
|
|
83
|
-
value: val
|
|
84
|
-
}));
|
|
85
|
-
} else if (item.options && Array.isArray(item.options)) {
|
|
86
|
-
defaultOptions = item.options;
|
|
87
|
-
}
|
|
88
|
-
setOptions(defaultOptions);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const getDict = async (interfaceType) => {
|
|
92
|
-
var _a;
|
|
93
|
-
if (item.classify) {
|
|
94
|
-
setLoading(true);
|
|
95
|
-
try {
|
|
96
|
-
const response = await commonRequest(interfaceType, {
|
|
97
|
-
asctypeid: item.classify
|
|
98
|
-
});
|
|
99
|
-
if (((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.list) && Array.isArray(response.data.list)) {
|
|
100
|
-
const dictionaryOptions = response.data.list.map((dictItem) => ({
|
|
101
|
-
label: `${dictItem.dicid || ""}-${dictItem.info || ""}`,
|
|
102
|
-
value: `${dictItem.dicid || ""}-${dictItem.info || ""}`
|
|
103
|
-
}));
|
|
104
|
-
setOptions(dictionaryOptions);
|
|
105
|
-
}
|
|
106
|
-
} catch (error) {
|
|
107
|
-
message.error("加载选项失败");
|
|
108
|
-
} finally {
|
|
109
|
-
setLoading(false);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
24
|
+
setLoading(true);
|
|
25
|
+
const list = await handleSelectOptions({
|
|
26
|
+
commonRequestWidthParams,
|
|
27
|
+
commonRequest,
|
|
28
|
+
interfaceTypeDict,
|
|
29
|
+
interfaceTypeSysDict,
|
|
30
|
+
actionUrlKey,
|
|
31
|
+
actionUrlExtraParams,
|
|
32
|
+
item
|
|
33
|
+
});
|
|
34
|
+
setOptions(list);
|
|
35
|
+
setLoading(false);
|
|
112
36
|
};
|
|
113
37
|
return /* @__PURE__ */ jsx(
|
|
114
38
|
Select,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { MinusSquareOutlined, PlusSquareOutlined, CloseOutlined, InfoCircleOutlined } from "@ant-design/icons";
|
|
3
2
|
import { handleSetFormItemInitialValue, handleGetPlaceholder, disabledDate } from "./func";
|
|
4
|
-
import { handleAttrList, getJson, base64ToString } from "../../utils/method";
|
|
3
|
+
import { handleAttrList, handleUrlOptions, getJson, base64ToString } from "../../utils/method";
|
|
5
4
|
import { useRef, useEffect, useCallback, Fragment as Fragment$1 } from "react";
|
|
6
5
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
7
6
|
import SelectModel from "./selectModel";
|
|
@@ -13,6 +12,7 @@ import MySelect from "./mySelect";
|
|
|
13
12
|
import MyUpload from "./myUpload";
|
|
14
13
|
import MyRadio from "./myRadio";
|
|
15
14
|
import _ from "lodash";
|
|
15
|
+
import { MinusSquareOutlined, PlusSquareOutlined, CloseOutlined, InfoCircleOutlined } from "@ant-design/icons";
|
|
16
16
|
import { App, Col, Collapse, Form, Card, Flex, Button, Space, Input, DatePicker, InputNumber, Tooltip } from "antd";
|
|
17
17
|
dayjs.extend(isoWeek);
|
|
18
18
|
function useDynamicForm(props) {
|
|
@@ -41,13 +41,6 @@ function useDynamicForm(props) {
|
|
|
41
41
|
}
|
|
42
42
|
formConfigRef.current = formConfig;
|
|
43
43
|
}, [formConfig]);
|
|
44
|
-
const handleUrlOptions = (val, delimiter, list) => {
|
|
45
|
-
let arr = [];
|
|
46
|
-
list.forEach((item) => {
|
|
47
|
-
arr.push(val == null ? void 0 : val[item]);
|
|
48
|
-
});
|
|
49
|
-
return arr.join(delimiter || "-");
|
|
50
|
-
};
|
|
51
44
|
const handleNormFile = useCallback((e) => {
|
|
52
45
|
if (Array.isArray(e)) {
|
|
53
46
|
return e;
|
|
@@ -528,7 +521,6 @@ function useDynamicForm(props) {
|
|
|
528
521
|
return /* @__PURE__ */ jsx(
|
|
529
522
|
MySelect,
|
|
530
523
|
{
|
|
531
|
-
handleUrlOptions,
|
|
532
524
|
item: item.json,
|
|
533
525
|
readonly,
|
|
534
526
|
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
|
package/es/utils/method.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Ijson } from '../components/DynamicForm/index.d';
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
1
3
|
export declare function getJson(jsonStr: string): any;
|
|
2
4
|
export declare function base64ToString(base64Str: string): string;
|
|
3
5
|
export declare function isBase64(str: string): boolean;
|
|
@@ -67,8 +69,45 @@ export declare const handleOperationFile: (params: any, data: any, commonRequest
|
|
|
67
69
|
*/
|
|
68
70
|
export declare function handleKebabToCamel(str: string): string;
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
72
|
+
* 处理属性列表为目标格式
|
|
71
73
|
* @param {Array} attrList 原始属性列表
|
|
72
74
|
* @returns {Object} 目标格式的data对象
|
|
73
75
|
*/
|
|
74
|
-
export declare const handleAttrListToObj: (attrList: any[]
|
|
76
|
+
export declare const handleAttrListToObj: (attrList: any[]) => {
|
|
77
|
+
data: {
|
|
78
|
+
asid: any;
|
|
79
|
+
data_list: any[];
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* 详情属性集列表合并详情数据
|
|
84
|
+
* @param param0
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
export declare const handleAttrListToObjDetail: ({ attrList, params, commonRequest, }: {
|
|
88
|
+
attrList: any[];
|
|
89
|
+
params: any;
|
|
90
|
+
extra?: {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
} | undefined;
|
|
93
|
+
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
94
|
+
}) => Promise<any[]>;
|
|
95
|
+
/**
|
|
96
|
+
* 处理URL选项
|
|
97
|
+
* 将URL中的指定字段拼接为字符串
|
|
98
|
+
*/
|
|
99
|
+
export declare const handleUrlOptions: (val: any, delimiter: string, list: any[]) => string;
|
|
100
|
+
/**
|
|
101
|
+
* 根据配置处理成下拉数据
|
|
102
|
+
* @param param0
|
|
103
|
+
* @returns
|
|
104
|
+
*/
|
|
105
|
+
export declare const handleSelectOptions: ({ commonRequestWidthParams, commonRequest, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, item, }: {
|
|
106
|
+
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
107
|
+
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
108
|
+
interfaceTypeDict?: string | undefined;
|
|
109
|
+
interfaceTypeSysDict?: string | undefined;
|
|
110
|
+
actionUrlKey?: string | undefined;
|
|
111
|
+
actionUrlExtraParams?: object | undefined;
|
|
112
|
+
item: Ijson;
|
|
113
|
+
}) => Promise<any[]>;
|
package/es/utils/method.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { message } from "antd";
|
|
1
2
|
import dayjs from "dayjs";
|
|
2
3
|
import _ from "lodash";
|
|
3
4
|
function getJson(jsonStr) {
|
|
@@ -298,54 +299,164 @@ function handleKebabToCamel(str) {
|
|
|
298
299
|
return letter.toUpperCase();
|
|
299
300
|
});
|
|
300
301
|
}
|
|
301
|
-
const handleAttrListToObj = (attrList
|
|
302
|
+
const handleAttrListToObj = (attrList) => {
|
|
302
303
|
var _a;
|
|
303
|
-
|
|
304
|
+
function processLevel(arr) {
|
|
305
|
+
const result = {};
|
|
306
|
+
arr.forEach((item) => {
|
|
307
|
+
var _a2, _b;
|
|
308
|
+
const key = `${item.attrid}_${item.attrtype}`;
|
|
309
|
+
if (item.attrtype === 1 && item.children.length > 0) {
|
|
310
|
+
result[key] = {
|
|
311
|
+
asid: ((_b = (_a2 = item.children) == null ? void 0 : _a2[0]) == null ? void 0 : _b.asid) || "",
|
|
312
|
+
data_list: [processLevel(item.children)]
|
|
313
|
+
};
|
|
314
|
+
} else {
|
|
315
|
+
result[key] = item.attrvalue;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
const asid = ((_a = attrList[0]) == null ? void 0 : _a.asid) || "";
|
|
321
|
+
const dataList = [processLevel(attrList)];
|
|
322
|
+
return {
|
|
304
323
|
data: {
|
|
305
|
-
asid
|
|
306
|
-
data_list:
|
|
324
|
+
asid,
|
|
325
|
+
data_list: dataList
|
|
307
326
|
}
|
|
308
327
|
};
|
|
309
|
-
|
|
328
|
+
};
|
|
329
|
+
const handleAttrListToObjDetail = async ({
|
|
330
|
+
attrList,
|
|
331
|
+
params,
|
|
332
|
+
commonRequest
|
|
333
|
+
}) => {
|
|
334
|
+
var _a, _b;
|
|
335
|
+
const res = await commonRequest("YLFWLRDataDetails", params);
|
|
336
|
+
const detail = (_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) == null ? void 0 : _b[0];
|
|
337
|
+
const attr_list = attrList == null ? void 0 : attrList.map((v) => {
|
|
310
338
|
var _a2;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
data_list: [],
|
|
317
|
-
data_list_obj: {}
|
|
318
|
-
};
|
|
319
|
-
item.children.forEach((child) => {
|
|
320
|
-
attrItem[key].data_list_obj[child.attrid] = child.attrvalue || "";
|
|
339
|
+
if (v.attrtype === 1 && ((_a2 = v == null ? void 0 : v.children) == null ? void 0 : _a2.length) && detail) {
|
|
340
|
+
handleAttrListToObjDetail({
|
|
341
|
+
attrList: (v == null ? void 0 : v.children) || [],
|
|
342
|
+
params: (detail == null ? void 0 : detail[v.attrid]) || {},
|
|
343
|
+
commonRequest
|
|
321
344
|
});
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
...v,
|
|
348
|
+
attrvalue: (detail == null ? void 0 : detail[v.attrid]) || ""
|
|
349
|
+
};
|
|
350
|
+
});
|
|
351
|
+
return attr_list;
|
|
352
|
+
};
|
|
353
|
+
const handleUrlOptions = (val, delimiter, list) => {
|
|
354
|
+
let arr = [];
|
|
355
|
+
list.forEach((item) => {
|
|
356
|
+
arr.push(val == null ? void 0 : val[item]);
|
|
357
|
+
});
|
|
358
|
+
return arr.join(delimiter || "-");
|
|
359
|
+
};
|
|
360
|
+
const handleSelectOptions = async ({
|
|
361
|
+
commonRequestWidthParams,
|
|
362
|
+
commonRequest,
|
|
363
|
+
interfaceTypeDict = "YLZDDictList",
|
|
364
|
+
interfaceTypeSysDict = "YLZDSysConfigList",
|
|
365
|
+
actionUrlKey = "action-url",
|
|
366
|
+
actionUrlExtraParams = {},
|
|
367
|
+
item
|
|
368
|
+
}) => {
|
|
369
|
+
var _a;
|
|
370
|
+
let options = [];
|
|
371
|
+
const getDict = async (interfaceType) => {
|
|
372
|
+
var _a2;
|
|
373
|
+
let list = [];
|
|
374
|
+
if (item.classify) {
|
|
375
|
+
try {
|
|
376
|
+
const response = await commonRequest(interfaceType, {
|
|
377
|
+
asctypeid: item.classify
|
|
378
|
+
});
|
|
379
|
+
if (((_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.list) && Array.isArray(response.data.list)) {
|
|
380
|
+
list = response.data.list.map((dictItem) => ({
|
|
381
|
+
label: `${dictItem.dicid || ""}-${dictItem.info || ""}`,
|
|
382
|
+
value: `${dictItem.dicid || ""}-${dictItem.info || ""}`
|
|
383
|
+
}));
|
|
325
384
|
}
|
|
326
|
-
}
|
|
327
|
-
|
|
385
|
+
} catch (error) {
|
|
386
|
+
message.error("加载选项失败");
|
|
328
387
|
}
|
|
329
|
-
} else {
|
|
330
|
-
attrItem[key] = item.attrvalue || "";
|
|
331
388
|
}
|
|
332
|
-
return
|
|
389
|
+
return list;
|
|
333
390
|
};
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
391
|
+
const getUrlOptions = async () => {
|
|
392
|
+
var _a2, _b;
|
|
393
|
+
try {
|
|
394
|
+
const keyFieldList = ((_a2 = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a2.list) || [];
|
|
395
|
+
const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "";
|
|
396
|
+
if (!keyFieldList.length) {
|
|
397
|
+
message.error("请配置key-field");
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const response = await commonRequestWidthParams(
|
|
401
|
+
{
|
|
402
|
+
PageName: "dns_relay",
|
|
403
|
+
Controlname: "CallActionUrl",
|
|
404
|
+
InterfaceType: ""
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
[actionUrlKey]: item == null ? void 0 : item["action-url"],
|
|
408
|
+
...actionUrlExtraParams
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
if (response == null ? void 0 : response.data) {
|
|
412
|
+
const data = response == null ? void 0 : response.data;
|
|
413
|
+
const list = (data == null ? void 0 : data.list) || [];
|
|
414
|
+
let urlData = [];
|
|
415
|
+
if (Array.isArray(data)) {
|
|
416
|
+
urlData = data;
|
|
417
|
+
}
|
|
418
|
+
if (Array.isArray(list)) {
|
|
419
|
+
urlData = list;
|
|
420
|
+
}
|
|
421
|
+
options = urlData.map((val) => ({
|
|
422
|
+
label: handleUrlOptions(val, delimiter, keyFieldList),
|
|
423
|
+
value: handleUrlOptions(val, delimiter, keyFieldList)
|
|
424
|
+
}));
|
|
425
|
+
}
|
|
426
|
+
} catch (error) {
|
|
427
|
+
message.error("加载选项失败");
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
if (item.inputType === "local") {
|
|
431
|
+
options = ((_a = item.data) == null ? void 0 : _a.map((val) => ({
|
|
432
|
+
label: val,
|
|
433
|
+
value: val
|
|
434
|
+
}))) || [];
|
|
435
|
+
if (item.options && Array.isArray(item.options)) {
|
|
436
|
+
options = item.options;
|
|
437
|
+
}
|
|
438
|
+
} else if (item.inputType === "dictionary") {
|
|
439
|
+
options = await getDict(interfaceTypeDict);
|
|
440
|
+
} else if (item.inputType === "system-dictionary") {
|
|
441
|
+
options = await getDict(interfaceTypeSysDict);
|
|
442
|
+
}
|
|
443
|
+
if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
|
|
444
|
+
await getUrlOptions();
|
|
445
|
+
}
|
|
446
|
+
return options;
|
|
339
447
|
};
|
|
340
448
|
export {
|
|
341
449
|
base64ToString,
|
|
342
450
|
getJson,
|
|
343
451
|
handleAttrList,
|
|
344
452
|
handleAttrListToObj,
|
|
453
|
+
handleAttrListToObjDetail,
|
|
345
454
|
handleBaseAttrList,
|
|
346
455
|
handleFormConfig,
|
|
347
456
|
handleKebabToCamel,
|
|
348
457
|
handleOperationFile,
|
|
458
|
+
handleSelectOptions,
|
|
349
459
|
handleSubmitForm,
|
|
460
|
+
handleUrlOptions,
|
|
350
461
|
isBase64
|
|
351
462
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Ijson } from '../index.d';
|
|
2
2
|
import { AxiosResponse } from 'axios';
|
|
3
|
-
declare const MySelect: ({ item, readonly, style,
|
|
3
|
+
declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, commonRequest, value, onChange, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, }: {
|
|
4
4
|
item: Ijson;
|
|
5
5
|
readonly?: boolean | undefined;
|
|
6
6
|
style?: any;
|
|
7
|
-
handleUrlOptions: (val: any, delimiter: string, list: any[]) => string;
|
|
8
7
|
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
9
8
|
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
10
9
|
value: string | number | (string | number)[];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const method = require("../../../utils/method");
|
|
3
4
|
const react = require("react");
|
|
4
5
|
const antd = require("antd");
|
|
5
6
|
const MySelect = ({
|
|
6
7
|
item,
|
|
7
8
|
readonly,
|
|
8
9
|
style,
|
|
9
|
-
handleUrlOptions,
|
|
10
10
|
commonRequestWidthParams,
|
|
11
11
|
commonRequest,
|
|
12
12
|
value,
|
|
@@ -16,100 +16,24 @@ const MySelect = ({
|
|
|
16
16
|
actionUrlKey,
|
|
17
17
|
actionUrlExtraParams
|
|
18
18
|
}) => {
|
|
19
|
-
const { message } = antd.App.useApp();
|
|
20
19
|
const [options, setOptions] = react.useState([]);
|
|
21
20
|
const [loading, setLoading] = react.useState(false);
|
|
22
21
|
react.useEffect(() => {
|
|
23
22
|
handleLoadOptions();
|
|
24
23
|
}, [item.inputType, item.classify, item.data, item.options]);
|
|
25
24
|
const handleLoadOptions = async () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} else if (item.inputType === "dictionary") {
|
|
39
|
-
getDict(interfaceTypeDict);
|
|
40
|
-
} else if (item.inputType === "system-dictionary") {
|
|
41
|
-
getDict(interfaceTypeSysDict);
|
|
42
|
-
} else if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
|
|
43
|
-
try {
|
|
44
|
-
const keyFieldList = ((_a = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a.list) || [];
|
|
45
|
-
const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "";
|
|
46
|
-
if (!keyFieldList.length) {
|
|
47
|
-
message.error("请配置key-field");
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const response = await commonRequestWidthParams(
|
|
51
|
-
{
|
|
52
|
-
PageName: "dns_relay",
|
|
53
|
-
Controlname: "CallActionUrl",
|
|
54
|
-
InterfaceType: ""
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
[actionUrlKey]: item == null ? void 0 : item["action-url"],
|
|
58
|
-
...actionUrlExtraParams
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
if (response == null ? void 0 : response.data) {
|
|
62
|
-
const data = response == null ? void 0 : response.data;
|
|
63
|
-
const list = data == null ? void 0 : data.list;
|
|
64
|
-
let urlData = [];
|
|
65
|
-
if (Array.isArray(data)) {
|
|
66
|
-
urlData = data;
|
|
67
|
-
}
|
|
68
|
-
if (Array.isArray(list)) {
|
|
69
|
-
urlData = list;
|
|
70
|
-
}
|
|
71
|
-
const urlOptions = urlData.map((val) => ({
|
|
72
|
-
label: handleUrlOptions(val, delimiter, keyFieldList),
|
|
73
|
-
value: handleUrlOptions(val, delimiter, keyFieldList)
|
|
74
|
-
}));
|
|
75
|
-
setOptions([...urlOptions]);
|
|
76
|
-
}
|
|
77
|
-
} catch (error) {
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
let defaultOptions = [];
|
|
81
|
-
if (item.data && Array.isArray(item.data)) {
|
|
82
|
-
defaultOptions = item.data.map((val) => ({
|
|
83
|
-
label: val,
|
|
84
|
-
value: val
|
|
85
|
-
}));
|
|
86
|
-
} else if (item.options && Array.isArray(item.options)) {
|
|
87
|
-
defaultOptions = item.options;
|
|
88
|
-
}
|
|
89
|
-
setOptions(defaultOptions);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const getDict = async (interfaceType) => {
|
|
93
|
-
var _a;
|
|
94
|
-
if (item.classify) {
|
|
95
|
-
setLoading(true);
|
|
96
|
-
try {
|
|
97
|
-
const response = await commonRequest(interfaceType, {
|
|
98
|
-
asctypeid: item.classify
|
|
99
|
-
});
|
|
100
|
-
if (((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.list) && Array.isArray(response.data.list)) {
|
|
101
|
-
const dictionaryOptions = response.data.list.map((dictItem) => ({
|
|
102
|
-
label: `${dictItem.dicid || ""}-${dictItem.info || ""}`,
|
|
103
|
-
value: `${dictItem.dicid || ""}-${dictItem.info || ""}`
|
|
104
|
-
}));
|
|
105
|
-
setOptions(dictionaryOptions);
|
|
106
|
-
}
|
|
107
|
-
} catch (error) {
|
|
108
|
-
message.error("加载选项失败");
|
|
109
|
-
} finally {
|
|
110
|
-
setLoading(false);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
25
|
+
setLoading(true);
|
|
26
|
+
const list = await method.handleSelectOptions({
|
|
27
|
+
commonRequestWidthParams,
|
|
28
|
+
commonRequest,
|
|
29
|
+
interfaceTypeDict,
|
|
30
|
+
interfaceTypeSysDict,
|
|
31
|
+
actionUrlKey,
|
|
32
|
+
actionUrlExtraParams,
|
|
33
|
+
item
|
|
34
|
+
});
|
|
35
|
+
setOptions(list);
|
|
36
|
+
setLoading(false);
|
|
113
37
|
};
|
|
114
38
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
115
39
|
antd.Select,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const icons = require("@ant-design/icons");
|
|
4
3
|
const func = require("./func");
|
|
5
4
|
const method = require("../../utils/method");
|
|
6
5
|
const react = require("react");
|
|
@@ -14,6 +13,7 @@ const MySelect = require("./mySelect");
|
|
|
14
13
|
const MyUpload = require("./myUpload");
|
|
15
14
|
const MyRadio = require("./myRadio");
|
|
16
15
|
const _ = require("lodash");
|
|
16
|
+
const icons = require("@ant-design/icons");
|
|
17
17
|
const antd = require("antd");
|
|
18
18
|
dayjs.extend(isoWeek);
|
|
19
19
|
function useDynamicForm(props) {
|
|
@@ -42,13 +42,6 @@ function useDynamicForm(props) {
|
|
|
42
42
|
}
|
|
43
43
|
formConfigRef.current = formConfig;
|
|
44
44
|
}, [formConfig]);
|
|
45
|
-
const handleUrlOptions = (val, delimiter, list) => {
|
|
46
|
-
let arr = [];
|
|
47
|
-
list.forEach((item) => {
|
|
48
|
-
arr.push(val == null ? void 0 : val[item]);
|
|
49
|
-
});
|
|
50
|
-
return arr.join(delimiter || "-");
|
|
51
|
-
};
|
|
52
45
|
const handleNormFile = react.useCallback((e) => {
|
|
53
46
|
if (Array.isArray(e)) {
|
|
54
47
|
return e;
|
|
@@ -529,7 +522,6 @@ function useDynamicForm(props) {
|
|
|
529
522
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
530
523
|
MySelect,
|
|
531
524
|
{
|
|
532
|
-
handleUrlOptions,
|
|
533
525
|
item: item.json,
|
|
534
526
|
readonly,
|
|
535
527
|
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
|
|
@@ -624,7 +616,7 @@ function useDynamicForm(props) {
|
|
|
624
616
|
item: item.json,
|
|
625
617
|
readonly,
|
|
626
618
|
options: params,
|
|
627
|
-
handleUrlOptions,
|
|
619
|
+
handleUrlOptions: method.handleUrlOptions,
|
|
628
620
|
value: formatValue,
|
|
629
621
|
interfaceTypeDict,
|
|
630
622
|
interfaceTypeSysDict,
|
|
@@ -646,7 +638,7 @@ function useDynamicForm(props) {
|
|
|
646
638
|
readonly,
|
|
647
639
|
options: params,
|
|
648
640
|
value: formatValue,
|
|
649
|
-
handleUrlOptions,
|
|
641
|
+
handleUrlOptions: method.handleUrlOptions,
|
|
650
642
|
interfaceTypeDict,
|
|
651
643
|
interfaceTypeSysDict,
|
|
652
644
|
actionUrlKey,
|
package/lib/utils/method.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Ijson } from '../components/DynamicForm/index.d';
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
1
3
|
export declare function getJson(jsonStr: string): any;
|
|
2
4
|
export declare function base64ToString(base64Str: string): string;
|
|
3
5
|
export declare function isBase64(str: string): boolean;
|
|
@@ -67,8 +69,45 @@ export declare const handleOperationFile: (params: any, data: any, commonRequest
|
|
|
67
69
|
*/
|
|
68
70
|
export declare function handleKebabToCamel(str: string): string;
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
72
|
+
* 处理属性列表为目标格式
|
|
71
73
|
* @param {Array} attrList 原始属性列表
|
|
72
74
|
* @returns {Object} 目标格式的data对象
|
|
73
75
|
*/
|
|
74
|
-
export declare const handleAttrListToObj: (attrList: any[]
|
|
76
|
+
export declare const handleAttrListToObj: (attrList: any[]) => {
|
|
77
|
+
data: {
|
|
78
|
+
asid: any;
|
|
79
|
+
data_list: any[];
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* 详情属性集列表合并详情数据
|
|
84
|
+
* @param param0
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
export declare const handleAttrListToObjDetail: ({ attrList, params, commonRequest, }: {
|
|
88
|
+
attrList: any[];
|
|
89
|
+
params: any;
|
|
90
|
+
extra?: {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
} | undefined;
|
|
93
|
+
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
94
|
+
}) => Promise<any[]>;
|
|
95
|
+
/**
|
|
96
|
+
* 处理URL选项
|
|
97
|
+
* 将URL中的指定字段拼接为字符串
|
|
98
|
+
*/
|
|
99
|
+
export declare const handleUrlOptions: (val: any, delimiter: string, list: any[]) => string;
|
|
100
|
+
/**
|
|
101
|
+
* 根据配置处理成下拉数据
|
|
102
|
+
* @param param0
|
|
103
|
+
* @returns
|
|
104
|
+
*/
|
|
105
|
+
export declare const handleSelectOptions: ({ commonRequestWidthParams, commonRequest, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, item, }: {
|
|
106
|
+
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
107
|
+
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
108
|
+
interfaceTypeDict?: string | undefined;
|
|
109
|
+
interfaceTypeSysDict?: string | undefined;
|
|
110
|
+
actionUrlKey?: string | undefined;
|
|
111
|
+
actionUrlExtraParams?: object | undefined;
|
|
112
|
+
item: Ijson;
|
|
113
|
+
}) => Promise<any[]>;
|