mirror of
https://github.com/PlayEdu/backend
synced 2025-06-28 23:42:51 +08:00
线上课添加、编辑课时优化
This commit is contained in:
parent
5f0c1f23de
commit
65a4045a8b
@ -109,10 +109,19 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
||||
setCheckedList(list);
|
||||
setIndeterminate(!!list.length && list.length < plainOptions.length);
|
||||
setCheckAll(list.length === plainOptions.length);
|
||||
const defalut = [...props.defaultCheckedList];
|
||||
let localKeys: any = [];
|
||||
list.map((item: any) => {
|
||||
if (defalut.indexOf(item) === -1) {
|
||||
localKeys.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
let arrVideos: any = [];
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
|
||||
for (let i = 0; i < localKeys.length; i++) {
|
||||
videoList.map((item: any, index: number) => {
|
||||
if (item.id === list[i]) {
|
||||
if (item.id === localKeys[i]) {
|
||||
arrVideos.push({
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
@ -123,8 +132,7 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
props.onSelected(list, arrVideos);
|
||||
props.onSelected(localKeys, arrVideos);
|
||||
};
|
||||
|
||||
const onCheckAllChange = (e: CheckboxChangeEvent) => {
|
||||
@ -132,18 +140,29 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
||||
setCheckedList(e.target.checked ? arr : []);
|
||||
setIndeterminate(false);
|
||||
setCheckAll(e.target.checked);
|
||||
let arrVideos: 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,
|
||||
});
|
||||
const defalut = [...props.defaultCheckedList];
|
||||
let localKeys: any = [];
|
||||
arr.map((item: any) => {
|
||||
if (defalut.indexOf(item) === -1) {
|
||||
localKeys.push(item);
|
||||
}
|
||||
});
|
||||
let arrVideos: any = [];
|
||||
for (let i = 0; i < localKeys.length; i++) {
|
||||
videoList.map((item: any, index: number) => {
|
||||
if (item.id === localKeys[i]) {
|
||||
arrVideos.push({
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
rid: item.id,
|
||||
duration: videosExtra[item.id].duration,
|
||||
disabled: plainOptions[index].disabled,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (e.target.checked) {
|
||||
props.onSelected(arr, arrVideos);
|
||||
props.onSelected(localKeys, arrVideos);
|
||||
} else {
|
||||
props.onSelected([], []);
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
||||
setThumb(defaultThumb1);
|
||||
setChapterType(0);
|
||||
setChapters([]);
|
||||
setChapterHours([]);
|
||||
setHours([]);
|
||||
setTreeData([]);
|
||||
}, [form, open]);
|
||||
@ -213,16 +214,20 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
||||
};
|
||||
|
||||
const selectData = (arr: any, videos: any) => {
|
||||
setHours(arr);
|
||||
setTreeData(videos);
|
||||
let keys = [...hours];
|
||||
let data = [...treeData];
|
||||
keys = keys.concat(arr);
|
||||
data = data.concat(videos);
|
||||
setHours(keys);
|
||||
setTreeData(data);
|
||||
setVideoVisible(false);
|
||||
};
|
||||
|
||||
const selectChapterData = (arr: any, videos: any) => {
|
||||
const data = [...chapters];
|
||||
const keys = [...chapterHours];
|
||||
keys[addvideoCurrent] = arr;
|
||||
data[addvideoCurrent].hours = videos;
|
||||
keys[addvideoCurrent] = keys[addvideoCurrent].concat(arr);
|
||||
data[addvideoCurrent].hours = data[addvideoCurrent].hours.concat(videos);
|
||||
setChapters(data);
|
||||
setChapterHours(keys);
|
||||
setVideoVisible(false);
|
||||
@ -361,6 +366,16 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
||||
setChapters(data);
|
||||
};
|
||||
|
||||
const changeChapterHours = (arr: any) => {
|
||||
const newArr: any = [];
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
arr[i].map((item: any) => {
|
||||
newArr.push(item);
|
||||
});
|
||||
}
|
||||
return newArr;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer
|
||||
@ -381,7 +396,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
||||
<div className="float-left mt-24">
|
||||
<SelectResource
|
||||
defaultKeys={
|
||||
chapterType == 0 ? hours : chapterHours[addvideoCurrent]
|
||||
chapterType == 0 ? hours : changeChapterHours(chapterHours)
|
||||
}
|
||||
open={videoVisible}
|
||||
onCancel={() => {
|
||||
|
@ -346,6 +346,16 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
||||
});
|
||||
};
|
||||
|
||||
const changeChapterHours = (arr: any) => {
|
||||
const newArr: any = [];
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
arr[i].map((item: any) => {
|
||||
newArr.push(item);
|
||||
});
|
||||
}
|
||||
return newArr;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Drawer
|
||||
@ -362,7 +372,7 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
||||
<div className="float-left mt-24">
|
||||
<SelectResource
|
||||
defaultKeys={
|
||||
chapterType === 0 ? hours : chapterHours[addvideoCurrent]
|
||||
chapterType === 0 ? hours : changeChapterHours(chapterHours)
|
||||
}
|
||||
open={videoVisible}
|
||||
onCancel={() => {
|
||||
|
@ -96,16 +96,6 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
||||
});
|
||||
};
|
||||
|
||||
const checkChild = (departments: any[], id: number) => {
|
||||
for (let key in departments) {
|
||||
for (let i = 0; i < departments[key].length; i++) {
|
||||
if (departments[key][i].id === id) {
|
||||
return departments[key][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const checkArr = (departments: any[], id: number) => {
|
||||
const arr = [];
|
||||
for (let i = 0; i < departments[id].length; i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user