king
2023-02-17 8137ac074ce6370e4b46295e7acf9c7870ef82d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React from 'react'
import { useDrop } from 'react-dnd'
 
import asyncComponent from '@/utils/asyncComponent'
import './index.scss'
 
const AntvTabs = asyncComponent(() => import('@/menu/components/tabs/table-tabs'))
const BaseTable = asyncComponent(() => import('@/menu/components/table/base-table'))
 
const Card = ({ id, card, delCard, updateConfig, switchConfig }) => {
  const [, drop] = useDrop({
    accept: 'menu',
    canDrop: () => true,
    drop: (item) => {
      item.dropTargetId = id
    }
  })
 
  const getCardComponent = () => {
    if (card.type === 'table') {
      return (<BaseTable card={card} updateConfig={updateConfig}/>)
    } else if (card.type === 'tabs') {
      return (<AntvTabs tabs={card} updateConfig={updateConfig} switchConfig={switchConfig} deletecomponent={delCard}/>)
    }
  }
  return (
    <div className={'ant-col mk-component-card ant-col-' + (card.width || 24)} ref={node => drop(node)}>
      {getCardComponent()}
    </div>
  )
}
export default Card