szld-libs 0.2.99 → 0.3.2

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.
Files changed (94) hide show
  1. package/dist/style.css +1 -1
  2. package/dist/szld-components.es.js +32023 -20148
  3. package/dist/szld-components.umd.js +72 -60
  4. package/es/components/DynamicForm/index.js +3 -2
  5. package/es/components/DynamicForm/selectModelBackfillFormItem/index.js +8 -7
  6. package/es/components/DynamicFormMobile/func.d.ts +35 -0
  7. package/es/components/DynamicFormMobile/func.js +204 -0
  8. package/es/components/DynamicFormMobile/index.d.ts +116 -0
  9. package/es/components/DynamicFormMobile/index.js +134 -0
  10. package/es/components/DynamicFormMobile/myCascader/index.d.ts +17 -0
  11. package/es/components/DynamicFormMobile/myCascader/index.js +196 -0
  12. package/es/components/DynamicFormMobile/myCascader/vite.svg +1 -0
  13. package/es/components/DynamicFormMobile/myCheckbox/index.d.ts +19 -0
  14. package/es/components/DynamicFormMobile/myCheckbox/index.js +109 -0
  15. package/es/components/DynamicFormMobile/myCheckbox/vite.svg +1 -0
  16. package/es/components/DynamicFormMobile/myRadio/index.d.ts +20 -0
  17. package/es/components/DynamicFormMobile/myRadio/index.js +107 -0
  18. package/es/components/DynamicFormMobile/myRadio/vite.svg +1 -0
  19. package/es/components/DynamicFormMobile/mySelect/index.css +31 -0
  20. package/es/components/DynamicFormMobile/mySelect/index.d.ts +16 -0
  21. package/es/components/DynamicFormMobile/mySelect/index.js +147 -0
  22. package/es/components/DynamicFormMobile/mySelect/vite.svg +1 -0
  23. package/es/components/DynamicFormMobile/myUpload/index.css +3 -0
  24. package/es/components/DynamicFormMobile/myUpload/index.d.ts +16 -0
  25. package/es/components/DynamicFormMobile/myUpload/index.js +103 -0
  26. package/es/components/DynamicFormMobile/myUpload/vite.svg +1 -0
  27. package/es/components/DynamicFormMobile/radioCard/index.d.ts +12 -0
  28. package/es/components/DynamicFormMobile/radioCard/index.js +142 -0
  29. package/es/components/DynamicFormMobile/radioCard/vite.svg +1 -0
  30. package/es/components/DynamicFormMobile/selectModel/index.d.ts +22 -0
  31. package/es/components/DynamicFormMobile/selectModel/index.js +235 -0
  32. package/es/components/DynamicFormMobile/selectModel/vite.svg +1 -0
  33. package/es/components/DynamicFormMobile/selectModelBackfillFormItem/index.d.ts +27 -0
  34. package/es/components/DynamicFormMobile/selectModelBackfillFormItem/index.js +242 -0
  35. package/es/components/DynamicFormMobile/selectModelBackfillFormItem/vite.svg +1 -0
  36. package/es/components/DynamicFormMobile/useDynamicForm.d.ts +43 -0
  37. package/es/components/DynamicFormMobile/useDynamicForm.js +772 -0
  38. package/es/components/DynamicFormMobile/vite.svg +1 -0
  39. package/es/index.css +1 -0
  40. package/es/index.d.ts +1 -1
  41. package/es/index.js +35 -29
  42. package/es/main.d.ts +2 -1
  43. package/es/main.js +22 -20
  44. package/es/mock/index.js +20 -59
  45. package/es/services/index.js +3 -5
  46. package/es/services/request.js +2 -2
  47. package/es/utils/method.d.ts +6 -1
  48. package/es/utils/method.js +60 -34
  49. package/lib/components/DynamicForm/index.js +3 -2
  50. package/lib/components/DynamicForm/selectModelBackfillFormItem/index.js +8 -7
  51. package/lib/components/DynamicFormMobile/func.d.ts +35 -0
  52. package/lib/components/DynamicFormMobile/func.js +204 -0
  53. package/lib/components/DynamicFormMobile/index.d.ts +116 -0
  54. package/lib/components/DynamicFormMobile/index.js +133 -0
  55. package/lib/components/DynamicFormMobile/myCascader/index.d.ts +17 -0
  56. package/lib/components/DynamicFormMobile/myCascader/index.js +195 -0
  57. package/lib/components/DynamicFormMobile/myCascader/vite.svg +1 -0
  58. package/lib/components/DynamicFormMobile/myCheckbox/index.d.ts +19 -0
  59. package/lib/components/DynamicFormMobile/myCheckbox/index.js +108 -0
  60. package/lib/components/DynamicFormMobile/myCheckbox/vite.svg +1 -0
  61. package/lib/components/DynamicFormMobile/myRadio/index.d.ts +20 -0
  62. package/lib/components/DynamicFormMobile/myRadio/index.js +106 -0
  63. package/lib/components/DynamicFormMobile/myRadio/vite.svg +1 -0
  64. package/lib/components/DynamicFormMobile/mySelect/index.css +31 -0
  65. package/lib/components/DynamicFormMobile/mySelect/index.d.ts +16 -0
  66. package/lib/components/DynamicFormMobile/mySelect/index.js +146 -0
  67. package/lib/components/DynamicFormMobile/mySelect/vite.svg +1 -0
  68. package/lib/components/DynamicFormMobile/myUpload/index.css +3 -0
  69. package/lib/components/DynamicFormMobile/myUpload/index.d.ts +16 -0
  70. package/lib/components/DynamicFormMobile/myUpload/index.js +102 -0
  71. package/lib/components/DynamicFormMobile/myUpload/vite.svg +1 -0
  72. package/lib/components/DynamicFormMobile/radioCard/index.d.ts +12 -0
  73. package/lib/components/DynamicFormMobile/radioCard/index.js +141 -0
  74. package/lib/components/DynamicFormMobile/radioCard/vite.svg +1 -0
  75. package/lib/components/DynamicFormMobile/selectModel/index.d.ts +22 -0
  76. package/lib/components/DynamicFormMobile/selectModel/index.js +235 -0
  77. package/lib/components/DynamicFormMobile/selectModel/vite.svg +1 -0
  78. package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/index.d.ts +27 -0
  79. package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/index.js +242 -0
  80. package/lib/components/DynamicFormMobile/selectModelBackfillFormItem/vite.svg +1 -0
  81. package/lib/components/DynamicFormMobile/useDynamicForm.d.ts +43 -0
  82. package/lib/components/DynamicFormMobile/useDynamicForm.js +771 -0
  83. package/lib/components/DynamicFormMobile/vite.svg +1 -0
  84. package/lib/index.css +1 -0
  85. package/lib/index.d.ts +1 -1
  86. package/lib/index.js +35 -29
  87. package/lib/main.d.ts +2 -1
  88. package/lib/main.js +2 -0
  89. package/lib/mock/index.js +20 -59
  90. package/lib/services/index.js +3 -5
  91. package/lib/services/request.js +2 -2
  92. package/lib/utils/method.d.ts +6 -1
  93. package/lib/utils/method.js +60 -34
  94. package/package.json +1 -1
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const icons = require("@ant-design/icons");
4
+ const react = require("react");
5
+ const antd = require("antd");
6
+ const RadioCard = ({ item, readonly, value, onChange, style, commonRequestWidthParams }) => {
7
+ const [cardData, setCardData] = react.useState([]);
8
+ const [loading, setLoading] = react.useState(false);
9
+ react.useEffect(() => {
10
+ const loadCardData = async () => {
11
+ var _a;
12
+ if (item.inputType === "url" && item["action-url"]) {
13
+ setLoading(true);
14
+ try {
15
+ const response = await commonRequestWidthParams(
16
+ {
17
+ PageName: "dns_relay",
18
+ Controlname: "CallActionUrl",
19
+ InterfaceType: ""
20
+ },
21
+ {
22
+ "action-url": item == null ? void 0 : item["action-url"]
23
+ }
24
+ );
25
+ if (((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.list) && Array.isArray(response.data.list)) {
26
+ setCardData(response.data.list);
27
+ } else if ((response == null ? void 0 : response.data) && Array.isArray(response.data)) {
28
+ setCardData(response.data);
29
+ } else if (Array.isArray(response == null ? void 0 : response.list)) {
30
+ setCardData(response.list);
31
+ } else if ((response == null ? void 0 : response.ReturnValue) === 1 && (response == null ? void 0 : response.data)) {
32
+ if (Array.isArray(response.data)) {
33
+ setCardData(response.data);
34
+ } else {
35
+ setCardData([response.data]);
36
+ }
37
+ }
38
+ } catch (error) {
39
+ } finally {
40
+ setLoading(false);
41
+ }
42
+ } else if (item.data && Array.isArray(item.data)) {
43
+ setCardData(item.data);
44
+ }
45
+ };
46
+ loadCardData();
47
+ }, [item.inputType, item["action-url"], item.data]);
48
+ const buildValue = (record) => {
49
+ return JSON.stringify(record);
50
+ };
51
+ const isSelected = (record) => {
52
+ const recordValue = buildValue(record);
53
+ return value === recordValue;
54
+ };
55
+ const handleCardClick = (record) => {
56
+ if (readonly)
57
+ return;
58
+ const recordValue = buildValue(record);
59
+ onChange && onChange(recordValue);
60
+ };
61
+ const imageWidth = item["card-image-width"] || 200;
62
+ const imageHeight = item["card-image-height"] || 100;
63
+ const imageField = item["card-image-field"];
64
+ const infoField = item["card-info-field"];
65
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...style }, children: loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", padding: "20px" }, children: "加载中..." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "0px" }, children: cardData.map((record, index) => {
66
+ const selected = isSelected(record);
67
+ return /* @__PURE__ */ jsxRuntime.jsxs(
68
+ "div",
69
+ {
70
+ onClick: () => handleCardClick(record),
71
+ style: {
72
+ flex: "1 1 auto",
73
+ width: `${imageWidth}px`,
74
+ padding: "12px",
75
+ cursor: readonly ? "not-allowed" : "pointer",
76
+ opacity: readonly ? 0.6 : 1,
77
+ transition: "all 0.3s"
78
+ },
79
+ children: [
80
+ record[imageField] && /* @__PURE__ */ jsxRuntime.jsx(
81
+ "img",
82
+ {
83
+ src: record.picurl,
84
+ alt: record[infoField] || "",
85
+ style: {
86
+ width: `${imageWidth}px`,
87
+ height: `${imageHeight}px`,
88
+ objectFit: "cover",
89
+ borderRadius: "4px",
90
+ marginBottom: "8px"
91
+ },
92
+ onError: (e) => {
93
+ e.currentTarget.style.display = "none";
94
+ }
95
+ }
96
+ ),
97
+ /* @__PURE__ */ jsxRuntime.jsx(
98
+ "div",
99
+ {
100
+ style: {
101
+ fontSize: "14px",
102
+ color: "#333333"
103
+ },
104
+ children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Space, { size: 6, children: [
105
+ /* @__PURE__ */ jsxRuntime.jsx(
106
+ "div",
107
+ {
108
+ style: {
109
+ width: "16px",
110
+ height: "16px",
111
+ borderRadius: "50%",
112
+ border: selected ? "none" : "1px solid #d9d9d9",
113
+ backgroundColor: selected ? "var(--color-primary)" : "transparent",
114
+ display: "flex",
115
+ alignItems: "center",
116
+ justifyContent: "center",
117
+ flexShrink: 0,
118
+ cursor: readonly ? "not-allowed" : "pointer"
119
+ },
120
+ children: selected && /* @__PURE__ */ jsxRuntime.jsx(
121
+ icons.CheckOutlined,
122
+ {
123
+ style: {
124
+ fontSize: "12px",
125
+ color: "#fff"
126
+ }
127
+ }
128
+ )
129
+ }
130
+ ),
131
+ record[infoField] || ""
132
+ ] })
133
+ }
134
+ )
135
+ ]
136
+ },
137
+ index
138
+ );
139
+ }) }) });
140
+ };
141
+ module.exports = RadioCard;
@@ -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,22 @@
1
+ import React from 'react';
2
+ import { AxiosResponse } from 'axios';
3
+ import { Ijson } from '../index.d';
4
+ interface SelectModelProps {
5
+ item: Ijson;
6
+ onSure: (value: string) => void;
7
+ value: string;
8
+ disabled: boolean;
9
+ style?: React.CSSProperties;
10
+ commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
11
+ commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
12
+ CustomModalComponent?: React.FC<ICustomModal>;
13
+ }
14
+ declare function SelectModel(props: SelectModelProps): import("react/jsx-runtime").JSX.Element;
15
+ /**
16
+ *
17
+ * @param selectedRows 选中的行数据
18
+ * @param attributeEnrollFormat 配置信息
19
+ * @returns 构建后的字符串
20
+ */
21
+ export declare function buildValueFromSelectedRows(selectedRows: any[], attributeEnrollFormat: Ijson): Promise<string>;
22
+ export default SelectModel;
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const antd = require("antd");
5
+ const react = require("react");
6
+ function SelectModel(props) {
7
+ const { item, disabled, style, commonRequestWidthParams, CustomModalComponent } = props;
8
+ const { message } = antd.App.useApp();
9
+ const mode = item.input;
10
+ const [value, setValue] = react.useState(props.value);
11
+ const [modalVisible, setModalVisible] = react.useState(false);
12
+ const [selectedRowKeys, setSelectedRowKeys] = react.useState([]);
13
+ const [selectedRecords, setSelectedRecords] = react.useState([]);
14
+ const [loading, setLoading] = react.useState(false);
15
+ const [params, setParams] = react.useState({
16
+ PageNum: 1,
17
+ PageSize: 6
18
+ });
19
+ const [dataSource, setDataSource] = react.useState([]);
20
+ const [total, setTotal] = react.useState(0);
21
+ const columns = buildColumns();
22
+ react.useEffect(() => {
23
+ if (!modalVisible) {
24
+ return;
25
+ }
26
+ getData();
27
+ }, [modalVisible, params]);
28
+ const onSelectChange = (keys, selectedRows) => {
29
+ setSelectedRowKeys(keys);
30
+ setSelectedRecords(selectedRows);
31
+ };
32
+ const getData = async () => {
33
+ var _a;
34
+ if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
35
+ setLoading(true);
36
+ try {
37
+ const response = await commonRequestWidthParams(
38
+ {
39
+ PageName: "dns_relay",
40
+ Controlname: "CallActionUrl",
41
+ InterfaceType: ""
42
+ },
43
+ {
44
+ "action-url": item == null ? void 0 : item["action-url"],
45
+ ...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, _b;
76
+ if (disabled) {
77
+ return;
78
+ }
79
+ if (value) {
80
+ const keyFieldList = ((_a = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a.list) ?? [];
81
+ const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) ?? "-";
82
+ if (!keyFieldList.length) {
83
+ message.error("请配置key-field");
84
+ return;
85
+ }
86
+ switch (mode) {
87
+ case "modal-select":
88
+ const id = value == null ? void 0 : value.split("-");
89
+ const index = dataSource == null ? void 0 : dataSource.findIndex((item2) => id.includes((item2 == null ? void 0 : item2.typeid) || (item2 == null ? void 0 : item2.instanceid)));
90
+ setSelectedRowKeys([index]);
91
+ break;
92
+ case "modal-mult-select":
93
+ const values = value == null ? void 0 : value.split(",");
94
+ const tempKeys = values == null ? void 0 : values.map((item2) => {
95
+ var _a2;
96
+ const id2 = (_a2 = item2.split(delimiter)) == null ? void 0 : _a2[0];
97
+ return dataSource == null ? void 0 : dataSource.findIndex((item3) => id2.includes((item3 == null ? void 0 : item3.typeid) || (item3 == null ? void 0 : item3.instanceid)));
98
+ });
99
+ setSelectedRowKeys(tempKeys);
100
+ break;
101
+ }
102
+ }
103
+ setModalVisible(true);
104
+ };
105
+ const handleOk = async () => {
106
+ try {
107
+ const value2 = await buildValueFromSelectedRows(selectedRecords, item);
108
+ setValue(value2);
109
+ props.onSure(value2);
110
+ setModalVisible(false);
111
+ } catch (error) {
112
+ message.error(error.msg || "参数错误");
113
+ }
114
+ };
115
+ const handleCancel = () => {
116
+ setParams({
117
+ ...params,
118
+ PageNum: 1
119
+ });
120
+ setModalVisible(false);
121
+ };
122
+ function buildColumns() {
123
+ const modalFieldList = item["modal-field-list"];
124
+ let columns2 = [];
125
+ for (let fieldName in modalFieldList) {
126
+ let title = modalFieldList[fieldName];
127
+ const column = { dataIndex: fieldName, title };
128
+ columns2 = [...columns2, column];
129
+ }
130
+ return columns2;
131
+ }
132
+ const onPageChange = (pageNum) => {
133
+ setParams({
134
+ ...params,
135
+ PageNum: pageNum
136
+ });
137
+ };
138
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
139
+ /* @__PURE__ */ jsxRuntime.jsx(
140
+ antd.Select,
141
+ {
142
+ placeholder: (item == null ? void 0 : item["default-prompt"]) || "请选择",
143
+ onClick: openModal,
144
+ value,
145
+ open: false,
146
+ disabled,
147
+ style
148
+ }
149
+ ),
150
+ CustomModalComponent && /* @__PURE__ */ jsxRuntime.jsx(
151
+ CustomModalComponent,
152
+ {
153
+ title: item["modal-caption"] || "",
154
+ open: modalVisible,
155
+ onOk: handleOk,
156
+ onCancel: handleCancel,
157
+ modalStyle: { width: item["modal-width"] ?? 600, minHeight: item["modal-height"] ?? 400 },
158
+ children: /* @__PURE__ */ jsxRuntime.jsx(
159
+ antd.Table,
160
+ {
161
+ columns,
162
+ loading,
163
+ dataSource,
164
+ rowKey: (record) => record._rowKey,
165
+ scroll: { y: "calc(80vh - 300px)" },
166
+ rowSelection: {
167
+ type: mode === "modal-select" ? "radio" : "checkbox",
168
+ selectedRowKeys,
169
+ onChange: onSelectChange
170
+ },
171
+ pagination: {
172
+ total,
173
+ current: params.PageNum,
174
+ pageSize: params.PageSize,
175
+ onChange: onPageChange
176
+ }
177
+ }
178
+ )
179
+ }
180
+ ) || /* @__PURE__ */ jsxRuntime.jsx(
181
+ antd.Modal,
182
+ {
183
+ title: item["modal-caption"],
184
+ open: modalVisible,
185
+ onOk: handleOk,
186
+ onCancel: handleCancel,
187
+ width: item["modal-width"] ?? 600,
188
+ okButtonProps: { disabled: selectedRowKeys.length === 0 },
189
+ children: /* @__PURE__ */ jsxRuntime.jsx(
190
+ antd.Table,
191
+ {
192
+ columns,
193
+ loading,
194
+ dataSource,
195
+ rowKey: (record) => record._rowKey,
196
+ rowSelection: {
197
+ type: mode === "modal-select" ? "radio" : "checkbox",
198
+ selectedRowKeys,
199
+ onChange: onSelectChange
200
+ },
201
+ pagination: {
202
+ total,
203
+ current: params.PageNum,
204
+ pageSize: params.PageSize,
205
+ onChange: onPageChange
206
+ }
207
+ }
208
+ )
209
+ }
210
+ )
211
+ ] });
212
+ }
213
+ function buildValueFromSelectedRows(selectedRows, attributeEnrollFormat) {
214
+ return new Promise((resolve, reject) => {
215
+ try {
216
+ var keyfields = attributeEnrollFormat["key-field"];
217
+ if (!keyfields) {
218
+ reject({ msg: "请配置key-field" });
219
+ return;
220
+ }
221
+ var fields = (keyfields == null ? void 0 : keyfields.list) ?? [];
222
+ let result = selectedRows.map((item) => {
223
+ let itemResult = fields.map((field) => {
224
+ return item[field];
225
+ }).join((keyfields == null ? void 0 : keyfields.delimiter) || "-");
226
+ return itemResult;
227
+ }).join(",");
228
+ resolve(result);
229
+ } catch (error) {
230
+ reject({ msg: "key-field参数配置错误" });
231
+ }
232
+ });
233
+ }
234
+ exports.buildValueFromSelectedRows = buildValueFromSelectedRows;
235
+ exports.default = SelectModel;
@@ -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,27 @@
1
+ import React from 'react';
2
+ import { AxiosResponse } from 'axios';
3
+ import { Ijson } from '../index.d';
4
+ import { FormInstance } from 'react-vant';
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
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const antd = require("antd");
5
+ const react = require("react");
6
+ function SelectModel(props) {
7
+ const { item, disabled, style, commonRequestWidthParams, CustomModalComponent, attrid, form } = props;
8
+ const attrValue = antd.Form.useWatch(attrid, form);
9
+ const { message } = antd.App.useApp();
10
+ const mode = item.input;
11
+ const [value, setValue] = react.useState(props.value);
12
+ const [modalVisible, setModalVisible] = react.useState(false);
13
+ const [selectedRowKeys, setSelectedRowKeys] = react.useState([]);
14
+ const [selectedRecords, setSelectedRecords] = react.useState([]);
15
+ const [loading, setLoading] = react.useState(false);
16
+ const [params, setParams] = react.useState({
17
+ PageNum: 1,
18
+ PageSize: 6
19
+ });
20
+ const [dataSource, setDataSource] = react.useState([]);
21
+ const [total, setTotal] = react.useState(0);
22
+ const columns = buildColumns();
23
+ react.useEffect(() => {
24
+ if (!modalVisible) {
25
+ return;
26
+ }
27
+ getData();
28
+ }, [modalVisible, params]);
29
+ const onSelectChange = (keys, selectedRows) => {
30
+ setSelectedRowKeys(keys);
31
+ setSelectedRecords(selectedRows);
32
+ };
33
+ const getData = async () => {
34
+ var _a;
35
+ if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
36
+ setLoading(true);
37
+ try {
38
+ const response = await commonRequestWidthParams(
39
+ {
40
+ PageName: "dns_relay",
41
+ Controlname: "CallActionUrl",
42
+ InterfaceType: ""
43
+ },
44
+ {
45
+ "action-url": item == null ? void 0 : item["action-url"],
46
+ ...params,
47
+ ...(item == null ? void 0 : item["action-url-extra-params"]) || {}
48
+ }
49
+ );
50
+ if ((response == null ? void 0 : response.ReturnValue) === 0) {
51
+ message.error(response.msg);
52
+ setLoading(false);
53
+ return;
54
+ }
55
+ const data = response == null ? void 0 : response.data;
56
+ const tempData = (_a = data == null ? void 0 : data.list) == null ? void 0 : _a.map((item2, index) => {
57
+ const _rowKey = (params.PageNum - 1) * params.PageSize + index;
58
+ return {
59
+ ...item2,
60
+ _rowKey
61
+ };
62
+ });
63
+ const tempSelectedRecords = (tempData == null ? void 0 : tempData.filter((item2) => selectedRowKeys.includes(item2._rowKey))) || [];
64
+ setSelectedRecords(tempSelectedRecords);
65
+ setDataSource([...tempData || []]);
66
+ setTotal((data == null ? void 0 : data.number) || 0);
67
+ setLoading(false);
68
+ } catch (error) {
69
+ setLoading(false);
70
+ message.error(error.msg || "参数错误");
71
+ }
72
+ return;
73
+ }
74
+ message.error("请配置action-url");
75
+ };
76
+ const openModal = () => {
77
+ var _a;
78
+ if (disabled) {
79
+ return;
80
+ }
81
+ if (value) {
82
+ const keyField = item == null ? void 0 : item["key-field"];
83
+ const el = keyField == null ? void 0 : keyField[attrid];
84
+ const { delimiter = "-", list = [] } = el || {};
85
+ if (!keyField) {
86
+ message.error("请配置key-field");
87
+ return;
88
+ }
89
+ switch (mode) {
90
+ case "mul-field-modal-select":
91
+ const id = (_a = value == null ? void 0 : value.split(delimiter)) == null ? void 0 : _a[0];
92
+ const index = dataSource == null ? void 0 : dataSource.findIndex((item2) => Object.values(item2).includes(id));
93
+ setSelectedRowKeys([index]);
94
+ break;
95
+ case "modal-mult-select":
96
+ const values = value == null ? void 0 : value.split(",");
97
+ const tempKeys = values == null ? void 0 : values.map((item2) => {
98
+ var _a2;
99
+ const id2 = (_a2 = item2.split(delimiter)) == null ? void 0 : _a2[0];
100
+ return dataSource == null ? void 0 : dataSource.findIndex((item3) => id2.includes((item3 == null ? void 0 : item3.typeid) || (item3 == null ? void 0 : item3.instanceid)));
101
+ });
102
+ setSelectedRowKeys(tempKeys);
103
+ break;
104
+ }
105
+ }
106
+ setModalVisible(true);
107
+ };
108
+ const handleOk = async () => {
109
+ try {
110
+ const value2 = await buildValueFromSelectedRows(selectedRecords, item);
111
+ setValue((value2 == null ? void 0 : value2[attrid]) || "");
112
+ props.onSure(value2);
113
+ setModalVisible(false);
114
+ } catch (error) {
115
+ message.error(error.msg || "参数错误");
116
+ }
117
+ };
118
+ const handleCancel = () => {
119
+ setParams({
120
+ ...params,
121
+ PageNum: 1
122
+ });
123
+ setModalVisible(false);
124
+ };
125
+ function buildColumns() {
126
+ const modalFieldList = item["modal-field-list"];
127
+ let columns2 = [];
128
+ for (let fieldName in modalFieldList) {
129
+ let title = modalFieldList[fieldName];
130
+ const column = { dataIndex: fieldName, title };
131
+ columns2 = [...columns2, column];
132
+ }
133
+ return columns2;
134
+ }
135
+ const onPageChange = (pageNum) => {
136
+ setParams({
137
+ ...params,
138
+ PageNum: pageNum
139
+ });
140
+ };
141
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
142
+ /* @__PURE__ */ jsxRuntime.jsx(
143
+ antd.Select,
144
+ {
145
+ placeholder: (item == null ? void 0 : item["default-prompt"]) || "请选择",
146
+ onClick: openModal,
147
+ open: false,
148
+ value: attrValue,
149
+ disabled,
150
+ style
151
+ }
152
+ ),
153
+ CustomModalComponent && /* @__PURE__ */ jsxRuntime.jsx(
154
+ CustomModalComponent,
155
+ {
156
+ title: item["modal-caption"] || "",
157
+ open: modalVisible,
158
+ onOk: handleOk,
159
+ onCancel: handleCancel,
160
+ modalStyle: { width: item["modal-width"] ?? 600, minHeight: item["modal-height"] ?? 400 },
161
+ children: /* @__PURE__ */ jsxRuntime.jsx(
162
+ antd.Table,
163
+ {
164
+ columns,
165
+ loading,
166
+ dataSource,
167
+ rowKey: (record) => record._rowKey,
168
+ scroll: { y: "calc(80vh - 300px)" },
169
+ rowSelection: {
170
+ type: mode === "mul-field-modal-select" ? "radio" : "checkbox",
171
+ selectedRowKeys,
172
+ onChange: onSelectChange
173
+ },
174
+ pagination: {
175
+ total,
176
+ current: params.PageNum,
177
+ pageSize: params.PageSize,
178
+ onChange: onPageChange
179
+ }
180
+ }
181
+ )
182
+ }
183
+ ) || /* @__PURE__ */ jsxRuntime.jsx(
184
+ antd.Modal,
185
+ {
186
+ title: item["modal-caption"],
187
+ open: modalVisible,
188
+ onOk: handleOk,
189
+ onCancel: handleCancel,
190
+ width: item["modal-width"] ?? 600,
191
+ okButtonProps: { disabled: selectedRowKeys.length === 0 },
192
+ children: /* @__PURE__ */ jsxRuntime.jsx(
193
+ antd.Table,
194
+ {
195
+ columns,
196
+ loading,
197
+ dataSource,
198
+ rowKey: (record) => record._rowKey,
199
+ rowSelection: {
200
+ type: mode === "mul-field-modal-select" ? "radio" : "checkbox",
201
+ selectedRowKeys,
202
+ onChange: onSelectChange
203
+ },
204
+ pagination: {
205
+ total,
206
+ current: params.PageNum,
207
+ pageSize: params.PageSize,
208
+ onChange: onPageChange
209
+ }
210
+ }
211
+ )
212
+ }
213
+ )
214
+ ] });
215
+ }
216
+ function buildValueFromSelectedRows(selectedRows, attributeEnrollFormat) {
217
+ return new Promise((resolve, reject) => {
218
+ try {
219
+ var keyfields = attributeEnrollFormat["key-field"];
220
+ if (!keyfields) {
221
+ reject({ msg: "请配置key-field" });
222
+ return;
223
+ }
224
+ let res = {};
225
+ selectedRows.forEach((item) => {
226
+ for (let [key, value] of Object.entries(keyfields)) {
227
+ const list = (value == null ? void 0 : value.list) ?? [];
228
+ const delimiter = (value == null ? void 0 : value.delimiter) ?? "-";
229
+ const arr = list.map((v) => {
230
+ return item == null ? void 0 : item[v];
231
+ });
232
+ res[key] = arr.join(delimiter);
233
+ }
234
+ });
235
+ resolve(res);
236
+ } catch (error) {
237
+ reject({ msg: "key-field参数配置错误" });
238
+ }
239
+ });
240
+ }
241
+ exports.buildValueFromSelectedRows = buildValueFromSelectedRows;
242
+ exports.default = SelectModel;
@@ -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>