king
2020-09-18 51a60b5cb00fdeaf9e42c29341242460bf2154e8
src/menu/menushell/index.jsx
@@ -2,13 +2,15 @@
import { useDrop } from 'react-dnd'
import { is, fromJS } from 'immutable'
import update from 'immutability-helper'
import { Empty, notification } from 'antd'
import { Empty, notification, Modal } from 'antd'
import Utils from '@/utils/utils.js'
import Card from './card'
import './index.scss'
const Container = ({menu, handleList, deleteCard, doubleClickCard }) => {
const { confirm } = Modal
const Container = ({menu, handleList, doubleClickCard }) => {
  let target = null
  const [cards, setCards] = useState(menu.components)
@@ -38,10 +40,33 @@
    handleList({...menu, components: cards.map(item => item.uuid === element.uuid ? element : item)})
  }
  const deleteCard = (id) => {
    const { card } = findCard(id)
    let hasComponent = false
    if (card.type === 'tabs') {
      card.subtabs.forEach(tab => {
        if (tab.components.length > 0) {
          hasComponent = true
        }
      })
    }
    confirm({
      title: `确定删除《${card.setting.name}》吗?`,
      content: hasComponent ? '当前组件中含有子组件!' : '',
      onOk() {
        handleList({...menu, components: cards.filter(item => item.uuid !== card.uuid)})
      },
      onCancel() {}
    })
  }
  const [, drop] = useDrop({
    accept: 'menu',
    drop(item) {
      if (item.hasOwnProperty('originalIndex') || item.added) {
        delete item.added // 删除组件添加标记
        return
      }
      if (item.component === 'search') { // 搜索组件不可重复添加