mirror of
https://github.com/PlayEdu/backend
synced 2025-06-18 04:08:29 +08:00
线上课编辑章节名时逻辑优化
This commit is contained in:
parent
d06214aec0
commit
7d37329713
@ -234,7 +234,7 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
|||||||
const arr = [...chapters];
|
const arr = [...chapters];
|
||||||
if (arr[index].id) {
|
if (arr[index].id) {
|
||||||
courseChapter
|
courseChapter
|
||||||
.updateCourseChapter(id, Number(arr[index].id), value, arr.length)
|
.updateCourseChapter(id, Number(arr[index].id), value, index + 1)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
console.log("ok");
|
console.log("ok");
|
||||||
getDetail();
|
getDetail();
|
||||||
|
@ -96,23 +96,35 @@ export const TreeHours = (props: PropInterface) => {
|
|||||||
|
|
||||||
// Find dragObject
|
// Find dragObject
|
||||||
let dragObj: DataNode;
|
let dragObj: DataNode;
|
||||||
loop(data, dragKey, (item, index, arr) => {
|
let dragLength = (info.dragNode as any).props.pos.split("-").length;
|
||||||
arr.splice(index, 1);
|
let dropLength = (info.node as any).props.pos.split("-").length;
|
||||||
dragObj = item;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!info.dropToGap) {
|
if (!info.dropToGap) {
|
||||||
// Drop on the content
|
// Drop on the content
|
||||||
loop(data, dropKey, (item) => {
|
if (
|
||||||
item.children = item.children || [];
|
(dropPosition == 0 && dropPos.length == 3) ||
|
||||||
// where to insert 示例添加到头部,可以是随意位置
|
(dropPosition == 0 && dropPos.length == 2 && dragLength == 2)
|
||||||
item.children.unshift(dragObj);
|
) {
|
||||||
});
|
} else {
|
||||||
|
loop(data, dragKey, (item, index, arr) => {
|
||||||
|
arr.splice(index, 1);
|
||||||
|
dragObj = item;
|
||||||
|
});
|
||||||
|
loop(data, dropKey, (item) => {
|
||||||
|
item.children = item.children || [];
|
||||||
|
// where to insert 示例添加到头部,可以是随意位置
|
||||||
|
item.children.unshift(dragObj);
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (
|
} else if (
|
||||||
((info.node as any).props.children || []).length > 0 && // Has children
|
((info.node as any).props.children || []).length > 0 && // Has children
|
||||||
(info.node as any).props.expanded && // Is expanded
|
(info.node as any).props.expanded && // Is expanded
|
||||||
dropPosition === 1 // On the bottom gap
|
dropPosition === 1 // On the bottom gap
|
||||||
) {
|
) {
|
||||||
|
loop(data, dragKey, (item, index, arr) => {
|
||||||
|
arr.splice(index, 1);
|
||||||
|
dragObj = item;
|
||||||
|
});
|
||||||
loop(data, dropKey, (item) => {
|
loop(data, dropKey, (item) => {
|
||||||
item.children = item.children || [];
|
item.children = item.children || [];
|
||||||
// where to insert 示例添加到头部,可以是随意位置
|
// where to insert 示例添加到头部,可以是随意位置
|
||||||
@ -121,6 +133,16 @@ export const TreeHours = (props: PropInterface) => {
|
|||||||
// item to the tail of the children
|
// item to the tail of the children
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
if (
|
||||||
|
(dragLength == 3 && dropLength == 2) ||
|
||||||
|
(dragLength == 2 && dropLength == 3)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loop(data, dragKey, (item, index, arr) => {
|
||||||
|
arr.splice(index, 1);
|
||||||
|
dragObj = item;
|
||||||
|
});
|
||||||
let ar: DataNode[] = [];
|
let ar: DataNode[] = [];
|
||||||
let i: number;
|
let i: number;
|
||||||
loop(data, dropKey, (_item, index, arr) => {
|
loop(data, dropKey, (_item, index, arr) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user