szld-libs 0.2.98 → 0.2.99

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.
@@ -0,0 +1,241 @@
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, _b;
78
+ if (disabled) {
79
+ return;
80
+ }
81
+ if (value) {
82
+ const keyFieldList = ((_a = item == null ? void 0 : item["key-field"]) == null ? void 0 : _a.list) ?? [];
83
+ const delimiter = ((_b = item == null ? void 0 : item["key-field"]) == null ? void 0 : _b.delimiter) ?? "-";
84
+ if (!keyFieldList.length) {
85
+ message.error("请配置key-field");
86
+ return;
87
+ }
88
+ switch (mode) {
89
+ case "modal-select":
90
+ const id = value == null ? void 0 : value.split("-");
91
+ const index = dataSource == null ? void 0 : dataSource.findIndex((item2) => id.includes((item2 == null ? void 0 : item2.typeid) || (item2 == null ? void 0 : item2.instanceid)));
92
+ setSelectedRowKeys([index]);
93
+ break;
94
+ case "modal-mult-select":
95
+ const values = value == null ? void 0 : value.split(",");
96
+ const tempKeys = values == null ? void 0 : values.map((item2) => {
97
+ var _a2;
98
+ const id2 = (_a2 = item2.split(delimiter)) == null ? void 0 : _a2[0];
99
+ return dataSource == null ? void 0 : dataSource.findIndex((item3) => id2.includes((item3 == null ? void 0 : item3.typeid) || (item3 == null ? void 0 : item3.instanceid)));
100
+ });
101
+ setSelectedRowKeys(tempKeys);
102
+ break;
103
+ }
104
+ }
105
+ setModalVisible(true);
106
+ };
107
+ const handleOk = async () => {
108
+ try {
109
+ const value2 = await buildValueFromSelectedRows(selectedRecords, item);
110
+ setValue((value2 == null ? void 0 : value2[attrid]) || "");
111
+ props.onSure(value2);
112
+ setModalVisible(false);
113
+ } catch (error) {
114
+ message.error(error.msg || "参数错误");
115
+ }
116
+ };
117
+ const handleCancel = () => {
118
+ setParams({
119
+ ...params,
120
+ PageNum: 1
121
+ });
122
+ setModalVisible(false);
123
+ };
124
+ function buildColumns() {
125
+ const modalFieldList = item["modal-field-list"];
126
+ let columns2 = [];
127
+ for (let fieldName in modalFieldList) {
128
+ let title = modalFieldList[fieldName];
129
+ const column = { dataIndex: fieldName, title };
130
+ columns2 = [...columns2, column];
131
+ }
132
+ return columns2;
133
+ }
134
+ const onPageChange = (pageNum) => {
135
+ setParams({
136
+ ...params,
137
+ PageNum: pageNum
138
+ });
139
+ };
140
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
141
+ /* @__PURE__ */ jsxRuntime.jsx(
142
+ antd.Select,
143
+ {
144
+ placeholder: (item == null ? void 0 : item["default-prompt"]) || "请选择",
145
+ onClick: openModal,
146
+ open: false,
147
+ value: attrValue,
148
+ disabled,
149
+ style
150
+ }
151
+ ),
152
+ CustomModalComponent && /* @__PURE__ */ jsxRuntime.jsx(
153
+ CustomModalComponent,
154
+ {
155
+ title: item["modal-caption"] || "",
156
+ open: modalVisible,
157
+ onOk: handleOk,
158
+ onCancel: handleCancel,
159
+ modalStyle: { width: item["modal-width"] ?? 600, minHeight: item["modal-height"] ?? 400 },
160
+ children: /* @__PURE__ */ jsxRuntime.jsx(
161
+ antd.Table,
162
+ {
163
+ columns,
164
+ loading,
165
+ dataSource,
166
+ rowKey: (record) => record._rowKey,
167
+ scroll: { y: "calc(80vh - 300px)" },
168
+ rowSelection: {
169
+ type: mode === "mul-field-modal-select" ? "radio" : "checkbox",
170
+ selectedRowKeys,
171
+ onChange: onSelectChange
172
+ },
173
+ pagination: {
174
+ total,
175
+ current: params.PageNum,
176
+ pageSize: params.PageSize,
177
+ onChange: onPageChange
178
+ }
179
+ }
180
+ )
181
+ }
182
+ ) || /* @__PURE__ */ jsxRuntime.jsx(
183
+ antd.Modal,
184
+ {
185
+ title: item["modal-caption"],
186
+ open: modalVisible,
187
+ onOk: handleOk,
188
+ onCancel: handleCancel,
189
+ width: item["modal-width"] ?? 600,
190
+ okButtonProps: { disabled: selectedRowKeys.length === 0 },
191
+ children: /* @__PURE__ */ jsxRuntime.jsx(
192
+ antd.Table,
193
+ {
194
+ columns,
195
+ loading,
196
+ dataSource,
197
+ rowKey: (record) => record._rowKey,
198
+ rowSelection: {
199
+ type: mode === "mul-field-modal-select" ? "radio" : "checkbox",
200
+ selectedRowKeys,
201
+ onChange: onSelectChange
202
+ },
203
+ pagination: {
204
+ total,
205
+ current: params.PageNum,
206
+ pageSize: params.PageSize,
207
+ onChange: onPageChange
208
+ }
209
+ }
210
+ )
211
+ }
212
+ )
213
+ ] });
214
+ }
215
+ function buildValueFromSelectedRows(selectedRows, attributeEnrollFormat) {
216
+ return new Promise((resolve, reject) => {
217
+ try {
218
+ var keyfields = attributeEnrollFormat["key-field"];
219
+ if (!keyfields) {
220
+ reject({ msg: "请配置key-field" });
221
+ return;
222
+ }
223
+ let res = {};
224
+ selectedRows.forEach((item) => {
225
+ for (let [key, value] of Object.entries(keyfields)) {
226
+ const list = (value == null ? void 0 : value.list) ?? [];
227
+ const delimiter = (value == null ? void 0 : value.delimiter) ?? "-";
228
+ const arr = list.map((v) => {
229
+ return item == null ? void 0 : item[v];
230
+ });
231
+ res[key] = arr.join(delimiter);
232
+ }
233
+ });
234
+ resolve(res);
235
+ } catch (error) {
236
+ reject({ msg: "key-field参数配置错误" });
237
+ }
238
+ });
239
+ }
240
+ exports.buildValueFromSelectedRows = buildValueFromSelectedRows;
241
+ 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>
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
+ const icons = require("@ant-design/icons");
3
4
  const func = require("./func");
