From 6c923e17569528afbd34b8318b7b8961fa81e970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Wed, 19 Apr 2023 16:12:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E9=97=A8=E5=88=97=E8=A1=A8=E5=AD=A6?= =?UTF-8?q?=E5=91=98=E5=85=A8=E9=83=A8=E4=BA=BA=E6=95=B0=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compenents/tree-department/index.tsx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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 && (