@hzab/group-user-selector 0.0.6 → 0.0.8

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # @hzab/group-user-selector@0.0.8
2
+
3
+ feat: 搜索条件提示词改为传入
4
+
5
+ # @hzab/group-user-selector@0.0.7
6
+
7
+ fix:部门点击下一级时,pageNum 初始化
8
+
1
9
  # @hzab/group-user-selector@0.0.6
2
10
 
3
11
  fix:部门分页切换带上部门 id
package/README.md CHANGED
@@ -35,6 +35,7 @@ import Demo from "@hzab/group-user-selector";
35
35
  | hasPagination | boolean | 否 | true | 列表是否分页 |
36
36
  | hasSearch | boolean | 否 | true | 是否有搜索 |
37
37
  | hasSearchPagination | boolean | 否 | true | 搜索列表是否分页 |
38
+ | searchPlaceholder | string | 否 | "搜索成员"| 搜索框的提示词 |
38
39
 
39
40
  # 组件开发流程
40
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/group-user-selector",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState, forwardRef } from "react";
2
- import { Input, message, Pagination, } from "antd";
2
+ import { Input, message, Pagination } from "antd";
3
3
 
4
4
  import "./index.less";
5
5
 
@@ -7,74 +7,79 @@ function SearchRenter(props, ref) {
7
7
  const {
8
8
  searchModel,
9
9
  searchQueryKey = "search",
10
+ searchPlaceholder = "搜索成员",
10
11
  hasSearchPagination = true,
11
12
  hasSearch = true,
12
13
  ItemRenter,
13
- setLoading = () => { },
14
+ setLoading = () => {},
14
15
  } = props;
15
16
 
16
17
  const [search, setSearch] = useState("");
17
18
  const [searchList, setSearchList] = useState([]);
18
19
  const [total, setTotal] = useState(0);
19
- const [pageData, setPageData] = useState(hasSearchPagination ? {
20
- pageSize: 10,
21
- pageNum: 1
22
- } : {});
23
-
24
-
20
+ const [pageData, setPageData] = useState(
21
+ hasSearchPagination
22
+ ? {
23
+ pageSize: 10,
24
+ pageNum: 1,
25
+ }
26
+ : {},
27
+ );
25
28
 
26
29
  const handleSearch = (data) => {
27
30
  setLoading && setLoading(true);
28
31
  searchModel &&
29
- searchModel.getList({ ...data }).then((res) => {
30
- setSearchList(res?.list || res || []);
31
- setTotal(res?.pagination?.total || res?.total || 0);
32
- }).catch((err) => {
33
- message.error(err._message || "未知错误");
34
- })
32
+ searchModel
33
+ .getList({ ...data })
34
+ .then((res) => {
35
+ setSearchList(res?.list || res || []);
36
+ setTotal(res?.pagination?.total || res?.total || 0);
37
+ })
38
+ .catch((err) => {
39
+ message.error(err._message || "未知错误");
40
+ })
35
41
  .finally(() => {
36
42
  setLoading && setLoading(false);
37
43
  });
38
- }
44
+ };
39
45
 
40
46
  const handleChangePage = (pageNum, pageSize) => {
41
47
  const pages = {
42
48
  pageNum: pageSize !== pageData?.pageSize ? 1 : pageNum,
43
- pageSize
44
- }
49
+ pageSize,
50
+ };
45
51
  setPageData({
46
- ...pages
47
- })
52
+ ...pages,
53
+ });
48
54
  handleSearch({
49
55
  [searchQueryKey]: search,
50
- ...pages
51
- })
52
- }
56
+ ...pages,
57
+ });
58
+ };
53
59
 
54
60
  const onSearch = (value) => {
55
61
  setSearch(value);
56
62
  if (!value) {
57
63
  setPageData({
58
64
  pageSize: 10,
59
- pageNum: 1
60
- })
61
- return
62
- };
65
+ pageNum: 1,
66
+ });
67
+ return;
68
+ }
63
69
  const data = {
64
70
  pageSize: pageData?.pageSize || 10,
65
- pageNum: 1
66
- }
67
- setPageData(data)
71
+ pageNum: 1,
72
+ };
73
+ setPageData(data);
68
74
  handleSearch({
69
75
  [searchQueryKey]: value,
70
- ...data
71
- })
76
+ ...data,
77
+ });
72
78
  };
73
79
 
74
-
75
80
  return (
76
81
  <>
77
- {hasSearch ? <Input.Search onSearch={onSearch} enterButton placeholder="搜索成员" allowClear /> : null}
82
+ {hasSearch ? <Input.Search onSearch={onSearch} enterButton placeholder={searchPlaceholder} allowClear /> : null}
78
83
  {search ? (
79
84
  <div className="group-selection-search-view">
80
85
  <div className="group-selection-search-list">
@@ -83,9 +88,17 @@ function SearchRenter(props, ref) {
83
88
  })}
84
89
  </div>
85
90
 
86
- {hasSearchPagination ? <div className="group-selection-search-pagination">
87
- <Pagination current={pageData?.pageNum} total={total} pageSize={pageData?.pageSize} onChange={handleChangePage} size="small" />
88
- </div> : null}
91
+ {hasSearchPagination ? (
92
+ <div className="group-selection-search-pagination">
93
+ <Pagination
94
+ current={pageData?.pageNum}
95
+ total={total}
96
+ pageSize={pageData?.pageSize}
97
+ onChange={handleChangePage}
98
+ size="small"
99
+ />
100
+ </div>
101
+ ) : null}
89
102
  </div>
90
103
  ) : null}
91
104
  </>
package/src/index.tsx CHANGED
@@ -101,6 +101,9 @@ function GroupSelection(props, ref) {
101
101
  arr.push(item);
102
102
  setBreadcrumb(arr);
103
103
  setQueryValue(item[valueKey]);
104
+ if (hasPagination) {
105
+ pageData.current.pageNum = 1;
106
+ }
104
107
  getTreeData(item[valueKey]);
105
108
  };
106
109