zy-react-library 1.0.64 → 1.0.66

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.
@@ -19,6 +19,8 @@ export interface BasicCascaderProps extends CascaderProps {
19
19
  placeholder?: string;
20
20
  /** 控制只能选择到第几级 */
21
21
  level?: number;
22
+ /** 获取数据 */
23
+ onGetData?: (data: Record<string, any>[], processedData: Record<string, any>[]) => void;
22
24
  }
23
25
 
24
26
  /**
@@ -1,4 +1,5 @@
1
1
  import { Cascader } from "antd";
2
+ import { useEffect } from "react";
2
3
  import { processTreeDataByLevel } from "../../../utils";
3
4
 
4
5
  /**
@@ -6,6 +7,7 @@ import { processTreeDataByLevel } from "../../../utils";
6
7
  */
7
8
  function BasicCascader(props) {
8
9
  const {
10
+ onGetData,
9
11
  onChange,
10
12
  onGetNodePaths,
11
13
  onGetNodePathsIsIncludeOneself = true,
@@ -42,6 +44,10 @@ function BasicCascader(props) {
42
44
  onChange?.(value, selectedOptions);
43
45
  };
44
46
 
47
+ useEffect(() => {
48
+ onGetData?.(data, processedData);
49
+ }, [data, processedData]);
50
+
45
51
  return (
46
52
  <Cascader
47
53
  options={processedData}
@@ -1,5 +1,5 @@
1
1
  import { request } from "@cqsjjb/jjb-common-lib/http";
2
- import { Descriptions, Divider } from "antd";
2
+ import { Descriptions, Divider, Spin } from "antd";
3
3
  import dayjs from "dayjs";
4
4
  import { useEffect, useState } from "react";
5
5
  import HeaderBack from "../../HeaderBack";
@@ -39,12 +39,14 @@ function HiddenInfo(props) {
39
39
  const [afterRectificationImageFiles, setAfterRectificationImageFiles] = useState([]);
40
40
  const [rectificationPlanImageFiles, setRectificationPlanImageFiles] = useState([]);
41
41
  const [acceptImageFiles, setAcceptImageFiles] = useState([]);
42
+ const [loading, setLoading] = useState(true);
42
43
  const { getFile } = useGetFile();
43
44
  const query = useGetUrlQuery();
44
45
 
45
46
  const getData = async () => {
46
47
  request(`/hidden/hidden/${id || query[idKey]}`, "get").then((res) => {
47
48
  setInfo(res.data);
49
+ setLoading(false);
48
50
  });
49
51
  const hiddenImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["3"], eqForeignKey: hiddenId || query[hiddenIdKey] });
50
52
  setHiddenImageFiles(hiddenImageFiles);
@@ -70,7 +72,8 @@ function HiddenInfo(props) {
70
72
  return (
71
73
  <div>
72
74
  {isShowHeaderBack && <HeaderBack title="查看" />}
73
- <div style={{ padding: 20 }}>
75
+ <Spin spinning={loading}>
76
+ <div style={{ padding: 20 }}>
74
77
  <Divider orientation="left">隐患信息</Divider>
75
78
  <Descriptions
76
79
  bordered
@@ -355,6 +358,7 @@ function HiddenInfo(props) {
355
358
  ]}
356
359
  />
357
360
  </div>
361
+ </Spin>
358
362
  </div>
359
363
  );
360
364
  }
@@ -15,6 +15,8 @@ export interface BasicLeftTreeProps extends TreeProps {
15
15
  onGetNodePathsIsIncludeOneself?: boolean;
16
16
  /** 获取父级节点 */
17
17
  onGetNodePaths?: () => Record<string, any>[];
18
+ /** 获取数据 */
19
+ onGetData?: (data: Record<string, any>[]) => void;
18
20
  }
19
21
 
20
22
  /**
@@ -9,6 +9,7 @@ const { Search } = Input;
9
9
  */
10
10
  const BasicLeftTree = (props) => {
11
11
  const {
12
+ onGetData,
12
13
  onSelect,
13
14
  onGetNodePaths,
14
15
  onGetNodePathsIsIncludeOneself = true,
@@ -141,6 +142,10 @@ const BasicLeftTree = (props) => {
141
142
  const filteredTreeData = filterTreeData(treeData, searchValue);
142
143
  const processedTreeData = processTreeData(filteredTreeData);
143
144
 
145
+ useEffect(() => {
146
+ onGetData?.(treeData);
147
+ }, [treeData]);
148
+
144
149
  return (
145
150
  <div style={{ width: 300 }}>
146
151
  <Search
@@ -14,7 +14,9 @@ export interface BasicSelectProps extends SelectProps {
14
14
  /** 占位符 */
15
15
  placeholder?: string;
16
16
  /** 获取 label */
17
- onGetLabel?: (label: string) => void;
17
+ onGetLabel?: (label: string | string[]) => void;
18
+ /** 获取数据 */
19
+ onGetData?: (data: Record<string, any>[]) => void;
18
20
  }
19
21
 
20
22
  /**
@@ -1,4 +1,5 @@
1
1
  import { Select } from "antd";
2
+ import { useEffect } from "react";
2
3
  import { getLabelName } from "../../../utils";
3
4
 
4
5
  /**
@@ -6,6 +7,7 @@ import { getLabelName } from "../../../utils";
6
7
  */
7
8
  function BasicSelect(props) {
8
9
  const {
10
+ onGetData,
9
11
  onChange,
10
12
  onGetLabel,
11
13
  placeholder = "",
@@ -16,13 +18,31 @@ function BasicSelect(props) {
16
18
  } = props;
17
19
 
18
20
  const handleChange = (event, option) => {
19
- if (event)
20
- onGetLabel?.(getLabelName({ list: data, status: event, idKey, nameKey }));
21
- else
22
- onGetLabel?.("");
21
+ if (Array.isArray(event)) {
22
+ if (event.length > 0) {
23
+ const name = [];
24
+ event.forEach((item) => {
25
+ name.push(getLabelName({ list: data, status: item, idKey, nameKey }));
26
+ });
27
+ onGetLabel?.(name);
28
+ }
29
+ else {
30
+ onGetLabel?.([]);
31
+ }
32
+ }
33
+ else {
34
+ if (event)
35
+ onGetLabel?.(getLabelName({ list: data, status: event, idKey, nameKey }));
36
+ else
37
+ onGetLabel?.("");
38
+ }
23
39
  onChange?.(event, option);
24
40
  };
25
41
 
42
+ useEffect(() => {
43
+ onGetData?.(data);
44
+ }, [data]);
45
+
26
46
  return (
27
47
  <Select placeholder={`请选择${placeholder}`} showSearch allowClear onChange={handleChange} {...restProps}>
28
48
  {data.map((item) => {
@@ -21,6 +21,8 @@ export interface BasicSelectTreeProps extends TreeSelectProps {
21
21
  level?: number;
22
22
  /** 获取 label */
23
23
  onGetLabel?: (label: string) => void;
24
+ /** 获取数据 */
25
+ onGetData?: (data: Record<string, any>[], processedData: Record<string, any>[]) => void;
24
26
  }
25
27
 
26
28
  /**
@@ -1,4 +1,5 @@
1
1
  import { TreeSelect } from "antd";
2
+ import { useEffect } from "react";
2
3
  import { getTreeNodePaths, processTreeDataByLevel } from "../../../utils";
3
4
 
4
5
  /**
@@ -6,6 +7,7 @@ import { getTreeNodePaths, processTreeDataByLevel } from "../../../utils";
6
7
  */
7
8
  function BasicSelectTree(props) {
8
9
  const {
10
+ onGetData,
9
11
  onChange,
10
12
  onGetLabel,
11
13
  onGetNodePaths,
@@ -48,6 +50,10 @@ function BasicSelectTree(props) {
48
50
  onChange?.(value, label, extra);
49
51
  };
50
52
 
53
+ useEffect(() => {
54
+ onGetData?.(treeData, processedTreeData);
55
+ }, [treeData, processedTreeData]);
56
+
51
57
  return (
52
58
  <TreeSelect
53
59
  showSearch
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.0.64",
4
+ "version": "1.0.66",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",