From 51a60b5cb00fdeaf9e42c29341242460bf2154e8 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 18 九月 2020 09:37:22 +0800
Subject: [PATCH] 2020-09-18

---
 src/menu/menushell/index.jsx |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/menu/menushell/index.jsx b/src/menu/menushell/index.jsx
index 55b5805..79a1223 100644
--- a/src/menu/menushell/index.jsx
+++ b/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') { // 鎼滅储缁勪欢涓嶅彲閲嶅娣诲姞

--
Gitblit v1.8.0