From 37a134bd23ec4b227a0e010b08a1a89c2bbaaa0d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 03 十一月 2020 17:10:14 +0800
Subject: [PATCH] 2020-11-03

---
 src/templates/sharecomponent/tabscomponent/tabdragelement/index.jsx |   22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/templates/sharecomponent/tabscomponent/tabdragelement/index.jsx b/src/templates/sharecomponent/tabscomponent/tabdragelement/index.jsx
index ad89ed3..9d819d5 100644
--- a/src/templates/sharecomponent/tabscomponent/tabdragelement/index.jsx
+++ b/src/templates/sharecomponent/tabscomponent/tabdragelement/index.jsx
@@ -10,7 +10,6 @@
 const { TabPane } = Tabs
 
 const Container = ({list, placeholder, handleList, handleMenu, deleteMenu, doubleClickCard }) => {
-  let target = null
   const [cards, setCards] = useState(list)
   const moveCard = (id, atIndex) => {
     const { card, index } = findCard(id)
@@ -33,10 +32,6 @@
     }
   }
 
-  const hasDrop = (item) => {
-    target = item
-  }
-
   const [, drop] = useDrop({
     accept: 'tabs',
     drop(item) {
@@ -54,19 +49,19 @@
       newcard.supMenu = 'mainTable'
       newcard.focus = true
 
-      let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0
-      if (target) {
-        targetId = target.uuid
+      let targetId = ''
+
+      if (item.dropTargetId) {
+        targetId = item.dropTargetId
+        delete item.dropTargetId
+      } else if (cards.length > 0) {
+        targetId = cards[cards.length - 1].uuid
       }
 
       const { index: overIndex } = findCard(`${targetId}`)
-      let targetIndex = overIndex
+      const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] })
 
-      targetIndex++
-
-      const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] })
       handleList(_cards, newcard)
-      target = null
     }
   })
 
@@ -98,7 +93,6 @@
               findCard={findCard}
               editCard={editCard}
               delCard={delCard}
-              hasDrop={hasDrop}
               doubleClickCard={doubleClickBab}
             />
           } key={`${index}`}>

--
Gitblit v1.8.0