diff --git a/src/compenents/select-attachment/index.tsx b/src/compenents/select-attachment/index.tsx index 5a4f08a..1a40742 100644 --- a/src/compenents/select-attachment/index.tsx +++ b/src/compenents/select-attachment/index.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import { Row, Modal, Tabs, Spin } from "antd"; +import { Row, Modal, Tabs } from "antd"; import styles from "./index.module.less"; import { UploadCoursewareSub } from "../../compenents"; import type { TabsProps } from "antd"; @@ -13,13 +13,12 @@ interface PropsInterface { export const SelectAttachment = (props: PropsInterface) => { const [refresh, setRefresh] = useState(true); - const [init, setInit] = useState(true); + const [tabKey, setTabKey] = useState(1); const [selectKeys, setSelectKeys] = useState([]); const [selectVideos, setSelectVideos] = useState([]); useEffect(() => { - setInit(true); setRefresh(!refresh); }, [props.open]); @@ -28,23 +27,15 @@ export const SelectAttachment = (props: PropsInterface) => { key: "1", label: `课件`, children: ( -
- { - setSelectKeys(arr); - setSelectVideos(videos); - }} - onSuccess={() => { - setInit(false); - }} - /> -
+ { + setSelectKeys(arr); + setSelectVideos(videos); + }} + /> ), }, ]; @@ -77,11 +68,6 @@ export const SelectAttachment = (props: PropsInterface) => { - {init && ( -
- -
- )} ) : null} diff --git a/src/compenents/select-resource/index.tsx b/src/compenents/select-resource/index.tsx index 93f4ca8..b30c29e 100644 --- a/src/compenents/select-resource/index.tsx +++ b/src/compenents/select-resource/index.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import { Row, Modal, Tabs, Spin } from "antd"; +import { Row, Modal, Tabs } from "antd"; import styles from "./index.module.less"; import { UploadVideoSub } from "../../compenents"; import type { TabsProps } from "antd"; @@ -13,13 +13,11 @@ interface PropsInterface { export const SelectResource = (props: PropsInterface) => { const [refresh, setRefresh] = useState(true); - const [init, setInit] = useState(true); const [tabKey, setTabKey] = useState(1); const [selectKeys, setSelectKeys] = useState([]); const [selectVideos, setSelectVideos] = useState([]); useEffect(() => { - setInit(true); setRefresh(!refresh); }, [props.open]); @@ -28,10 +26,7 @@ export const SelectResource = (props: PropsInterface) => { key: "1", label: `视频`, children: ( -
+
{ setSelectKeys(arr); setSelectVideos(videos); }} - onSuccess={() => { - setInit(false); - }} />
), @@ -77,11 +69,6 @@ export const SelectResource = (props: PropsInterface) => { - {init && ( -
- -
- )} ) : null} diff --git a/src/compenents/upload-courseware-sub/index.tsx b/src/compenents/upload-courseware-sub/index.tsx index 013264b..9866ca2 100644 --- a/src/compenents/upload-courseware-sub/index.tsx +++ b/src/compenents/upload-courseware-sub/index.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import { Row, Col, Empty, Table } from "antd"; +import { Row, Col, Empty, Table, Spin } from "antd"; import type { ColumnsType } from "antd/es/table"; import { resource } from "../../api"; import styles from "./index.module.less"; @@ -34,10 +34,10 @@ interface PropsInterface { label: string; open: boolean; onSelected: (arr: any[], videos: []) => void; - onSuccess: () => void; } export const UploadCoursewareSub = (props: PropsInterface) => { + const [init, setInit] = useState(true); const [category_ids, setCategoryIds] = useState([]); const [loading, setLoading] = useState(false); const [videoList, setVideoList] = useState([]); @@ -50,6 +50,7 @@ export const UploadCoursewareSub = (props: PropsInterface) => { // 加载列表 useEffect(() => { + setInit(true); getvideoList(); }, [props.open, category_ids, refresh, page, size]); @@ -61,6 +62,7 @@ export const UploadCoursewareSub = (props: PropsInterface) => { // 获取列表 const getvideoList = () => { + setLoading(true); let categoryIds = category_ids.join(","); resource .resourceList( @@ -76,9 +78,12 @@ export const UploadCoursewareSub = (props: PropsInterface) => { setTotal(res.data.result.total); setExistingTypes(res.data.existing_types); setVideoList(res.data.result.data); - props.onSuccess(); + setLoading(false); + setInit(false); }) .catch((err) => { + setLoading(false); + setInit(false); console.log("错误,", err); }); }; @@ -154,12 +159,22 @@ export const UploadCoursewareSub = (props: PropsInterface) => { <> - setCategoryIds(keys)} - /> + {init && ( +
+ +
+ )} +
+ setCategoryIds(keys)} + /> +
@@ -172,7 +187,15 @@ export const UploadCoursewareSub = (props: PropsInterface) => { > -
+ {init && ( +
+ +
+ )} +
{videoList.length === 0 && ( diff --git a/src/compenents/upload-video-sub/index.tsx b/src/compenents/upload-video-sub/index.tsx index cd81a19..a503a75 100644 --- a/src/compenents/upload-video-sub/index.tsx +++ b/src/compenents/upload-video-sub/index.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import { Row, Col, Empty, Table } from "antd"; +import { Row, Col, Empty, Table, Spin } from "antd"; import type { ColumnsType } from "antd/es/table"; import { resource } from "../../api"; import styles from "./index.module.less"; @@ -35,10 +35,10 @@ interface PropsInterface { label: string; open: boolean; onSelected: (arr: any[], videos: []) => void; - onSuccess: () => void; } export const UploadVideoSub = (props: PropsInterface) => { + const [init, setInit] = useState(true); const [category_ids, setCategoryIds] = useState([]); const [loading, setLoading] = useState(false); const [videoList, setVideoList] = useState([]); @@ -51,6 +51,7 @@ export const UploadVideoSub = (props: PropsInterface) => { // 加载列表 useEffect(() => { + setInit(true); getvideoList(); }, [props.open, category_ids, refresh, page, size]); @@ -62,6 +63,7 @@ export const UploadVideoSub = (props: PropsInterface) => { // 获取列表 const getvideoList = () => { + setLoading(true); let categoryIds = category_ids.join(","); resource .resourceList(page, size, "", "", "", "VIDEO", categoryIds) @@ -69,9 +71,12 @@ export const UploadVideoSub = (props: PropsInterface) => { setTotal(res.data.result.total); setVideoExtra(res.data.videos_extra); setVideoList(res.data.result.data); - props.onSuccess(); + setLoading(false); + setInit(false); }) .catch((err) => { + setLoading(false); + setInit(false); console.log("错误,", err); }); }; @@ -154,12 +159,22 @@ export const UploadVideoSub = (props: PropsInterface) => { <> - setCategoryIds(keys)} - /> + {init && ( +
+ +
+ )} +
+ setCategoryIds(keys)} + /> +
@@ -172,7 +187,15 @@ export const UploadVideoSub = (props: PropsInterface) => { > -
+ {init && ( +
+ +
+ )} +
{videoList.length === 0 && (