线上课列表切换tab重置分类、部门组件

This commit is contained in:
禺狨 2023-04-24 09:19:58 +08:00
parent 27ec0e6c4a
commit b34cd955c4
7 changed files with 20 additions and 0 deletions

View File

@ -5,12 +5,14 @@ import { resourceCategory } from "../../api/index";
interface Option {
key: string | number;
title: any;
children?: Option[];
}
interface PropInterface {
type: string;
text: string;
refresh: boolean;
onUpdate: (keys: any, title: any) => void;
}
@ -36,6 +38,10 @@ export const TreeCategory = (props: PropInterface) => {
});
}, []);
useEffect(() => {
setSelectKey([]);
}, [props.refresh]);
const checkArr = (categories: any[], id: number) => {
const arr = [];
for (let i = 0; i < categories[id].length; i++) {

View File

@ -24,6 +24,7 @@ export const TreeDepartment = (props: PropInterface) => {
useEffect(() => {
setLoading(true);
setSelectKey([])
department.departmentList().then((res: any) => {
const departments = res.data.departments;
const departCount = res.data.dep_user_count;

View File

@ -101,6 +101,7 @@ export const UploadImageButton = (props: PropsInterface) => {
<Row style={{ width: 752, minHeight: 520, marginTop: 24 }}>
<Col span={7}>
<TreeCategory
refresh={false}
type="no-cate"
text={"图片"}
onUpdate={(keys: any) => setCategoryIds(keys)}

View File

@ -173,6 +173,7 @@ export const UploadVideoSub = (props: PropsInterface) => {
<Row style={{ width: 752, minHeight: 520 }}>
<Col span={7}>
<TreeCategory
refresh={false}
type="no-cate"
text={props.label}
onUpdate={(keys: any) => setCategoryIds(keys)}

View File

@ -69,6 +69,7 @@ const CoursePage = () => {
children: (
<div className="float-left">
<TreeCategory
refresh={refresh}
type=""
text={"分类"}
onUpdate={(keys: any, title: any) => {
@ -331,6 +332,14 @@ const CoursePage = () => {
};
const onChange = (key: string) => {
setCategoryIds([]);
setDepIds([]);
if (Number(key) === 1) {
setLabel("全部分类");
} else {
setLabel("全部部门");
}
setRefresh(!refresh);
setTabKey(Number(key));
};

View File

@ -150,6 +150,7 @@ const ResourceImagesPage = () => {
<div className="tree-main-body">
<div className="left-box">
<TreeCategory
refresh={false}
type="no-cate"
text={"图片"}
onUpdate={(keys: any, title: any) => {

View File

@ -170,6 +170,7 @@ const ResourceVideosPage = () => {
<div className="tree-main-body">
<div className="left-box">
<TreeCategory
refresh={false}
type="no-cate"
text={"视频"}
onUpdate={(keys: any, title: any) => {