4
5
  const method = require("../../utils/method");
6
+ const SelectModelBackfillFormItem = require("./selectModelBackfillFormItem");
5
7
  const react = require("react");
6
8
  const isoWeek = require("dayjs/plugin/isoWeek");
7
9
  const SelectModel = require("./selectModel");
@@ -12,7 +14,6 @@ const RadioCard = require("./radioCard");
12
14
  const MySelect = require("./mySelect");
13
15
  const MyUpload = require("./myUpload");
14
16
  const MyRadio = require("./myRadio");
15
- const icons = require("@ant-design/icons");
16
17
  const antd = require("antd");
17
18
  dayjs.extend(isoWeek);
18
19
  function useDynamicForm(props) {
@@ -433,6 +434,7 @@ function useDynamicForm(props) {
433
434
  }) => {
434
435
  var _a, _b, _c, _d;
435
436
  const mode = item.json.input || "text";
437
+ const attrid = item.attrid;
436
438
  const formatValue = func.handleSetFormItemInitialValue(item);
437
439
  const message2 = ((_a = item.json) == null ? void 0 : _a["default-prompt"]) || "";
438
440
  const disableDateGoover = ((_b = item.json) == null ? void 0 : _b["disable-date-goover"]) || false;
@@ -534,6 +536,25 @@ function useDynamicForm(props) {
534
536
  }
535
537
  );
536
538
  }
539
+ case "mul-field-modal-select": {
540
+ return /* @__PURE__ */ jsxRuntime.jsx(
541
+ SelectModelBackfillFormItem,
542
+ {
543
+ style: { width: defaultWidth, ...itemStyle == null ? void 0 : itemStyle.style, ...customWidth },
544
+ item: item.json,
545
+ form,
546
+ attrid,
547
+ value: item.attrvalue || item.json.default || "",
548
+ commonRequestWidthParams,
549
+ commonRequest,
550
+ onSure: async (value) => {
551
+ form.setFieldsValue(value);
552
+ },
553
+ disabled: readonly,
554
+ CustomModalComponent
555
+ }
556
+ );
557
+ }
537
558
  case "date-picker":
538
559
  case "time-picker":
539
560
  case "week-picker":
