From 407c0f1765c7d085218a91ad8842784977383d05 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 23 十月 2020 00:18:13 +0800
Subject: [PATCH] 2020-10-23

---
 src/menu/menushell/index.jsx |   29 +++++++++++------------------
 1 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/src/menu/menushell/index.jsx b/src/menu/menushell/index.jsx
index f5b7a2d..a48ece6 100644
--- a/src/menu/menushell/index.jsx
+++ b/src/menu/menushell/index.jsx
@@ -10,9 +10,7 @@
 
 const { confirm } = Modal
 
-const Container = ({menu, handleList, doubleClickCard }) => {
-  let target = null
-
+const Container = ({menu, handleList }) => {
   const [cards, setCards] = useState(menu.components)
   const moveCard = (id, atIndex) => {
     const { card, index } = findCard(id)
@@ -30,10 +28,6 @@
       card,
       index: cards.indexOf(card),
     }
-  }
-
-  const hasDrop = (item) => {
-    target = item
   }
 
   const updateConfig = (element) => {
@@ -85,6 +79,7 @@
         bar: '鏌辩姸鍥�',
         line: '鎶樼嚎鍥�',
         tabs: '鏍囩缁�',
+        pie: '楗煎浘',
         card: '鍗$墖'
       }
       let i = 1
@@ -101,25 +96,25 @@
         uuid: Utils.getuuid(),
         type: item.component,
         subtype: item.subtype,
+        config: item.config,
+        width: item.width || 24,
         name: name,
         floor: 1,   // 缁勪欢鐨勫眰绾�
         isNew: true // 鏂版坊鍔犳爣蹇楋紝鐢ㄤ簬鍒濆鍖�
       }
       
-      let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0
-      if (target) {
-        targetId = target.uuid
+      let targetId = '0'
+
+      if (item.dropTargetId) {
+        targetId = 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 _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] })
 
       handleList({...menu, components: _cards})
-      target = null
     }
   })
 
@@ -134,9 +129,7 @@
             moveCard={moveCard}
             delCard={deleteCard}
             findCard={findCard}
-            hasDrop={hasDrop}
             updateConfig={updateConfig}
-            doubleClickCard={doubleClickCard}
           />
         ))}
       </div>

--
Gitblit v1.8.0