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/mob/mobshell/index.jsx |   28 ++++++++++------------------
 1 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/src/mob/mobshell/index.jsx b/src/mob/mobshell/index.jsx
index f293e7b..d803eb8 100644
--- a/src/mob/mobshell/index.jsx
+++ b/src/mob/mobshell/index.jsx
@@ -9,8 +9,6 @@
 import './index.scss'
 
 const Container = ({config, editId, handleList, editCard, deleteCard, doubleClickCard }) => {
-  let target = null
-
   const [cards, setCards] = useState(config.components)
   const moveCard = (id, atIndex) => {
     const { card, index } = findCard(id)
@@ -28,10 +26,6 @@
       card,
       index: cards.indexOf(card),
     }
-  }
-
-  const hasDrop = (item) => {
-    target = item
   }
 
   const updateConfig = (element) => {
@@ -55,21 +49,20 @@
         type: item.componentType,
         subtype: item.subtype,
       }
-      
-      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
-
-      targetIndex++
-
-      const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] })
+      const { index: overIndex } = findCard(`${targetId}`) // cards涓虹┖鏃� overIndex 涓� -1
+      const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] })
 
       handleList({...config, components: _cards})
-      target = null
     }
   })
 
@@ -85,7 +78,6 @@
           editCard={editCard}
           delCard={deleteCard}
           findCard={findCard}
-          hasDrop={hasDrop}
           updateConfig={updateConfig}
           doubleClickCard={doubleClickCard}
         />

--
Gitblit v1.8.0