package/lib/index.js CHANGED
@@ -30,13 +30,12 @@ const Demo = () => {
30
30
  readonly: false,
31
31
  relatedid: "",
32
32
  colNum: 1,
33
- defaultWidth: "100%",
33
+ defaultWidth: 358,
34
34
  commonRequestWidthParams: services.commonRequestWidthParams,
35
35
  uploadAction: services.uploadFormAction,
36
36
  commonRequest: services.commonRequest,
37
37
  instructionShowMode: "icon",
38
- ref: formRef,
39
- isMobile: true
38
+ ref: formRef
40
39
  }
41
40
  ),
42
41
  /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "primary", htmlType: "submit", children: "提交" }) })
@@ -1,306 +1,2 @@
1
- export declare const baseAttrList: ({
2
- xh: number;
3
- asid: string;
4
- astype: number;
5
- tname: string;
6
- attrid: string;
7
- attrname: string;
8
- attrtype: number;
9
- info: string;
10
- info_base64: number;
11
- createtime: string;
12
- attrvalue: string;
13
- serialnum: number;
14
- children: never[];
15
- json: {
16
- input: string;
17
- dataType: string;
18
- length: number;
19
- 'range-picker-save'?: undefined;
20
- 'disable-date-goover'?: undefined;
21
- };
22
- } | {
23
- xh: number;
24
- asid: string;
25
- astype: number;
26
- tname: string;
27
- attrid: string;
28
- attrname: string;
29
- attrtype: number;
30
- info: string;
31
- info_base64: number;
32
- createtime: string;
33
- attrvalue: string;
34
- serialnum: number;
35
- children: never[];
36
- json: {
37
- input: string;
38
- dataType: string;
39
- length?: undefined;
40
- 'range-picker-save'?: undefined;
41
- 'disable-date-goover'?: undefined;
42
- };
43
- } | {
44
- xh: number;
45
- asid: string;
46
- astype: number;
47
- tname: string;
48
- attrid: string;
49
- attrname: string;
50
- attrtype: number;
51
- info: string;
52
- info_base64: number;
53
- createtime: string;
54
- attrvalue: string;
55
- serialnum: number;
56
- children: never[];
57
- json: {
58
- input: string;
59
- 'range-picker-save': string;
60
- dataType: string;
61
- length: number;
62
- 'disable-date-goover': boolean;
63
- };
64
- })[];
1
+ export declare const baseAttrList: never[];
65
2
  export declare const attrList: any;
