mirror of
https://github.com/PlayEdu/backend
synced 2025-12-23 07:19:32 +08:00
部门列表学员全部人数渲染
This commit is contained in:
@@ -19,23 +19,18 @@ export const TreeDepartment = (props: PropInterface) => {
|
|||||||
const [treeData, setTreeData] = useState<any>([]);
|
const [treeData, setTreeData] = useState<any>([]);
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [selectKey, setSelectKey] = useState<any>([]);
|
const [selectKey, setSelectKey] = useState<any>([]);
|
||||||
const [total, setTotal] = useState(0);
|
const [userTotal, setUserTotal] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
department.departmentList().then((res: any) => {
|
department.departmentList().then((res: any) => {
|
||||||
const departments = res.data.departments;
|
const departments = res.data.departments;
|
||||||
const departCount = res.data.dep_user_count;
|
const departCount = res.data.dep_user_count;
|
||||||
|
setUserTotal(res.data.user_total);
|
||||||
if (JSON.stringify(departments) !== "{}") {
|
if (JSON.stringify(departments) !== "{}") {
|
||||||
if (props.showNum) {
|
if (props.showNum) {
|
||||||
const new_arr: any = checkNewArr(departments, 0, departCount);
|
const new_arr: any = checkNewArr(departments, 0, departCount);
|
||||||
setTreeData(new_arr);
|
setTreeData(new_arr);
|
||||||
let num = 0;
|
|
||||||
for (let item in departCount) {
|
|
||||||
num = num + Number(departCount[item]);
|
|
||||||
|
|
||||||
}
|
|
||||||
setTotal(num);
|
|
||||||
} else {
|
} else {
|
||||||
const new_arr: Option[] = checkArr(departments, 0);
|
const new_arr: Option[] = checkArr(departments, 0);
|
||||||
setTreeData(new_arr);
|
setTreeData(new_arr);
|
||||||
@@ -144,7 +139,7 @@ export const TreeDepartment = (props: PropInterface) => {
|
|||||||
onClick={() => onSelect([], "")}
|
onClick={() => onSelect([], "")}
|
||||||
>
|
>
|
||||||
全部{props.text}
|
全部{props.text}
|
||||||
{props.showNum && total ? "(" + total + ")" : ""}
|
{props.showNum && userTotal ? "(" + userTotal + ")" : ""}
|
||||||
</div>
|
</div>
|
||||||
{treeData.length > 0 && (
|
{treeData.length > 0 && (
|
||||||
<Tree
|
<Tree
|
||||||
|
|||||||
Reference in New Issue
Block a user