diff --git a/src/compenents/tree-department/index.tsx b/src/compenents/tree-department/index.tsx index 4ea497d..000d665 100644 --- a/src/compenents/tree-department/index.tsx +++ b/src/compenents/tree-department/index.tsx @@ -19,23 +19,18 @@ export const TreeDepartment = (props: PropInterface) => { const [treeData, setTreeData] = useState([]); const [loading, setLoading] = useState(true); const [selectKey, setSelectKey] = useState([]); - const [total, setTotal] = useState(0); + const [userTotal, setUserTotal] = useState(0); useEffect(() => { setLoading(true); department.departmentList().then((res: any) => { const departments = res.data.departments; const departCount = res.data.dep_user_count; + setUserTotal(res.data.user_total); if (JSON.stringify(departments) !== "{}") { if (props.showNum) { const new_arr: any = checkNewArr(departments, 0, departCount); setTreeData(new_arr); - let num = 0; - for (let item in departCount) { - num = num + Number(departCount[item]); - - } - setTotal(num); } else { const new_arr: Option[] = checkArr(departments, 0); setTreeData(new_arr); @@ -144,7 +139,7 @@ export const TreeDepartment = (props: PropInterface) => { onClick={() => onSelect([], "")} > 全部{props.text} - {props.showNum && total ? "(" + total + ")" : ""} + {props.showNum && userTotal ? "(" + userTotal + ")" : ""} {treeData.length > 0 && (