From c7aece35a62b6e91fd98a625bf0e53f64bfbd18d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 17 八月 2023 16:22:15 +0800
Subject: [PATCH] 2023-08-17

---
 src/templates/sharecomponent/actioncomponent/dragaction/card.jsx |   65 +++++++++++++++++++-------------
 1 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/src/templates/sharecomponent/actioncomponent/dragaction/card.jsx b/src/templates/sharecomponent/actioncomponent/dragaction/card.jsx
index 946a950..e350a80 100644
--- a/src/templates/sharecomponent/actioncomponent/dragaction/card.jsx
+++ b/src/templates/sharecomponent/actioncomponent/dragaction/card.jsx
@@ -1,9 +1,10 @@
 import React from 'react'
 import { useDrag, useDrop } from 'react-dnd'
-import { Icon, Button } from 'antd'
+import { Button, Popover } from 'antd'
+import { EditOutlined, CopyOutlined, ProfileOutlined, CloseOutlined, TableOutlined, DisconnectOutlined } from '@ant-design/icons'
 import './index.scss'
 
-const Card = ({ id, card, moveCard, findCard, editCard, delCard, copyCard, profileCard, hasDrop, doubleClickCard }) => {
+const Card = ({ id, card, moveCard, findCard, editCard, delCard, copyCard, profileCard, doubleClickCard }) => {
   const originalIndex = findCard(id).index
   const [{ isDragging }, drag] = useDrag({
     item: { type: 'action', id, originalIndex },
@@ -15,46 +16,58 @@
     accept: 'action',
     canDrop: () => true,
     drop: (item) => {
-      if (!item.hasOwnProperty('originalIndex')) {
-        hasDrop(card)
-      }
-    },
-    hover({ id: draggedId }) {
-      if (!draggedId) return
-      if (draggedId !== id) {
+      const { id: draggedId, originalIndex } = item
+      
+      if (originalIndex === undefined) {
+        item.dropTargetId = id
+      } else if (draggedId && draggedId !== id) {
         const { index: overIndex } = findCard(id)
         moveCard(draggedId, overIndex)
       }
-    },
+    }
   })
-  const opacity = isDragging ? 0 : 1
+  const opacity = isDragging ? 0.5 : 1
 
   let hasProfile = false
+  let forbidSql = false
   if (['pop', 'prompt', 'exec'].includes(card.OpenType)) {
     hasProfile = true
+    if (card.verify && card.verify.default === 'false') {
+      forbidSql = true
+    }
   } else if (card.OpenType === 'excelIn' || card.OpenType === 'excelOut') {
     hasProfile = true
+    if (card.verify && card.verify.default === 'false') {
+      forbidSql = true
+    }
   } else if (card.funcType === 'print') {
+    hasProfile = true
+  } else if (card.funcType === 'megvii') {
     hasProfile = true
   }
 
   return (
-    <div className="page-card" style={{ opacity: opacity}}>
-      <div ref={node => drag(drop(node))}>
-        <Button
-          className={'mk-btn mk-' + card.class}
-          icon={card.icon}
-          key={card.uuid}
-          onDoubleClick={() => doubleClickCard(id)}
-        >
-          {card.label}{card.position === 'grid' && <Icon type="table" />}
-        </Button>
+    <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
+      <div className="mk-popover-control">
+        <EditOutlined className="edit" onClick={() => editCard(id)} />
+        <CopyOutlined className="copy" onClick={() => copyCard(id)} />
+        <CloseOutlined className="close" onClick={() => delCard(id)} />
+        {hasProfile ? <ProfileOutlined className="profile" onClick={() => profileCard(id)} /> : null}
       </div>
-      <Icon className="edit" title="edit" type="edit" onClick={() => editCard(id)} />
-      <Icon className="edit copy" title="copy" type="copy" onClick={() => copyCard(id)} />
-      <Icon className="edit close" title="close" type="close" onClick={() => delCard(id)} />
-      {hasProfile ? <Icon className="edit profile" title="verify" type="profile" onClick={() => profileCard(id)} /> : null}
-    </div>
+    } trigger="hover">
+      <div className="page-card" style={{ opacity: opacity}}>
+        <div ref={node => drag(drop(node))}>
+          <Button
+            className={'mk-btn mk-' + card.class + (card.hidden === 'true' ? ' mk-hidden' : '')}
+            icon={card.icon}
+            key={card.uuid}
+            onDoubleClick={() => doubleClickCard(id)}
+          >
+            {card.label}{card.position === 'grid' && <TableOutlined />}{forbidSql && <DisconnectOutlined />}
+          </Button>
+        </div>
+      </div>
+    </Popover>
   )
 }
 export default Card

--
Gitblit v1.8.0