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