From 9ff5920c0a58771219b134a7b46b7d0c1e1542ad Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 19 六月 2024 23:50:13 +0800
Subject: [PATCH] 2024-06-19

---
 src/menu/components/card/cardcellcomponent/dragaction/index.jsx |  134 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 117 insertions(+), 17 deletions(-)

diff --git a/src/menu/components/card/cardcellcomponent/dragaction/index.jsx b/src/menu/components/card/cardcellcomponent/dragaction/index.jsx
index 119bcd2..e55c040 100644
--- a/src/menu/components/card/cardcellcomponent/dragaction/index.jsx
+++ b/src/menu/components/card/cardcellcomponent/dragaction/index.jsx
@@ -1,6 +1,7 @@
 import React, { useState } from 'react'
 import { useDrop } from 'react-dnd'
 import { is, fromJS } from 'immutable'
+import { message } from 'antd'
 import update from 'immutability-helper'
 
 import Card from './card'
@@ -8,7 +9,7 @@
 import Action from './action'
 import './index.scss'
 
-const Container = ({list, handleList, handleMenu, deleteMenu, profileAction, handleStyle, dropButton, handleSubConfig }) => {
+const Container = ({list, parent, fields, handleList, handleMenu, deleteMenu, profileAction, handleStyle, updateMarks, dropButton, handleSubConfig }) => {
   const [cards, setCards] = useState(list)
   const moveCard = (id, atIndex) => {
     const { card, index } = findCard(id)
@@ -34,18 +35,36 @@
   }
 
   const copyCard = id => {
-    const { card, index: overIndex } = findCard(id)
+    const { card } = findCard(id)
     let copycard = fromJS(card).toJS()
+    let _cards = fromJS(cards).toJS()
 
-    copycard.uuid = Utils.getuuid()
-    copycard.copyType = 'customCardElement'
+    if (card.eleType === 'button') {
+      copycard.copyType = 'action'
+    } else {
+      copycard.copyType = 'customCardElement'
+    }
     copycard.focus = true
 
-    let _val = ''
+    let _val = fromJS(copycard).toJS()
+
+    if (_val.control) {
+      delete _val.controlField
+      delete _val.controlVal
+    }
+
+    copycard.uuid = Utils.getuuid()
 
     try {
-      _val = window.btoa(window.encodeURIComponent(JSON.stringify(copycard)))
-    } catch {
+      delete _val.$srcId
+    
+      let srcid = localStorage.getItem(window.GLOB.sysSign + 'srcId')
+      if (srcid) {
+        _val.$srcId = srcid
+      }
+      
+      _val = window.btoa(window.encodeURIComponent(JSON.stringify(_val)))
+    } catch (e) {
       console.warn('Stringify Failure')
       _val = ''
     }
@@ -57,12 +76,18 @@
       oInput.select()
       document.execCommand('Copy')
       document.body.removeChild(oInput)
+      
+      message.success('澶嶅埗鎴愬姛銆�')
+    } else {
+      message.warning('澶嶅埗澶辫触銆�')
     }
 
-    const _cards = update(cards, { $splice: [[overIndex + 1, 0, copycard]] })
-
-    handleList(_cards)
-    handleMenu(copycard)
+    if (card.eleType !== 'button') {
+      _cards.push(copycard)
+  
+      handleList(_cards)
+      handleMenu(copycard)
+    }
   }
 
   const changeStyle = id => {
@@ -77,9 +102,12 @@
 
   const doubleClickCard = id => {
     const { card } = findCard(id)
-    if (card.OpenType === 'pop') {
-      handleSubConfig(card)
+
+    if (card.eleType !== 'button') {
+      return
     }
+    
+    handleSubConfig(card)
   }
 
   const delCard = id => {
@@ -87,11 +115,81 @@
     deleteMenu(card)
   }
 
-  let cardIds = cards.map(card => card.uuid)
-
   const [, drop] = useDrop({
     accept: 'action',
     drop(item) {
+      if (item.$init) { // 鎷栨嫿娣诲姞
+        let newcard = {}
+        newcard.uuid = Utils.getuuid()
+        newcard.focus = true
+
+        // 鏄剧ず鍒楄繃婊�
+        if (parent.type === 'custom' && item.class !== 'element') {
+          delete item.overIndex
+          return
+        } else if (parent.type === 'action' && item.class === 'element') {
+          delete item.overIndex
+          return
+        }
+        
+        if (item.class === 'element') {
+          newcard.eleType = item.value
+          newcard.datatype = 'dynamic'
+          newcard.height = 1
+
+          if (item.value === 'splitline') {
+            newcard.width = 24
+            newcard.color = '#EBE9E9'
+          } else if (item.value === 'tag') {
+            newcard.style = {
+              backgroundColor: 'var(--mk-sys-color1)',
+              color: 'var(--mk-sys-color)',
+              borderColor: 'var(--mk-sys-color)',
+              borderWidth: '1px',
+              borderRadius: '4px',
+              paddingLeft: '7px',
+              paddingRight: '7px',
+              marginRight: '8px',
+              marginBottom: '8px',
+            }
+          } else if (item.value === 'slider') {
+            newcard.width = 24
+            newcard.color = '#1890ff'
+          }
+        } else {
+          newcard.eleType = 'button'
+          newcard.label = 'button'
+          newcard.verify = null
+          newcard.show = 'link'
+          newcard.Ot = 'requiredSgl'
+          newcard.OpenType = item.value
+          newcard.class = 'primary'
+
+          if (newcard.OpenType === 'excelIn') {
+            newcard.label = item.text
+            newcard.class = 'border-dgreen'
+            newcard.Ot = 'notRequired'
+          } else if (item.subType === 'excelOut') {
+            newcard.label = item.text
+            newcard.execSuccess = 'never'
+            newcard.class = 'dgreen'
+          }
+        }
+
+        if (item.overIndex) {
+          const { index } = findCard(item.overIndex)
+          const _cards = update(cards, { $splice: [[index + 1, 0, newcard]] })
+          handleList(_cards)
+        } else {
+          handleList([...cards, newcard])
+        }
+
+        handleMenu(newcard)
+
+        delete item.overIndex
+        return
+      }
+
       const { index } = findCard(item.id)
       if (index > -1) return
       dropButton(item.id)
@@ -106,8 +204,8 @@
             <Action
               id={card.uuid}
               key={card.uuid}
-              cardIds={cardIds}
               card={card}
+              copyCard={copyCard}
               moveCard={moveCard}
               editCard={editCard}
               changeStyle={changeStyle}
@@ -122,11 +220,13 @@
             <Card
               id={card.uuid}
               key={card.uuid}
-              cardIds={cardIds}
               card={card}
+              parent={parent}
+              fields={fields}
               moveCard={moveCard}
               copyCard={copyCard}
               editCard={editCard}
+              updateMarks={updateMarks}
               changeStyle={changeStyle}
               delCard={delCard}
               findCard={findCard}

--
Gitblit v1.8.0