mirror of
https://github.com/PlayEdu/backend
synced 2025-06-21 10:32:45 +08:00
线上课新建、编辑优化
This commit is contained in:
parent
2b40133ed8
commit
11896ac9a2
@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Button, Row, Col, Modal, message, Tabs } from "antd";
|
||||
import { Button, Row, Modal, message, Tabs } from "antd";
|
||||
import styles from "./index.module.less";
|
||||
import { UploadVideoSub } from "../../compenents";
|
||||
import type { TabsProps } from "antd";
|
||||
|
@ -25,7 +25,7 @@ interface PropsInterface {
|
||||
|
||||
export const UploadVideoSub = (props: PropsInterface) => {
|
||||
const [category_ids, setCategoryIds] = useState<any>([]);
|
||||
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [videoList, setVideoList] = useState<VideoItem[]>([]);
|
||||
const [videosExtra, setVideoExtra] = useState<any>([]);
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
@ -39,7 +39,7 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
||||
const [checkAll, setCheckAll] = useState(false);
|
||||
|
||||
// 获取列表
|
||||
const getvideoList = () => {
|
||||
const getvideoList = (defaultKeys: any[]) => {
|
||||
let categoryIds = category_ids.join(",");
|
||||
resource
|
||||
.resourceList(page, size, "", "", "", "VIDEO", categoryIds)
|
||||
@ -69,8 +69,18 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
||||
</div>
|
||||
),
|
||||
value: data[i].id,
|
||||
disabled: false,
|
||||
});
|
||||
}
|
||||
if (defaultKeys.length > 0 && arr.length > 0) {
|
||||
for (let i = 0; i < defaultKeys.length; i++) {
|
||||
for (let j = 0; j < arr.length; j++) {
|
||||
if (arr[j].value === defaultKeys[i]) {
|
||||
arr[j].disabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setPlainOptions(arr);
|
||||
})
|
||||
.catch((err) => {
|
||||
@ -83,7 +93,8 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
||||
setVideoList([]);
|
||||
setRefresh(!refresh);
|
||||
};
|
||||
//重置选中的key
|
||||
|
||||
// 加载列表
|
||||
useEffect(() => {
|
||||
const arr = [...props.defaultCheckedList];
|
||||
setCheckedList(arr);
|
||||
@ -91,12 +102,8 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
||||
setIndeterminate(false);
|
||||
setCheckAll(false);
|
||||
}
|
||||
}, [props.defaultCheckedList]);
|
||||
|
||||
// 加载列表
|
||||
useEffect(() => {
|
||||
getvideoList();
|
||||
}, [props.open, category_ids, refresh, page, size]);
|
||||
getvideoList(arr);
|
||||
}, [props.open, props.defaultCheckedList, category_ids, refresh, page, size]);
|
||||
|
||||
const onChange = (list: CheckboxValueType[]) => {
|
||||
setCheckedList(list);
|
||||
@ -104,13 +111,14 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
||||
setCheckAll(list.length === plainOptions.length);
|
||||
let arrVideos: any = [];
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
videoList.map((item: any) => {
|
||||
videoList.map((item: any, index: number) => {
|
||||
if (item.id === list[i]) {
|
||||
arrVideos.push({
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
rid: item.id,
|
||||
duration: videosExtra[item.id].duration,
|
||||
disabled: plainOptions[index].disabled,
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -125,12 +133,13 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
||||
setIndeterminate(false);
|
||||
setCheckAll(e.target.checked);
|
||||
let arrVideos: any = [];
|
||||
videoList.map((item: any) => {
|
||||
videoList.map((item: any, index: number) => {
|
||||
arrVideos.push({
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
rid: item.id,
|
||||
duration: videosExtra[item.id].duration,
|
||||
disabled: plainOptions[index].disabled,
|
||||
});
|
||||
});
|
||||
if (e.target.checked) {
|
||||
@ -184,11 +193,6 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{/* {videoList.map((item) => (
|
||||
<div className={styles["video-item"]} key={item.id}>
|
||||
{item.name}
|
||||
</div>
|
||||
))} */}
|
||||
</div>
|
||||
<Row
|
||||
style={{
|
||||
|
@ -105,15 +105,18 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
||||
|
||||
const selectData = (arr: any, videos: any) => {
|
||||
const hours: any = [];
|
||||
console.log(videos);
|
||||
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,
|
||||
});
|
||||
if (videos[i].disabled === false) {
|
||||
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)
|
||||
@ -135,14 +138,16 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
||||
}
|
||||
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,
|
||||
});
|
||||
if (videos[i].disabled === false) {
|
||||
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)
|
||||
|
@ -80,7 +80,7 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
||||
let box = res.data.dep_ids;
|
||||
let depIds: any[] = [];
|
||||
let type = res.data.dep_ids.length > 0 ? "elective" : "open";
|
||||
if (box.length > 1) {
|
||||
if (box.length > 0) {
|
||||
for (let i = 0; i < box.length; i++) {
|
||||
let item = checkChild(deps, box[i]);
|
||||
let arr: any[] = [];
|
||||
|
@ -157,7 +157,6 @@ export const CoursePage = () => {
|
||||
{
|
||||
title: "必修/选修",
|
||||
dataIndex: "isRequired",
|
||||
width: 120,
|
||||
render: (isRequired: number) => (
|
||||
<span>{isRequired === 1 ? "必修课" : "选修课"}</span>
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user