线上课tab切换

This commit is contained in:
禺狨 2023-04-24 11:11:18 +08:00
parent b897dfffac
commit 18f6056dc9
7 changed files with 12 additions and 25 deletions

View File

@ -12,7 +12,6 @@ interface 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;
} }
@ -38,10 +37,6 @@ 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,7 +24,6 @@ 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

@ -110,7 +110,6 @@ 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) => { onUpdate={(keys: any) => {

View File

@ -173,7 +173,6 @@ 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

@ -51,6 +51,7 @@ const CoursePage = () => {
const [title, setTitle] = useState<string>(""); const [title, setTitle] = useState<string>("");
const [dep_ids, setDepIds] = useState<any>([]); const [dep_ids, setDepIds] = useState<any>([]);
const [selLabel, setLabel] = useState<string>("全部分类"); const [selLabel, setLabel] = useState<string>("全部分类");
const [selDepLabel, setDepLabel] = useState<string>("全部部门");
const [course_category_ids, setCourseCategoryIds] = useState<any>({}); const [course_category_ids, setCourseCategoryIds] = useState<any>({});
const [course_dep_ids, setCourseDepIds] = useState<any>({}); const [course_dep_ids, setCourseDepIds] = useState<any>({});
const [categories, setCategories] = useState<any>({}); const [categories, setCategories] = useState<any>({});
@ -69,7 +70,6 @@ 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) => {
@ -96,7 +96,7 @@ const CoursePage = () => {
text={"部门"} text={"部门"}
onUpdate={(keys: any, title: any) => { onUpdate={(keys: any, title: any) => {
setDepIds(keys); setDepIds(keys);
setLabel(title); setDepLabel(title);
}} }}
/> />
</div> </div>
@ -283,11 +283,16 @@ const CoursePage = () => {
}); });
}; };
// 获取视频列表 // 获取列表
const getList = () => { const getList = () => {
setLoading(true); setLoading(true);
let categoryIds = category_ids.join(","); let categoryIds = "";
let depIds = dep_ids.join(","); let depIds = "";
if (tabKey === 1) {
categoryIds = category_ids.join(",");
} else {
depIds = dep_ids.join(",");
}
course course
.courseList(page, size, "", "", title, depIds, categoryIds) .courseList(page, size, "", "", title, depIds, categoryIds)
.then((res: any) => { .then((res: any) => {
@ -315,7 +320,7 @@ const CoursePage = () => {
// 加载列表 // 加载列表
useEffect(() => { useEffect(() => {
getList(); getList();
}, [category_ids, dep_ids, refresh, page, size]); }, [category_ids, dep_ids, refresh, page, size, tabKey]);
const paginationProps = { const paginationProps = {
current: page, //当前页码 current: page, //当前页码
@ -332,14 +337,6 @@ 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));
}; };
@ -357,7 +354,7 @@ const CoursePage = () => {
</div> </div>
<div className="right-box"> <div className="right-box">
<div className="playedu-main-title float-left mb-24"> <div className="playedu-main-title float-left mb-24">
线 | {selLabel} 线 | {tabKey === 1 ? selLabel : selDepLabel}
</div> </div>
<div className="float-left j-b-flex mb-24"> <div className="float-left j-b-flex mb-24">
<div className="d-flex"> <div className="d-flex">

View File

@ -150,7 +150,6 @@ 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,7 +170,6 @@ 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) => {