szld-libs 0.4.27 → 0.4.29

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.
@@ -7,13 +7,15 @@ declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, comm
7
7
  commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
8
8
  commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
9
9
  value: string | number | (string | number)[];
10
- onChange: (val: string | number | (string | number)[]) => void;
10
+ onChange: (val: string | number | (string | number)[] | {
11
+ [key: string]: any;
12
+ }) => void;
11
13
  interfaceTypeDict: string;
12
14
  interfaceTypeSysDict: string;
13
15
  actionUrlKey: string;
14
16
  actionUrlExtraParams: object;
15
17
  langId?: string | undefined;
16
18
  getTitle?: ((pageID: string, dataID: string) => string) | undefined;
17
- attrid?: string | undefined;
19
+ attrid: string;
18
20
  }) => import("react/jsx-runtime").JSX.Element;
19
21
  export default MySelect;
@@ -1,8 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { handleSelectOptions, handleGetPlaceholder, findRowByValue } from "../func";
3
+ import { handleGetList, handleGetControlPanelConfig } from "../../../utils/szxkFunc";
3
4
  import { useState, useEffect } from "react";
4
5
  import { message, Select } from "antd";
5
- import { handleGetList, handleGetControlPanelConfig } from "../../../utils/szxkFunc";
6
6
  const MySelect = ({
7
7
  item,
8
8
  readonly,
@@ -104,6 +104,7 @@ const MySelect = ({
104
104
  return prev;
105
105
  }, {});
106
106
  onChange(newObj);
107
+ return;
107
108
  }
108
109
  onChange(val);
109
110
  }
@@ -18,6 +18,7 @@ export interface IformConfigItem {
18
18
  }
19
19
 
20
20
  export interface Ijson {
21
+ readonly: boolean; // 是否只读字段
21
22
  'auto-generate'?: boolean; // 是否自动生成
22
23
  'auto-generate-type'?: string; // 自动生成类型
23
24
  'instance-source-number'?: string; // 实例来源编号,配合instance-url使用
@@ -1,6 +1,6 @@
1
1
  import { Ijson } from '../index.d';
2
2
  import { AxiosResponse } from 'axios';
3
- declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, commonRequest, value, onChange, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, langId, }: {
3
+ declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, commonRequest, value, onChange, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, langId, getTitle, attrid, }: {
4
4
  item: Ijson;
5
5
  readonly?: boolean | undefined;
6
6
  style?: any;
@@ -13,5 +13,7 @@ declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, comm
13
13
  actionUrlKey: string;
14
14
  actionUrlExtraParams: object;
15
15
  langId?: string | undefined;
16
+ getTitle?: ((pageID: string, dataID: string) => string) | undefined;
17
+ attrid?: string | undefined;
16
18
  }) => import("react/jsx-runtime").JSX.Element;
17
19
  export default MySelect;
@@ -1,8 +1,9 @@
1
1
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import { Field, Popup, Checkbox, Picker } from "react-vant";
3
- import { handleSelectOptions } from "../func";
2
+ import { handleSelectOptions, findRowByValue } from "../../DynamicForm/func";
3
+ import { Toast, Field, Popup, Checkbox, Picker } from "react-vant";
4
4
  import { useState, useEffect } from "react";
5
- import { Flex } from "antd";
5
+ import { message, Flex } from "antd";
6
+ import { handleGetList, handleGetControlPanelConfig } from "../../../utils/szxkFunc";
6
7
  const checkboxGroup = "index-module_checkbox-group_4684b";
7
8
  const checkboxGroupHeader = "index-module_checkbox-group-header_192bd";
8
9
  const checkboxGroupContent = "index-module_checkbox-group-content_f81a1";
