szld-libs 0.2.99 → 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 +32001 -20129
- package/dist/szld-components.umd.js +72 -60
- package/es/components/DynamicForm/index.js +3 -2
- package/es/components/DynamicForm/selectModelBackfillFormItem/index.js +8 -7
- 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 -29
- package/es/main.d.ts +2 -1
- package/es/main.js +22 -20
- package/es/mock/index.js +20 -59
- 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.js +3 -2
- package/lib/components/DynamicForm/selectModelBackfillFormItem/index.js +8 -7
- 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 -29
- package/lib/main.d.ts +2 -1
- package/lib/main.js +2 -0
- package/lib/mock/index.js +20 -59
- 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
|
@@ -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>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IformConfigItem, IformItemStyle } from './index.d';
|
|
3
|
+
import { AxiosResponse } from 'axios';
|
|
4
|
+
import { FormListFieldData, UploadFile } from 'antd';
|
|
5
|
+
import { FormInstance } from 'react-vant';
|
|
6
|
+
interface IDynamicFormProps {
|
|
7
|
+
commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
8
|
+
commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
|
|
9
|
+
uploadAction: (PageName?: string | undefined) => string;
|
|
10
|
+
formConfig?: IformConfigItem[];
|
|
11
|
+
setFormConfig?: (config: IformConfigItem[]) => void;
|
|
12
|
+
updateDelFileList: (file: UploadFile) => void;
|
|
13
|
+
interfaceTypeChildren?: string;
|
|
14
|
+
interfaceTypeDict: string;
|
|
15
|
+
interfaceTypeSysDict: string;
|
|
16
|
+
relatedidKey: string;
|
|
17
|
+
actionUrlKey: string;
|
|
18
|
+
actionUrlExtraParams: object;
|
|
19
|
+
CustomModalComponent?: React.FC<ICustomModal>;
|
|
20
|
+
setAttrList?: (config: IformConfigItem[]) => void;
|
|
21
|
+
hideAttrList?: string[];
|
|
22
|
+
}
|
|
23
|
+
type NestedFormListFieldData = FormListFieldData & {
|
|
24
|
+
parentName?: (string | number)[];
|
|
25
|
+
};
|
|
26
|
+
declare function useDynamicForm(props: IDynamicFormProps): {
|
|
27
|
+
handleRenderItem: ({ item, readonly, colNum, instructionShowMode, relatedid, form, defaultWidth, formItemStyle, radioAlign, isFormListItem, formListField, isShowLabel, }: {
|
|
28
|
+
item: IformConfigItem;
|
|
29
|
+
readonly: boolean;
|
|
30
|
+
colNum: number;
|
|
31
|
+
instructionShowMode?: "icon" | "flex" | undefined;
|
|
32
|
+
relatedid?: string | undefined;
|
|
33
|
+
form: FormInstance;
|
|
34
|
+
defaultWidth?: string | number | undefined;
|
|
35
|
+
formItemStyle: IformItemStyle[] | undefined;
|
|
36
|
+
radioAlign?: "horizontal" | "vertical" | undefined;
|
|
37
|
+
isFormListItem?: boolean | undefined;
|
|
38
|
+
formListField?: NestedFormListFieldData | undefined;
|
|
39
|
+
isShowLabel?: boolean | undefined;
|
|
40
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
41
|
+
handleSetFormItemInitialValue: (itemWithJson: IformConfigItem) => any;
|
|
42
|
+
};
|
|
43
|
+
export default useDynamicForm;
|