From f824396b059f1deb9109368a09ca2aa959f101fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Tue, 21 Mar 2023 18:32:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BF=E4=B8=8A=E8=AF=BE=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compenents/tree-category/index.tsx | 4 +- src/compenents/upload-image-button/index.tsx | 2 - src/compenents/upload-video-sub/index.tsx | 6 -- src/pages/course/index.tsx | 60 ++++++++++++++------ src/pages/resource/images/index.tsx | 6 -- src/pages/resource/videos/index.tsx | 6 -- 6 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/compenents/tree-category/index.tsx b/src/compenents/tree-category/index.tsx index 940edd2..85ae164 100644 --- a/src/compenents/tree-category/index.tsx +++ b/src/compenents/tree-category/index.tsx @@ -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 = []; diff --git a/src/compenents/upload-image-button/index.tsx b/src/compenents/upload-image-button/index.tsx index 93d739b..545a0ab 100644 --- a/src/compenents/upload-image-button/index.tsx +++ b/src/compenents/upload-image-button/index.tsx @@ -99,8 +99,6 @@ export const UploadImageButton = (props: PropsInterface) => { setCategoryIds(keys)} /> diff --git a/src/compenents/upload-video-sub/index.tsx b/src/compenents/upload-video-sub/index.tsx index f95a115..3757d05 100644 --- a/src/compenents/upload-video-sub/index.tsx +++ b/src/compenents/upload-video-sub/index.tsx @@ -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({}); const [plainOptions, setPlainOptions] = useState([]); const [checkedList, setCheckedList] = useState([]); @@ -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) => { setCategoryIds(keys)} /> diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index 5431178..5cc0368 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -45,9 +45,11 @@ export const CoursePage = () => { const [title, setTitle] = useState(""); const [dep_ids, setDepIds] = useState([]); const [selLabel, setLabel] = useState("全部课程"); - const [categoryCount, setCategoryCount] = useState({}); + const [course_category_ids, setCourseCategoryIds] = useState({}); + const [course_dep_ids, setCourseDepIds] = useState({}); + const [categories, setCategories] = useState({}); + const [departments, setDepartments] = useState({}); const [tabKey, setTabKey] = useState(1); - const [pureTotal, setPureTotal] = useState(0); const [createVisible, setCreateVisible] = useState(false); const [updateVisible, setUpdateVisible] = useState(false); @@ -62,9 +64,7 @@ export const CoursePage = () => {
{ setCategoryIds(keys); if (typeof title == "string") { @@ -111,19 +111,45 @@ export const CoursePage = () => { ), }, { - title: "类别", - dataIndex: "isRequired", - render: (isRequired: number) => ( - {isRequired === 1 ? "必修课" : "选修课"} + title: "课程分类", + dataIndex: "id", + render: (id: number) => ( +
+ {course_category_ids[id].map((item: any, index: number) => { + return ( + + {index === course_category_ids[id].length - 1 + ? categories[item] + : categories[item] + "、"} + + ); + })} +
), }, { - title: "是否显示", - dataIndex: "is_show", - render: (is_show: number) => ( - - {is_show === 1 ? "· 显示" : "· 隐藏"} - + title: "指派部门", + dataIndex: "id", + render: (id: number) => ( +
+ {course_dep_ids[id] && + course_dep_ids[id].map((item: any, index: number) => { + return ( + + {index === course_dep_ids[id].length - 1 + ? departments[item] + : departments[item] + "、"} + + ); + })} +
+ ), + }, + { + title: "必修/选修", + dataIndex: "isRequired", + render: (isRequired: number) => ( + {isRequired === 1 ? "必修课" : "选修课"} ), }, { @@ -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) => { diff --git a/src/pages/resource/images/index.tsx b/src/pages/resource/images/index.tsx index ae97a05..09ca393 100644 --- a/src/pages/resource/images/index.tsx +++ b/src/pages/resource/images/index.tsx @@ -43,8 +43,6 @@ export const ResourceImagesPage = () => { const [hoverArr, setHoverArr] = useState([]); const [selLabel, setLabel] = useState("全部图片"); const [loading, setLoading] = useState(false); - const [categoryCount, setCategoryCount] = useState({}); - 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 = () => { { setCategoryIds(keys); if (typeof title == "string") { diff --git a/src/pages/resource/videos/index.tsx b/src/pages/resource/videos/index.tsx index 8a3203d..fc5d8b6 100644 --- a/src/pages/resource/videos/index.tsx +++ b/src/pages/resource/videos/index.tsx @@ -29,8 +29,6 @@ export const ResourceVideosPage = () => { const [loading, setLoading] = useState(true); const [category_ids, setCategoryIds] = useState([]); const [selLabel, setLabel] = useState("全部视频"); - const [categoryCount, setCategoryCount] = useState({}); - const [pureTotal, setPureTotal] = useState(0); const columns: ColumnsType = [ // { @@ -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 = () => {
{ setCategoryIds(keys); if (typeof title == "string") {