king
2021-10-14 e41a64966b7832baffe96c21d1ea77ef6adb2905
src/menu/menushell/index.jsx
@@ -1,12 +1,11 @@
import React, { useState } from 'react'
import { useDrop } from 'react-dnd'
import { is, fromJS } from 'immutable'
import update from 'immutability-helper'
import { Empty, notification, Modal } from 'antd'
import Utils from '@/utils/utils.js'
import MKEmitter from '@/utils/events.js'
import MenuUtils from '@/menu/utils/menuUtils.js'
import MenuUtils from '@/utils/utils-custom.js'
import Card from './card'
import './index.scss'
@@ -18,9 +17,10 @@
    const { card, index } = findCard(id)
    const _cards = update(cards, { $splice: [[index, 1], [atIndex, 0, card]] })
    handleList({...menu, components: _cards})
    setCards(_cards)
  }
  if (!is(fromJS(cards), fromJS(menu.components))) {
  if (menu.components.length > cards.length) {
    setCards(menu.components)
  }
  
@@ -33,7 +33,9 @@
  }
  const updateConfig = (element) => {
    handleList({...menu, components: cards.map(item => item.uuid === element.uuid ? element : item)})
    const _cards = cards.map(item => item.uuid === element.uuid ? element : item)
    handleList({...menu, components: _cards})
    setCards(_cards)
  }
  const deleteCard = (id) => {
@@ -54,8 +56,13 @@
      title: `确定删除《${card.name}》吗?`,
      content: hasComponent ? '当前组件中含有子组件!' : '',
      onOk() {
        const _cards = cards.filter(item => item.uuid !== card.uuid)
        handleList({...menu, components: _cards})
        setCards(_cards)
        if (uuids.length === 0) return
        MKEmitter.emit('delButtons', uuids)
        handleList({...menu, components: cards.filter(item => item.uuid !== card.uuid)})
      },
      onCancel() {}
    })
@@ -83,6 +90,7 @@
      let name = ''
      let names = {
        bar: '柱状图',
        chart: '图表',
        line: '折线图',
        tabs: '标签组',
        pie: '饼图',
@@ -91,6 +99,12 @@
        group: '分组',
        editor: '富文本',
        code: '自定义',
        carousel: '轮播',
        form: '表单',
        dashboard: '仪表盘',
        scatter: '散点图',
        tree: '树形列表',
        balcony: '浮动卡',
        card: '卡片'
      }
      let i = 1
@@ -128,6 +142,7 @@
      const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] })
      handleList({...menu, components: _cards})
      setCards(_cards)
    }
  })