szld-libs 0.2.77 → 0.2.80
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 +10685 -10663
- 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 +1 -9
- package/es/utils/method.d.ts +37 -2
- package/es/utils/method.js +121 -4
- 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 +2 -10
- package/lib/utils/method.d.ts +37 -2
- package/lib/utils/method.js +121 -4
- 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,6 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { handleSetFormItemInitialValue, handleGetPlaceholder, disabledDate } from "./func";
|
|
3
|
-
import { handleAttrList, getJson, base64ToString } from "../../utils/method";
|
|
3
|
+
import { handleAttrList, handleUrlOptions, getJson, base64ToString } from "../../utils/method";
|
|
4
4
|
import { useRef, useEffect, useCallback, Fragment as Fragment$1 } from "react";
|
|
5
5
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
6
6
|
import SelectModel from "./selectModel";
|
|
@@ -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,41 @@ export declare const handleOperationFile: (params: any, data: any, commonRequest
|
|
|
67
69
|
*/
|
|
68
70
|
export declare function handleKebabToCamel(str: string): string;
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
72
|
+
* 处理属性列表为目标格式(修复children的data_list为空问题)
|
|
71
73
|
* @param {Array} attrList 原始属性列表
|
|
72
74
|
* @returns {Object} 目标格式的data对象
|
|
73
75
|
*/
|
|
74
|
-
export declare const handleAttrListToObj: (attrList: any[]) => any;
|
|
76
|
+
export declare const handleAttrListToObj: (attrList: any[], num?: number) => any;
|
|
77
|
+
/**
|
|
78
|
+
* 详情属性集列表合并详情数据
|
|
79
|
+
* @param param0
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
export declare const handleAttrListToObjDetail: ({ attrList, detail, extra, }: {
|
|
83
|
+
attrList: any[];
|
|
84
|
+
detail: {
|
|
85
|
+
[key: string]: any;
|
|
86
|
+
};
|
|
87
|
+
extra?: {
|
|
88
|
+
[key: string]: any;
|
|
89
|
+
} | undefined;
|
|
90
|
+
}) => any[];
|
|
91
|
+
/**
|
|
92
|
+
* 处理URL选项
|
|
93
|
+
* 将URL中的指定字段拼接为字符串
|
|
94
|
+
*/
|
|
95
|
+
export declare const handleUrlOptions: (val: any, delimiter: string, list: any[]) => string;
|
|
96
|
+
/**
|
|
97
|
+
* 根据配置处理成下拉数据
|
|
98
|
+
* @param param0
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
export declare const handleSelectOptions: ({ commonRequestWidthParams, commonRequest, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, item, }: {
|
|
102
|
+
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
103
|
+
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
104
|
+
interfaceTypeDict?: string | undefined;
|
|
105
|
+
interfaceTypeSysDict?: string | undefined;
|
|
106
|
+
actionUrlKey?: string | undefined;
|
|
107
|
+
actionUrlExtraParams?: object | undefined;
|
|
108
|
+
item: Ijson;
|
|
109
|
+
}) => 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,7 +299,7 @@ function handleKebabToCamel(str) {
|
|
|
298
299
|
return letter.toUpperCase();
|
|
299
300
|
});
|
|
300
301
|
}
|
|
301
|
-
const handleAttrListToObj = (attrList) => {
|
|
302
|
+
const handleAttrListToObj = (attrList, num) => {
|
|
302
303
|
var _a;
|
|
303
304
|
const result = {
|
|
304
305
|
data: {
|
|
@@ -313,12 +314,19 @@ const handleAttrListToObj = (attrList) => {
|
|
|
313
314
|
if (item.children && item.children.length > 0 && item.attrtype == 1) {
|
|
314
315
|
attrItem[key] = {
|
|
315
316
|
asid: ((_a2 = item.children[0]) == null ? void 0 : _a2.asid) || "",
|
|
316
|
-
data_list:
|
|
317
|
+
data_list: [],
|
|
318
|
+
data_list_obj: {}
|
|
317
319
|
};
|
|
318
320
|
item.children.forEach((child) => {
|
|
319
|
-
attrItem[key].
|
|
321
|
+
attrItem[key].data_list_obj[child.attrid] = child.attrvalue || "";
|
|
320
322
|
});
|
|
321
|
-
|
|
323
|
+
if (num && num > 1) {
|
|
324
|
+
for (let i = 0; i < num; i++) {
|
|
325
|
+
attrItem[key].data_list.push(attrItem[key].data_list_obj);
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
attrItem[key].data_list.push(attrItem[key].data_list_obj);
|
|
329
|
+
}
|
|
322
330
|
} else {
|
|
323
331
|
attrItem[key] = item.attrvalue || "";
|
|
324
332
|
}
|
|
@@ -330,15 +338,124 @@ const handleAttrListToObj = (attrList) => {
|
|
|
330
338
|
result.data.data_list = [Object.assign({}, ...result.data.data_list)];
|
|
331
339
|
return result;
|
|
332
340
|
};
|
|
341
|
+
const handleAttrListToObjDetail = ({
|
|
342
|
+
attrList,
|
|
343
|
+
detail,
|
|
344
|
+
extra
|
|
345
|
+
}) => {
|
|
346
|
+
return attrList == null ? void 0 : attrList.map((v) => ({
|
|
347
|
+
...v,
|
|
348
|
+
...extra,
|
|
349
|
+
attrvalue: (detail == null ? void 0 : detail[v.attrid]) || ""
|
|
350
|
+
}));
|
|
351
|
+
};
|
|
352
|
+
const handleUrlOptions = (val, delimiter, list) => {
|
|
353
|
+
let arr = [];
|
|
354
|
+
list.forEach((item) => {
|
|
355
|
+
arr.push(val == null ? void 0 : val[item]);
|
|
356
|
+
});
|
|
357
|
+
return arr.join(delimiter || "-");
|
|
358
|
+
};
|
|
359
|
+
const handleSelectOptions = async ({
|
|
360
|
+
commonRequestWidthParams,
|
|
361
|
+
commonRequest,
|
|
362
|
+
interfaceTypeDict = "YLZDDictList",
|
|
363
|
+
interfaceTypeSysDict = "YLZDSysConfigList",
|
|
364
|
+
actionUrlKey = "action-url",
|
|
365
|
+
actionUrlExtraParams = {},
|
|
366
|
+
item
|
|
367
|
+
}) => {
|
|
368
|
+
var _a;
|
|
369
|
+
let options = [];
|
|
370
|
+
const getDict = async (interfaceType) => {
|
|
371
|
+
var _a2;
|
|
372
|
+
let list = [];
|
|
373
|
+
if (item.classify) {
|
|
374
|
+
try {
|
|
375
|
+
const response = await commonRequest(interfaceType, {
|
|
376
|
+
asctypeid: item.classify
|
|
377
|
+
});
|
|
378
|
+
if (((_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.list) && Array.isArray(response.data.list)) {
|
|
379
|
+
list = response.data.list.map((dictItem) => ({
|
|
380
|
+
label: `${dictItem.dicid || ""}-${dictItem.info || ""}`,
|
|
381
|
+
value: `${dictItem.dicid || ""}-${dictItem.info || ""}`
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
} catch (error) {
|
|
385
|
+
message.error("加载选项失败");
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return list;
|
|
389
|
+
};
|
|
390
|
+
const getUrlOptions = async () => {
|
|
391
|
+
var _a2, _b;
|
|
392
|
+
try {
|
|
393
|
+
const keyFieldList = ((_a2 = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a2.list) || [];
|
|
394
|
+
const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "";
|
|
395
|
+
if (!keyFieldList.length) {
|
|
396
|
+
message.error("请配置key-field");
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const response = await commonRequestWidthParams(
|
|
400
|
+
{
|
|
401
|
+
PageName: "dns_relay",
|
|
402
|
+
Controlname: "CallActionUrl",
|
|
403
|
+
InterfaceType: ""
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
[actionUrlKey]: item == null ? void 0 : item["action-url"],
|
|
407
|
+
...actionUrlExtraParams
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
if (response == null ? void 0 : response.data) {
|
|
411
|
+
const data = response == null ? void 0 : response.data;
|
|
412
|
+
const list = (data == null ? void 0 : data.list) || [];
|
|
413
|
+
let urlData = [];
|
|
414
|
+
if (Array.isArray(data)) {
|
|
415
|
+
urlData = data;
|
|
416
|
+
}
|
|
417
|
+
if (Array.isArray(list)) {
|
|
418
|
+
urlData = list;
|
|
419
|
+
}
|
|
420
|
+
options = urlData.map((val) => ({
|
|
421
|
+
label: handleUrlOptions(val, delimiter, keyFieldList),
|
|
422
|
+
value: handleUrlOptions(val, delimiter, keyFieldList)
|
|
423
|
+
}));
|
|
424
|
+
}
|
|
425
|
+
} catch (error) {
|
|
426
|
+
message.error("加载选项失败");
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
if (item.inputType === "local") {
|
|
430
|
+
options = ((_a = item.data) == null ? void 0 : _a.map((val) => ({
|
|
431
|
+
label: val,
|
|
432
|
+
value: val
|
|
433
|
+
}))) || [];
|
|
434
|
+
if (item.options && Array.isArray(item.options)) {
|
|
435
|
+
options = item.options;
|
|
436
|
+
}
|
|
437
|
+
} else if (item.inputType === "dictionary") {
|
|
438
|
+
options = await getDict(interfaceTypeDict);
|
|
439
|
+
} else if (item.inputType === "system-dictionary") {
|
|
440
|
+
options = await getDict(interfaceTypeSysDict);
|
|
441
|
+
}
|
|
442
|
+
if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
|
|
443
|
+
await getUrlOptions();
|
|
444
|
+
}
|
|
445
|
+
return options;
|
|
446
|
+
};
|
|
333
447
|
export {
|
|
334
448
|
base64ToString,
|
|
335
449
|
getJson,
|
|
336
450
|
handleAttrList,
|
|
337
451
|
handleAttrListToObj,
|
|
452
|
+
handleAttrListToObjDetail,
|
|
338
453
|
handleBaseAttrList,
|
|
339
454
|
handleFormConfig,
|
|
340
455
|
handleKebabToCamel,
|
|
341
456
|
handleOperationFile,
|
|
457
|
+
handleSelectOptions,
|
|
342
458
|
handleSubmitForm,
|
|
459
|
+
handleUrlOptions,
|
|
343
460
|
isBase64
|
|
344
461
|
};
|
|
@@ -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,
|
|
@@ -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,41 @@ export declare const handleOperationFile: (params: any, data: any, commonRequest
|
|
|
67
69
|
*/
|
|
68
70
|
export declare function handleKebabToCamel(str: string): string;
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
72
|
+
* 处理属性列表为目标格式(修复children的data_list为空问题)
|
|
71
73
|
* @param {Array} attrList 原始属性列表
|
|
72
74
|
* @returns {Object} 目标格式的data对象
|
|
73
75
|
*/
|
|
74
|
-
export declare const handleAttrListToObj: (attrList: any[]) => any;
|
|
76
|
+
export declare const handleAttrListToObj: (attrList: any[], num?: number) => any;
|
|
77
|
+
/**
|
|
78
|
+
* 详情属性集列表合并详情数据
|
|
79
|
+
* @param param0
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
export declare const handleAttrListToObjDetail: ({ attrList, detail, extra, }: {
|
|
83
|
+
attrList: any[];
|
|
84
|
+
detail: {
|
|
85
|
+
[key: string]: any;
|
|
86
|
+
};
|
|
87
|
+
extra?: {
|
|
88
|
+
[key: string]: any;
|
|
89
|
+
} | undefined;
|
|
90
|
+
}) => any[];
|
|
91
|
+
/**
|
|
92
|
+
* 处理URL选项
|
|
93
|
+
* 将URL中的指定字段拼接为字符串
|
|
94
|
+
*/
|
|
95
|
+
export declare const handleUrlOptions: (val: any, delimiter: string, list: any[]) => string;
|
|
96
|
+
/**
|
|
97
|
+
* 根据配置处理成下拉数据
|
|
98
|
+
* @param param0
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
export declare const handleSelectOptions: ({ commonRequestWidthParams, commonRequest, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, item, }: {
|
|
102
|
+
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
103
|
+
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
104
|
+
interfaceTypeDict?: string | undefined;
|
|
105
|
+
interfaceTypeSysDict?: string | undefined;
|
|
106
|
+
actionUrlKey?: string | undefined;
|
|
107
|
+
actionUrlExtraParams?: object | undefined;
|
|
108
|
+
item: Ijson;
|
|
109
|
+
}) => Promise<any[]>;
|