66
- export declare const testList: ({
67
- xh: number;
68
- asid: string;
69
- astype: number;
70
- tname: string;
71
- attrid: string;
72
- attrname: string;
73
- attrtype: number;
74
- info: string;
75
- info_base64: number;
76
- createtime: string;
77
- attrvalue: string;
78
- serialnum: number;
79
- children: never[];
80
- json: {
81
- input: string;
82
- dataType: string;
83
- length: number;
84
- 'auto-generate': boolean;
85
- 'auto-generate-type': string;
86
- must?: undefined;
87
- 'upload-accept'?: undefined;
88
- 'upload-max-count'?: undefined;
89
- 'upload-size'?: undefined;
90
- instruction?: undefined;
91
- 'instruction-color'?: undefined;
92
- default?: undefined;
93
- propertiesID?: undefined;
94
- };
95
- } | {
96
- xh: number;
97
- asid: string;
98
- astype: number;
99
- tname: string;
100
- attrid: string;
101
- attrname: string;
102
- attrtype: number;
103
- info: string;
104
- info_base64: number;
105
- createtime: string;
106
- attrvalue: string;
107
- serialnum: number;
108
- children: never[];
109
- json: {
110
- input: string;
111
- dataType: string;
112
- length: number;
113
- must: boolean;
114
- 'auto-generate'?: undefined;
115
- 'auto-generate-type'?: undefined;
116
- 'upload-accept'?: undefined;
117
- 'upload-max-count'?: undefined;
118
- 'upload-size'?: undefined;
119
- instruction?: undefined;
120
- 'instruction-color'?: undefined;
121
- default?: undefined;
122
- propertiesID?: undefined;
123
- };
124
- } | {
125
- xh: number;
126
- asid: string;
127
- astype: number;
128
- tname: string;
129
- attrid: string;
130
- attrname: string;
131
- attrtype: number;
132
- info: string;
133
- info_base64: number;
134
- createtime: string;
135
- attrvalue: string;
136
- serialnum: number;
137
- children: never[];
138
- json: {
139
- input: string;
140
- dataType: string;
141
- length: number;
142
- 'auto-generate'?: undefined;
143
- 'auto-generate-type'?: undefined;
144
- must?: undefined;
145
- 'upload-accept'?: undefined;
146
- 'upload-max-count'?: undefined;
147
- 'upload-size'?: undefined;
148
- instruction?: undefined;
149
- 'instruction-color'?: undefined;
150
- default?: undefined;
151
- propertiesID?: undefined;
152
- };
153
- } | {
154
- xh: number;
155
- asid: string;
156
- astype: number;
157
- tname: string;
158
- attrid: string;
159
- attrname: string;
160
- attrtype: number;
161
- info: string;
162
- info_base64: number;
163
- createtime: string;
164
- attrvalue: string;
165
- serialnum: number;
166
- children: never[];
167
- json: {
168
- input: string;
169
- 'upload-accept': string;
170
- 'upload-max-count': string;
171
- 'upload-size': string;
172
- dataType: string;
173
- length: number;
174
- instruction: string;
175
- 'instruction-color': string;
176
- 'auto-generate'?: undefined;
177
- 'auto-generate-type'?: undefined;
178
- must?: undefined;
179
- default?: undefined;
180
- propertiesID?: undefined;
181
- };
182
- } | {
183
- xh: number;
184
- asid: string;
185
- astype: number;
186
- tname: string;
187
- attrid: string;
188
- attrname: string;
189
- attrtype: number;
190
- info: string;
191
- info_base64: number;
192
- createtime: string;
193
- attrvalue: string;
194
- serialnum: number;
195
- children: never[];
196
- json: {
197
- input: string;
198
- dataType: string;
199
- default: string;
200
- length?: undefined;
201
- 'auto-generate'?: undefined;
202
- 'auto-generate-type'?: undefined;
203
- must?: undefined;
204
- 'upload-accept'?: undefined;
205
- 'upload-max-count'?: undefined;
206
- 'upload-size'?: undefined;
207
- instruction?: undefined;
208
- 'instruction-color'?: undefined;
209
- propertiesID?: undefined;
210
- };
211
- } | {
212
- xh: number;
213
- asid: string;
214
- astype: number;
215
- tname: string;
216
- attrid: string;
217
- attrname: string;
218
- attrtype: number;
219
- info: string;
220
- info_base64: number;
221
- createtime: string;
222
- attrvalue: string;
223
- serialnum: number;
224
- children: ({
225
- xh: number;
226
- asid: string;
227
- astype: number;
228
- tname: string;
229
- attrid: string;
230
- attrname: string;
231
- attrtype: number;
232
- info: string;
233
- info_base64: number;
234
- createtime: string;
235
- attrvalue: string;
236
- serialnum: number;
237
- children: never[];
238
- json: {
239
- input: string;
240
- dataType: string;
241
- length: number;
242
- 'auto-generate': boolean;
243
- 'auto-generate-type': string;
244
- must?: undefined;
245
- };
246
- } | {
247
- xh: number;
248
- asid: string;
249
- astype: number;
250
- tname: string;
251
- attrid: string;
252
- attrname: string;
253
- attrtype: number;
254
- info: string;
255
- info_base64: number;
256
- createtime: string;
257
- attrvalue: string;
258
- serialnum: number;
259
- children: never[];
260
- json: {
261
- input: string;
262
- dataType: string;
263
- length: number;
264
- must: boolean;
265
- 'auto-generate'?: undefined;
266
- 'auto-generate-type'?: undefined;
267
- };
268
- } | {
269
- xh: number;
270
- asid: string;
271
- astype: number;
272
- tname: string;
273
- attrid: string;
274
- attrname: string;
275
- attrtype: number;
276
- info: string;
277
- info_base64: number;
278
- createtime: string;
279
- attrvalue: string;
280
- serialnum: number;
281
- children: never[];
282
- json: {
283
- input: string;
284
- dataType: string;
285
- length: number;
286
- 'auto-generate'?: undefined;
287
- 'auto-generate-type'?: undefined;
288
- must?: undefined;
289
- };
290
- })[][];
291
- json: {
292
- propertiesID: string;
293
- input?: undefined;
294
- dataType?: undefined;
295
- length?: undefined;
296
- 'auto-generate'?: undefined;
297
- 'auto-generate-type'?: undefined;
298
- must?: undefined;
299
- 'upload-accept'?: undefined;
300
- 'upload-max-count'?: undefined;
301
- 'upload-size'?: undefined;
302
- instruction?: undefined;
303
- 'instruction-color'?: undefined;
304
- default?: undefined;
305
- };
306
- })[];