From 31ec63f0419895876cbaba99637a884a32d33d0d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 01 九月 2021 10:31:45 +0800
Subject: [PATCH] 2021-09-01

---
 src/templates/formtabconfig/dragelement/card.jsx |  152 +++++++++++++++++++++++++++-----------------------
 1 files changed, 81 insertions(+), 71 deletions(-)

diff --git a/src/templates/formtabconfig/dragelement/card.jsx b/src/templates/formtabconfig/dragelement/card.jsx
index f6617d9..d2817df 100644
--- a/src/templates/formtabconfig/dragelement/card.jsx
+++ b/src/templates/formtabconfig/dragelement/card.jsx
@@ -1,6 +1,6 @@
 import React from 'react'
 import { useDrag, useDrop } from 'react-dnd'
-import { Icon, Button, Select, DatePicker, Input, InputNumber } from 'antd'
+import { Icon, Button, Select, DatePicker, Input, InputNumber, Popover } from 'antd'
 import moment from 'moment'
 import ItemTypes from './itemtypes'
 import './index.scss'
@@ -8,7 +8,7 @@
 const { MonthPicker } = DatePicker
 const { TextArea } = Input
 
-const Card = ({ id, type, cols, card, moveCard, findCard, editCard, delCard, profileCard, hasDrop }) => {
+const Card = ({ id, type, cols, card, moveCard, findCard, editCard, delCard, profileCard, copyCard }) => {
   const originalIndex = findCard(id).index
   const [{ isDragging }, drag] = useDrag({
     item: { type: ItemTypes[type], id, originalIndex },
@@ -20,17 +20,15 @@
     accept: ItemTypes[type],
     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
 
@@ -40,6 +38,10 @@
   
   const del = () => {
     delCard(id)
+  }
+
+  const copy = () => {
+    copyCard(id)
   }
   
   const profile = () => {
@@ -57,7 +59,7 @@
         _defaultValue = ''
       }
     } else if (card.setAll === 'true') {
-      _defaultValue = '鍏ㄩ儴'
+      _defaultValue = card.emptyText || '绌�'
     }
   } else if (type === 'search' && card.type === 'daterange') {
     _defaultValue = [null, null]
@@ -65,7 +67,7 @@
       try {
         let _initval = JSON.parse(card.initval)
         _defaultValue = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')]
-      } catch {
+      } catch (e) {
         _defaultValue = [null, null]
       }
     }
@@ -75,72 +77,80 @@
   let wrapCol = 'ant-col-sm-16'
   if (card.type === 'textarea') {
     if (cols === '2') {
-      labelCol = 'ant-col-sm-4'
-      wrapCol = 'ant-col-sm-20'
+      labelCol = 'textarea-line ant-col-sm-4'
+      wrapCol = 'textarea-line ant-col-sm-20'
     } else if (cols === '3') {
-      labelCol = 'ant-col-cuslabel'
-      wrapCol = 'ant-col-cuswrap'
+      labelCol = 'textarea-line ant-col-cuslabel'
+      wrapCol = 'textarea-line ant-col-cuswrap'
+    } else if (cols === '4') {
+      labelCol = 'textarea-line ant-col-sm-2'
+      wrapCol = 'textarea-line ant-col-sm-22'
     }
   }
 
   return (
-    <div className="page-card" style={{ opacity: opacity}}>
-      <div ref={node => drag(drop(node))}>
-        {type === 'search' ?
-          <div className="ant-row ant-form-item">
-            <div className={'ant-col ant-form-item-label ant-col-xs-24 ' + labelCol}>
-              <label title={card.label}>{card.label}</label>
-            </div>
-            <div className={'ant-col ant-form-item-control-wrapper ant-col-xs-24 ' + wrapCol}>
-              {card.type === 'text' ?
-                <Input style={{marginTop: '4px'}} defaultValue={card.initval} /> : null
-              }
-              {card.type === 'number' ?
-                <InputNumber defaultValue={card.initval} precision={card.decimal} /> : null
-              }
-              {(card.type === 'multiselect' || card.type === 'select' || card.type === 'link') ?
-                <Select defaultValue={_defaultValue}></Select> : null
-              }
-              {card.type === 'date' ?
-                <DatePicker defaultValue={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null
-              }
-              {card.type === 'datemonth' ?
-                <MonthPicker defaultValue={card.initval ? moment().subtract(card.initval, 'month') : null} /> : null
-              }
-              {card.type === 'datetime' ?
-                <DatePicker showTime defaultValue={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null
-              }
-              {card.type === 'textarea' ?
-                <TextArea defaultValue={card.initval} autosize={{ minRows: 2, maxRows: 6 }} /> : null
-              }
-              {card.type === 'funcvar' &&
-                <Input style={{marginTop: '4px'}} defaultValue={card.linkfield} />
-              }
-              {card.type === 'fileupload' ?
-                <Button>
-                  <Icon type="upload" /> 鐐瑰嚮涓婁紶
-                </Button> : null
-              }
-              <div className="input-mask"></div>
-            </div>
-          </div> : null
+    <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
+      <div className="mk-popover-control">
+        <Icon className="edit" title="缂栬緫" type="edit" onClick={edit} />
+        {type === 'search' ? <Icon className="edit copy" title="澶嶅埗" type="copy" onClick={copy} /> : null}
+        {type === 'action' && card.btnType !== 'cancel' ?
+          <Icon className="edit profile" title="鏍¢獙瑙勫垯" type="profile" onClick={profile} /> : null
         }
-        {type === 'action' ?
-          <Button
-            className={'mk-btn mk-' + card.class}
-            icon={card.icon}
-            key={card.uuid}
-          >
-            {card.label}{card.position === 'grid' && <Icon type="table" />}
-          </Button> : null
-        }
+        {type === 'search' || (type === 'action' && card.btnType !== 'confirm' && card.btnType !== 'cancel') ? <Icon className="edit close" title="鍒犻櫎" type="close" onClick={del} /> : null}
       </div>
-      <Icon className="edit" title="缂栬緫" type="edit" onClick={edit} />
-      {type === 'action' && card.btnType === 'confirm' && card.intertype === 'inner' && !card.innerFunc ?
-        <Icon className="edit profile" title="鏍¢獙瑙勫垯" type="profile" onClick={profile} /> : null
-      }
-      {card.btnType !== 'confirm' && card.btnType !== 'cancel' && <Icon className="edit close" title="鍒犻櫎" type="close" onClick={del} />}
-    </div>
+    } trigger="hover">
+      <div className="page-card" style={{ opacity: opacity}}>
+        <div ref={node => drag(drop(node))}>
+          {type === 'search' ?
+            <div className="ant-row ant-form-item">
+              <div className={'ant-col ant-form-item-label ant-col-xs-24 ' + labelCol}>
+                <label title={card.label}>{card.label}</label>
+              </div>
+              <div className={'ant-col ant-form-item-control-wrapper ant-col-xs-24 ' + wrapCol}>
+                {card.type === 'text' ?
+                  <Input style={{marginTop: '4px'}} value={card.initval} /> : null
+                }
+                {card.type === 'number' ?
+                  <InputNumber value={card.initval} precision={card.decimal} /> : null
+                }
+                {(card.type === 'multiselect' || card.type === 'select' || card.type === 'link') ?
+                  <Select value={_defaultValue}></Select> : null
+                }
+                {card.type === 'date' ?
+                  <DatePicker value={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null
+                }
+                {card.type === 'datemonth' ?
+                  <MonthPicker value={card.initval ? moment().subtract(card.initval, 'month') : null} /> : null
+                }
+                {card.type === 'datetime' ?
+                  <DatePicker showTime value={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null
+                }
+                {card.type === 'textarea' ?
+                  <TextArea value={card.initval} autoSize={{ minRows: 2, maxRows: 6 }} /> : null
+                }
+                {card.type === 'funcvar' &&
+                  <Input style={{marginTop: '4px'}} value={card.linkfield} />
+                }
+                {card.type === 'fileupload' ?
+                  <Button>
+                    <Icon type="upload" /> 鐐瑰嚮涓婁紶
+                  </Button> : null
+                }
+              </div>
+            </div> : null
+          }
+          {type === 'action' ?
+            <Button
+              className={'mk-btn mk-' + card.class}
+              icon={card.icon}
+              key={card.uuid}
+            >
+              {card.label}{card.position === 'grid' && <Icon type="table" />}
+            </Button> : null
+          }
+        </div>
+      </div>
+    </Popover>
   )
 }
 export default Card

--
Gitblit v1.8.0