@@ -32,9 +33,12 @@ const MySelect = ({
32
33
  interfaceTypeSysDict,
33
34
  actionUrlKey,
34
35
  actionUrlExtraParams,
35
- langId
36
+ langId,
37
+ getTitle,
38
+ attrid
36
39
  }) => {
37
40
  const [options, setOptions] = useState([]);
41
+ const [instanceList, setInstanceList] = useState([]);
38
42
  useEffect(() => {
39
43
  if (item.input === "mult-select" && value && Array.isArray(value)) {
40
44
  setSelectedValues(value || []);
@@ -45,6 +49,39 @@ const MySelect = ({
45
49
  handleLoadOptions();
46
50
  }, [item.inputType, item.classify, item.data, item.options]);
47
51
  const handleLoadOptions = async () => {
52
+ if (item.inputType === "instance-url" && (item == null ? void 0 : item["instance-source-number"]) && attrid) {
53
+ const keyField = item == null ? void 0 : item["key-field"];
54
+ if (!keyField) {
55
+ Toast("请配置key-field");
56
+ return;
57
+ }
58
+ const params = {
59
+ "source-number": item == null ? void 0 : item["instance-source-number"]
60
+ };
61
+ let list2 = await handleGetList(params, commonRequestWidthParams);
62
+ const controlPanelConfig = await handleGetControlPanelConfig(item == null ? void 0 : item["instance-source-number"], commonRequest);
63
+ if (controlPanelConfig) {
64
+ const nonUniversalHeader = (controlPanelConfig == null ? void 0 : controlPanelConfig["non-universal-header"]) || [];
65
+ const labelConfig = (nonUniversalHeader == null ? void 0 : nonUniversalHeader["label"]) || [];
66
+ const valueConfig = (keyField == null ? void 0 : keyField[attrid]) || {};
67
+ const options2 = list2 == null ? void 0 : list2.map((v) => {
68
+ const label = labelConfig == null ? void 0 : labelConfig.map((x) => v == null ? void 0 : v[x]).join("-");
69
+ const { list: list3, delimiter } = valueConfig;
70
+ const value2 = list3 == null ? void 0 : list3.map((x) => v == null ? void 0 : v[x]).join(delimiter || "-");
71
+ if (!label) {
72
+ return null;
73
+ }
74
+ return {
75
+ label: getTitle == null ? void 0 : getTitle("5000000", label),
76
+ value: value2
77
+ };
78
+ });
79
+ message.success(JSON.stringify(options2));
80
+ setOptions(options2);
81
+ setInstanceList(list2);
82
+ }
83
+ return;
84
+ }
48
85
  const list = await handleSelectOptions({
49
86
  commonRequestWidthParams,
50
87
  commonRequest,
@@ -121,7 +158,22 @@ const MySelect = ({
121
158
  columnsFieldNames: {
122
159
  text: "label"
123
160
  },
124
- onConfirm: onChange,
161
+ onConfirm: (val) => {
162
+ if (attrid && (instanceList == null ? void 0 : instanceList.length) > 0 && (item == null ? void 0 : item.inputType) === "instance-url") {
163
+ const keyField = item == null ? void 0 : item["key-field"];
164
+ const row = findRowByValue(instanceList, String(val));
165
+ const keys = Object.keys(keyField || {});
166
+ const newObj = keys == null ? void 0 : keys.reduce((prev, cur) => {
167
+ const { list, delimiter } = (keyField == null ? void 0 : keyField[cur]) || {};
168
+ const value2 = list == null ? void 0 : list.map((x) => row == null ? void 0 : row[x]).join(delimiter || "-");
169
+ prev[cur] = value2;
170
+ return prev;
171
+ }, {});
172
+ onChange(newObj);
173
+ return;
174
+ }
175
+ onChange(val);
176
+ },
125
177
  children: (val, _, actions) => {
126
178
  var _a;
127
179
  val = val || value;
@@ -499,8 +499,17 @@ function useDynamicForm(props) {
499
499
  actionUrlKey,
500
500
  actionUrlExtraParams,
501
501
  langId,
502
+ getTitle,
503
+ attrid,
502
504
  onChange: (val) => {
503
- form.setFieldValue(item.attrid, val);
505
+ if (typeof val === "object" && !Array.isArray(val)) {
506
+ form.setFieldsValue({
507
+ ...form.getFieldsValue(),
508
+ ...val
509
+ });
510
+ } else {
511
+ form.setFieldValue(item.attrid, val);
512
+ }
504
513
  }
505
514
  }
506
515
  );
@@ -7,13 +7,15 @@ declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, comm
7
7
  commonRequestWidthParams: (params: object, data?: any) => Promise<AxiosResponse<any, any>>;
8
8
  commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
9
9
  value: string | number | (string | number)[];
10
- onChange: (val: string | number | (string | number)[]) => void;
10
+ onChange: (val: string | number | (string | number)[] | {
11
+ [key: string]: any;
12
+ }) => void;
11
13
  interfaceTypeDict: string;
12
14
  interfaceTypeSysDict: string;
13
15
  actionUrlKey: string;
14
16
  actionUrlExtraParams: object;
15
17
  langId?: string | undefined;
16
18
  getTitle?: ((pageID: string, dataID: string) => string) | undefined;
17
- attrid?: string | undefined;
19
+ attrid: string;
18
20
  }) => import("react/jsx-runtime").JSX.Element;
19
21
  export default MySelect;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
3
  const func = require("../func");
4
+ const szxkFunc = require("../../../utils/szxkFunc");
4
5
  const react = require("react");
5
6
  const antd = require("antd");
6
- const szxkFunc = require("../../../utils/szxkFunc");
7
7
  const MySelect = ({
8
8
  item,
9
9
  readonly,
@@ -105,6 +105,7 @@ const MySelect = ({
105
105
  return prev;
106
106
  }, {});
107
107
  onChange(newObj);
108
+ return;
108
109
  }
109
110
  onChange(val);
110
111
  }
@@ -18,6 +18,7 @@ export interface IformConfigItem {
18
18
  }
19
19
 
20
20
  export interface Ijson {
21
+ readonly: boolean; // 是否只读字段
21
22
  'auto-generate'?: boolean; // 是否自动生成
22
23
  'auto-generate-type'?: string; // 自动生成类型
23
24
  'instance-source-number'?: string; // 实例来源编号,配合instance-url使用
@@ -1,6 +1,6 @@
1
1
  import { Ijson } from '../index.d';
2
2
  import { AxiosResponse } from 'axios';
3
- declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, commonRequest, value, onChange, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, langId, }: {
3
+ declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, commonRequest, value, onChange, interfaceTypeDict, interfaceTypeSysDict, actionUrlKey, actionUrlExtraParams, langId, getTitle, attrid, }: {
4
4
  item: Ijson;
5
5
  readonly?: boolean | undefined;
6
6
  style?: any;
@@ -13,5 +13,7 @@ declare const MySelect: ({ item, readonly, style, commonRequestWidthParams, comm
13
13
  actionUrlKey: string;
14
14
  actionUrlExtraParams: object;
15
15
  langId?: string | undefined;
16
+ getTitle?: ((pageID: string, dataID: string) => string) | undefined;
17
+ attrid?: string | undefined;
16
18
  }) => import("react/jsx-runtime").JSX.Element;
17
19
  export default MySelect;
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
+ const func = require("../../DynamicForm/func");
3
4
  const reactVant = require("react-vant");
4
- const func = require("../func");
5
5
  const react = require("react");
6
6
  const antd = require("antd");
7
+ const szxkFunc = require("../../../utils/szxkFunc");
7
8
  const checkboxGroup = "index-module_checkbox-group_4684b";
8
9
  const checkboxGroupHeader = "index-module_checkbox-group-header_192bd";
9
10
  const checkboxGroupContent = "index-module_checkbox-group-content_f81a1";
@@ -33,9 +34,12 @@ const MySelect = ({
33
34
  interfaceTypeSysDict,
34
35
  actionUrlKey,
35
36
  actionUrlExtraParams,
36
- langId
37
+ langId,
38
+ getTitle,
39
+ attrid
37
40
  }) => {
38
41
  const [options, setOptions] = react.useState([]);
42
+ const [instanceList, setInstanceList] = react.useState([]);
39
43
  react.useEffect(() => {
40
44
  if (item.input === "mult-select" && value && Array.isArray(value)) {
41
45
  setSelectedValues(value || []);
@@ -46,6 +50,39 @@ const MySelect = ({
46
50
  handleLoadOptions();
47
51
  }, [item.inputType, item.classify, item.data, item.options]);
48
52
  const handleLoadOptions = async () => {
53
+ if (item.inputType === "instance-url" && (item == null ? void 0 : item["instance-source-number"]) && attrid) {
54
+ const keyField = item == null ? void 0 : item["key-field"];
55
+ if (!keyField) {
56
+ reactVant.Toast("请配置key-field");
57
+ return;
58
+ }
59
+ const params = {
60
+ "source-number": item == null ? void 0 : item["instance-source-number"]
61
+ };
62
+ let list2 = await szxkFunc.handleGetList(params, commonRequestWidthParams);
63
+ const controlPanelConfig = await szxkFunc.handleGetControlPanelConfig(item == null ? void 0 : item["instance-source-number"], commonRequest);
64
+ if (controlPanelConfig) {
65
+ const nonUniversalHeader = (controlPanelConfig == null ? void 0 : controlPanelConfig["non-universal-header"]) || [];
66
+ const labelConfig = (nonUniversalHeader == null ? void 0 : nonUniversalHeader["label"]) || [];
67
+ const valueConfig = (keyField == null ? void 0 : keyField[attrid]) || {};
68
+ const options2 = list2 == null ? void 0 : list2.map((v) => {
69
+ const label = labelConfig == null ? void 0 : labelConfig.map((x) => v == null ? void 0 : v[x]).join("-");
70
+ const { list: list3, delimiter } = valueConfig;
71
+ const value2 = list3 == null ? void 0 : list3.map((x) => v == null ? void 0 : v[x]).join(delimiter || "-");
72
+ if (!label) {
73
+ return null;
74
+ }
75
+ return {
76
+ label: getTitle == null ? void 0 : getTitle("5000000", label),
77
+ value: value2
78
+ };
79
+ });
80
+ antd.message.success(JSON.stringify(options2));
81
+ setOptions(options2);
82
+ setInstanceList(list2);
83
+ }
84
+ return;
85
+ }
49
86
  const list = await func.handleSelectOptions({
50
87
  commonRequestWidthParams,
51
88
  commonRequest,
@@ -122,7 +159,22 @@ const MySelect = ({
122
159
  columnsFieldNames: {
123
160
  text: "label"
124
161
  },
125
- onConfirm: onChange,
162
+ onConfirm: (val) => {
163
+ if (attrid && (instanceList == null ? void 0 : instanceList.length) > 0 && (item == null ? void 0 : item.inputType) === "instance-url") {
164
+ const keyField = item == null ? void 0 : item["key-field"];
165
+ const row = func.findRowByValue(instanceList, String(val));
166
+ const keys = Object.keys(keyField || {});
167
+ const newObj = keys == null ? void 0 : keys.reduce((prev, cur) => {
168
+ const { list, delimiter } = (keyField == null ? void 0 : keyField[cur]) || {};
169
+ const value2 = list == null ? void 0 : list.map((x) => row == null ? void 0 : row[x]).join(delimiter || "-");
170
+ prev[cur] = value2;
171
+ return prev;
172
+ }, {});
173
+ onChange(newObj);
174
+ return;
175
+ }
176
+ onChange(val);
177
+ },
126
178
  children: (val, _, actions) => {
127
179
  var _a;
128
180
  val = val || value;
@@ -500,8 +500,17 @@ function useDynamicForm(props) {
500
500
  actionUrlKey,
501
501
  actionUrlExtraParams,
502
502
  langId,
503
+ getTitle,
504
+ attrid,
503
505
  onChange: (val) => {
504
- form.setFieldValue(item.attrid, val);
506
+ if (typeof val === "object" && !Array.isArray(val)) {
507
+ form.setFieldsValue({
508
+ ...form.getFieldsValue(),
509
+ ...val
510
+ });
511
+ } else {
512
+ form.setFieldValue(item.attrid, val);
513
+ }
505
514
  }
506
515
  }
507
516
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "szld-libs",
3
3
  "private": false,
4
- "version": "0.4.27",
4
+ "version": "0.4.29",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",