From c34bcb0a3054bdab29fbaff17e587c19d7b5de28 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 16 九月 2020 23:39:28 +0800
Subject: [PATCH] 2020-09-16

---
 src/menu/menushell/card.jsx |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/menu/menushell/card.jsx b/src/menu/menushell/card.jsx
index ac08014..ed095af 100644
--- a/src/menu/menushell/card.jsx
+++ b/src/menu/menushell/card.jsx
@@ -6,11 +6,12 @@
 import './index.scss'
 
 const AntvBar = asyncComponent(() => import('@/menu/components/chart/antv-bar'))
+const AntvTabs = asyncComponent(() => import('@/menu/components/tabs/antv-tabs'))
 
-const Card = ({ id, config, card, moveCard, findCard, editId, editCard, delCard, hasDrop, doubleClickCard, updateConfig }) => {
+const Card = ({ id, menu, card, moveCard, findCard, delCard, hasDrop, doubleClickCard, updateConfig }) => {
   const originalIndex = findCard(id).index
   const [{ isDragging }, drag] = useDrag({
-    item: { type: 'menu', id, originalIndex },
+    item: { type: 'menu', id, originalIndex, floor: card.floor },
     collect: monitor => ({
       isDragging: monitor.isDragging(),
     }),
@@ -18,18 +19,16 @@
   const [, drop] = useDrop({
     accept: 'menu',
     canDrop: () => true,
-    drop: (item) => {
-      if (!item.hasOwnProperty('originalIndex')) {
+    drop: ({ id: draggedId, originalIndex, floor }) => {
+      if (originalIndex === undefined) {
         hasDrop(card)
+      } else if (draggedId && floor === card.floor) {
+        if (draggedId !== id) {
+          const { index: overIndex } = findCard(id)
+          moveCard(draggedId, overIndex)
+        }
       }
-    },
-    hover({ id: draggedId }) {
-      if (!draggedId) return
-      if (draggedId !== id) {
-        const { index: overIndex } = findCard(id)
-        moveCard(draggedId, overIndex)
-      }
-    },
+    }
   })
 
   let style = { opacity: 1}
@@ -38,8 +37,10 @@
   }
 
   const getCardComponent = () => {
-    if (card.type === 'bar') {
-      return (<AntvBar config={config} card={card} triggerEdit={editCard} editId={editId} updateConfig={updateConfig} />)
+    if (card.type === 'bar' || card.type === 'line') {
+      return (<AntvBar menu={menu} card={card} updateConfig={updateConfig} />)
+    } else if (card.type === 'tabs') {
+      return (<AntvTabs menu={menu} tabs={card} updateConfig={updateConfig} />)
     }
   }
 

--
Gitblit v1.8.0