From faa03f19e021a917c1dc3506dec2dd963afbe4c8 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:01:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BF=E4=B8=8A=E8=AF=BE=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=92=8C=E8=AF=BE=E6=97=B6=E7=AE=A1=E7=90=86=E5=88=9D=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/course-chapter.ts | 16 +- src/api/course-hour.ts | 34 +- src/assets/iconfont/iconfont.css | 10 +- src/assets/iconfont/iconfont.ttf | Bin 7604 -> 7856 bytes src/assets/iconfont/iconfont.woff | Bin 4900 -> 5068 bytes src/assets/iconfont/iconfont.woff2 | Bin 4160 -> 4328 bytes src/index.less | 3 +- src/pages/course/compenents/create.tsx | 49 +- .../course/compenents/hour-update.module.less | 109 +++++ src/pages/course/compenents/hour-update.tsx | 462 ++++++++++++++++++ src/pages/course/compenents/update.tsx | 331 +------------ src/pages/course/index.tsx | 40 +- 12 files changed, 687 insertions(+), 367 deletions(-) create mode 100644 src/pages/course/compenents/hour-update.module.less create mode 100644 src/pages/course/compenents/hour-update.tsx diff --git a/src/api/course-chapter.ts b/src/api/course-chapter.ts index 7585d8c..62f29cf 100644 --- a/src/api/course-chapter.ts +++ b/src/api/course-chapter.ts @@ -1,11 +1,11 @@ import client from "./internal/httpClient"; export function courseChapterList(courseId: number) { - return client.get(`/backend/v1/course/${courseId}/course-chapter/index`, {}); + return client.get(`/backend/v1/course/${courseId}/chapter/index`, {}); } export function createCourseChapter(courseId: number) { - return client.get(`/backend/v1/course/${courseId}/course-chapter/create`, {}); + return client.get(`/backend/v1/course/${courseId}/chapter/create`, {}); } export function storeCourseChapter( @@ -13,7 +13,7 @@ export function storeCourseChapter( name: string, sort: number ) { - return client.post(`/backend/v1/course/${courseId}/course-chapter/create`, { + return client.post(`/backend/v1/course/${courseId}/chapter/create`, { name: name, sort: sort, }); @@ -29,12 +29,18 @@ export function updateCourseChapter( name: string, sort: number ) { - return client.post(`/backend/v1/course/${courseId}/course-chapter/${id}`, { + return client.put(`/backend/v1/course/${courseId}/chapter/${id}`, { name: name, sort: sort, }); } export function destroyCourseChapter(courseId: number, id: number) { - return client.destroy(`/backend/v1/course/${courseId}/course-chapter/${id}`); + return client.destroy(`/backend/v1/course/${courseId}/chapter/${id}`); +} + +export function transCourseChapter(courseId: number, ids: number[]) { + return client.put(`/backend/v1/course/${courseId}/chapter/update/sort`, { + ids: ids, + }); } diff --git a/src/api/course-hour.ts b/src/api/course-hour.ts index 207e8f1..cfc53dd 100644 --- a/src/api/course-hour.ts +++ b/src/api/course-hour.ts @@ -1,11 +1,11 @@ import client from "./internal/httpClient"; export function courseHourList(courseId: number) { - return client.get(`/backend/v1/course/${courseId}/course-hour/index`, {}); + return client.get(`/backend/v1/course/${courseId}/hour/index`, {}); } export function createCourseHour(courseId: number) { - return client.get(`/backend/v1/course/${courseId}/course-hour/create`, {}); + return client.get(`/backend/v1/course/${courseId}/hour/create`, {}); } export function storeCourseHour( @@ -14,19 +14,26 @@ export function storeCourseHour( title: string, type: string, druation: number, - publishedAt: string + rid: number ) { - return client.post(`/backend/v1/course/${courseId}/course-hour/create`, { + return client.post(`/backend/v1/course/${courseId}/hour/create`, { chapter_id: chapterId, title, type, druation, - published_at: publishedAt, + sort: 0, + rid, + }); +} + +export function storeCourseHourMulti(courseId: number, hours: number[]) { + return client.post(`/backend/v1/course/${courseId}/hour/create-batch`, { + hours: hours, }); } export function courseHour(courseId: number, id: number) { - return client.get(`/backend/v1/course/${courseId}/course-hour/${id}`, {}); + return client.get(`/backend/v1/course/${courseId}/hour/${id}`, {}); } export function updateCourseHour( @@ -36,17 +43,24 @@ export function updateCourseHour( title: string, type: string, druation: number, - publishedAt: string + rid: number ) { - return client.post(`/backend/v1/course/${courseId}/course-hour/${id}`, { + return client.put(`/backend/v1/course/${courseId}/hour/${id}`, { chapter_id: chapterId, title, type, druation, - published_at: publishedAt, + sort: 0, + rid, }); } export function destroyCourseHour(courseId: number, id: number) { - return client.destroy(`/backend/v1/course/${courseId}/course-hour/${id}`); + return client.destroy(`/backend/v1/course/${courseId}/hour/${id}`); +} + +export function transCourseHour(courseId: number, ids: number[]) { + return client.put(`/backend/v1/course/${courseId}/hour/update/sort`, { + ids: ids, + }); } diff --git a/src/assets/iconfont/iconfont.css b/src/assets/iconfont/iconfont.css index d5191f7..bfbcd32 100644 --- a/src/assets/iconfont/iconfont.css +++ b/src/assets/iconfont/iconfont.css @@ -1,8 +1,8 @@ @font-face { font-family: "iconfont"; /* Project id 3943555 */ - src: url('iconfont.woff2?t=1679377698528') format('woff2'), - url('iconfont.woff?t=1679377698528') format('woff'), - url('iconfont.ttf?t=1679377698528') format('truetype'); + src: url('iconfont.woff2?t=1679383201256') format('woff2'), + url('iconfont.woff?t=1679383201256') format('woff'), + url('iconfont.ttf?t=1679383201256') format('truetype'); } .iconfont { @@ -13,6 +13,10 @@ -moz-osx-font-smoothing: grayscale; } +.icon-icon-tips:before { + content: "\e74a"; +} + .icon-icon-fold:before { content: "\e749"; } diff --git a/src/assets/iconfont/iconfont.ttf b/src/assets/iconfont/iconfont.ttf index 4da2d9bd7c21b8752b9d5c3faa353449a455ca3c..ab333cf8a0e87ee4323d1a86cad26bfb96380c6e 100644 GIT binary patch delta 964 zcmYk4O-vI}5XWb>?Jn)wFS_lv+fqw`(jwS|)LlMX6hS2(NhETB@*yRm&;$<9OEuAi z5Mt1tJs3^&UE#`}}o(EdrHb6K+0q06f z%PY5S>puY+ZqlLDo!zFKACS%xgPW&%C)|C%LAKHcrI3>wkH=cARtXxG8?>$i!Q7>0 z>ipFxmIUjc>K5j3q`HU6>MtB0FCQ5JR={#JYp2mciZWQ?BFU`uk(`axYSbHMPir%- z6I|d14|t&-e4xMyu#-{-8;BrLaO=)vp&lz{?4zcbdJbuUb#cfGux<|d1J=VK&%k;) z6a!cvhoS-N=TKZ=Sq^0Yj2^^r3!42LrDWW&!O~z4RPoq zz=k<=C14jgW&s$L$Ak(7>=MVUI2+;c!cu%#fGzlIEnD|&9@|4PCeDb@q!DSO&QN6*2AQ!_m{_d@|^i{IghhTCJZ5{xK5 zM3*bl7}1jo3hu^^(B)K&DnLI$?W1MQk~Ck^hFQ!cTJbcx(C<~EsN+k#@1}M*;Y+t^ zT3gzOqjJ1CF5{?MR8s1}n40v{v+M+I_f+&(Uqq5l41j%pdTFs^Wxljr{T%u5589`@ APXGV_ delta 714 zcmXw$%WG3X6vn?vZr-tv^fot?q)4mHRZ9esM$OCAwl?CzosWfWY-$50HfR=cV{qX{ zgjS+UK_Z9?kz&<_^p7a03sJ${xNvD*S+Cz@bS}S{IcLuMZscBP*2mj%K->qgxKuAU zzJDzS0aupPR%*AdF0|5XfbjtszEE8*SJLkf7is&AOjW6fo7N}Zx5&O~z1gbFI)51N z2jz3M)ur=-xa0Bk%ZIUP37A+W&eMWWV5qWWR zA}J=u`o!>{IVz5b{jO_fG-~cXGE=r?*{PgphLWjdNHoJy+uDs;c68J4eQXJ{^DJQt JbUr6O{sod!kjwx8 diff --git a/src/assets/iconfont/iconfont.woff b/src/assets/iconfont/iconfont.woff index a7f521eb586266fd9907af7f55d8b1bb2920accf..2830f65bcf00ac5ee97bcc748ab2940cea901782 100644 GIT binary patch delta 4670 zcmV-E62a}HCd?-kcTYw}00961000xr01E&B0017akrY3F5o2v(Z~y=ShyVZpz5oCM zdJC-V>St_uW&i*JNB{s1$p8QrG>8+%&uC>~WB>pW6aWAKF#rGnHaF8+KWJ!WVE_OT zNB{r;AOHXWBpehM+GuTbcmMzqXaE2J82|tPRA@#2{%mh!VE_OTga7~lEC2uiEI+PB zl5JslZ~y={5wHLN03QGV03ZQA0)=j2ZDjxe5zqht0YCr%0%s7TJg{(Yb94Xz6A%CZ z0J{JH0V$3Ji1U*O0YQKH&NzXAm4Sh&lj#ft14BQ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E1e9cXhxDR&uvU=8*(mpBi`ql?>FMORIqkM7o}@q7)ZEhA*51+C)!ozE*PkbE zzWfF3j!Bc=QZyUKH@iSnN9NYKu+Oql#KD$aYimLS)FelZI K*NWt*N!J18*A^52 diff --git a/src/index.less b/src/index.less index a4b3a11..652d94e 100644 --- a/src/index.less +++ b/src/index.less @@ -213,14 +213,13 @@ code { height: 40px; border-radius: 6px; font-size: 14px; - font-weight: 500; color: rgba(0, 0, 0, 0.88); line-height: 40px; box-sizing: border-box; padding-left: 16px; cursor: pointer; &.active { - background: rgba(#ff4d4f, 0.1); + background-color: #fff2f0; } } diff --git a/src/pages/course/compenents/create.tsx b/src/pages/course/compenents/create.tsx index 486a1ee..9522e60 100644 --- a/src/pages/course/compenents/create.tsx +++ b/src/pages/course/compenents/create.tsx @@ -168,26 +168,31 @@ export const CourseCreate: React.FC = ({ open, onCancel }) => { }; const getChapterType = (e: any) => { - confirm({ - title: "操作确认", - icon: , - content: "切换列表选项会清空已添加课时,确认切换?", - centered: true, - okText: "确认", - cancelText: "取消", - onOk() { - setChapterType(e.target.value); - setChapters([]); - setHours([]); - setChapterHours([]); - setTreeData([]); - }, - onCancel() { - form.setFieldsValue({ - hasChapter: chapterType, - }); - }, - }); + const arr = [...chapters]; + if (arr.length > 0) { + confirm({ + title: "操作确认", + icon: , + content: "切换列表选项会清空已添加课时,确认切换?", + centered: true, + okText: "确认", + cancelText: "取消", + onOk() { + setChapterType(e.target.value); + setChapters([]); + setHours([]); + setChapterHours([]); + setTreeData([]); + }, + onCancel() { + form.setFieldsValue({ + hasChapter: chapterType, + }); + }, + }); + } else { + setChapterType(e.target.value); + } }; const delHour = (id: number) => { @@ -378,7 +383,9 @@ export const CourseCreate: React.FC = ({ open, onCancel }) => { rules={[{ required: true, message: "请选择课程类型!" }]} > - 公开课 + + 公开课 + 部门课 diff --git a/src/pages/course/compenents/hour-update.module.less b/src/pages/course/compenents/hour-update.module.less new file mode 100644 index 0000000..80e90f4 --- /dev/null +++ b/src/pages/course/compenents/hour-update.module.less @@ -0,0 +1,109 @@ +.top-content { + width: 502px; + height: 80px; + background: rgba(255, 77, 79, 0.1); + border-radius: 6px; + display: flex; + flex-direction: column; + justify-content: center; + box-sizing: border-box; + padding: 16px; + margin: 0 auto; + p { + font-size: 14px; + font-weight: 400; + color: #ff4d4f; + line-height: 24px; + margin: 0; + } +} + +.thumb-item { + width: 80px; + height: 60px; + cursor: pointer; + margin-right: 8px; + border-radius: 6px; + &:last-child { + margin-right: 0; + } +} + +.thumb-item-avtive { + width: 80px; + height: 60px; + border: 2px solid #ff4d4f; + cursor: pointer; + margin-right: 8px; + border-radius: 8px; + &:last-child { + margin-right: 0; + } +} + +.hous-box { + width: 502px; + min-height: 56px; + background: #ffffff; + border-radius: 6px; + border: 1px solid rgba(0, 0, 0, 0.15); + box-sizing: border-box; + -moz-box-sizing: border-box; + /* Firefox */ + -webkit-box-sizing: border-box; + /* Safari */ + padding: 16px 16px 16px 0; + margin-left: 42px; + .no-hours { + height: 24px; + font-size: 14px; + font-weight: 400; + color: rgba(0, 0, 0, 0.25); + line-height: 24px; + margin-left: 16px; + } +} + +.chapter-item { + width: 502px; + height: auto; + display: flex; + flex-direction: column; + margin-left: 42px; + margin-bottom: 16px; + .label { + width: 78px; + height: 32px; + font-size: 14px; + font-weight: 400; + color: rgba(0, 0, 0, 0.85); + line-height: 32px; + } + .input { + width: 208px; + height: 32px; + margin-right: 24px; + } + .chapter-hous-box { + width: 502px; + min-height: 56px; + background: #ffffff; + border-radius: 6px; + border: 1px solid rgba(0, 0, 0, 0.15); + box-sizing: border-box; + -moz-box-sizing: border-box; + /* Firefox */ + -webkit-box-sizing: border-box; + /* Safari */ + padding: 16px 16px 16px 0; + margin-top: 16px; + .no-hours { + height: 24px; + font-size: 14px; + font-weight: 400; + color: rgba(0, 0, 0, 0.25); + line-height: 24px; + margin-left: 16px; + } + } +} diff --git a/src/pages/course/compenents/hour-update.tsx b/src/pages/course/compenents/hour-update.tsx new file mode 100644 index 0000000..7602371 --- /dev/null +++ b/src/pages/course/compenents/hour-update.tsx @@ -0,0 +1,462 @@ +import React, { useState, useEffect } from "react"; +import { Space, Button, Drawer, Form, Input, Modal, message } from "antd"; +import styles from "./hour-update.module.less"; +import { course, courseHour, courseChapter } from "../../../api/index"; +import { SelectResource } from "../../../compenents"; +import { ExclamationCircleFilled } from "@ant-design/icons"; +import { TreeHours } from "./hours"; + +const { confirm } = Modal; + +interface PropInterface { + id: number; + open: boolean; + onCancel: () => void; +} + +interface Option { + value: string | number; + label: string; + children?: Option[]; +} + +export const CourseHourUpdate: React.FC = ({ + id, + open, + onCancel, +}) => { + const [form] = Form.useForm(); + const [chapterType, setChapterType] = useState(0); + const [chapters, setChapters] = useState([]); + const [hours, setHours] = useState([]); + const [chapterHours, setChapterHours] = useState([]); + const [videoVisible, setVideoVisible] = useState(false); + const [treeData, setTreeData] = useState([]); + const [addvideoCurrent, setAddvideoCurrent] = useState(0); + + useEffect(() => { + if (id === 0) { + return; + } + getDetail(); + }, [id]); + + const getDetail = () => { + course.course(id).then((res: any) => { + let chapterType = res.data.chapters.length > 0 ? 1 : 0; + setChapterType(chapterType); + if (chapterType === 1) { + setTreeData([]); + setHours([]); + let hours = res.data.hours; + let chapters = res.data.chapters; + const arr: any = []; + const keys: any = []; + for (let i = 0; i < chapters.length; i++) { + arr.push({ + id: chapters[i].id, + name: chapters[i].name, + hours: resetHours(hours[chapters[i].id]).arr, + }); + keys.push(resetHours(hours[chapters[i].id]).keys); + } + setChapters(arr); + setChapterHours(keys); + } else { + setChapters([]); + setChapterHours([]); + let hours = res.data.hours; + if (JSON.stringify(hours) !== "{}") { + const arr: any = resetHours(hours[0]).arr; + const keys: any = resetHours(hours[0]).keys; + setTreeData(arr); + setHours(keys); + } else { + setTreeData([]); + setHours([]); + } + } + }); + }; + + const resetHours = (data: any) => { + const arr: any = []; + const keys: any = []; + if (data) { + for (let i = 0; i < data.length; i++) { + arr.push({ + duration: data[i].duration, + type: data[i].type, + name: data[i].title, + rid: data[i].rid, + id: data[i].id, + }); + keys.push(data[i].rid); + } + } + return { arr, keys }; + }; + + const onFinish = (values: any) => {}; + + const onFinishFailed = (errorInfo: any) => { + console.log("Failed:", errorInfo); + }; + + const selectData = (arr: any, videos: any) => { + const hours: any = []; + for (let i = 0; i < videos.length; i++) { + hours.push({ + chapter_id: 0, + sort: i, + title: videos[i].name, + type: videos[i].type, + duration: videos[i].duration, + rid: videos[i].rid, + }); + } + courseHour + .storeCourseHourMulti(id, hours) + .then((res: any) => { + console.log("ok"); + setVideoVisible(false); + getDetail(); + }) + .catch((err) => { + message.error(err.message); + }); + }; + + const selectChapterData = (arr: any, videos: any) => { + const data = [...chapters]; + if (!data[addvideoCurrent].id) { + message.error("添加课时失败"); + return; + } + const hours: any = []; + for (let i = 0; i < videos.length; i++) { + hours.push({ + chapter_id: data[addvideoCurrent].id, + sort: i, + title: videos[i].name, + type: videos[i].type, + duration: videos[i].duration, + rid: videos[i].rid, + }); + } + courseHour + .storeCourseHourMulti(id, hours) + .then((res: any) => { + console.log("ok"); + setVideoVisible(false); + getDetail(); + }) + .catch((err) => { + message.error(err.message); + }); + }; + + const delHour = (hid: number) => { + const data = [...treeData]; + const index = data.findIndex((i: any) => i.rid === hid); + let delId = data[index].id; + if (index >= 0) { + data.splice(index, 1); + } + if (data.length > 0) { + setTreeData(data); + const keys = data.map((item: any) => item.rid); + setHours(keys); + } else { + setTreeData([]); + setHours([]); + } + if (delId) { + courseHour.destroyCourseHour(id, delId).then((res: any) => { + console.log("ok"); + }); + } + }; + + const transHour = (arr: any) => { + setHours(arr); + const data = [...treeData]; + const newArr: any = []; + const hourIds: any = []; + for (let i = 0; i < arr.length; i++) { + data.map((item: any) => { + if (item.rid === arr[i]) { + newArr.push(item); + hourIds.push(item.id); + } + }); + } + setTreeData(newArr); + courseHour.transCourseHour(id, hourIds).then((res: any) => { + console.log("ok"); + }); + }; + + const addNewChapter = () => { + const arr = [...chapters]; + const keys = [...chapterHours]; + arr.push({ + name: "", + hours: [], + }); + keys.push([]); + setChapters(arr); + setChapterHours(keys); + }; + + const setChapterName = (index: number, value: string) => { + const arr = [...chapters]; + arr[index].name = value; + setChapters(arr); + }; + + const saveChapterName = (index: number, value: string) => { + const arr = [...chapters]; + if (arr[index].id) { + courseChapter + .updateCourseChapter(id, arr[index].id, value, arr.length) + .then((res: any) => { + console.log("ok"); + getDetail(); + }) + .catch((err) => { + message.error(err.message); + }); + } else { + courseChapter + .storeCourseChapter(id, value, arr.length) + .then((res: any) => { + console.log("ok"); + getDetail(); + }) + .catch((err) => { + message.error(err.message); + }); + } + }; + + const delChapter = (index: number) => { + const arr = [...chapters]; + const keys = [...chapterHours]; + confirm({ + title: "操作确认", + icon: , + content: "删除章节会清空已添加课时,确认删除?", + centered: true, + okText: "确认", + cancelText: "取消", + onOk() { + if (arr[index].id) { + courseChapter + .destroyCourseChapter(id, arr[index].id) + .then((res: any) => { + console.log("ok"); + getDetail(); + }) + .catch((err) => { + message.error(err.message); + }); + } + }, + onCancel() {}, + }); + }; + + const delChapterHour = (index: number, hid: number) => { + const keys = [...chapterHours]; + const data = [...chapters]; + const current = data[index].hours.findIndex((i: any) => i.rid === hid); + let delId = data[index].hours.map((item: any) => item.id); + if (current >= 0) { + data[index].hours.splice(current, 1); + } + if (data[index].hours.length > 0) { + setChapters(data); + keys[index] = data[index].hours.map((item: any) => item.rid); + setChapterHours(keys); + } else { + keys[index] = []; + data[index].hours = []; + setChapters(data); + setChapterHours(keys); + } + + if (delId) { + courseHour.destroyCourseHour(id, delId).then((res: any) => { + console.log("ok"); + }); + } + }; + + const transChapterHour = (index: number, arr: any) => { + const keys = [...chapterHours]; + keys[index] = arr; + setChapterHours(keys); + + const data = [...chapters]; + const newArr: any = []; + const hourIds: any = []; + for (let i = 0; i < arr.length; i++) { + data[index].hours.map((item: any) => { + if (item.rid === arr[i]) { + newArr.push(item); + hourIds.push(item.id); + } + }); + } + data[index].hours = newArr; + setChapters(data); + courseHour.transCourseHour(id, hourIds).then((res: any) => { + console.log("ok"); + }); + }; + + return ( + <> + +
+

1.线上课课时调整及时生效,操作不可逆,请谨慎操作。

+

2.课时调整后,已有学习进度会在学员学习时重新计算。

+
+
+ { + setVideoVisible(false); + }} + onSelected={(arr: any, videos: any) => { + if (chapterType == 0) { + selectData(arr, videos); + } else { + selectChapterData(arr, videos); + } + }} + /> +
+ {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 ( +
+
+
+ 章节{index + 1}: +
+ { + setChapterName(index, e.target.value); + }} + onBlur={(e) => { + saveChapterName(index, e.target.value); + }} + placeholder="请在此处输入章节名称" + /> + + +
+
+ {item.hours.length === 0 && ( + + 请点击上方按钮添加课时 + + )} + {item.hours.length > 0 && ( + { + delChapterHour(index, id); + }} + onUpdate={(arr: any[]) => { + transChapterHour(index, arr); + }} + /> + )} +
+
+ ); + })} + +
+ +
+
+
+ )} +
+
+
+ + ); +}; diff --git a/src/pages/course/compenents/update.tsx b/src/pages/course/compenents/update.tsx index b29605d..1cb7235 100644 --- a/src/pages/course/compenents/update.tsx +++ b/src/pages/course/compenents/update.tsx @@ -13,10 +13,8 @@ import { } from "antd"; import styles from "./update.module.less"; import { course, department } from "../../../api/index"; -import { UploadImageButton, SelectResource } from "../../../compenents"; -import { ExclamationCircleFilled } from "@ant-design/icons"; +import { UploadImageButton } from "../../../compenents"; import { getHost } from "../../../utils/index"; -import { TreeHours } from "./hours"; const { confirm } = Modal; @@ -46,13 +44,6 @@ export const CourseUpdate: React.FC = ({ const [categories, setCategories] = useState([]); const [thumb, setThumb] = useState(""); const [type, setType] = useState("open"); - const [chapterType, setChapterType] = useState(0); - const [chapters, setChapters] = useState([]); - const [hours, setHours] = useState([]); - const [chapterHours, setChapterHours] = useState([]); - const [videoVisible, setVideoVisible] = useState(false); - const [treeData, setTreeData] = useState([]); - const [addvideoCurrent, setAddvideoCurrent] = useState(0); useEffect(() => { if (id === 0) { @@ -143,55 +134,9 @@ export const CourseUpdate: React.FC = ({ }); setType(type); setThumb(res.data.course.thumb); - setChapterType(chapterType); - if (chapterType === 1) { - setTreeData([]); - setHours([]); - let hours = res.data.hours; - let chapters = res.data.chapters; - const arr: any = []; - const keys: any = []; - for (let i = 0; i < chapters.length; i++) { - arr.push({ - name: chapters[i].name, - hours: resetHours(hours[chapters[i].id]).arr, - }); - keys.push(resetHours(hours[chapters[i].id]).keys); - } - setChapters(arr); - setChapterHours(keys); - } else { - setChapters([]); - setChapterHours([]); - let hours = res.data.hours; - if (JSON.stringify(hours) !== "{}") { - const arr: any = resetHours(hours[0]).arr; - const keys: any = resetHours(hours[0]).keys; - setTreeData(arr); - setHours(keys); - } else { - setTreeData([]); - setHours([]); - } - } }); }; - const resetHours = (data: any) => { - const arr: any = []; - const keys: any = []; - for (let i = 0; i < data.length; i++) { - arr.push({ - duration: data[i].duration, - type: data[i].type, - name: data[i].title, - rid: data[i].rid, - }); - keys.push(data[i].rid); - } - return { arr, keys }; - }; - const checkChild = (departments: any[], id: number) => { for (let key in departments) { for (let i = 0; i < departments[key].length; i++) { @@ -247,8 +192,8 @@ export const CourseUpdate: React.FC = ({ values.isRequired, dep_ids, category_ids, - chapters, - treeData + [], + [] ) .then((res: any) => { message.success("保存成功!"); @@ -264,150 +209,6 @@ export const CourseUpdate: React.FC = ({ setType(e.target.value); }; - const selectData = (arr: any, videos: any) => { - setHours(arr); - setTreeData(videos); - setVideoVisible(false); - }; - - const selectChapterData = (arr: any, videos: any) => { - const data = [...chapters]; - const keys = [...chapterHours]; - keys[addvideoCurrent] = arr; - data[addvideoCurrent].hours = videos; - setChapters(data); - setChapterHours(keys); - setVideoVisible(false); - }; - - const getChapterType = (e: any) => { - confirm({ - title: "操作确认", - icon: , - content: "切换列表选项会清空已添加课时,确认切换?", - centered: true, - okText: "确认", - cancelText: "取消", - onOk() { - setChapterType(e.target.value); - setChapters([]); - setHours([]); - setChapterHours([]); - setTreeData([]); - }, - onCancel() { - form.setFieldsValue({ - hasChapter: chapterType, - }); - }, - }); - }; - - const delHour = (id: number) => { - const data = [...treeData]; - const index = data.findIndex((i: any) => i.rid === id); - if (index >= 0) { - data.splice(index, 1); - } - if (data.length > 0) { - setTreeData(data); - const keys = data.map((item: any) => item.rid); - setHours(keys); - } else { - setTreeData([]); - setHours([]); - } - }; - - const transHour = (arr: any) => { - setHours(arr); - const data = [...treeData]; - const newArr: any = []; - for (let i = 0; i < arr.length; i++) { - data.map((item: any) => { - if (item.rid === arr[i]) { - newArr.push(item); - } - }); - } - setTreeData(newArr); - }; - - const addNewChapter = () => { - const arr = [...chapters]; - const keys = [...chapterHours]; - arr.push({ - name: "", - hours: [], - }); - keys.push([]); - setChapters(arr); - setChapterHours(keys); - }; - - const setChapterName = (index: number, value: string) => { - const arr = [...chapters]; - arr[index].name = value; - setChapters(arr); - }; - - const delChapter = (index: number) => { - const arr = [...chapters]; - const keys = [...chapterHours]; - confirm({ - title: "操作确认", - icon: , - content: "删除章节会清空已添加课时,确认删除?", - centered: true, - okText: "确认", - cancelText: "取消", - onOk() { - arr.splice(index, 1); - keys.splice(index, 1); - setChapters(arr); - setChapterHours(keys); - }, - onCancel() {}, - }); - }; - - const delChapterHour = (index: number, id: number) => { - const keys = [...chapterHours]; - const data = [...chapters]; - const current = data[index].hours.findIndex((i: any) => i.rid === id); - if (current >= 0) { - data[index].hours.splice(current, 1); - } - if (data[index].hours.length > 0) { - setChapters(data); - keys[index] = data[index].hours.map((item: any) => item.rid); - setChapterHours(keys); - } else { - keys[index] = []; - data[index].hours = []; - setChapters(data); - setChapterHours(keys); - } - }; - - const transChapterHour = (index: number, arr: any) => { - const keys = [...chapterHours]; - keys[index] = arr; - setChapterHours(keys); - - const data = [...chapters]; - const newArr: any = []; - for (let i = 0; i < arr.length; i++) { - data[index].hours.map((item: any) => { - if (item.rid === arr[i]) { - newArr.push(item); - } - }); - } - data[index].hours = newArr; - setChapters(data); - }; - return ( <> = ({ width={634} >
- { - setVideoVisible(false); - }} - onSelected={(arr: any, videos: any) => { - if (chapterType == 0) { - selectData(arr, videos); - } else { - selectChapterData(arr, videos); - } - }} - />
= ({ rules={[{ required: true, message: "请选择课程类型!" }]} > - 公开课 + + 公开课 + + 部门课 @@ -617,111 +405,6 @@ export const CourseUpdate: React.FC = ({ placeholder="请输入课程简介" /> - - - 无章节 - 有章节 - - - {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 ( -
-
-
- 章节{index + 1}: -
- { - setChapterName(index, e.target.value); - }} - placeholder="请在此处输入章节名称" - /> - - -
-
- {item.hours.length === 0 && ( - - 请点击上方按钮添加课时 - - )} - {item.hours.length > 0 && ( - { - delChapterHour(index, id); - }} - onUpdate={(arr: any[]) => { - transChapterHour(index, arr); - }} - /> - )} -
-
- ); - })} - -
- -
-
-
- )}
diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index 5d65b87..5431178 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -10,7 +10,7 @@ import { Space, Tabs, } from "antd"; -import { course, department, resourceCategory } from "../../api"; +import { course } from "../../api"; import styles from "./index.module.less"; import { PlusOutlined, ExclamationCircleFilled } from "@ant-design/icons"; import type { ColumnsType } from "antd/es/table"; @@ -20,6 +20,7 @@ import { TreeDepartment, TreeCategory, PerButton } from "../../compenents"; import type { TabsProps } from "antd"; import { CourseCreate } from "./compenents/create"; import { CourseUpdate } from "./compenents/update"; +import { CourseHourUpdate } from "./compenents/hour-update"; const { confirm } = Modal; @@ -50,6 +51,7 @@ export const CoursePage = () => { const [createVisible, setCreateVisible] = useState(false); const [updateVisible, setUpdateVisible] = useState(false); + const [updateHourVisible, setHourUpdateVisible] = useState(false); const [cid, setCid] = useState(0); const items: TabsProps["items"] = [ @@ -133,9 +135,35 @@ export const CoursePage = () => { title: "操作", key: "action", fixed: "right", - width: 100, + width: 210, render: (_, record: any) => ( + { + setCid(Number(record.id)); + console.log("学员" + record.id); + }} + disabled={null} + /> +
+ { + setCid(Number(record.id)); + setHourUpdateVisible(true); + }} + disabled={null} + /> +
{ setRefresh(!refresh); }} /> + { + setHourUpdateVisible(false); + setRefresh(!refresh); + }} + />