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,16 @@
1
+ import { UploadFile } from 'antd/es/upload/interface';
2
+ import { Ijson } from '../index.d';
3
+ interface IMYUpload {
4
+ action?: string;
5
+ onChange?: (checkedValue: any[]) => void;
6
+ onRemove?: (file: UploadFile) => void;
7
+ item: Ijson;
8
+ relatedid?: string;
9
+ readonly?: boolean;
10
+ list?: UploadFile[];
11
+ uploadText?: string;
12
+ uploadType?: string;
13
+ relatedidKey: string;
14
+ }
15
+ declare const MyUpload: (props: IMYUpload) => import("react/jsx-runtime").JSX.Element;
16
+ export default MyUpload;
@@ -0,0 +1,103 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { PlusOutlined, UploadOutlined } from "@ant-design/icons";
3
+ import { App, Upload, Image, Button } from "antd";
4
+ import { useState, useEffect } from "react";
5
+ const customUpload = "myUpload-module_customUpload_5ec38";
6
+ const styles = {
7
+ customUpload
8
+ };
9
+ const getBase64 = (file) => new Promise((resolve, reject) => {
10
+ const reader = new FileReader();
11
+ reader.readAsDataURL(file);
12
+ reader.onload = () => resolve(reader.result);
13
+ reader.onerror = (error) => reject(error);
14
+ });
15
+ const MyUpload = (props) => {
16
+ const {
17
+ action,
18
+ item,
19
+ onChange,
20
+ readonly = false,
21
+ relatedid,
22
+ uploadText = "上传文件",
23
+ onRemove,
24
+ list = [],
25
+ uploadType,
26
+ relatedidKey
27
+ } = props;
28
+ const { message } = App.useApp();
29
+ const accept = (item == null ? void 0 : item["upload-accept"]) || "*";
30
+ const input = item == null ? void 0 : item["input"];
31
+ const size = item == null ? void 0 : item["upload-size"];
32
+ const maxCount = (item == null ? void 0 : item["upload-max-count"]) || 1;
33
+ const [listType, setListType] = useState(input === "image" ? "picture-card" : "text");
34
+ const [fileList, setFileList] = useState([]);
35
+ const [previewOpen, setPreviewOpen] = useState(false);
36
+ const [previewImage, setPreviewImage] = useState("");
37
+ useEffect(() => {
38
+ if (list && list.length) {
39
+ setFileList(list);
40
+ }
41
+ }, [list]);
42
+ const handlePreview = async (file) => {
43
+ if (uploadType !== "image")
44
+ return;
45
+ if (!file.url && !file.preview) {
46
+ file.preview = await getBase64(file.originFileObj);
47
+ }
48
+ setPreviewImage(file.url || file.preview);
49
+ setPreviewOpen(true);
50
+ };
51
+ const handleChange = ({ fileList: newFileList }) => {
52
+ setFileList(newFileList);
53
+ onChange && onChange(newFileList);
54
+ };
55
+ const handleBeforeUpload = (file) => {
56
+ if (!size)
57
+ return true;
58
+ const isLt = file.size / 1024 / 1024 < Number(size);
59
+ if (!isLt) {
60
+ message.error(`请上传不超过${size}MB的文件`);
61
+ }
62
+ return isLt;
63
+ };
64
+ const uploadButton = input === "image" ? /* @__PURE__ */ jsxs("button", { style: { border: 0, background: "none" }, type: "button", children: [
65
+ /* @__PURE__ */ jsx(PlusOutlined, {}),
66
+ /* @__PURE__ */ jsx("div", { style: { marginTop: 8 }, children: "Upload" })
67
+ ] }) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(UploadOutlined, {}), children: uploadText }) });
68
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
69
+ /* @__PURE__ */ jsx(
70
+ Upload,
71
+ {
72
+ action,
73
+ beforeUpload: handleBeforeUpload,
74
+ listType,
75
+ accept,
76
+ fileList,
77
+ onPreview: handlePreview,
78
+ data: { [relatedidKey]: relatedid },
79
+ maxCount,
80
+ onChange: handleChange,
81
+ onRemove,
82
+ disabled: readonly,
83
+ className: styles.customUpload,
84
+ children: fileList.length >= maxCount ? null : uploadButton
85
+ }
86
+ ),
87
+ previewImage && /* @__PURE__ */ jsx(
88
+ Image,
89
+ {
90
+ wrapperStyle: { display: "none" },
91
+ preview: {
92
+ visible: previewOpen,
93
+ onVisibleChange: (visible) => setPreviewOpen(visible),
94
+ afterOpenChange: (visible) => !visible && setPreviewImage("")
95
+ },
96
+ src: previewImage
97
+ }
98
+ )
99
+ ] });
100
+ };
101
+ export {
102
+ MyUpload as default
103
+ };
@@ -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,12 @@
1
+ /// <reference types="react" />
2
+ import { AxiosResponse } from 'axios';
3
+ interface RadioCardProps {
4
+ item: any;
5
+ readonly?: boolean;
6
+ value?: string;
7
+ onChange?: (value: any) => void;
8
+ style?: React.CSSProperties;
9
+ commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
10
+ }
11
+ declare const RadioCard: ({ item, readonly, value, onChange, style, commonRequestWidthParams }: RadioCardProps) => import("react/jsx-runtime").JSX.Element;
12
+ export default RadioCard;
@@ -0,0 +1,142 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { CheckOutlined } from "@ant-design/icons";
3
+ import { useState, useEffect } from "react";
4
+ import { Space } from "antd";
5
+ const RadioCard = ({ item, readonly, value, onChange, style, commonRequestWidthParams }) => {
6
+ const [cardData, setCardData] = useState([]);
7
+ const [loading, setLoading] = useState(false);
8
+ useEffect(() => {
9
+ const loadCardData = async () => {
10
+ var _a;
11
+ if (item.inputType === "url" && item["action-url"]) {
12
+ setLoading(true);
13
+ try {
14
+ const response = await commonRequestWidthParams(
15
+ {
16
+ PageName: "dns_relay",
17
+ Controlname: "CallActionUrl",
18
+ InterfaceType: ""
19
+ },
20
+ {
21
+ "action-url": item == null ? void 0 : item["action-url"]
22
+ }
23
+ );
24
+ if (((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.list) && Array.isArray(response.data.list)) {
25
+ setCardData(response.data.list);
26
+ } else if ((response == null ? void 0 : response.data) && Array.isArray(response.data)) {
27
+ setCardData(response.data);
28
+ } else if (Array.isArray(response == null ? void 0 : response.list)) {
29
+ setCardData(response.list);
30
+ } else if ((response == null ? void 0 : response.ReturnValue) === 1 && (response == null ? void 0 : response.data)) {
31
+ if (Array.isArray(response.data)) {
32
+ setCardData(response.data);
33
+ } else {
34
+ setCardData([response.data]);
35
+ }
36
+ }
37
+ } catch (error) {
38
+ } finally {
39
+ setLoading(false);
40
+ }
41
+ } else if (item.data && Array.isArray(item.data)) {
42
+ setCardData(item.data);
43
+ }
44
+ };
45
+ loadCardData();
46
+ }, [item.inputType, item["action-url"], item.data]);
47
+ const buildValue = (record) => {
48
+ return JSON.stringify(record);
49
+ };
50
+ const isSelected = (record) => {
51
+ const recordValue = buildValue(record);
52
+ return value === recordValue;
53
+ };
54
+ const handleCardClick = (record) => {
55
+ if (readonly)
56
+ return;
57
+ const recordValue = buildValue(record);
58
+ onChange && onChange(recordValue);
59
+ };
60
+ const imageWidth = item["card-image-width"] || 200;
61
+ const imageHeight = item["card-image-height"] || 100;
62
+ const imageField = item["card-image-field"];
63
+ const infoField = item["card-info-field"];
64
+ return /* @__PURE__ */ jsx("div", { style: { ...style }, children: loading ? /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "20px" }, children: "加载中..." }) : /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "0px" }, children: cardData.map((record, index) => {
65
+ const selected = isSelected(record);
66
+ return /* @__PURE__ */ jsxs(
67
+ "div",
68
+ {
69
+ onClick: () => handleCardClick(record),
70
+ style: {
71
+ flex: "1 1 auto",
72
+ width: `${imageWidth}px`,
73
+ padding: "12px",
74
+ cursor: readonly ? "not-allowed" : "pointer",
75
+ opacity: readonly ? 0.6 : 1,
76
+ transition: "all 0.3s"
77
+ },
78
+ children: [
79
+ record[imageField] && /* @__PURE__ */ jsx(
80
+ "img",
81
+ {
82
+ src: record.picurl,
83
+ alt: record[infoField] || "",
84
+ style: {
85
+ width: `${imageWidth}px`,
86
+ height: `${imageHeight}px`,
87
+ objectFit: "cover",
88
+ borderRadius: "4px",
89
+ marginBottom: "8px"
90
+ },
91
+ onError: (e) => {
92
+ e.currentTarget.style.display = "none";
93
+ }
94
+ }
95
+ ),
96
+ /* @__PURE__ */ jsx(
97
+ "div",
98
+ {
99
+ style: {
100
+ fontSize: "14px",
101
+ color: "#333333"
102
+ },
103
+ children: /* @__PURE__ */ jsxs(Space, { size: 6, children: [
104
+ /* @__PURE__ */ jsx(
105
+ "div",
106
+ {
107
+ style: {
108
+ width: "16px",
109
+ height: "16px",
110
+ borderRadius: "50%",
111
+ border: selected ? "none" : "1px solid #d9d9d9",
112
+ backgroundColor: selected ? "var(--color-primary)" : "transparent",
113
+ display: "flex",
114
+ alignItems: "center",
115
+ justifyContent: "center",
116
+ flexShrink: 0,
117
+ cursor: readonly ? "not-allowed" : "pointer"
118
+ },
119
+ children: selected && /* @__PURE__ */ jsx(
120
+ CheckOutlined,
121
+ {
122
+ style: {
123
+ fontSize: "12px",
124
+ color: "#fff"
125
+ }
126
+ }
127
+ )
128
+ }
129
+ ),
130
+ record[infoField] || ""
131
+ ] })
132
+ }
133
+ )
134
+ ]
135
+ },
136
+ index
137
+ );
138
+ }) }) });
139
+ };
140
+ export {
141
+ RadioCard as default
142
+ };
@@ -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
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { App, Select, Table, Modal } from "antd";
3
+ import { useState, useEffect } from "react";
4
+ function SelectModel(props) {
5
+ const { item, disabled, style, commonRequestWidthParams, CustomModalComponent } = props;
6
+ const { message } = App.useApp();
7
+ const mode = item.input;
8
+ const [value, setValue] = useState(props.value);
9
+ const [modalVisible, setModalVisible] = useState(false);
10
+ const [selectedRowKeys, setSelectedRowKeys] = useState([]);
11
+ const [selectedRecords, setSelectedRecords] = useState([]);
12
+ const [loading, setLoading] = useState(false);
13
+ const [params, setParams] = useState({
14
+ PageNum: 1,
15
+ PageSize: 6
16
+ });
17
+ const [dataSource, setDataSource] = useState([]);
18
+ const [total, setTotal] = useState(0);
19
+ const columns = buildColumns();
20
+ useEffect(() => {
21
+ if (!modalVisible) {
22
+ return;
23
+ }
24
+ getData();
25
+ }, [modalVisible, params]);
26
+ const onSelectChange = (keys, selectedRows) => {
27
+ setSelectedRowKeys(keys);
28
+ setSelectedRecords(selectedRows);
29
+ };
30
+ const getData = async () => {
31
+ var _a;
32
+ if (item.inputType === "url" && (item == null ? void 0 : item["action-url"])) {
33
+ setLoading(true);
34
+ try {
35
+ const response = await commonRequestWidthParams(
36
+ {
37
+ PageName: "dns_relay",
38
+ Controlname: "CallActionUrl",
39
+ InterfaceType: ""
40
+ },
41
+ {
42
+ "action-url": item == null ? void 0 : item["action-url"],
43
+ ...params
44
+ }
45
+ );
46
+ if ((response == null ? void 0 : response.ReturnValue) === 0) {
47
+ message.error(response.msg);
48
+ setLoading(false);
49
+ return;
50
+ }
51
+ const data = response == null ? void 0 : response.data;
52
+ const tempData = (_a = data == null ? void 0 : data.list) == null ? void 0 : _a.map((item2, index) => {
53
+ const _rowKey = (params.PageNum - 1) * params.PageSize + index;
54
+ return {
55
+ ...item2,
56
+ _rowKey
57
+ };
58
+ });
59
+ const tempSelectedRecords = (tempData == null ? void 0 : tempData.filter((item2) => selectedRowKeys.includes(item2._rowKey))) || [];
60
+ setSelectedRecords(tempSelectedRecords);
61
+ setDataSource([...tempData || []]);
62
+ setTotal((data == null ? void 0 : data.number) || 0);
63
+ setLoading(false);
64
+ } catch (error) {
65
+ setLoading(false);
66
+ message.error(error.msg || "参数错误");
67
+ }
68
+ return;
69
+ }
70
+ message.error("请配置action-url");
71
+ };
72
+ const openModal = () => {
73
+ var _a, _b;
74
+ if (disabled) {
75
+ return;
76
+ }
77
+ if (value) {
78
+ const keyFieldList = ((_a = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a.list) ?? [];
79
+ const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) ?? "-";
80
+ if (!keyFieldList.length) {
81
+ message.error("请配置key-field");
82
+ return;
83
+ }
84
+ switch (mode) {
85
+ case "modal-select":
86
+ const id = value == null ? void 0 : value.split("-");
87
+ const index = dataSource == null ? void 0 : dataSource.findIndex((item2) => id.includes((item2 == null ? void 0 : item2.typeid) || (item2 == null ? void 0 : item2.instanceid)));
88
+ setSelectedRowKeys([index]);
89
+ break;
90
+ case "modal-mult-select":
91
+ const values = value == null ? void 0 : value.split(",");
92
+ const tempKeys = values == null ? void 0 : values.map((item2) => {
93
+ var _a2;
94
+ const id2 = (_a2 = item2.split(delimiter)) == null ? void 0 : _a2[0];
95
+ return dataSource == null ? void 0 : dataSource.findIndex((item3) => id2.includes((item3 == null ? void 0 : item3.typeid) || (item3 == null ? void 0 : item3.instanceid)));
96
+ });
97
+ setSelectedRowKeys(tempKeys);
98
+ break;
99
+ }
100
+ }
101
+ setModalVisible(true);
102
+ };
103
+ const handleOk = async () => {
104
+ try {
105
+ const value2 = await buildValueFromSelectedRows(selectedRecords, item);
106
+ setValue(value2);
107
+ props.onSure(value2);
108
+ setModalVisible(false);
109
+ } catch (error) {
110
+ message.error(error.msg || "参数错误");
111
+ }
112
+ };
113
+ const handleCancel = () => {
114
+ setParams({
115
+ ...params,
116
+ PageNum: 1
117
+ });
118
+ setModalVisible(false);
119
+ };
120
+ function buildColumns() {
121
+ const modalFieldList = item["modal-field-list"];
122
+ let columns2 = [];
123
+ for (let fieldName in modalFieldList) {
124
+ let title = modalFieldList[fieldName];
125
+ const column = { dataIndex: fieldName, title };
126
+ columns2 = [...columns2, column];
127
+ }
128
+ return columns2;
129
+ }
130
+ const onPageChange = (pageNum) => {
131
+ setParams({
132
+ ...params,
133
+ PageNum: pageNum
134
+ });
135
+ };
136
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
137
+ /* @__PURE__ */ jsx(
138
+ Select,
139
+ {
140
+ placeholder: (item == null ? void 0 : item["default-prompt"]) || "请选择",
141
+ onClick: openModal,
142
+ value,
143
+ open: false,
144
+ disabled,
145
+ style
146
+ }
147
+ ),
148
+ CustomModalComponent && /* @__PURE__ */ jsx(
149
+ CustomModalComponent,
150
+ {
151
+ title: item["modal-caption"] || "",
152
+ open: modalVisible,
153
+ onOk: handleOk,
154
+ onCancel: handleCancel,
155
+ modalStyle: { width: item["modal-width"] ?? 600, minHeight: item["modal-height"] ?? 400 },
156
+ children: /* @__PURE__ */ jsx(
157
+ Table,
158
+ {
159
+ columns,
160
+ loading,
161
+ dataSource,
162
+ rowKey: (record) => record._rowKey,
163
+ scroll: { y: "calc(80vh - 300px)" },
164
+ rowSelection: {
165
+ type: mode === "modal-select" ? "radio" : "checkbox",
166
+ selectedRowKeys,
167
+ onChange: onSelectChange
168
+ },
169
+ pagination: {
170
+ total,
171
+ current: params.PageNum,
172
+ pageSize: params.PageSize,
173
+ onChange: onPageChange
174
+ }
175
+ }
176
+ )
177
+ }
178
+ ) || /* @__PURE__ */ jsx(
179
+ Modal,
180
+ {
181
+ title: item["modal-caption"],
182
+ open: modalVisible,
183
+ onOk: handleOk,
184
+ onCancel: handleCancel,
185
+ width: item["modal-width"] ?? 600,
186
+ okButtonProps: { disabled: selectedRowKeys.length === 0 },
187
+ children: /* @__PURE__ */ jsx(
188
+ Table,
189
+ {
190
+ columns,
191
+ loading,
192
+ dataSource,
193
+ rowKey: (record) => record._rowKey,
194
+ rowSelection: {
195
+ type: mode === "modal-select" ? "radio" : "checkbox",
196
+ selectedRowKeys,
197
+ onChange: onSelectChange
198
+ },
199
+ pagination: {
200
+ total,
201
+ current: params.PageNum,
202
+ pageSize: params.PageSize,
203
+ onChange: onPageChange
204
+ }
205
+ }
206
+ )
207
+ }
208
+ )
209
+ ] });
210
+ }
211
+ function buildValueFromSelectedRows(selectedRows, attributeEnrollFormat) {
212
+ return new Promise((resolve, reject) => {
213
+ try {
214
+ var keyfields = attributeEnrollFormat["key-field"];
215
+ if (!keyfields) {
216
+ reject({ msg: "请配置key-field" });
217
+ return;
218
+ }
219
+ var fields = (keyfields == null ? void 0 : keyfields.list) ?? [];
220
+ let result = selectedRows.map((item) => {
221
+ let itemResult = fields.map((field) => {
222
+ return item[field];
223
+ }).join((keyfields == null ? void 0 : keyfields.delimiter) || "-");
224
+ return itemResult;
225
+ }).join(",");
226
+ resolve(result);
227
+ } catch (error) {
228
+ reject({ msg: "key-field参数配置错误" });
229
+ }
230
+ });
231
+ }
232
+ export {
233
+ buildValueFromSelectedRows,
234
+ SelectModel as default
235
+ };
@@ -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;