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