szld-libs 0.4.12 → 0.4.13
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 +3907 -3854
- package/dist/szld-components.umd.js +40 -40
- package/es/components/DynamicForm/func.d.ts +15 -0
- package/es/components/DynamicForm/func.js +40 -0
- package/es/components/DynamicForm/mySelect/index.d.ts +3 -1
- package/es/components/DynamicForm/mySelect/index.js +67 -15
- package/es/components/DynamicForm/selectModelBackfillFormItem/index.d.ts +0 -7
- package/es/components/DynamicForm/selectModelBackfillFormItem/index.js +2 -28
- package/es/components/DynamicForm/useDynamicForm.js +6 -0
- package/es/utils/szxkFunc.d.ts +3 -2
- package/es/utils/szxkFunc.js +12 -0
- package/lib/components/DynamicForm/func.d.ts +15 -0
- package/lib/components/DynamicForm/func.js +40 -0
- package/lib/components/DynamicForm/mySelect/index.d.ts +3 -1
- package/lib/components/DynamicForm/mySelect/index.js +65 -13
- package/lib/components/DynamicForm/selectModelBackfillFormItem/index.d.ts +0 -7
- package/lib/components/DynamicForm/selectModelBackfillFormItem/index.js +3 -30
- package/lib/components/DynamicForm/useDynamicForm.js +6 -0
- package/lib/utils/szxkFunc.d.ts +3 -2
- package/lib/utils/szxkFunc.js +12 -0
- package/package.json +1 -1
|
@@ -45,3 +45,18 @@ export declare const handleSelectOptions: ({ commonRequestWidthParams, commonReq
|
|
|
45
45
|
* @returns 处理后的属性集列表,每个属性项包含attrvalue
|
|
46
46
|
*/
|
|
47
47
|
export declare const handleObjDetailToSignleAttrList: (attrList: any[], detail: any) => any[];
|
|
48
|
+
/**
|
|
49
|
+
* 处理input-type 为instance-url类型的属性 选中后回填表单值的函数
|
|
50
|
+
* @param selectedRows 选中的行数据
|
|
51
|
+
* @param attributeEnrollFormat 配置信息
|
|
52
|
+
* @returns 构建后的字符串
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildValueFromSelectedRows(selectedRows: any[], attributeEnrollFormat: Ijson, langId?: string): Promise<any>;
|
|
55
|
+
/**
|
|
56
|
+
* 从数组中根据值查找对象
|
|
57
|
+
* @param list 要搜索的数组
|
|
58
|
+
* @param targetValue 要查找的值
|
|
59
|
+
* @param matchExact 是否严格匹配(默认true)
|
|
60
|
+
* @returns 匹配的对象或undefined
|
|
61
|
+
*/
|
|
62
|
+
export declare const findRowByValue: (list: Record<string, any>[], targetValue: string | number, matchExact?: boolean) => Record<string, any> | undefined;
|
|
@@ -216,8 +216,48 @@ const handleObjDetailToSignleAttrList = (attrList, detail) => {
|
|
|
216
216
|
attrvalue: detail[item.attrid] || ""
|
|
217
217
|
}));
|
|
218
218
|
};
|
|
219
|
+
function buildValueFromSelectedRows(selectedRows, attributeEnrollFormat, langId) {
|
|
220
|
+
return new Promise((resolve, reject) => {
|
|
221
|
+
try {
|
|
222
|
+
var keyfields = attributeEnrollFormat["key-field"];
|
|
223
|
+
if (!keyfields) {
|
|
224
|
+
reject({ msg: langId === "10001" ? "请配置key-field" : "Please configure key-field" });
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
let res = {};
|
|
228
|
+
selectedRows.forEach((item) => {
|
|
229
|
+
for (let [key, value] of Object.entries(keyfields)) {
|
|
230
|
+
const list = (value == null ? void 0 : value.list) ?? [];
|
|
231
|
+
const delimiter = (value == null ? void 0 : value.delimiter) ?? "-";
|
|
232
|
+
const arr = list.map((v) => {
|
|
233
|
+
return item == null ? void 0 : item[v];
|
|
234
|
+
});
|
|
235
|
+
res[key] = arr.join(delimiter);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
resolve(res);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
reject({ msg: langId === "10001" ? "key-field参数配置错误" : "key-field parameter configuration error" });
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
const findRowByValue = (list, targetValue, matchExact = true) => {
|
|
245
|
+
const target = String(targetValue);
|
|
246
|
+
return list.find((item) => {
|
|
247
|
+
return Object.values(item).some((value) => {
|
|
248
|
+
const valStr = String(value);
|
|
249
|
+
if (matchExact) {
|
|
250
|
+
return valStr === target;
|
|
251
|
+
} else {
|
|
252
|
+
return valStr.includes(target);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
};
|
|
219
257
|
export {
|
|
258
|
+
buildValueFromSelectedRows,
|
|
220
259
|
disabledDate,
|
|
260
|
+
findRowByValue,
|
|
221
261
|
getTitle,
|
|
222
262
|
handleGetPlaceholder,
|
|
223
263
|
handleGetSingleAttrListObj,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ijson } from '../index.d';
|
|
2
2
|
import { AxiosResponse } from 'axios';
|
|
3
|
-
declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, commonRequest, value, onChange, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, langId, }: {
|
|
3
|
+
declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, commonRequest, value, onChange, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, langId, getTitle, attrid, }: {
|
|
4
4
|
item: Ijson;
|
|
5
5
|
readonly?: boolean | undefined;
|
|
6
6
|
style?: any;
|
|
@@ -13,5 +13,7 @@ declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, comm
|
|
|
13
13
|
actionUrlKey: string;
|
|
14
14
|
actionUrlExtraParams: object;
|
|
15
15
|
langId?: string | undefined;
|
|
16
|
+
getTitle?: ((pageID: string, dataID: string) => string) | undefined;
|
|
17
|
+
attrid?: string | undefined;
|
|
16
18
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
17
19
|
export default MySelect;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { handleSelectOptions, handleGetPlaceholder } from "../func";
|
|
2
|
+
import { handleSelectOptions, handleGetPlaceholder, findRowByValue } from "../func";
|
|
3
3
|
import { useState, useEffect } from "react";
|
|
4
|
-
import { Select } from "antd";
|
|
4
|
+
import { message, Select } from "antd";
|
|
5
|
+
import { handleGetList, handleGetControlPanelConfig } from "../../../utils/szxkFunc";
|
|
5
6
|
const MySelect = ({
|
|
6
7
|
item,
|
|
7
8
|
readonly,
|
|
@@ -14,26 +15,65 @@ const MySelect = ({
|
|
|
14
15
|
interfaceTypeSysDict,
|
|
15
16
|
actionUrlKey,
|
|
16
17
|
actionUrlExtraParams,
|
|
17
|
-
langId
|
|
18
|
+
langId,
|
|
19
|
+
getTitle,
|
|
20
|
+
attrid
|
|
18
21
|
}) => {
|
|
19
22
|
const [options, setOptions] = useState([]);
|
|
20
23
|
const [loading, setLoading] = useState(false);
|
|
24
|
+
const [instanceList, setInstanceList] = useState([]);
|
|
21
25
|
useEffect(() => {
|
|
22
26
|
handleLoadOptions();
|
|
23
27
|
}, [item.inputType, item.classify, item.data, item.options]);
|
|
24
28
|
const handleLoadOptions = async () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
try {
|
|
30
|
+
setLoading(true);
|
|
31
|
+
if (item.inputType === "instance-url" && (item == null ? void 0 : item["instance-source-number"]) && attrid) {
|
|
32
|
+
const keyField = item == null ? void 0 : item["key-field"];
|
|
33
|
+
if (!keyField) {
|
|
34
|
+
message.warning("请配置key-field");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const params = {
|
|
38
|
+
"source-number": item == null ? void 0 : item["instance-source-number"]
|
|
39
|
+
};
|
|
40
|
+
let list2 = await handleGetList(params, commonRequestWidthParams);
|
|
41
|
+
const controlPanelConfig = await handleGetControlPanelConfig(item == null ? void 0 : item["instance-source-number"], commonRequest);
|
|
42
|
+
if (controlPanelConfig) {
|
|
43
|
+
const nonUniversalHeader = (controlPanelConfig == null ? void 0 : controlPanelConfig["non-universal-header"]) || [];
|
|
44
|
+
const labelConfig = (nonUniversalHeader == null ? void 0 : nonUniversalHeader["label"]) || [];
|
|
45
|
+
const valueConfig = (keyField == null ? void 0 : keyField[attrid]) || {};
|
|
46
|
+
const options2 = list2 == null ? void 0 : list2.map((v) => {
|
|
47
|
+
const label = labelConfig == null ? void 0 : labelConfig.map((x) => v == null ? void 0 : v[x]).join("-");
|
|
48
|
+
const { list: list3, delimiter } = valueConfig;
|
|
49
|
+
const value2 = list3 == null ? void 0 : list3.map((x) => v == null ? void 0 : v[x]).join(delimiter || "-");
|
|
50
|
+
if (!label) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
label: getTitle == null ? void 0 : getTitle("5000000", label),
|
|
55
|
+
value: value2
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
setOptions(options2);
|
|
59
|
+
setInstanceList(list2);
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const list = await handleSelectOptions({
|
|
64
|
+
commonRequestWidthParams,
|
|
65
|
+
commonRequest,
|
|
66
|
+
interfaceTypeDict,
|
|
67
|
+
interfaceTypeSysDict,
|
|
68
|
+
actionUrlKey,
|
|
69
|
+
actionUrlExtraParams,
|
|
70
|
+
item
|
|
71
|
+
});
|
|
72
|
+
setOptions(list);
|
|
73
|
+
setLoading(false);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
setLoading(false);
|
|
76
|
+
}
|
|
37
77
|
};
|
|
38
78
|
return /* @__PURE__ */ jsx(
|
|
39
79
|
Select,
|
|
@@ -52,6 +92,18 @@ const MySelect = ({
|
|
|
52
92
|
style: { ...style },
|
|
53
93
|
allowClear: true,
|
|
54
94
|
onChange: (val) => {
|
|
95
|
+
if (attrid && (instanceList == null ? void 0 : instanceList.length) > 0 && (item == null ? void 0 : item.inputType) === "instance-url") {
|
|
96
|
+
const keyField = item == null ? void 0 : item["key-field"];
|
|
97
|
+
const row = findRowByValue(instanceList, String(val));
|
|
98
|
+
const keys = Object.keys(keyField || {});
|
|
99
|
+
const newObj = keys == null ? void 0 : keys.reduce((prev, cur) => {
|
|
100
|
+
const { list, delimiter } = (keyField == null ? void 0 : keyField[cur]) || {};
|
|
101
|
+
const value2 = list == null ? void 0 : list.map((x) => row == null ? void 0 : row[x]).join(delimiter || "-");
|
|
102
|
+
prev[cur] = value2;
|
|
103
|
+
return prev;
|
|
104
|
+
}, {});
|
|
105
|
+
onChange(newObj);
|
|
106
|
+
}
|
|
55
107
|
onChange(val);
|
|
56
108
|
}
|
|
57
109
|
}
|
|
@@ -19,11 +19,4 @@ interface SelectModelProps {
|
|
|
19
19
|
langId?: string;
|
|
20
20
|
}
|
|
21
21
|
declare function SelectModel(props: SelectModelProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param selectedRows 选中的行数据
|
|
25
|
-
* @param attributeEnrollFormat 配置信息
|
|
26
|
-
* @returns 构建后的字符串
|
|
27
|
-
*/
|
|
28
|
-
export declare function buildValueFromSelectedRows(selectedRows: any[], attributeEnrollFormat: Ijson, langId?: string): Promise<any>;
|
|
29
22
|
export default SelectModel;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Form, App, Select, Table, Modal } from "antd";
|
|
3
|
-
import {
|
|
4
|
-
import { handleGetPlaceholder } from "../func";
|
|
3
|
+
import { handleGetPlaceholder, buildValueFromSelectedRows } from "../func";
|
|
5
4
|
import useUniversalTable from "../../../hooks/useUniversalTable";
|
|
5
|
+
import { useState, useEffect } from "react";
|
|
6
6
|
function SelectModel(props) {
|
|
7
7
|
const {
|
|
8
8
|
item,
|
|
@@ -269,32 +269,6 @@ function SelectModel(props) {
|
|
|
269
269
|
)
|
|
270
270
|
] });
|
|
271
271
|
}
|
|
272
|
-
function buildValueFromSelectedRows(selectedRows, attributeEnrollFormat, langId) {
|
|
273
|
-
return new Promise((resolve, reject) => {
|
|
274
|
-
try {
|
|
275
|
-
var keyfields = attributeEnrollFormat["key-field"];
|
|
276
|
-
if (!keyfields) {
|
|
277
|
-
reject({ msg: langId === "10001" ? "请配置key-field" : "Please configure key-field" });
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
let res = {};
|
|
281
|
-
selectedRows.forEach((item) => {
|
|
282
|
-
for (let [key, value] of Object.entries(keyfields)) {
|
|
283
|
-
const list = (value == null ? void 0 : value.list) ?? [];
|
|
284
|
-
const delimiter = (value == null ? void 0 : value.delimiter) ?? "-";
|
|
285
|
-
const arr = list.map((v) => {
|
|
286
|
-
return item == null ? void 0 : item[v];
|
|
287
|
-
});
|
|
288
|
-
res[key] = arr.join(delimiter);
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
resolve(res);
|
|
292
|
-
} catch (error) {
|
|
293
|
-
reject({ msg: langId === "10001" ? "key-field参数配置错误" : "key-field parameter configuration error" });
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
272
|
export {
|
|
298
|
-
buildValueFromSelectedRows,
|
|
299
273
|
SelectModel as default
|
|
300
274
|
};
|
|
@@ -537,6 +537,7 @@ function useDynamicForm(props) {
|
|
|
537
537
|
MySelect,
|
|
538
538
|
{
|
|
539
539
|
item: item.json,
|
|
540
|
+
attrid,
|
|
540
541
|
readonly: readonly || ((_k = item.json) == null ? void 0 : _k.readonly),
|
|
541
542
|
style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
|
|
542
543
|
commonRequestWidthParams,
|
|
@@ -546,8 +547,13 @@ function useDynamicForm(props) {
|
|
|
546
547
|
interfaceTypeSysDict,
|
|
547
548
|
actionUrlKey,
|
|
548
549
|
actionUrlExtraParams,
|
|
550
|
+
getTitle,
|
|
549
551
|
langId,
|
|
550
552
|
onChange: (val) => {
|
|
553
|
+
var _a2;
|
|
554
|
+
if (((_a2 = item.json) == null ? void 0 : _a2.inputType) === "instance-url") {
|
|
555
|
+
form.setFieldsValue(val);
|
|
556
|
+
}
|
|
551
557
|
form.setFieldValue(item.attrid, val);
|
|
552
558
|
}
|
|
553
559
|
}
|
package/es/utils/szxkFunc.d.ts
CHANGED
|
@@ -29,8 +29,8 @@ export declare const handleGetAttrDetail: (params: {
|
|
|
29
29
|
*/
|
|
30
30
|
export declare const handleGetList: (params: {
|
|
31
31
|
[key: string]: any;
|
|
32
|
-
pageSize
|
|
33
|
-
pageNum
|
|
32
|
+
pageSize?: number | undefined;
|
|
33
|
+
pageNum?: number | undefined;
|
|
34
34
|
'source-number': string | number;
|
|
35
35
|
}, commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>, requestParams?: {
|
|
36
36
|
PageName: string;
|
|
@@ -68,3 +68,4 @@ export declare const handleSetTableRowColor: (record: any, index: number | undef
|
|
|
68
68
|
};
|
|
69
69
|
export declare const handleFormatMobileDate: (values: Record<string, any>, format?: string) => Record<string, any>;
|
|
70
70
|
export declare const handleNonUniversalHeader: (nonUniversalHeader: Record<string, string>, data: Record<string, any>) => Record<string, any>;
|
|
71
|
+
export declare const handleGetControlPanelConfig: (sourceNumber: string | number, commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>) => Promise<any>;
|
package/es/utils/szxkFunc.js
CHANGED
|
@@ -87,11 +87,23 @@ const handleNonUniversalHeader = (nonUniversalHeader, data) => {
|
|
|
87
87
|
}
|
|
88
88
|
return mappedResult;
|
|
89
89
|
};
|
|
90
|
+
const handleGetControlPanelConfig = async (sourceNumber, commonRequest) => {
|
|
91
|
+
var _a;
|
|
92
|
+
try {
|
|
93
|
+
const res = await commonRequest("YLKHDSelPCParam", { "source-number": sourceNumber });
|
|
94
|
+
if ((res == null ? void 0 : res.ReturnValue) === 1) {
|
|
95
|
+
return ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a[sourceNumber]) || {};
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
}
|
|
100
|
+
};
|
|
90
101
|
export {
|
|
91
102
|
handleCallSupportCode,
|
|
92
103
|
handleFormatMobileDate,
|
|
93
104
|
handleGetAttrDetail,
|
|
94
105
|
handleGetAttrList,
|
|
106
|
+
handleGetControlPanelConfig,
|
|
95
107
|
handleGetList,
|
|
96
108
|
handleNonUniversalHeader,
|
|
97
109
|
handleObjDetailToSignleAttrList,
|
|
@@ -45,3 +45,18 @@ export declare const handleSelectOptions: ({ commonRequestWidthParams, commonReq
|
|
|
45
45
|
* @returns 处理后的属性集列表,每个属性项包含attrvalue
|
|
46
46
|
*/
|
|
47
47
|
export declare const handleObjDetailToSignleAttrList: (attrList: any[], detail: any) => any[];
|
|
48
|
+
/**
|
|
49
|
+
* 处理input-type 为instance-url类型的属性 选中后回填表单值的函数
|
|
50
|
+
* @param selectedRows 选中的行数据
|
|
51
|
+
* @param attributeEnrollFormat 配置信息
|
|
52
|
+
* @returns 构建后的字符串
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildValueFromSelectedRows(selectedRows: any[], attributeEnrollFormat: Ijson, langId?: string): Promise<any>;
|
|
55
|
+
/**
|
|
56
|
+
* 从数组中根据值查找对象
|
|
57
|
+
* @param list 要搜索的数组
|
|
58
|
+
* @param targetValue 要查找的值
|
|
59
|
+
* @param matchExact 是否严格匹配(默认true)
|
|
60
|
+
* @returns 匹配的对象或undefined
|
|
61
|
+
*/
|
|
62
|
+
export declare const findRowByValue: (list: Record<string, any>[], targetValue: string | number, matchExact?: boolean) => Record<string, any> | undefined;
|
|
@@ -218,7 +218,47 @@ const handleObjDetailToSignleAttrList = (attrList, detail) => {
|
|
|
218
218
|
attrvalue: detail[item.attrid] || ""
|
|
219
219
|
}));
|
|
220
220
|
};
|
|
221
|
+
function buildValueFromSelectedRows(selectedRows, attributeEnrollFormat, langId) {
|
|
222
|
+
return new Promise((resolve, reject) => {
|
|
223
|
+
try {
|
|
224
|
+
var keyfields = attributeEnrollFormat["key-field"];
|
|
225
|
+
if (!keyfields) {
|
|
226
|
+
reject({ msg: langId === "10001" ? "请配置key-field" : "Please configure key-field" });
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
let res = {};
|
|
230
|
+
selectedRows.forEach((item) => {
|
|
231
|
+
for (let [key, value] of Object.entries(keyfields)) {
|
|
232
|
+
const list = (value == null ? void 0 : value.list) ?? [];
|
|
233
|
+
const delimiter = (value == null ? void 0 : value.delimiter) ?? "-";
|
|
234
|
+
const arr = list.map((v) => {
|
|
235
|
+
return item == null ? void 0 : item[v];
|
|
236
|
+
});
|
|
237
|
+
res[key] = arr.join(delimiter);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
resolve(res);
|
|
241
|
+
} catch (error) {
|
|
242
|
+
reject({ msg: langId === "10001" ? "key-field参数配置错误" : "key-field parameter configuration error" });
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
const findRowByValue = (list, targetValue, matchExact = true) => {
|
|
247
|
+
const target = String(targetValue);
|
|
248
|
+
return list.find((item) => {
|
|
249
|
+
return Object.values(item).some((value) => {
|
|
250
|
+
const valStr = String(value);
|
|
251
|
+
if (matchExact) {
|
|
252
|
+
return valStr === target;
|
|
253
|
+
} else {
|
|
254
|
+
return valStr.includes(target);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
exports.buildValueFromSelectedRows = buildValueFromSelectedRows;
|
|
221
260
|
exports.disabledDate = disabledDate;
|
|
261
|
+
exports.findRowByValue = findRowByValue;
|
|
222
262
|
exports.getTitle = getTitle;
|
|
223
263
|
exports.handleGetPlaceholder = handleGetPlaceholder;
|
|
224
264
|
exports.handleGetSingleAttrListObj = handleGetSingleAttrListObj;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ijson } from '../index.d';
|
|
2
2
|
import { AxiosResponse } from 'axios';
|
|
3
|
-
declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, commonRequest, value, onChange, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, langId, }: {
|
|
3
|
+
declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, commonRequest, value, onChange, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, langId, getTitle, attrid, }: {
|
|
4
4
|
item: Ijson;
|
|
5
5
|
readonly?: boolean | undefined;
|
|
6
6
|
style?: any;
|
|
@@ -13,5 +13,7 @@ declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, comm
|
|
|
13
13
|
actionUrlKey: string;
|
|
14
14
|
actionUrlExtraParams: object;
|
|
15
15
|
langId?: string | undefined;
|
|
16
|
+
getTitle?: ((pageID: string, dataID: string) => string) | undefined;
|
|
17
|
+
attrid?: string | undefined;
|
|
16
18
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
17
19
|
export default MySelect;
|
|
@@ -3,6 +3,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
3
3
|
const func = require("../func");
|
|
4
4
|
const react = require("react");
|
|
5
5
|
const antd = require("antd");
|
|
6
|
+
const szxkFunc = require("../../../utils/szxkFunc");
|
|
6
7
|
const MySelect = ({
|
|
7
8
|
item,
|
|
8
9
|
readonly,
|
|
@@ -15,26 +16,65 @@ const MySelect = ({
|
|
|
15
16
|
interfaceTypeSysDict,
|
|
16
17
|
actionUrlKey,
|
|
17
18
|
actionUrlExtraParams,
|
|
18
|
-
langId
|
|
19
|
+
langId,
|
|
20
|
+
getTitle,
|
|
21
|
+
attrid
|
|
19
22
|
}) => {
|
|
20
23
|
const [options, setOptions] = react.useState([]);
|
|
21
24
|
const [loading, setLoading] = react.useState(false);
|
|
25
|
+
const [instanceList, setInstanceList] = react.useState([]);
|
|
22
26
|
react.useEffect(() => {
|
|
23
27
|
handleLoadOptions();
|
|
24
28
|
}, [item.inputType, item.classify, item.data, item.options]);
|
|
25
29
|
const handleLoadOptions = async () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
try {
|
|
31
|
+
setLoading(true);
|
|
32
|
+
if (item.inputType === "instance-url" && (item == null ? void 0 : item["instance-source-number"]) && attrid) {
|
|
33
|
+
const keyField = item == null ? void 0 : item["key-field"];
|
|
34
|
+
if (!keyField) {
|
|
35
|
+
antd.message.warning("请配置key-field");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const params = {
|
|
39
|
+
"source-number": item == null ? void 0 : item["instance-source-number"]
|
|
40
|
+
};
|
|
41
|
+
let list2 = await szxkFunc.handleGetList(params, commonRequestWidthParams);
|
|
42
|
+
const controlPanelConfig = await szxkFunc.handleGetControlPanelConfig(item == null ? void 0 : item["instance-source-number"], commonRequest);
|
|
43
|
+
if (controlPanelConfig) {
|
|
44
|
+
const nonUniversalHeader = (controlPanelConfig == null ? void 0 : controlPanelConfig["non-universal-header"]) || [];
|
|
45
|
+
const labelConfig = (nonUniversalHeader == null ? void 0 : nonUniversalHeader["label"]) || [];
|
|
46
|
+
const valueConfig = (keyField == null ? void 0 : keyField[attrid]) || {};
|
|
47
|
+
const options2 = list2 == null ? void 0 : list2.map((v) => {
|
|
48
|
+
const label = labelConfig == null ? void 0 : labelConfig.map((x) => v == null ? void 0 : v[x]).join("-");
|
|
49
|
+
const { list: list3, delimiter } = valueConfig;
|
|
50
|
+
const value2 = list3 == null ? void 0 : list3.map((x) => v == null ? void 0 : v[x]).join(delimiter || "-");
|
|
51
|
+
if (!label) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
label: getTitle == null ? void 0 : getTitle("5000000", label),
|
|
56
|
+
value: value2
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
setOptions(options2);
|
|
60
|
+
setInstanceList(list2);
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const list = await func.handleSelectOptions({
|
|
65
|
+
commonRequestWidthParams,
|
|
66
|
+
commonRequest,
|
|
67
|
+
interfaceTypeDict,
|
|
68
|
+
interfaceTypeSysDict,
|
|
69
|
+
actionUrlKey,
|
|
70
|
+
actionUrlExtraParams,
|
|
71
|
+
item
|
|
72
|
+
});
|
|
73
|
+
setOptions(list);
|
|
74
|
+
setLoading(false);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
setLoading(false);
|
|
77
|
+
}
|
|
38
78
|
};
|
|
39
79
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
40
80
|
antd.Select,
|
|
@@ -53,6 +93,18 @@ const MySelect = ({
|
|
|
53
93
|
style: { ...style },
|
|
54
94
|
allowClear: true,
|
|
55
95
|
onChange: (val) => {
|
|
96
|
+
if (attrid && (instanceList == null ? void 0 : instanceList.length) > 0 && (item == null ? void 0 : item.inputType) === "instance-url") {
|
|
97
|
+
const keyField = item == null ? void 0 : item["key-field"];
|
|
98
|
+
const row = func.findRowByValue(instanceList, String(val));
|
|
99
|
+
const keys = Object.keys(keyField || {});
|
|
100
|
+
const newObj = keys == null ? void 0 : keys.reduce((prev, cur) => {
|
|
101
|
+
const { list, delimiter } = (keyField == null ? void 0 : keyField[cur]) || {};
|
|
102
|
+
const value2 = list == null ? void 0 : list.map((x) => row == null ? void 0 : row[x]).join(delimiter || "-");
|
|
103
|
+
prev[cur] = value2;
|
|
104
|
+
return prev;
|
|
105
|
+
}, {});
|
|
106
|
+
onChange(newObj);
|
|
107
|
+
}
|
|
56
108
|
onChange(val);
|
|
57
109
|
}
|
|
58
110
|
}
|
|
@@ -19,11 +19,4 @@ interface SelectModelProps {
|
|
|
19
19
|
langId?: string;
|
|
20
20
|
}
|
|
21
21
|
declare function SelectModel(props: SelectModelProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param selectedRows 选中的行数据
|
|
25
|
-
* @param attributeEnrollFormat 配置信息
|
|
26
|
-
* @returns 构建后的字符串
|
|
27
|
-
*/
|
|
28
|
-
export declare function buildValueFromSelectedRows(selectedRows: any[], attributeEnrollFormat: Ijson, langId?: string): Promise<any>;
|
|
29
22
|
export default SelectModel;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
3
|
const antd = require("antd");
|
|
5
|
-
const react = require("react");
|
|
6
4
|
const func = require("../func");
|
|
7
5
|
const useUniversalTable = require("../../../hooks/useUniversalTable");
|
|
6
|
+
const react = require("react");
|
|
8
7
|
function SelectModel(props) {
|
|
9
8
|
const {
|
|
10
9
|
item,
|
|
@@ -162,7 +161,7 @@ function SelectModel(props) {
|
|
|
162
161
|
};
|
|
163
162
|
const handleOk = async () => {
|
|
164
163
|
try {
|
|
165
|
-
const value2 = await buildValueFromSelectedRows(selectedRecords, item, langId);
|
|
164
|
+
const value2 = await func.buildValueFromSelectedRows(selectedRecords, item, langId);
|
|
166
165
|
setValue((value2 == null ? void 0 : value2[attrid]) || "");
|
|
167
166
|
props.onSure(value2);
|
|
168
167
|
setModalVisible(false);
|
|
@@ -271,30 +270,4 @@ function SelectModel(props) {
|
|
|
271
270
|
)
|
|
272
271
|
] });
|
|
273
272
|
}
|
|
274
|
-
|
|
275
|
-
return new Promise((resolve, reject) => {
|
|
276
|
-
try {
|
|
277
|
-
var keyfields = attributeEnrollFormat["key-field"];
|
|
278
|
-
if (!keyfields) {
|
|
279
|
-
reject({ msg: langId === "10001" ? "请配置key-field" : "Please configure key-field" });
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
let res = {};
|
|
283
|
-
selectedRows.forEach((item) => {
|
|
284
|
-
for (let [key, value] of Object.entries(keyfields)) {
|
|
285
|
-
const list = (value == null ? void 0 : value.list) ?? [];
|
|
286
|
-
const delimiter = (value == null ? void 0 : value.delimiter) ?? "-";
|
|
287
|
-
const arr = list.map((v) => {
|
|
288
|
-
return item == null ? void 0 : item[v];
|
|
289
|
-
});
|
|
290
|
-
res[key] = arr.join(delimiter);
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
resolve(res);
|
|
294
|
-
} catch (error) {
|
|
295
|
-
reject({ msg: langId === "10001" ? "key-field参数配置错误" : "key-field parameter configuration error" });
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
exports.buildValueFromSelectedRows = buildValueFromSelectedRows;
|
|
300
|
-
exports.default = SelectModel;
|
|
273
|
+
module.exports = SelectModel;
|
|
@@ -538,6 +538,7 @@ function useDynamicForm(props) {
|
|
|
538
538
|
MySelect,
|
|
539
539
|
{
|
|
540
540
|
item: item.json,
|
|
541
|
+
attrid,
|
|
541
542
|
readonly: readonly || ((_k = item.json) == null ? void 0 : _k.readonly),
|
|
542
543
|
style: { width, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
|
|
543
544
|
commonRequestWidthParams,
|
|
@@ -547,8 +548,13 @@ function useDynamicForm(props) {
|
|
|
547
548
|
interfaceTypeSysDict,
|
|
548
549
|
actionUrlKey,
|
|
549
550
|
actionUrlExtraParams,
|
|
551
|
+
getTitle,
|
|
550
552
|
langId,
|
|
551
553
|
onChange: (val) => {
|
|
554
|
+
var _a2;
|
|
555
|
+
if (((_a2 = item.json) == null ? void 0 : _a2.inputType) === "instance-url") {
|
|
556
|
+
form.setFieldsValue(val);
|
|
557
|
+
}
|
|
552
558
|
form.setFieldValue(item.attrid, val);
|
|
553
559
|
}
|
|
554
560
|
}
|
package/lib/utils/szxkFunc.d.ts
CHANGED
|
@@ -29,8 +29,8 @@ export declare const handleGetAttrDetail: (params: {
|
|
|
29
29
|
*/
|
|
30
30
|
export declare const handleGetList: (params: {
|
|
31
31
|
[key: string]: any;
|
|
32
|
-
pageSize
|
|
33
|
-
pageNum
|
|
32
|
+
pageSize?: number | undefined;
|
|
33
|
+
pageNum?: number | undefined;
|
|
34
34
|
'source-number': string | number;
|
|
35
35
|
}, commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>, requestParams?: {
|
|
36
36
|
PageName: string;
|
|
@@ -68,3 +68,4 @@ export declare const handleSetTableRowColor: (record: any, index: number | undef
|
|
|
68
68
|
};
|
|
69
69
|
export declare const handleFormatMobileDate: (values: Record<string, any>, format?: string) => Record<string, any>;
|
|
70
70
|
export declare const handleNonUniversalHeader: (nonUniversalHeader: Record<string, string>, data: Record<string, any>) => Record<string, any>;
|
|
71
|
+
export declare const handleGetControlPanelConfig: (sourceNumber: string | number, commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>) => Promise<any>;
|
package/lib/utils/szxkFunc.js
CHANGED
|
@@ -89,10 +89,22 @@ const handleNonUniversalHeader = (nonUniversalHeader, data) => {
|
|
|
89
89
|
}
|
|
90
90
|
return mappedResult;
|
|
91
91
|
};
|
|
92
|
+
const handleGetControlPanelConfig = async (sourceNumber, commonRequest) => {
|
|
93
|
+
var _a;
|
|
94
|
+
try {
|
|
95
|
+
const res = await commonRequest("YLKHDSelPCParam", { "source-number": sourceNumber });
|
|
96
|
+
if ((res == null ? void 0 : res.ReturnValue) === 1) {
|
|
97
|
+
return ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a[sourceNumber]) || {};
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
}
|
|
102
|
+
};
|
|
92
103
|
exports.handleCallSupportCode = handleCallSupportCode;
|
|
93
104
|
exports.handleFormatMobileDate = handleFormatMobileDate;
|
|
94
105
|
exports.handleGetAttrDetail = handleGetAttrDetail;
|
|
95
106
|
exports.handleGetAttrList = handleGetAttrList;
|
|
107
|
+
exports.handleGetControlPanelConfig = handleGetControlPanelConfig;
|
|
96
108
|
exports.handleGetList = handleGetList;
|
|
97
109
|
exports.handleNonUniversalHeader = handleNonUniversalHeader;
|
|
98
110
|
exports.handleObjDetailToSignleAttrList = handleObjDetailToSignleAttrList;
|