From 0667b630fbaf29ee12d5d332fb6da5c32231cd0f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 06 六月 2023 17:59:38 +0800
Subject: [PATCH] 2023-06-06

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

diff --git a/src/menu/menushell/card.jsx b/src/menu/menushell/card.jsx
index ed095af..5cdd3e2 100644
--- a/src/menu/menushell/card.jsx
+++ b/src/menu/menushell/card.jsx
@@ -1,17 +1,43 @@
 import React from 'react'
 import { useDrag, useDrop } from 'react-dnd'
-import { Icon } from 'antd'
 
 import asyncComponent from '@/utils/asyncComponent'
 import './index.scss'
 
 const AntvBar = asyncComponent(() => import('@/menu/components/chart/antv-bar'))
+const MainSearch = asyncComponent(() => import('@/menu/components/search/main-search'))
+const AntvPie = asyncComponent(() => import('@/menu/components/chart/antv-pie'))
+const AntvDashboard = asyncComponent(() => import('@/menu/components/chart/antv-dashboard'))
+const AntvScatter = asyncComponent(() => import('@/menu/components/chart/antv-scatter'))
 const AntvTabs = asyncComponent(() => import('@/menu/components/tabs/antv-tabs'))
+const DataCard = asyncComponent(() => import('@/menu/components/card/data-card'))
+const DoubleDataCard = asyncComponent(() => import('@/menu/components/card/double-data-card'))
+const PropCard = asyncComponent(() => import('@/menu/components/card/prop-card'))
+const Balcony = asyncComponent(() => import('@/menu/components/card/balcony'))
+const NormalTree = asyncComponent(() => import('@/menu/components/tree/antd-tree'))
+const CarouselDataCard = asyncComponent(() => import('@/menu/components/carousel/data-card'))
+const CarouselPropCard = asyncComponent(() => import('@/menu/components/carousel/prop-card'))
+const TableCard = asyncComponent(() => import('@/menu/components/card/table-card'))
+const NormalTable = asyncComponent(() => import('@/menu/components/table/normal-table'))
+const EditTable = asyncComponent(() => import('@/menu/components/table/edit-table'))
+const SimpleForm = asyncComponent(() => import('@/menu/components/form/simple-form'))
+const StepForm = asyncComponent(() => import('@/menu/components/form/step-form'))
+const TabForm = asyncComponent(() => import('@/menu/components/form/tab-form'))
+const NormalGroup = asyncComponent(() => import('@/menu/components/group/normal-group'))
+const BraftEditor = asyncComponent(() => import('@/menu/components/editor/braft-editor'))
+const CodeSandbox = asyncComponent(() => import('@/menu/components/code/sandbox'))
+const CustomChart = asyncComponent(() => import('@/menu/components/chart/chart-custom'))
+const Timeline = asyncComponent(() => import('@/menu/components/timeline/normal-timeline'))
+const Voucher = asyncComponent(() => import('@/menu/components/module/voucher'))
+const Account = asyncComponent(() => import('@/menu/components/module/account'))
+const Iframe = asyncComponent(() => import('@/menu/components/iframe'))
+const AntvG6 = asyncComponent(() => import('@/menu/components/chart/antv-G6'))
+const AntvX6 = asyncComponent(() => import('@/menu/components/chart/antv-X6'))
 
