线上课列表切换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 { interface Option {
key: string | number; key: string | number;
title: any; title: any;
children?: Option[]; children?: Option[];
} }
interface PropInterface { interface PropInterface {
type: string; type: string;
text: string; text: string;
refresh: boolean;
onUpdate: (keys: any, title: any) => void; 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 checkArr = (categories: any[], id: number) => {
const arr = []; const arr = [];
for (let i = 0; i < categories[id].length; i++) { for (let i = 0; i < categories[id].length; i++) {

View File

@ -24,6 +24,7 @@ export const TreeDepartment = (props: PropInterface) => {
useEffect(() => { useEffect(() => {
setLoading(true); setLoading(true);
setSelectKey([])
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;

View File

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

View File

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

View File

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

View File

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

View File

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