diff --git a/src/pages/course/compenents/attachment-update.tsx b/src/pages/course/compenents/attachment-update.tsx index 3fd7867..76a4541 100644 --- a/src/pages/course/compenents/attachment-update.tsx +++ b/src/pages/course/compenents/attachment-update.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from "react"; -import { Button, Drawer, Form, Modal, message } from "antd"; +import { Button, Drawer, Form, Modal, message, Spin } from "antd"; import styles from "./hour-update.module.less"; import { course, courseAttachment } from "../../../api/index"; import { SelectAttachment } from "../../../compenents"; @@ -20,11 +20,13 @@ export const CourseAttachmentUpdate: React.FC = ({ onCancel, }) => { const [form] = Form.useForm(); + const [init, setInit] = useState(true); const [attachmentVisible, setAttachmentVisible] = useState(false); const [attachmentData, setAttachmentData] = useState([]); const [attachments, setAttachments] = useState([]); useEffect(() => { + setInit(true); if (id === 0) { return; } @@ -43,6 +45,7 @@ export const CourseAttachmentUpdate: React.FC = ({ setAttachmentData(arr); setAttachments(keys); } + setInit(false); }); }; @@ -169,47 +172,57 @@ export const CourseAttachmentUpdate: React.FC = ({ selectAttachmentData(arr, videos); }} > -
-
- -
- -
-
-
- {attachmentData.length === 0 && ( - - 请点击上方按钮添加课件 - - )} - {attachmentData.length > 0 && ( - { - delAttachments(id); - }} - onUpdate={(arr: any[]) => { - transAttachments(arr); - }} - /> - )} -
+ {init && ( +
+
- + )} +
+
+
+ +
+ +
+
+
+ {attachmentData.length === 0 && ( + + 请点击上方按钮添加课件 + + )} + {attachmentData.length > 0 && ( + { + delAttachments(id); + }} + onUpdate={(arr: any[]) => { + transAttachments(arr); + }} + /> + )} +
+
+
+
) : null} diff --git a/src/pages/course/compenents/hour-update.tsx b/src/pages/course/compenents/hour-update.tsx index 90d1958..e3d5361 100644 --- a/src/pages/course/compenents/hour-update.tsx +++ b/src/pages/course/compenents/hour-update.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from "react"; -import { Button, Drawer, Form, Input, Modal, message } from "antd"; +import { Button, Drawer, Form, Input, Modal, message, Spin } from "antd"; import styles from "./hour-update.module.less"; import { course, courseHour, courseChapter } from "../../../api/index"; import { SelectResource } from "../../../compenents"; @@ -20,6 +20,7 @@ export const CourseHourUpdate: React.FC = ({ onCancel, }) => { const [form] = Form.useForm(); + const [init, setInit] = useState(true); const [chapterType, setChapterType] = useState(0); const [chapters, setChapters] = useState([]); const [hours, setHours] = useState([]); @@ -29,6 +30,7 @@ export const CourseHourUpdate: React.FC = ({ const [addvideoCurrent, setAddvideoCurrent] = useState(0); useEffect(() => { + setInit(true); if (id === 0) { return; } @@ -77,6 +79,7 @@ export const CourseHourUpdate: React.FC = ({ setHours([]); } } + setInit(false); }); }; @@ -373,117 +376,129 @@ export const CourseHourUpdate: React.FC = ({ } }} /> -
+ + + )} +
- {chapterType === 0 && ( -
- -
- -
-
-
- {treeData.length === 0 && ( - - 请点击上方按钮添加课时 - - )} - {treeData.length > 0 && ( - { - delHour(id); - }} - onUpdate={(arr: any[]) => { - transHour(arr); - }} - /> - )} -
-
- )} - {chapterType === 1 && ( -
- {chapters.length > 0 && - chapters.map((item: any, index: number) => { - return ( -
+ {chapterType === 0 && ( +
+ +
+ - -
-
- {item.hours.length === 0 && ( - - 请点击上方按钮添加课时 - - )} - {item.hours.length > 0 && ( - { - delChapterHour(index, id); - }} - onUpdate={(arr: any[]) => { - transChapterHour(index, arr); - }} - /> - )} -
-
- ); - })} - -
- + 添加课时 + +
+
+
+ {treeData.length === 0 && ( + + 请点击上方按钮添加课时 + + )} + {treeData.length > 0 && ( + { + delHour(id); + }} + onUpdate={(arr: any[]) => { + transHour(arr); + }} + /> + )}
- -
- )} - +
+ )} + {chapterType === 1 && ( +
+ {chapters.length > 0 && + chapters.map((item: any, index: number) => { + return ( +
+
+
+ 章节{index + 1}: +
+ { + setChapterName(index, e.target.value); + }} + onBlur={(e) => { + saveChapterName(index, e.target.value); + }} + placeholder="请在此处输入章节名称" + allowClear + /> + + +
+
+ {item.hours.length === 0 && ( + + 请点击上方按钮添加课时 + + )} + {item.hours.length > 0 && ( + { + delChapterHour(index, id); + }} + onUpdate={(arr: any[]) => { + transChapterHour(index, arr); + }} + /> + )} +
+
+ ); + })} + +
+ +
+
+
+ )} + +
) : null}