mirror of
https://github.com/PlayEdu/backend
synced 2025-06-23 11:52:44 +08:00
线上课列表渲染优化
This commit is contained in:
parent
7d665085a8
commit
f824396b05
@ -11,8 +11,6 @@ interface Option {
|
|||||||
interface PropInterface {
|
interface PropInterface {
|
||||||
type: string;
|
type: string;
|
||||||
text: string;
|
text: string;
|
||||||
categoryCount: any;
|
|
||||||
resourceTotal: number;
|
|
||||||
|
|
||||||
onUpdate: (keys: any, title: any) => void;
|
onUpdate: (keys: any, title: any) => void;
|
||||||
}
|
}
|
||||||
@ -37,7 +35,7 @@ export const TreeCategory = (props: PropInterface) => {
|
|||||||
setTreeData(new_arr);
|
setTreeData(new_arr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [props.categoryCount]);
|
}, []);
|
||||||
|
|
||||||
const checkArr = (categories: any[], id: number) => {
|
const checkArr = (categories: any[], id: number) => {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
|
@ -99,8 +99,6 @@ export const UploadImageButton = (props: PropsInterface) => {
|
|||||||
<Col span={7}>
|
<Col span={7}>
|
||||||
<TreeCategory
|
<TreeCategory
|
||||||
type="no-cate"
|
type="no-cate"
|
||||||
resourceTotal={0}
|
|
||||||
categoryCount={{}}
|
|
||||||
text={"图片"}
|
text={"图片"}
|
||||||
onUpdate={(keys: any) => setCategoryIds(keys)}
|
onUpdate={(keys: any) => setCategoryIds(keys)}
|
||||||
/>
|
/>
|
||||||
|
@ -32,8 +32,6 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
|||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const [size, setSize] = useState(10);
|
const [size, setSize] = useState(10);
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
const [pureTotal, setPureTotal] = useState(0);
|
|
||||||
const [categoryCount, setCategoryCount] = useState<any>({});
|
|
||||||
|
|
||||||
const [plainOptions, setPlainOptions] = useState<any>([]);
|
const [plainOptions, setPlainOptions] = useState<any>([]);
|
||||||
const [checkedList, setCheckedList] = useState<CheckboxValueType[]>([]);
|
const [checkedList, setCheckedList] = useState<CheckboxValueType[]>([]);
|
||||||
@ -48,8 +46,6 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
|||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
setTotal(res.data.result.total);
|
setTotal(res.data.result.total);
|
||||||
setVideoExtra(res.data.videos_extra);
|
setVideoExtra(res.data.videos_extra);
|
||||||
setCategoryCount(res.data.category_count);
|
|
||||||
setPureTotal(res.data.pure_total);
|
|
||||||
setVideoList(res.data.result.data);
|
setVideoList(res.data.result.data);
|
||||||
let data = res.data.result.data;
|
let data = res.data.result.data;
|
||||||
const arr = [];
|
const arr = [];
|
||||||
@ -150,8 +146,6 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
|||||||
<Col span={7}>
|
<Col span={7}>
|
||||||
<TreeCategory
|
<TreeCategory
|
||||||
type="no-cate"
|
type="no-cate"
|
||||||
resourceTotal={pureTotal}
|
|
||||||
categoryCount={{ categoryCount }}
|
|
||||||
text={props.label}
|
text={props.label}
|
||||||
onUpdate={(keys: any) => setCategoryIds(keys)}
|
onUpdate={(keys: any) => setCategoryIds(keys)}
|
||||||
/>
|
/>
|
||||||
|
@ -45,9 +45,11 @@ export 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 [categoryCount, setCategoryCount] = useState<any>({});
|
const [course_category_ids, setCourseCategoryIds] = useState<any>({});
|
||||||
|
const [course_dep_ids, setCourseDepIds] = useState<any>({});
|
||||||
|
const [categories, setCategories] = useState<any>({});
|
||||||
|
const [departments, setDepartments] = useState<any>({});
|
||||||
const [tabKey, setTabKey] = useState(1);
|
const [tabKey, setTabKey] = useState(1);
|
||||||
const [pureTotal, setPureTotal] = useState(0);
|
|
||||||
|
|
||||||
const [createVisible, setCreateVisible] = useState<boolean>(false);
|
const [createVisible, setCreateVisible] = useState<boolean>(false);
|
||||||
const [updateVisible, setUpdateVisible] = useState<boolean>(false);
|
const [updateVisible, setUpdateVisible] = useState<boolean>(false);
|
||||||
@ -62,9 +64,7 @@ export const CoursePage = () => {
|
|||||||
<div className="float-left">
|
<div className="float-left">
|
||||||
<TreeCategory
|
<TreeCategory
|
||||||
type=""
|
type=""
|
||||||
resourceTotal={pureTotal}
|
|
||||||
text={"课程"}
|
text={"课程"}
|
||||||
categoryCount={categoryCount}
|
|
||||||
onUpdate={(keys: any, title: any) => {
|
onUpdate={(keys: any, title: any) => {
|
||||||
setCategoryIds(keys);
|
setCategoryIds(keys);
|
||||||
if (typeof title == "string") {
|
if (typeof title == "string") {
|
||||||
@ -111,19 +111,45 @@ export const CoursePage = () => {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "类别",
|
title: "课程分类",
|
||||||
dataIndex: "isRequired",
|
dataIndex: "id",
|
||||||
render: (isRequired: number) => (
|
render: (id: number) => (
|
||||||
<span>{isRequired === 1 ? "必修课" : "选修课"}</span>
|
<div className="d-flex">
|
||||||
|
{course_category_ids[id].map((item: any, index: number) => {
|
||||||
|
return (
|
||||||
|
<span key={index}>
|
||||||
|
{index === course_category_ids[id].length - 1
|
||||||
|
? categories[item]
|
||||||
|
: categories[item] + "、"}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "是否显示",
|
title: "指派部门",
|
||||||
dataIndex: "is_show",
|
dataIndex: "id",
|
||||||
render: (is_show: number) => (
|
render: (id: number) => (
|
||||||
<span className={is_show === 1 ? "c-success" : "c-red"}>
|
<div className="d-flex">
|
||||||
{is_show === 1 ? "· 显示" : "· 隐藏"}
|
{course_dep_ids[id] &&
|
||||||
</span>
|
course_dep_ids[id].map((item: any, index: number) => {
|
||||||
|
return (
|
||||||
|
<span key={index}>
|
||||||
|
{index === course_dep_ids[id].length - 1
|
||||||
|
? departments[item]
|
||||||
|
: departments[item] + "、"}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "必修/选修",
|
||||||
|
dataIndex: "isRequired",
|
||||||
|
render: (isRequired: number) => (
|
||||||
|
<span>{isRequired === 1 ? "必修课" : "选修课"}</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -225,8 +251,10 @@ export const CoursePage = () => {
|
|||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
setTotal(res.data.total);
|
setTotal(res.data.total);
|
||||||
setList(res.data.data);
|
setList(res.data.data);
|
||||||
setCategoryCount(res.data.category_count);
|
setCourseCategoryIds(res.data.course_category_ids);
|
||||||
setPureTotal(res.data.pure_total);
|
setCourseDepIds(res.data.course_dep_ids);
|
||||||
|
setCategories(res.data.categories);
|
||||||
|
setDepartments(res.data.departments);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
})
|
})
|
||||||
.catch((err: any) => {
|
.catch((err: any) => {
|
||||||
|
@ -43,8 +43,6 @@ export const ResourceImagesPage = () => {
|
|||||||
const [hoverArr, setHoverArr] = useState<any>([]);
|
const [hoverArr, setHoverArr] = useState<any>([]);
|
||||||
const [selLabel, setLabel] = useState<string>("全部图片");
|
const [selLabel, setLabel] = useState<string>("全部图片");
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
const [categoryCount, setCategoryCount] = useState<any>({});
|
|
||||||
const [pureTotal, setPureTotal] = useState(0);
|
|
||||||
|
|
||||||
// 删除图片
|
// 删除图片
|
||||||
const removeResource = () => {
|
const removeResource = () => {
|
||||||
@ -89,8 +87,6 @@ export const ResourceImagesPage = () => {
|
|||||||
}
|
}
|
||||||
setVisibleArr(arr);
|
setVisibleArr(arr);
|
||||||
setHoverArr(arr);
|
setHoverArr(arr);
|
||||||
setCategoryCount(res.data.category_count);
|
|
||||||
setPureTotal(res.data.pure_total);
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
})
|
})
|
||||||
.catch((err: any) => {
|
.catch((err: any) => {
|
||||||
@ -156,8 +152,6 @@ export const ResourceImagesPage = () => {
|
|||||||
<TreeCategory
|
<TreeCategory
|
||||||
type="no-cate"
|
type="no-cate"
|
||||||
text={"图片"}
|
text={"图片"}
|
||||||
categoryCount={categoryCount}
|
|
||||||
resourceTotal={pureTotal}
|
|
||||||
onUpdate={(keys: any, title: any) => {
|
onUpdate={(keys: any, title: any) => {
|
||||||
setCategoryIds(keys);
|
setCategoryIds(keys);
|
||||||
if (typeof title == "string") {
|
if (typeof title == "string") {
|
||||||
|
@ -29,8 +29,6 @@ export const ResourceVideosPage = () => {
|
|||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [category_ids, setCategoryIds] = useState<any>([]);
|
const [category_ids, setCategoryIds] = useState<any>([]);
|
||||||
const [selLabel, setLabel] = useState<string>("全部视频");
|
const [selLabel, setLabel] = useState<string>("全部视频");
|
||||||
const [categoryCount, setCategoryCount] = useState<any>({});
|
|
||||||
const [pureTotal, setPureTotal] = useState(0);
|
|
||||||
|
|
||||||
const columns: ColumnsType<DataType> = [
|
const columns: ColumnsType<DataType> = [
|
||||||
// {
|
// {
|
||||||
@ -129,8 +127,6 @@ export const ResourceVideosPage = () => {
|
|||||||
setVideoList(res.data.result.data);
|
setVideoList(res.data.result.data);
|
||||||
setVideoExtra(res.data.videos_extra);
|
setVideoExtra(res.data.videos_extra);
|
||||||
setAdminUsers(res.data.admin_users);
|
setAdminUsers(res.data.admin_users);
|
||||||
setCategoryCount(res.data.category_count);
|
|
||||||
setPureTotal(res.data.pure_total);
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
})
|
})
|
||||||
.catch((err: any) => {
|
.catch((err: any) => {
|
||||||
@ -170,9 +166,7 @@ export const ResourceVideosPage = () => {
|
|||||||
<div className="left-box">
|
<div className="left-box">
|
||||||
<TreeCategory
|
<TreeCategory
|
||||||
type="no-cate"
|
type="no-cate"
|
||||||
resourceTotal={pureTotal}
|
|
||||||
text={"视频"}
|
text={"视频"}
|
||||||
categoryCount={categoryCount}
|
|
||||||
onUpdate={(keys: any, title: any) => {
|
onUpdate={(keys: any, title: any) => {
|
||||||
setCategoryIds(keys);
|
setCategoryIds(keys);
|
||||||
if (typeof title == "string") {
|
if (typeof title == "string") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user