-const Card = ({ id, menu, card, moveCard, findCard, delCard, hasDrop, doubleClickCard, updateConfig }) => {
+const Card = ({ id, card, moveCard, findCard, delCard, unGroup, updateConfig }) => {
   const originalIndex = findCard(id).index
   const [{ isDragging }, drag] = useDrag({
-    item: { type: 'menu', id, originalIndex, floor: card.floor },
+    item: { type: 'menu', id, originalIndex },
     collect: monitor => ({
       isDragging: monitor.isDragging(),
     }),
@@ -19,14 +45,19 @@
   const [, drop] = useDrop({
     accept: 'menu',
     canDrop: () => true,
-    drop: ({ id: draggedId, originalIndex, floor }) => {
+    drop: (item) => {
+      const { id: draggedId, originalIndex } = item
       if (originalIndex === undefined) {
-        hasDrop(card)
-      } else if (draggedId && floor === card.floor) {
-        if (draggedId !== id) {
-          const { index: overIndex } = findCard(id)
-          moveCard(draggedId, overIndex)
-        }
+        item.dropTargetId = id
+      } else if (draggedId) {
+        if (draggedId === id) return
+        const { index: originIndex } = findCard(draggedId)
+
+        if (originIndex === -1) return
+
+        const { index: overIndex } = findCard(id)
+
+        moveCard(draggedId, overIndex)
       }
     }
   })
@@ -36,18 +67,83 @@
     style = { opacity: 0.3}
   }
 
+  if (card.style && card.style.clear === 'left') {
+    style.clear = 'left'
+  }
+
   const getCardComponent = () => {
-    if (card.type === 'bar' || card.type === 'line') {
-      return (<AntvBar menu={menu} card={card} updateConfig={updateConfig} />)
+    if (card.type === 'card' && card.subtype === 'datacard') {
+      return (<DataCard card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'card' && card.subtype === 'propcard') {
+      return (<PropCard card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'bar' || card.type === 'line') {
+      return (<AntvBar card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'search') {
+      return (<MainSearch card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'card' && card.subtype === 'dualdatacard') {
+      return (<DoubleDataCard card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'pie') {
+      return (<AntvPie card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'dashboard') {
+      return (<AntvDashboard card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'tree') {
+      return (<NormalTree card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'scatter') {
+      return (<AntvScatter card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'form' && card.subtype === 'simpleform') {
+      return (<SimpleForm card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'form' && card.subtype === 'stepform') {
+      return (<StepForm card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'form' && card.subtype === 'tabform') {
+      return (<TabForm card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
     } else if (card.type === 'tabs') {
-      return (<AntvTabs menu={menu} tabs={card} updateConfig={updateConfig} />)
+      return (<AntvTabs tabs={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'carousel' && card.subtype === 'datacard') {
+      return (<CarouselDataCard card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'carousel' && card.subtype === 'propcard') {
+      return (<CarouselPropCard card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'card' && card.subtype === 'tablecard') {
+      return (<TableCard card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'table' && card.subtype === 'normaltable') {
+      return (<NormalTable card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'table' && card.subtype === 'editable') {
+      return (<EditTable card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'group' && card.subtype === 'normalgroup') {
+      return (<NormalGroup group={card} updateConfig={updateConfig} unGroup={unGroup} deletecomponent={delCard}/>)
+    } else if (card.type === 'editor') {
+      return (<BraftEditor card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'code') {
+      return (<CodeSandbox card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'balcony') {
+      return (<Balcony card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'timeline') {
+      return (<Timeline card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'chart') {
+      return (<CustomChart card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'iframe') {
+      return (<Iframe card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'antvG6') {
+      return (<AntvG6 card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'antvX6') {
+      return (<AntvX6 card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'module' && card.subtype === 'voucher') {
+      return (<Voucher card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
+    } else if (card.type === 'module' && card.subtype === 'account') {
+      return (<Account card={card} updateConfig={updateConfig} deletecomponent={delCard}/>)
     }
   }
 
+  if (card.type === 'antvX6') { // 娴嬭瘯
+    return (
+      <div className={'ant-col mk-component-card ant-col-' + (card.width || 24)} style={style}>
+        <AntvX6 card={card} updateConfig={updateConfig} deletecomponent={delCard}/>
+      </div>
+    )
+  }
+
   return (
-    <div className={'ant-col mk-component-card ant-col-' + (card.setting ? card.setting.span : 12)} ref={node => drag(drop(node))} style={style}>
+    <div className={'ant-col mk-component-card ant-col-' + (card.width || 24)} ref={node => drag(drop(node))} style={style}>
       {getCardComponent()}
-      <Icon className="remove-component" title="delete" type="delete" onClick={() => delCard(id)} />
     </div>
   )
 }

--
Gitblit v1.8.0