线上课添加、编辑课时优化

This commit is contained in:
禺狨
2023-03-29 13:36:12 +08:00
parent 5f0c1f23de
commit 65a4045a8b
4 changed files with 64 additions and 30 deletions

View File

@@ -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([], []);
}