szld-libs 0.2.98 → 0.3.1
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 +32089 -20004
- package/dist/szld-components.umd.js +72 -60
- package/es/components/DynamicForm/index.d.ts +2 -0
- package/es/components/DynamicForm/index.js +3 -2
- package/es/components/DynamicForm/selectModel/index.js +1 -1
- package/es/components/DynamicForm/selectModelBackfillFormItem/index.d.ts +27 -0
- package/es/components/DynamicForm/selectModelBackfillFormItem/index.js +242 -0
- package/es/components/DynamicForm/selectModelBackfillFormItem/vite.svg +1 -0
- package/es/components/DynamicForm/useDynamicForm.js +22 -1
- package/es/components/DynamicFormMobile/func.d.ts +35 -0
- package/es/components/DynamicFormMobile/func.js +204 -0
- package/es/components/DynamicFormMobile/index.d.ts +116 -0
- package/es/components/DynamicFormMobile/index.js +134 -0
- package/es/components/DynamicFormMobile/myCascader/index.d.ts +17 -0
- package/es/components/DynamicFormMobile/myCascader/index.js +196 -0
- package/es/components/DynamicFormMobile/myCascader/vite.svg +1 -0
- package/es/components/DynamicFormMobile/myCheckbox/index.d.ts +19 -0
- package/es/components/DynamicFormMobile/myCheckbox/index.js +109 -0
- package/es/components/DynamicFormMobile/myCheckbox/vite.svg +1 -0
- package/es/components/DynamicFormMobile/myRadio/index.d.ts +20 -0
- package/es/components/DynamicFormMobile/myRadio/index.js +107 -0
- package/es/components/DynamicFormMobile/myRadio/vite.svg +1 -0
- package/es/components/DynamicFormMobile/mySelect/index.css +31 -0
- package/es/components/DynamicFormMobile/mySelect/index.d.ts +16 -0
- package/es/components/DynamicFormMobile/mySelect/index.js +147 -0
- package/es/components/DynamicFormMobile/mySelect/vite.svg +1 -0
- package/es/components/DynamicFormMobile/myUpload/index.css +3 -0
- package/es/components/DynamicFormMobile/myUpload/index.d.ts +16 -0
- package/es/components/DynamicFormMobile/myUpload/index.js +103 -0
- package/es/components/DynamicFormMobile/myUpload/vite.svg +1 -0
- package/es/components/DynamicFormMobile/radioCard/index.d.ts +12 -0
- package/es/components/DynamicFormMobile/radioCard/index.js +142 -0
- package/es/components/DynamicFormMobile/radioCard/vite.svg +1 -0
- package/es/components/DynamicFormMobile/selectModel/index.d.ts +22 -0
- package/es/components/DynamicFormMobile/selectModel/index.js +235 -0
- package/es/components/DynamicFormMobile/selectModel/vite.svg +1 -0
- package/es/components/DynamicFormMobile/selectModelBackfillFormItem/index.d.ts +27 -0
- package/es/components/DynamicFormMobile/selectModelBackfillFormItem/index.js +242 -0
- package/es/components/DynamicFormMobile/selectModelBackfillFormItem/vite.svg +1 -0
- package/es/components/DynamicFormMobile/useDynamicForm.d.ts +43 -0
- package/es/components/DynamicFormMobile/useDynamicForm.js +772 -0
- package/es/components/DynamicFormMobile/vite.svg +1 -0
- package/es/index.css +1 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +36 -30
- package/es/main.d.ts +2 -1
- package/es/main.js +22 -20
- package/es/mock/index.d.ts +1 -305
- package/es/mock/index.js +20 -364
- package/es/services/index.js +3 -5
- package/es/services/request.js +2 -2
- package/es/utils/method.d.ts +4 -1
- package/es/utils/method.js +25 -8
- package/lib/components/DynamicForm/index.d.ts +2 -0
- package/lib/components/DynamicForm/index.js +3 -2
- package/lib/components/DynamicForm/selectModel/index.js +1 -1
- package/lib/components/DynamicForm/selectModelBackfillFormItem/index.d.ts +27 -0
- package/lib/components/DynamicForm/selectModelBackfillFormItem/index.js +242 -0
- package/lib/components/DynamicForm/selectModelBackfillFormItem/vite.svg +1 -0
- package/lib/components/DynamicForm/useDynamicForm.js +22 -1
- package/lib/components/DynamicFormMobile/func.d.ts +35 -0
- package/lib/components/DynamicFormMobile/func.js +204 -0
- package/lib/components/DynamicFormMobile/index.d.ts +116 -0
- package/lib/components/DynamicFormMobile/index.js +133 -0
- package/lib/components/DynamicFormMobile/myCascader/index.d.ts +17 -0
- package/lib/components/DynamicFormMobile/myCascader/index.js +195 -0
- package/lib/components/DynamicFormMobile/myCascader/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/myCheckbox/index.d.ts +19 -0
- package/lib/components/DynamicFormMobile/myCheckbox/index.js +108 -0
- package/lib/components/DynamicFormMobile/myCheckbox/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/myRadio/index.d.ts +20 -0
- package/lib/components/DynamicFormMobile/myRadio/index.js +106 -0
- package/lib/components/DynamicFormMobile/myRadio/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/mySelect/index.css +31 -0
- package/lib/components/DynamicFormMobile/mySelect/index.d.ts +16 -0
- package/lib/components/DynamicFormMobile/mySelect/index.js +146 -0
- package/lib/components/DynamicFormMobile/mySelect/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/myUpload/index.css +3 -0
- package/lib/components/DynamicFormMobile/myUpload/index.d.ts +16 -0
- package/lib/components/DynamicFormMobile/myUpload/index.js +102 -0
- package/lib/components/DynamicFormMobile/myUpload/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/radioCard/index.d.ts +12 -0
- package/lib/components/DynamicFormMobile/radioCard/index.js +141 -0
- package/lib/components/DynamicFormMobile/radioCard/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/selectModel/index.d.ts +22 -0
- package/lib/components/DynamicFormMobile/selectModel/index.js +235 -0
- package/lib/components/DynamicFormMobile/selectModel/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/index.d.ts +27 -0
- package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/index.js +242 -0
- package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/vite.svg +1 -0
- package/lib/components/DynamicFormMobile/useDynamicForm.d.ts +43 -0
- package/lib/components/DynamicFormMobile/useDynamicForm.js +771 -0
- package/lib/components/DynamicFormMobile/vite.svg +1 -0
- package/lib/index.css +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +36 -30
- package/lib/main.d.ts +2 -1
- package/lib/main.js +2 -0
- package/lib/mock/index.d.ts +1 -305
- package/lib/mock/index.js +19 -363
- package/lib/services/index.js +3 -5
- package/lib/services/request.js +2 -2
- package/lib/utils/method.d.ts +4 -1
- package/lib/utils/method.js +25 -8
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ export interface IformConfigItem {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface Ijson {
|
|
21
|
+
'action-url-extra-params'?: { [key: string]: any }; // 弹窗选择对应多个表单字段时,额外的参数
|
|
21
22
|
'disable-date-goover'?: boolean; // 禁用日期选择器超出当前日期
|
|
22
23
|
'default-prompt'?: string; // 提示信息
|
|
23
24
|
'regexp-message'?: string; // 正则表达式提示信息
|
|
@@ -91,6 +92,7 @@ export type InputType =
|
|
|
91
92
|
| 'radio'
|
|
92
93
|
| 'checkbox'
|
|
93
94
|
| 'cascader'
|
|
95
|
+
| 'mult-field-modal-select' // 弹窗选择对应多个表单字段
|
|
94
96
|
| string;
|
|
95
97
|
|
|
96
98
|
// 定义文件上传值类型
|
|
@@ -29,7 +29,8 @@ const DynamicForm = forwardRef((props, ref) => {
|
|
|
29
29
|
hideAttrList = [],
|
|
30
30
|
formShowType = "form",
|
|
31
31
|
headerWidth,
|
|
32
|
-
formListItemWidth
|
|
32
|
+
formListItemWidth,
|
|
33
|
+
formListItemName
|
|
33
34
|
} = props;
|
|
34
35
|
const delFileListRef = useRef([]);
|
|
35
36
|
const updateDelFileList = (file) => {
|
|
@@ -57,7 +58,7 @@ const DynamicForm = forwardRef((props, ref) => {
|
|
|
57
58
|
return delFileListRef.current;
|
|
58
59
|
}
|
|
59
60
|
}));
|
|
60
|
-
return /* @__PURE__ */ jsx(Fragment, { children: formShowType === "table" ? /* @__PURE__ */ jsx(Form.List, { name: "customFormList", initialValue: [{}], children: (fields, { add, remove }) => /* @__PURE__ */ jsxs("div", { className: "custom-form-list", children: [
|
|
61
|
+
return /* @__PURE__ */ jsx(Fragment, { children: formShowType === "table" ? /* @__PURE__ */ jsx(Form.List, { name: formListItemName || "customFormList", initialValue: [{}], children: (fields, { add, remove }) => /* @__PURE__ */ jsxs("div", { className: "custom-form-list", children: [
|
|
61
62
|
/* @__PURE__ */ jsxs(Flex, { align: "center", children: [
|
|
62
63
|
/* @__PURE__ */ jsx(Flex, { className: "custom-form-list-header", align: "center", children: formConfig == null ? void 0 : formConfig.map((child, index) => {
|
|
63
64
|
return /* @__PURE__ */ jsxs(Flex, { style: { width: (headerWidth == null ? void 0 : headerWidth[index]) || defaultWidth }, align: "center", children: [
|
|
@@ -137,7 +137,7 @@ function SelectModel(props) {
|
|
|
137
137
|
/* @__PURE__ */ jsx(
|
|
138
138
|
Select,
|
|
139
139
|
{
|
|
140
|
-
placeholder: (item == null ? void 0 : item["
|
|
140
|
+
placeholder: (item == null ? void 0 : item["default-prompt"]) || "请选择",
|
|
141
141
|
onClick: openModal,
|
|
142
142
|
value,
|
|
143
143
|
open: false,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FormInstance } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { AxiosResponse } from 'axios';
|
|
4
|
+
import { Ijson } from '../index.d';
|
|
5
|
+
interface SelectModelProps {
|
|
6
|
+
item: Ijson;
|
|
7
|
+
onSure: (value: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}) => void;
|
|
10
|
+
value: string;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
14
|
+
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
15
|
+
CustomModalComponent?: React.FC<ICustomModal>;
|
|
16
|
+
attrid: string;
|
|
17
|
+
form: FormInstance;
|
|
18
|
+
}
|
|
19
|
+
declare function SelectModel(props: SelectModelProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param selectedRows 选中的行数据
|
|
23
|
+
* @param attributeEnrollFormat 配置信息
|
|
24
|
+
* @returns 构建后的字符串
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildValueFromSelectedRows(selectedRows: any[], attributeEnrollFormat: Ijson): Promise<any>;
|
|
27
|
+
export default SelectModel;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Form, App, Select, Table, Modal } from "antd";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
function SelectModel(props) {
|
|
5
|
+
const { item, disabled, style, commonRequestWidthParams, CustomModalComponent, attrid, form } = props;
|
|
6
|
+
const attrValue = Form.useWatch(attrid, form);
|
|
7
|
+
const { message } = App.useApp();
|
|
8
|
+
const mode = item.input;
|
|
9
|
+
const [value, setValue] = useState(props.value);
|
|
10
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
11
|
+
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
12
|
+
const [selectedRecords, setSelectedRecords] = useState([]);
|
|
13
|
+
const [loading, setLoading] = useState(false);
|
|
14
|
+
const [params, setParams] = useState({
|
|
15
|
+
PageNum: 1,
|
|
16
|
+
PageSize: 6
|
|
17
|
+
});
|
|
18
|
+
const [dataSource, setDataSource] = useState([]);
|
|
19
|
+
const [total, setTotal] = useState(0);
|
|
20
|
+
const columns = buildColumns();
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!modalVisible) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
getData();
|
|
26
|
+
}, [modalVisible, params]);
|
|
27
|
+
const onSelectChange = (keys, selectedRows) => {
|
|
28
|
+
setSelectedRowKeys(keys);
|
|
29
|
+
setSelectedRecords(selectedRows);
|
|
30
|
+
};
|
|
31
|
+
const getData = async () => {
|
|
32
|
+
var _a;
|
|
33
|
+
if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
|
|
34
|
+
setLoading(true);
|
|
35
|
+
try {
|
|
36
|
+
const response = await commonRequestWidthParams(
|
|
37
|
+
{
|
|
38
|
+
PageName: "dns_relay",
|
|
39
|
+
Controlname: "CallActionUrl",
|
|
40
|
+
InterfaceType: ""
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"action-url": item == null ? void 0 : item["action-url"],
|
|
44
|
+
...params,
|
|
45
|
+
...(item == null ? void 0 : item["action-url-extra-params"]) || {}
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
if ((response == null ? void 0 : response.ReturnValue) === 0) {
|
|
49
|
+
message.error(response.msg);
|
|
50
|
+
setLoading(false);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const data = response == null ? void 0 : response.data;
|
|
54
|
+
const tempData = (_a = data == null ? void 0 : data.list) == null ? void 0 : _a.map((item2, index) => {
|
|
55
|
+
const _rowKey = (params.PageNum - 1) * params.PageSize + index;
|
|
56
|
+
return {
|
|
57
|
+
...item2,
|
|
58
|
+
_rowKey
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
const tempSelectedRecords = (tempData == null ? void 0 : tempData.filter((item2) => selectedRowKeys.includes(item2._rowKey))) || [];
|
|
62
|
+
setSelectedRecords(tempSelectedRecords);
|
|
63
|
+
setDataSource([...tempData || []]);
|
|
64
|
+
setTotal((data == null ? void 0 : data.number) || 0);
|
|
65
|
+
setLoading(false);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
setLoading(false);
|
|
68
|
+
message.error(error.msg || "参数错误");
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
message.error("请配置action-url");
|
|
73
|
+
};
|
|
74
|
+
const openModal = () => {
|
|
75
|
+
var _a;
|
|
76
|
+
if (disabled) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (value) {
|
|
80
|
+
const keyField = item == null ? void 0 : item["key-field"];
|
|
81
|
+
const el = keyField == null ? void 0 : keyField[attrid];
|
|
82
|
+
const { delimiter = "-", list = [] } = el || {};
|
|
83
|
+
if (!keyField) {
|
|
84
|
+
message.error("请配置key-field");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
switch (mode) {
|
|
88
|
+
case "mul-field-modal-select":
|
|
89
|
+
const id = (_a = value == null ? void 0 : value.split(delimiter)) == null ? void 0 : _a[0];
|
|
90
|
+
const index = dataSource == null ? void 0 : dataSource.findIndex((item2) => Object.values(item2).includes(id));
|
|
91
|
+
setSelectedRowKeys([index]);
|
|
92
|
+
break;
|
|
93
|
+
case "modal-mult-select":
|
|
94
|
+
const values = value == null ? void 0 : value.split(",");
|
|
95
|
+
const tempKeys = values == null ? void 0 : values.map((item2) => {
|
|
96
|
+
var _a2;
|
|
97
|
+
const id2 = (_a2 = item2.split(delimiter)) == null ? void 0 : _a2[0];
|
|
98
|
+
return dataSource == null ? void 0 : dataSource.findIndex((item3) => id2.includes((item3 == null ? void 0 : item3.typeid) || (item3 == null ? void 0 : item3.instanceid)));
|
|
99
|
+
});
|
|
100
|
+
setSelectedRowKeys(tempKeys);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
setModalVisible(true);
|
|
105
|
+
};
|
|
106
|
+
const handleOk = async () => {
|
|
107
|
+
try {
|
|
108
|
+
const value2 = await buildValueFromSelectedRows(selectedRecords, item);
|
|
109
|
+
setValue((value2 == null ? void 0 : value2[attrid]) || "");
|
|
110
|
+
props.onSure(value2);
|
|
111
|
+
setModalVisible(false);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
message.error(error.msg || "参数错误");
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const handleCancel = () => {
|
|
117
|
+
setParams({
|
|
118
|
+
...params,
|
|
119
|
+
PageNum: 1
|
|
120
|
+
});
|
|
121
|
+
setModalVisible(false);
|
|
122
|
+
};
|
|
123
|
+
function buildColumns() {
|
|
124
|
+
const modalFieldList = item["modal-field-list"];
|
|
125
|
+
let columns2 = [];
|
|
126
|
+
for (let fieldName in modalFieldList) {
|
|
127
|
+
let title = modalFieldList[fieldName];
|
|
128
|
+
const column = { dataIndex: fieldName, title };
|
|
129
|
+
columns2 = [...columns2, column];
|
|
130
|
+
}
|
|
131
|
+
return columns2;
|
|
132
|
+
}
|
|
133
|
+
const onPageChange = (pageNum) => {
|
|
134
|
+
setParams({
|
|
135
|
+
...params,
|
|
136
|
+
PageNum: pageNum
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
Select,
|
|
142
|
+
{
|
|
143
|
+
placeholder: (item == null ? void 0 : item["default-prompt"]) || "请选择",
|
|
144
|
+
onClick: openModal,
|
|
145
|
+
open: false,
|
|
146
|
+
value: attrValue,
|
|
147
|
+
disabled,
|
|
148
|
+
style
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
CustomModalComponent && /* @__PURE__ */ jsx(
|
|
152
|
+
CustomModalComponent,
|
|
153
|
+
{
|
|
154
|
+
title: item["modal-caption"] || "",
|
|
155
|
+
open: modalVisible,
|
|
156
|
+
onOk: handleOk,
|
|
157
|
+
onCancel: handleCancel,
|
|
158
|
+
modalStyle: { width: item["modal-width"] ?? 600, minHeight: item["modal-height"] ?? 400 },
|
|
159
|
+
children: /* @__PURE__ */ jsx(
|
|
160
|
+
Table,
|
|
161
|
+
{
|
|
162
|
+
columns,
|
|
163
|
+
loading,
|
|
164
|
+
dataSource,
|
|
165
|
+
rowKey: (record) => record._rowKey,
|
|
166
|
+
scroll: { y: "calc(80vh - 300px)" },
|
|
167
|
+
rowSelection: {
|
|
168
|
+
type: mode === "mul-field-modal-select" ? "radio" : "checkbox",
|
|
169
|
+
selectedRowKeys,
|
|
170
|
+
onChange: onSelectChange
|
|
171
|
+
},
|
|
172
|
+
pagination: {
|
|
173
|
+
total,
|
|
174
|
+
current: params.PageNum,
|
|
175
|
+
pageSize: params.PageSize,
|
|
176
|
+
onChange: onPageChange
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
) || /* @__PURE__ */ jsx(
|
|
182
|
+
Modal,
|
|
183
|
+
{
|
|
184
|
+
title: item["modal-caption"],
|
|
185
|
+
open: modalVisible,
|
|
186
|
+
onOk: handleOk,
|
|
187
|
+
onCancel: handleCancel,
|
|
188
|
+
width: item["modal-width"] ?? 600,
|
|
189
|
+
okButtonProps: { disabled: selectedRowKeys.length === 0 },
|
|
190
|
+
children: /* @__PURE__ */ jsx(
|
|
191
|
+
Table,
|
|
192
|
+
{
|
|
193
|
+
columns,
|
|
194
|
+
loading,
|
|
195
|
+
dataSource,
|
|
196
|
+
rowKey: (record) => record._rowKey,
|
|
197
|
+
rowSelection: {
|
|
198
|
+
type: mode === "mul-field-modal-select" ? "radio" : "checkbox",
|
|
199
|
+
selectedRowKeys,
|
|
200
|
+
onChange: onSelectChange
|
|
201
|
+
},
|
|
202
|
+
pagination: {
|
|
203
|
+
total,
|
|
204
|
+
current: params.PageNum,
|
|
205
|
+
pageSize: params.PageSize,
|
|
206
|
+
onChange: onPageChange
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
] });
|
|
213
|
+
}
|
|
214
|
+
function buildValueFromSelectedRows(selectedRows, attributeEnrollFormat) {
|
|
215
|
+
return new Promise((resolve, reject) => {
|
|
216
|
+
try {
|
|
217
|
+
var keyfields = attributeEnrollFormat["key-field"];
|
|
218
|
+
if (!keyfields) {
|
|
219
|
+
reject({ msg: "请配置key-field" });
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
let res = {};
|
|
223
|
+
selectedRows.forEach((item) => {
|
|
224
|
+
for (let [key, value] of Object.entries(keyfields)) {
|
|
225
|
+
const list = (value == null ? void 0 : value.list) ?? [];
|
|
226
|
+
const delimiter = (value == null ? void 0 : value.delimiter) ?? "-";
|
|
227
|
+
const arr = list.map((v) => {
|
|
228
|
+
return item == null ? void 0 : item[v];
|
|
229
|
+
});
|
|
230
|
+
res[key] = arr.join(delimiter);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
resolve(res);
|
|
234
|
+
} catch (error) {
|
|
235
|
+
reject({ msg: "key-field参数配置错误" });
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
export {
|
|
240
|
+
buildValueFromSelectedRows,
|
|
241
|
+
SelectModel as default
|
|
242
|
+
};
|
|
@@ -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>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
2
|
+
import { MinusSquareOutlined, PlusSquareOutlined, CloseOutlined, InfoCircleOutlined } from "@ant-design/icons";
|
|
2
3
|
import { handleSetFormItemInitialValue, handleGetPlaceholder, disabledDate } from "./func";
|
|
3
4
|
import { handleUrlOptions, getJson, base64ToString } from "../../utils/method";
|
|
5
|
+
import SelectModelBackfillFormItem from "./selectModelBackfillFormItem";
|
|
4
6
|
import { useRef, useEffect, useCallback, Fragment } from "react";
|
|
5
7
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
6
8
|
import SelectModel from "./selectModel";
|
|
@@ -11,7 +13,6 @@ import RadioCard from "./radioCard";
|
|
|
11
13
|
import MySelect from "./mySelect";
|
|
12
14
|
import MyUpload from "./myUpload";
|
|
13
15
|
import MyRadio from "./myRadio";
|
|
14
|
-
import { MinusSquareOutlined, PlusSquareOutlined, CloseOutlined, InfoCircleOutlined } from "@ant-design/icons";
|
|
15
16
|
import { App, Col, Collapse, Form, Card, Flex, Button, Space, Input, DatePicker, InputNumber, Tooltip } from "antd";
|
|
16
17
|
dayjs.extend(isoWeek);
|
|
17
18
|
function useDynamicForm(props) {
|
|
@@ -432,6 +433,7 @@ function useDynamicForm(props) {
|
|
|
432
433
|
}) => {
|
|
433
434
|
var _a, _b, _c, _d;
|
|
434
435
|
const mode = item.json.input || "text";
|
|
436
|
+
const attrid = item.attrid;
|
|
435
437
|
const formatValue = handleSetFormItemInitialValue(item);
|
|
436
438
|
const message2 = ((_a = item.json) == null ? void 0 : _a["default-prompt"]) || "";
|
|
437
439
|
const disableDateGoover = ((_b = item.json) == null ? void 0 : _b["disable-date-goover"]) || false;
|
|
@@ -533,6 +535,25 @@ function useDynamicForm(props) {
|
|
|
533
535
|
}
|
|
534
536
|
);
|
|
535
537
|
}
|
|
538
|
+
case "mul-field-modal-select": {
|
|
539
|
+
return /* @__PURE__ */ jsx(
|
|
540
|
+
SelectModelBackfillFormItem,
|
|
541
|
+
{
|
|
542
|
+
style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
|
|
543
|
+
item: item.json,
|
|
544
|
+
form,
|
|
545
|
+
attrid,
|
|
546
|
+
value: item.attrvalue || item.json.default || "",
|
|
547
|
+
commonRequestWidthParams,
|
|
548
|
+
commonRequest,
|
|
549
|
+
onSure: async (value) => {
|
|
550
|
+
form.setFieldsValue(value);
|
|
551
|
+
},
|
|
552
|
+
disabled: readonly,
|
|
553
|
+
CustomModalComponent
|
|
554
|
+
}
|
|
555
|
+
);
|
|
556
|
+
}
|
|
536
557
|
case "date-picker":
|
|
537
558
|
case "time-picker":
|
|
538
559
|
case "week-picker":
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IformConfigItem, Ijson } from './index.d';
|
|
2
|
+
import { RangePickerProps } from 'antd/es/date-picker';
|
|
3
|
+
import { AxiosResponse } from 'axios';
|
|
4
|
+
export declare const handleGetPlaceholder: (itemWithJson: IformConfigItem) => string;
|
|
5
|
+
/**
|
|
6
|
+
* 处理表单项目初始值
|
|
7
|
+
* 根据输入类型转换初始值为组件所需格式
|
|
8
|
+
*/
|
|
9
|
+
export declare const handleSetFormItemInitialValue: (itemWithJson: IformConfigItem) => any;
|
|
10
|
+
export declare const disabledDate: RangePickerProps['disabledDate'];
|
|
11
|
+
/**
|
|
12
|
+
* 处理URL选项
|
|
13
|
+
* 将URL中的指定字段拼接为字符串
|
|
14
|
+
*/
|
|
15
|
+
export declare const handleUrlOptions: (val: any, delimiter: string, list: any[]) => string;
|
|
16
|
+
/**
|
|
17
|
+
* 根据配置处理成下拉数据
|
|
18
|
+
* @param param0
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export declare const handleSelectOptions: ({ commonRequestWidthParams, commonRequest, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, item, }: {
|
|
22
|
+
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
23
|
+
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
24
|
+
interfaceTypeDict?: string | undefined;
|
|
25
|
+
interfaceTypeSysDict?: string | undefined;
|
|
26
|
+
actionUrlKey?: string | undefined;
|
|
27
|
+
actionUrlExtraParams?: object | undefined;
|
|
28
|
+
item: Ijson;
|
|
29
|
+
}) => Promise<any[]>;
|
|
30
|
+
/**
|
|
31
|
+
* attrList 格式的单层数组 处理成对象{attrid:attrname}
|
|
32
|
+
*/
|
|
33
|
+
export declare const handleGetSingleAttrListObj: (children: any[]) => {
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}[];
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { message } from "antd";
|
|
3
|
+
const handleGetPlaceholder = (itemWithJson) => {
|
|
4
|
+
const { input = "" } = itemWithJson.json || {};
|
|
5
|
+
let placeholder = "请输入";
|
|
6
|
+
if ([
|
|
7
|
+
"radio",
|
|
8
|
+
"checkbox",
|
|
9
|
+
"select",
|
|
10
|
+
"mult-select",
|
|
11
|
+
"modal-select",
|
|
12
|
+
"date-picker",
|
|
13
|
+
"range-picker",
|
|
14
|
+
"multiple-date-picker",
|
|
15
|
+
"time-picker",
|
|
16
|
+
"week-picker",
|
|
17
|
+
"month-picker",
|
|
18
|
+
"quarter-picker",
|
|
19
|
+
"year-picker",
|
|
20
|
+
"second-picker"
|
|
21
|
+
].includes(input)) {
|
|
22
|
+
placeholder = "请选择";
|
|
23
|
+
}
|
|
24
|
+
if (["image", "file", "video", "audio"].includes(input)) {
|
|
25
|
+
placeholder = "请上传";
|
|
26
|
+
}
|
|
27
|
+
return placeholder;
|
|
28
|
+
};
|
|
29
|
+
const handleSetFormItemInitialValue = (itemWithJson) => {
|
|
30
|
+
var _a, _b, _c, _d;
|
|
31
|
+
const inputType = (_a = itemWithJson.json) == null ? void 0 : _a.input;
|
|
32
|
+
let initialValue = itemWithJson.attrvalue || ((_b = itemWithJson.json) == null ? void 0 : _b.default) || "";
|
|
33
|
+
if (inputType === "label" && initialValue) {
|
|
34
|
+
initialValue = ((_c = itemWithJson.json) == null ? void 0 : _c["label-value"]) ?? initialValue ?? "-";
|
|
35
|
+
}
|
|
36
|
+
if (inputType === "range-picker" && initialValue) {
|
|
37
|
+
try {
|
|
38
|
+
initialValue = initialValue == null ? void 0 : initialValue.split("~");
|
|
39
|
+
initialValue = initialValue.map((v) => v);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
initialValue = void 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (inputType === "multiple-date-picker" && initialValue) {
|
|
45
|
+
try {
|
|
46
|
+
initialValue = initialValue == null ? void 0 : initialValue.split(",");
|
|
47
|
+
initialValue = initialValue.map((v) => dayjs());
|
|
48
|
+
} catch (error) {
|
|
49
|
+
initialValue = void 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (inputType === "cascader" && initialValue && typeof initialValue === "string") {
|
|
53
|
+
const delimiter = (_d = itemWithJson.json) == null ? void 0 : _d["cascader-delimiter"];
|
|
54
|
+
if (delimiter) {
|
|
55
|
+
initialValue = initialValue.split(delimiter).filter(Boolean);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (["mult-select", "checkbox"].includes(inputType) && initialValue && typeof initialValue === "string") {
|
|
59
|
+
initialValue = initialValue.split(",").filter(Boolean);
|
|
60
|
+
}
|
|
61
|
+
if (["image", "video", "audio", "file"].includes(inputType) && initialValue) {
|
|
62
|
+
try {
|
|
63
|
+
const fileList = Array.isArray(initialValue) ? initialValue : JSON.parse(initialValue);
|
|
64
|
+
initialValue = fileList.map((file) => ({
|
|
65
|
+
...file,
|
|
66
|
+
url: file.FilePath,
|
|
67
|
+
name: file.FileName,
|
|
68
|
+
uid: file.FileId
|
|
69
|
+
}));
|
|
70
|
+
} catch (error) {
|
|
71
|
+
initialValue = [];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (itemWithJson.attrtype === 1) {
|
|
75
|
+
initialValue = handleGetSingleAttrListObj(itemWithJson.children || []);
|
|
76
|
+
}
|
|
77
|
+
return initialValue || void 0;
|
|
78
|
+
};
|
|
79
|
+
const disabledDate = (current) => {
|
|
80
|
+
return current && current < dayjs().startOf("day");
|
|
81
|
+
};
|
|
82
|
+
const handleUrlOptions = (val, delimiter, list) => {
|
|
83
|
+
let arr = [];
|
|
84
|
+
list.forEach((item) => {
|
|
85
|
+
arr.push(val == null ? void 0 : val[item]);
|
|
86
|
+
});
|
|
87
|
+
return arr.join(delimiter || "-");
|
|
88
|
+
};
|
|
89
|
+
const handleSelectOptions = async ({
|
|
90
|
+
commonRequestWidthParams,
|
|
91
|
+
commonRequest,
|
|
92
|
+
interfaceTypeDict = "YLZDDictList",
|
|
93
|
+
interfaceTypeSysDict = "YLZDSysConfigList",
|
|
94
|
+
actionUrlKey = "action-url",
|
|
95
|
+
actionUrlExtraParams = {},
|
|
96
|
+
item
|
|
97
|
+
}) => {
|
|
98
|
+
var _a;
|
|
99
|
+
let options = [];
|
|
100
|
+
const getDict = async (interfaceType) => {
|
|
101
|
+
var _a2;
|
|
102
|
+
let list = [];
|
|
103
|
+
if (item.classify) {
|
|
104
|
+
try {
|
|
105
|
+
const response = await commonRequest(interfaceType, {
|
|
106
|
+
asctypeid: item.classify
|
|
107
|
+
});
|
|
108
|
+
if (((_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.list) && Array.isArray(response.data.list)) {
|
|
109
|
+
list = response.data.list.map((dictItem) => ({
|
|
110
|
+
label: `${dictItem.dicid || ""}-${dictItem.info || ""}`,
|
|
111
|
+
value: `${dictItem.dicid || ""}-${dictItem.info || ""}`
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
message.error("加载选项失败");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return list;
|
|
119
|
+
};
|
|
120
|
+
const getUrlOptions = async () => {
|
|
121
|
+
var _a2, _b;
|
|
122
|
+
try {
|
|
123
|
+
const keyFieldList = ((_a2 = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a2.list) || [];
|
|
124
|
+
const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) || "";
|
|
125
|
+
if (!keyFieldList.length) {
|
|
126
|
+
message.error("请配置key-field");
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const response = await commonRequestWidthParams(
|
|
130
|
+
{
|
|
131
|
+
PageName: "dns_relay",
|
|
132
|
+
Controlname: "CallActionUrl",
|
|
133
|
+
InterfaceType: ""
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
[actionUrlKey]: item == null ? void 0 : item["action-url"],
|
|
137
|
+
...actionUrlExtraParams
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
if (response == null ? void 0 : response.data) {
|
|
141
|
+
const data = response == null ? void 0 : response.data;
|
|
142
|
+
const list = (data == null ? void 0 : data.list) || [];
|
|
143
|
+
let urlData = [];
|
|
144
|
+
if (Array.isArray(data)) {
|
|
145
|
+
urlData = data;
|
|
146
|
+
}
|
|
147
|
+
if (Array.isArray(list)) {
|
|
148
|
+
urlData = list;
|
|
149
|
+
}
|
|
150
|
+
options = urlData.map((val) => ({
|
|
151
|
+
label: handleUrlOptions(val, delimiter, keyFieldList),
|
|
152
|
+
value: handleUrlOptions(val, delimiter, keyFieldList)
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
message.error("加载选项失败");
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
if (item.inputType === "local") {
|
|
160
|
+
options = ((_a = item.data) == null ? void 0 : _a.map((val) => ({
|
|
161
|
+
label: val,
|
|
162
|
+
value: val
|
|
163
|
+
}))) || [];
|
|
164
|
+
if (item.options && Array.isArray(item.options)) {
|
|
165
|
+
options = item.options;
|
|
166
|
+
}
|
|
167
|
+
} else if (item.inputType === "dictionary") {
|
|
168
|
+
options = await getDict(interfaceTypeDict);
|
|
169
|
+
} else if (item.inputType === "system-dictionary") {
|
|
170
|
+
options = await getDict(interfaceTypeSysDict);
|
|
171
|
+
}
|
|
172
|
+
if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
|
|
173
|
+
await getUrlOptions();
|
|
174
|
+
}
|
|
175
|
+
return options;
|
|
176
|
+
};
|
|
177
|
+
const handleGetSingleAttrListObj = (children) => {
|
|
178
|
+
if (!(children == null ? void 0 : children.length)) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
const dealList = (children2) => children2 == null ? void 0 : children2.map((v) => {
|
|
182
|
+
const obj = {};
|
|
183
|
+
if (Array.isArray(v)) {
|
|
184
|
+
v.forEach((x) => {
|
|
185
|
+
var _a;
|
|
186
|
+
if ((_a = x == null ? void 0 : x.children) == null ? void 0 : _a.length) {
|
|
187
|
+
obj[x.attrid] = dealList(x.children);
|
|
188
|
+
} else {
|
|
189
|
+
obj[x.attrid] = x.attrvalue;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return obj;
|
|
194
|
+
});
|
|
195
|
+
return dealList(children);
|
|
196
|
+
};
|
|
197
|
+
export {
|
|
198
|
+
disabledDate,
|
|
199
|
+
handleGetPlaceholder,
|
|
200
|
+
handleGetSingleAttrListObj,
|
|
201
|
+
handleSelectOptions,
|
|
202
|
+
handleSetFormItemInitialValue,
|
|
203
|
+
handleUrlOptions
|
|
204
|
+
};
|