zy-react-library 1.0.66 → 1.0.68

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.
@@ -14,6 +14,8 @@ export interface HiddenInfoProps {
14
14
  hiddenIdKey?: string;
15
15
  /** 是否显示头部的返回,默认 true */
16
16
  isShowHeaderBack?: boolean;
17
+ /** 获取数据 */
18
+ onGetData?: (data: Record<string, any>) => void;
17
19
  }
18
20
 
19
21
  /**
@@ -22,6 +22,7 @@ function HiddenInfo(props) {
22
22
  hiddenId = "",
23
23
  hiddenIdKey = "hiddenId",
24
24
  isShowHeaderBack = true,
25
+ onGetData,
25
26
  } = props;
26
27
 
27
28
  const [info, setInfo] = useState({
@@ -47,6 +48,7 @@ function HiddenInfo(props) {
47
48
  request(`/hidden/hidden/${id || query[idKey]}`, "get").then((res) => {
48
49
  setInfo(res.data);
49
50
  setLoading(false);
51
+ onGetData?.(res.data);
50
52
  });
51
53
  const hiddenImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["3"], eqForeignKey: hiddenId || query[hiddenIdKey] });
52
54
  setHiddenImageFiles(hiddenImageFiles);
@@ -15,6 +15,8 @@ export interface BasicSelectProps extends SelectProps {
15
15
  placeholder?: string;
16
16
  /** 获取 label */
17
17
  onGetLabel?: (label: string | string[]) => void;
18
+ /** 获取选中的项 */
19
+ onGetOption?: (option: Record<string, any> | Record<string, any>[]) => void;
18
20
  /** 获取数据 */
19
21
  onGetData?: (data: Record<string, any>[]) => void;
20
22
  }
@@ -1,6 +1,5 @@
1
1
  import { Select } from "antd";
2
2
  import { useEffect } from "react";
3
- import { getLabelName } from "../../../utils";
4
3
 
5
4
  /**
6
5
  * 基础下拉组件(不建议直接使用此组件,二次继承使用)
@@ -10,6 +9,7 @@ function BasicSelect(props) {
10
9
  onGetData,
11
10
  onChange,
12
11
  onGetLabel,
12
+ onGetOption,
13
13
  placeholder = "",
14
14
  data = [],
15
15
  nameKey = "name",
@@ -20,21 +20,33 @@ function BasicSelect(props) {
20
20
  const handleChange = (event, option) => {
21
21
  if (Array.isArray(event)) {
22
22
  if (event.length > 0) {
23
- const name = [];
23
+ const findItems = [];
24
+ const names = [];
24
25
  event.forEach((item) => {
25
- name.push(getLabelName({ list: data, status: item, idKey, nameKey }));
26
+ const findItem = data.find(dataItem => dataItem[idKey] === item);
27
+ if (findItem) {
28
+ findItems.push(findItem);
29
+ names.push(findItem[nameKey]);
30
+ }
26
31
  });
27
- onGetLabel?.(name);
32
+ onGetLabel?.(names);
33
+ onGetOption?.(findItems);
28
34
  }
29
35
  else {
30
36
  onGetLabel?.([]);
37
+ onGetOption?.([]);
31
38
  }
32
39
  }
33
40
  else {
34
- if (event)
35
- onGetLabel?.(getLabelName({ list: data, status: event, idKey, nameKey }));
36
- else
41
+ if (event) {
42
+ const findItem = data.find(item => item[idKey] === event);
43
+ onGetLabel?.(findItem[nameKey]);
44
+ onGetOption?.(findItem);
45
+ }
46
+ else {
37
47
  onGetLabel?.("");
48
+ onGetOption?.({});
49
+ }
38
50
  }
39
51
  onChange?.(event, option);
40
52
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.0.66",
4
+ "version": "1.0.68",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",