@hzab/group-user-selector 0.0.3 → 0.0.4
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState, forwardRef } from "react";
|
|
2
|
-
import { Input,message,
|
|
2
|
+
import { Input, message, Pagination, } from "antd";
|
|
3
3
|
|
|
4
4
|
import "./index.less";
|
|
5
5
|
|
|
@@ -27,15 +27,13 @@ function SearchRenter(props, ref) {
|
|
|
27
27
|
setLoading && setLoading(true);
|
|
28
28
|
searchModel &&
|
|
29
29
|
searchModel.getList({ ...data }).then((res) => {
|
|
30
|
-
console.log(res, 2222222);
|
|
31
|
-
|
|
32
30
|
setSearchList(res?.list || res || []);
|
|
33
|
-
setTotal(res?.pagination?.total||res?.total || 0);
|
|
31
|
+
setTotal(res?.pagination?.total || res?.total || 0);
|
|
34
32
|
}).catch((err) => {
|
|
35
33
|
message.error(err._message || "未知错误");
|
|
36
34
|
})
|
|
37
35
|
.finally(() => {
|
|
38
|
-
setLoading &&
|
|
36
|
+
setLoading && setLoading(false);
|
|
39
37
|
});
|
|
40
38
|
}
|
|
41
39
|
|
|
@@ -54,12 +52,22 @@ function SearchRenter(props, ref) {
|
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
const onSearch = (value) => {
|
|
57
|
-
|
|
58
55
|
setSearch(value);
|
|
59
|
-
if (!value)
|
|
56
|
+
if (!value) {
|
|
57
|
+
setPageData({
|
|
58
|
+
pageSize: 10,
|
|
59
|
+
pageNum: 1
|
|
60
|
+
})
|
|
61
|
+
return
|
|
62
|
+
};
|
|
63
|
+
const data = {
|
|
64
|
+
pageSize: pageData?.pageSize || 10,
|
|
65
|
+
pageNum: 1
|
|
66
|
+
}
|
|
67
|
+
setPageData(data)
|
|
60
68
|
handleSearch({
|
|
61
69
|
[searchQueryKey]: value,
|
|
62
|
-
...
|
|
70
|
+
...data
|
|
63
71
|
})
|
|
64
72
|
};
|
|
65
73
|
|
|
@@ -80,7 +88,7 @@ function SearchRenter(props, ref) {
|
|
|
80
88
|
</div> : null}
|
|
81
89
|
</div>
|
|
82
90
|
) : null}
|
|
83
|
-
|
|
91
|
+
</>
|
|
84
92
|
);
|
|
85
93
|
}
|
|
86
94
|
|
package/src/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState, useImperativeHandle, forwardRef } from "react";
|
|
1
|
+
import { useEffect, useState, useImperativeHandle, forwardRef, useReducer, useRef } from "react";
|
|
2
2
|
import { Input, Breadcrumb, Checkbox, message, Spin, Pagination, ConfigProvider } from "antd";
|
|
3
3
|
import zhCN from 'antd/es/locale/zh_CN';
|
|
4
4
|
import { CloseCircleFilled, SearchOutlined } from "@ant-design/icons";
|
|
@@ -35,7 +35,9 @@ function GroupSelection(props, ref) {
|
|
|
35
35
|
const [selectedList, setSelectedList] = useState([...value]);
|
|
36
36
|
const [queryValue, setQueryValue] = useState(undefined);
|
|
37
37
|
const [total, setTotal] = useState(0);
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const pageData = useRef(hasPagination ? {
|
|
39
41
|
pageSize: 10,
|
|
40
42
|
pageNum: 1
|
|
41
43
|
} : {});
|
|
@@ -54,7 +56,7 @@ function GroupSelection(props, ref) {
|
|
|
54
56
|
const getTreeData = (value?: string | number) => {
|
|
55
57
|
setLoading(true);
|
|
56
58
|
model &&
|
|
57
|
-
model.getList({ [queryKey]: value || queryValue, ...pageData }).then((res) => {
|
|
59
|
+
model.getList({ [queryKey]: value || queryValue, ...pageData.current }).then((res) => {
|
|
58
60
|
setSelectList(res?.list || res || []);
|
|
59
61
|
setTotal(res?.pagination?.total||res?.total || 0);
|
|
60
62
|
})
|
|
@@ -74,12 +76,11 @@ function GroupSelection(props, ref) {
|
|
|
74
76
|
|
|
75
77
|
const handleChangePage = (pageNum, pageSize) => {
|
|
76
78
|
const pages = {
|
|
77
|
-
pageNum: pageSize !== pageData?.pageSize ? 1 : pageNum,
|
|
79
|
+
pageNum: pageSize !== pageData.current?.pageSize ? 1 : pageNum,
|
|
78
80
|
pageSize
|
|
79
81
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
82
|
+
pageData.current = pages
|
|
83
|
+
|
|
83
84
|
getTreeData()
|
|
84
85
|
}
|
|
85
86
|
|
|
@@ -179,7 +180,7 @@ function GroupSelection(props, ref) {
|
|
|
179
180
|
})}
|
|
180
181
|
</div>
|
|
181
182
|
{hasPagination ? <div>
|
|
182
|
-
<Pagination current={pageData?.pageNum} total={total} pageSize={pageData?.pageSize} onChange={handleChangePage} size="small" />
|
|
183
|
+
<Pagination current={pageData.current?.pageNum} total={total} pageSize={pageData.current?.pageSize} onChange={handleChangePage} size="small" />
|
|
183
184
|
</div> : null}
|
|
184
185
|
</div>
|
|
185
186
|
<div className="group-selection-detail">
|