From 7d37329713f5f23fcf21c5a214974e68f3df5e66 Mon Sep 17 00:00:00 2001 From: unknown <18119604035@163.com> Date: Wed, 1 Nov 2023 16:14:30 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=BA=BF=E4=B8=8A=E8=AF=BE=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E7=AB=A0=E8=8A=82=E5=90=8D=E6=97=B6=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/compenents/hour-update.tsx | 2 +- src/pages/course/compenents/hours.tsx | 40 ++++++++++++++++----- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/pages/course/compenents/hour-update.tsx b/src/pages/course/compenents/hour-update.tsx index 3a86d03..2bb7888 100644 --- a/src/pages/course/compenents/hour-update.tsx +++ b/src/pages/course/compenents/hour-update.tsx @@ -234,7 +234,7 @@ export const CourseHourUpdate: React.FC = ({ const arr = [...chapters]; if (arr[index].id) { courseChapter - .updateCourseChapter(id, Number(arr[index].id), value, arr.length) + .updateCourseChapter(id, Number(arr[index].id), value, index + 1) .then((res: any) => { console.log("ok"); getDetail(); diff --git a/src/pages/course/compenents/hours.tsx b/src/pages/course/compenents/hours.tsx index 8765df8..a6dd81d 100644 --- a/src/pages/course/compenents/hours.tsx +++ b/src/pages/course/compenents/hours.tsx @@ -96,23 +96,35 @@ export const TreeHours = (props: PropInterface) => { // Find dragObject let dragObj: DataNode; - loop(data, dragKey, (item, index, arr) => { - arr.splice(index, 1); - dragObj = item; - }); + let dragLength = (info.dragNode as any).props.pos.split("-").length; + let dropLength = (info.node as any).props.pos.split("-").length; if (!info.dropToGap) { // Drop on the content - loop(data, dropKey, (item) => { - item.children = item.children || []; - // where to insert 示例添加到头部,可以是随意位置 - item.children.unshift(dragObj); - }); + if ( + (dropPosition == 0 && dropPos.length == 3) || + (dropPosition == 0 && dropPos.length == 2 && dragLength == 2) + ) { + } 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 ( ((info.node as any).props.children || []).length > 0 && // Has children (info.node as any).props.expanded && // Is expanded dropPosition === 1 // On the bottom gap ) { + loop(data, dragKey, (item, index, arr) => { + arr.splice(index, 1); + dragObj = item; + }); loop(data, dropKey, (item) => { item.children = item.children || []; // where to insert 示例添加到头部,可以是随意位置 @@ -121,6 +133,16 @@ export const TreeHours = (props: PropInterface) => { // item to the tail of the children }); } 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 i: number; loop(data, dropKey, (_item, index, arr) => { From 272e9a5d50b9b185f2ae19ac8a48a4e603143ce6 Mon Sep 17 00:00:00 2001 From: unknown <18119604035@163.com> Date: Wed, 1 Nov 2023 17:03:48 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E3=80=81=E7=BC=96=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/system/administrator/compenents/create.tsx | 4 ++-- src/pages/system/administrator/compenents/update.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/system/administrator/compenents/create.tsx b/src/pages/system/administrator/compenents/create.tsx index ffae3ed..d8f82ee 100644 --- a/src/pages/system/administrator/compenents/create.tsx +++ b/src/pages/system/administrator/compenents/create.tsx @@ -149,12 +149,12 @@ export const SystemAdministratorCreate: React.FC = ({ = ({ From caf377eb1ae48891c19e5dc2ba531d5bccb1553d Mon Sep 17 00:00:00 2001 From: unknown <18119604035@163.com> Date: Wed, 1 Nov 2023 17:04:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E3=80=81=E7=BC=96=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/system/administrator/compenents/update.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/system/administrator/compenents/update.tsx b/src/pages/system/administrator/compenents/update.tsx index a6801c3..883d927 100644 --- a/src/pages/system/administrator/compenents/update.tsx +++ b/src/pages/system/administrator/compenents/update.tsx @@ -111,7 +111,7 @@ export const SystemAdministratorUpdate: React.FC = ({ <> {open ? (