@hzab/group-user-selector 0.0.9 → 0.0.10
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 +4 -0
- package/package.json +57 -52
- package/src/components/ItemRenter/index.jsx +47 -46
- package/src/components/SearchRenter/index.jsx +108 -108
- package/src/index.tsx +3 -2
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,52 +1,57 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hzab/group-user-selector",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "src",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "webpack serve -c ./config/webpack.config.js --env local",
|
|
8
|
-
"build": "webpack -c ./config/webpack.config.js --env production",
|
|
9
|
-
"
|
|
10
|
-
"publish
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@hzab/group-user-selector",
|
|
3
|
+
"version": "0.0.10",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "src",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "webpack serve -c ./config/webpack.config.js --env local",
|
|
8
|
+
"build": "webpack -c ./config/webpack.config.js --env production",
|
|
9
|
+
"version:alpha": "npm version prerelease --preid=alpha",
|
|
10
|
+
"publish:alpha": "npm publish --tag alpha",
|
|
11
|
+
"version:beta": "npm version prerelease --preid=beta",
|
|
12
|
+
"publish:beta": "npm publish --tag beta",
|
|
13
|
+
"version:patch": "npm version patch",
|
|
14
|
+
"version:minior": "npm version minor",
|
|
15
|
+
"version:major": "npm version major",
|
|
16
|
+
"publish:stable": "npm publish --access public",
|
|
17
|
+
"prepare": "husky install",
|
|
18
|
+
"mac-chmod": "chmod +x .husky && chmod +x .husky/pre-commit",
|
|
19
|
+
"docs": "typedoc"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"src",
|
|
23
|
+
"CHANGELOG.md"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [],
|
|
26
|
+
"author": "CaiYansong",
|
|
27
|
+
"license": "ISC",
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@hzab/permissions": "^1.0.0",
|
|
30
|
+
"@hzab/webpack-config": "^1.0.0",
|
|
31
|
+
"@types/react": "^17.0.62",
|
|
32
|
+
"@types/react-dom": "^17.0.20",
|
|
33
|
+
"antd": "^4.14.0",
|
|
34
|
+
"axios": "^1.4.0",
|
|
35
|
+
"eslint": "^8.30.0",
|
|
36
|
+
"less": "^4.1.3",
|
|
37
|
+
"mobx": "^6.7.0",
|
|
38
|
+
"mobx-react": "^7.6.0",
|
|
39
|
+
"react": "^17.0.2",
|
|
40
|
+
"react-dom": "^17.0.2",
|
|
41
|
+
"react-router-dom": "^6.14.1",
|
|
42
|
+
"typedoc": "^0.24.8",
|
|
43
|
+
"typescript": "^4.9.4"
|
|
44
|
+
},
|
|
45
|
+
"directories": {
|
|
46
|
+
"src": "src"
|
|
47
|
+
},
|
|
48
|
+
"lint-staged": {
|
|
49
|
+
"**.{js,jsx,ts,tsx,css,scss,less,json,html}": [
|
|
50
|
+
"prettier --write"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@hzab/data-model": "^1.7.0",
|
|
55
|
+
"lodash": "^4.17.21"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
import { forwardRef } from "react";
|
|
2
|
-
import { Checkbox } from "antd";
|
|
3
|
-
|
|
4
|
-
import defaultAvatar from "../../assets/imgs/defaultAvatar.png";
|
|
5
|
-
import department from "../../assets/imgs/department.png";
|
|
6
|
-
|
|
7
|
-
import "./index.less";
|
|
8
|
-
|
|
9
|
-
function ItemRenter(props, ref) {
|
|
10
|
-
const {
|
|
11
|
-
labelKey = "label",
|
|
12
|
-
valueKey = "value",
|
|
13
|
-
isUserKey = "isUser",
|
|
14
|
-
imgKey = "img",
|
|
15
|
-
isCheck = false,
|
|
16
|
-
item,
|
|
17
|
-
handleClickItem,
|
|
18
|
-
handleCheckItem
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { Checkbox } from "antd";
|
|
3
|
+
|
|
4
|
+
import defaultAvatar from "../../assets/imgs/defaultAvatar.png";
|
|
5
|
+
import department from "../../assets/imgs/department.png";
|
|
6
|
+
|
|
7
|
+
import "./index.less";
|
|
8
|
+
|
|
9
|
+
function ItemRenter(props, ref) {
|
|
10
|
+
const {
|
|
11
|
+
labelKey = "label",
|
|
12
|
+
valueKey = "value",
|
|
13
|
+
isUserKey = "isUser",
|
|
14
|
+
imgKey = "img",
|
|
15
|
+
isCheck = false,
|
|
16
|
+
item,
|
|
17
|
+
handleClickItem,
|
|
18
|
+
handleCheckItem,
|
|
19
|
+
noNextLevel = false
|
|
20
|
+
} = props;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<div className="group-selection-list-item" key={item[valueKey]}>
|
|
26
|
+
<div className="avatar" onClick={() => handleCheckItem(item)}>
|
|
27
|
+
<Checkbox checked={isCheck} />
|
|
28
|
+
<img src={item[imgKey] ? item[imgKey] : item[isUserKey] ? defaultAvatar : department} />
|
|
29
|
+
<div className="label">{item[labelKey]}</div>
|
|
30
|
+
</div>
|
|
31
|
+
{(item[isUserKey] || noNextLevel) ? null : <div
|
|
32
|
+
className={`next ${isCheck ? "noNext" : ""}`}
|
|
33
|
+
onClick={() => {
|
|
34
|
+
if (isCheck) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
handleClickItem(item);
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
下级
|
|
41
|
+
</div>}
|
|
42
|
+
</div>
|
|
43
|
+
</>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default forwardRef(ItemRenter);
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import { useEffect, useState, forwardRef } from "react";
|
|
2
|
-
import { Input, message, Pagination } from "antd";
|
|
3
|
-
|
|
4
|
-
import "./index.less";
|
|
5
|
-
|
|
6
|
-
function SearchRenter(props, ref) {
|
|
7
|
-
const {
|
|
8
|
-
searchModel,
|
|
9
|
-
searchQueryKey = "search",
|
|
10
|
-
searchPlaceholder = "搜索成员",
|
|
11
|
-
hasSearchPagination = true,
|
|
12
|
-
hasSearch = true,
|
|
13
|
-
ItemRenter,
|
|
14
|
-
setLoading = () => {},
|
|
15
|
-
} = props;
|
|
16
|
-
|
|
17
|
-
const [search, setSearch] = useState("");
|
|
18
|
-
const [searchList, setSearchList] = useState([]);
|
|
19
|
-
const [total, setTotal] = useState(0);
|
|
20
|
-
const [pageData, setPageData] = useState(
|
|
21
|
-
hasSearchPagination
|
|
22
|
-
? {
|
|
23
|
-
pageSize: 10,
|
|
24
|
-
pageNum: 1,
|
|
25
|
-
}
|
|
26
|
-
: {},
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const handleSearch = (data) => {
|
|
30
|
-
setLoading && setLoading(true);
|
|
31
|
-
searchModel &&
|
|
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
|
-
})
|
|
41
|
-
.finally(() => {
|
|
42
|
-
setLoading && setLoading(false);
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const handleChangePage = (pageNum, pageSize) => {
|
|
47
|
-
const pages = {
|
|
48
|
-
pageNum: pageSize !== pageData?.pageSize ? 1 : pageNum,
|
|
49
|
-
pageSize,
|
|
50
|
-
};
|
|
51
|
-
setPageData({
|
|
52
|
-
...pages,
|
|
53
|
-
});
|
|
54
|
-
handleSearch({
|
|
55
|
-
[searchQueryKey]: search,
|
|
56
|
-
...pages,
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const onSearch = (value) => {
|
|
61
|
-
setSearch(value);
|
|
62
|
-
if (!value) {
|
|
63
|
-
setPageData({
|
|
64
|
-
pageSize: 10,
|
|
65
|
-
pageNum: 1,
|
|
66
|
-
});
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const data = {
|
|
70
|
-
pageSize: pageData?.pageSize || 10,
|
|
71
|
-
pageNum: 1,
|
|
72
|
-
};
|
|
73
|
-
setPageData(data);
|
|
74
|
-
handleSearch({
|
|
75
|
-
[searchQueryKey]: value,
|
|
76
|
-
...data,
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<>
|
|
82
|
-
{hasSearch ? <Input.Search onSearch={onSearch} enterButton placeholder={searchPlaceholder} allowClear /> : null}
|
|
83
|
-
{search ? (
|
|
84
|
-
<div className="group-selection-search-view">
|
|
85
|
-
<div className="group-selection-search-list">
|
|
86
|
-
{searchList.map((item, index) => {
|
|
87
|
-
return ItemRenter(item);
|
|
88
|
-
})}
|
|
89
|
-
</div>
|
|
90
|
-
|
|
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}
|
|
102
|
-
</div>
|
|
103
|
-
) : null}
|
|
104
|
-
</>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export default forwardRef(SearchRenter);
|
|
1
|
+
import { useEffect, useState, forwardRef } from "react";
|
|
2
|
+
import { Input, message, Pagination } from "antd";
|
|
3
|
+
|
|
4
|
+
import "./index.less";
|
|
5
|
+
|
|
6
|
+
function SearchRenter(props, ref) {
|
|
7
|
+
const {
|
|
8
|
+
searchModel,
|
|
9
|
+
searchQueryKey = "search",
|
|
10
|
+
searchPlaceholder = "搜索成员",
|
|
11
|
+
hasSearchPagination = true,
|
|
12
|
+
hasSearch = true,
|
|
13
|
+
ItemRenter,
|
|
14
|
+
setLoading = () => {},
|
|
15
|
+
} = props;
|
|
16
|
+
|
|
17
|
+
const [search, setSearch] = useState("");
|
|
18
|
+
const [searchList, setSearchList] = useState([]);
|
|
19
|
+
const [total, setTotal] = useState(0);
|
|
20
|
+
const [pageData, setPageData] = useState(
|
|
21
|
+
hasSearchPagination
|
|
22
|
+
? {
|
|
23
|
+
pageSize: 10,
|
|
24
|
+
pageNum: 1,
|
|
25
|
+
}
|
|
26
|
+
: {},
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const handleSearch = (data) => {
|
|
30
|
+
setLoading && setLoading(true);
|
|
31
|
+
searchModel &&
|
|
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
|
+
})
|
|
41
|
+
.finally(() => {
|
|
42
|
+
setLoading && setLoading(false);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const handleChangePage = (pageNum, pageSize) => {
|
|
47
|
+
const pages = {
|
|
48
|
+
pageNum: pageSize !== pageData?.pageSize ? 1 : pageNum,
|
|
49
|
+
pageSize,
|
|
50
|
+
};
|
|
51
|
+
setPageData({
|
|
52
|
+
...pages,
|
|
53
|
+
});
|
|
54
|
+
handleSearch({
|
|
55
|
+
[searchQueryKey]: search,
|
|
56
|
+
...pages,
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const onSearch = (value) => {
|
|
61
|
+
setSearch(value);
|
|
62
|
+
if (!value) {
|
|
63
|
+
setPageData({
|
|
64
|
+
pageSize: 10,
|
|
65
|
+
pageNum: 1,
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const data = {
|
|
70
|
+
pageSize: pageData?.pageSize || 10,
|
|
71
|
+
pageNum: 1,
|
|
72
|
+
};
|
|
73
|
+
setPageData(data);
|
|
74
|
+
handleSearch({
|
|
75
|
+
[searchQueryKey]: value,
|
|
76
|
+
...data,
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<>
|
|
82
|
+
{hasSearch ? <Input.Search onSearch={onSearch} enterButton placeholder={searchPlaceholder} allowClear /> : null}
|
|
83
|
+
{search ? (
|
|
84
|
+
<div className="group-selection-search-view">
|
|
85
|
+
<div className="group-selection-search-list">
|
|
86
|
+
{searchList.map((item, index) => {
|
|
87
|
+
return ItemRenter(item, true);
|
|
88
|
+
})}
|
|
89
|
+
</div>
|
|
90
|
+
|
|
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}
|
|
102
|
+
</div>
|
|
103
|
+
) : null}
|
|
104
|
+
</>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default forwardRef(SearchRenter);
|
package/src/index.tsx
CHANGED
|
@@ -149,7 +149,7 @@ function GroupSelection(props, ref) {
|
|
|
149
149
|
return is;
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
const Renter = (item) => {
|
|
152
|
+
const Renter = (item, noNextLevel) => {
|
|
153
153
|
const isCheck = handleCheck(item);
|
|
154
154
|
return (
|
|
155
155
|
<ItemRenter
|
|
@@ -159,6 +159,7 @@ function GroupSelection(props, ref) {
|
|
|
159
159
|
handleCheckItem={handleCheckItem}
|
|
160
160
|
handleCheckDelete={handleCheckDelete}
|
|
161
161
|
handleClickItem={handleClickItem}
|
|
162
|
+
noNextLevel={noNextLevel}
|
|
162
163
|
/>
|
|
163
164
|
);
|
|
164
165
|
};
|
|
@@ -191,7 +192,7 @@ function GroupSelection(props, ref) {
|
|
|
191
192
|
</div>
|
|
192
193
|
<div className="group-selection-list-view">
|
|
193
194
|
{selectList.map((item, index) => {
|
|
194
|
-
return Renter(item);
|
|
195
|
+
return Renter(item, false);
|
|
195
196
|
})}
|
|
196
197
|
</div>
|
|
197
198
|
{hasPagination ? (
|