分类、部门组件点击全部取消选中状态修复

This commit is contained in:
禺狨 2023-03-15 14:28:13 +08:00
parent b54bf7646e
commit 7d253ef888
5 changed files with 24 additions and 6 deletions

View File

@ -50,3 +50,7 @@ export function dropDiffClass(id: number, parent_id: number, ids: number[]) {
ids: ids,
});
}
export function checkDestroy(id: number) {
return client.get(`/backend/v1/department/${id}/destroy`, {});
}

View File

@ -54,3 +54,7 @@ export function dropDiffClass(id: number, parent_id: number, ids: number[]) {
ids: ids,
});
}
export function checkDestroy(id: number) {
return client.get(`/backend/v1/resource-category/${id}/destroy`, {});
}

View File

@ -20,14 +20,12 @@ export const TreeCategory = (props: PropInterface) => {
const [selectKey, setSelectKey] = useState<any>([]);
useEffect(() => {
setLoading(true);
resourceCategory.resourceCategoryList().then((res: any) => {
const categories = res.data.categories;
if (JSON.stringify(categories) !== "{}") {
const new_arr: Option[] = checkArr(categories, 0);
setTreeData(new_arr);
}
setLoading(false);
});
}, [props.categoryCount]);
@ -93,14 +91,21 @@ export const TreeCategory = (props: PropInterface) => {
? "mb-8 category-label active"
: "mb-8 category-label"
}
onClick={() => onSelect([], "")}
onClick={() => {
onSelect([], "");
}}
>
{props.text}
{JSON.stringify(props.categoryCount) !== "{}" && (
<span className="tree-num">({props.categoryCount["0"]})</span>
)}
</div>
<Tree onSelect={onSelect} onExpand={onExpand} treeData={treeData} />
<Tree
onSelect={onSelect}
selectedKeys={selectKey}
onExpand={onExpand}
treeData={treeData}
/>
</div>
);
};

View File

@ -89,7 +89,12 @@ export const TreeDepartment = (props: PropInterface) => {
>
{props.text}
</div>
<Tree onSelect={onSelect} onExpand={onExpand} treeData={treeData} />
<Tree
selectedKeys={selectKey}
onSelect={onSelect}
onExpand={onExpand}
treeData={treeData}
/>
</div>
);
};

View File

@ -43,7 +43,7 @@ export const CoursePage = () => {
const [category_ids, setCategoryIds] = useState<any>([]);
const [title, setTitle] = useState<string>("");
const [dep_ids, setDepIds] = useState<any>([]);
const [selLabel, setLabel] = useState<string>("全部视频");
const [selLabel, setLabel] = useState<string>("全部课程");
const [categoryCount, setCategoryCount] = useState<any>({});
const items: TabsProps["items"] = [