From 137fb8ea6af2789b3238b22bac31d80bced41dfe Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 28 七月 2021 11:39:39 +0800
Subject: [PATCH] 2021-07-28

---
 src/templates/zshare/editcomponent/index.jsx |   82 ++++++++++++-----------------------------
 1 files changed, 24 insertions(+), 58 deletions(-)

diff --git a/src/templates/zshare/editcomponent/index.jsx b/src/templates/zshare/editcomponent/index.jsx
index 80f2599..6fd72b8 100644
--- a/src/templates/zshare/editcomponent/index.jsx
+++ b/src/templates/zshare/editcomponent/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { fromJS } from 'immutable'
-import { Menu, Dropdown, Icon, Modal, Spin, notification } from 'antd'
+import { Modal, Spin, notification, Button } from 'antd'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
@@ -25,14 +25,7 @@
     thawVisible: false,
     thawbtnlist: null,
     pasteVisible: false,
-  }
-
-  handleMenuClick = e => {
-    if (e.key === 'thaw') {
-      this.handleThaw()
-    } else if (e.key === 'paste') {
-      this.setState({pasteVisible: true})
-    }
+    targetKeys: []
   }
 
   /**
@@ -42,7 +35,8 @@
     const { MenuID } = this.props
 
     this.setState({
-      thawVisible: true
+      thawVisible: true,
+      targetKeys: []
     })
 
     Api.getSystemConfig({
@@ -92,32 +86,31 @@
    */
   thawBtnSubmit = () => {
     const { thawButtons } = this.props
-    const { thawbtnlist, dict } = this.state
+    const { thawbtnlist, dict, targetKeys } = this.state
     let config = fromJS(this.props.config).toJS()
 
-    // 涓夌骇鑿滃崟瑙i櫎鍐荤粨
-    if (this.refs.trawmenu.state.targetKeys.length === 0) {
+    if (targetKeys.length === 0) {
       notification.warning({
         top: 92,
         message: dict['form.required.select'] + dict['header.form.thawbutton'],
         duration: 5
       })
     } else {
-
       thawbtnlist.forEach(item => {
-        if (this.refs.trawmenu.state.targetKeys.includes(item.key)) {
+        if (targetKeys.includes(item.key)) {
           config.action.push(item.btnParam)
         }
       })
 
       this.props.refresh({
         type: 'thaw',
-        thawButtons: [...thawButtons, ...this.refs.trawmenu.state.targetKeys],
+        thawButtons: [...thawButtons, ...targetKeys],
         config: config
       })
 
       this.setState({
-        thawVisible: false
+        thawVisible: false,
+        targetKeys: []
       })
     }
   }
@@ -141,26 +134,10 @@
             config: _config
           })
         })
-      } else if (options.includes('search') && (res.copyType === 'search' || res.copyType === 'form')) {
+      } else if (options.includes('search') && res.copyType === 'search') {
         res.uuid = Utils.getuuid()
         _config.search = _config.search.filter(item => !item.origin)
         let keys = _config.search.map(item => item.field.toLowerCase())
-
-        // search锛� text select multiselect link date dateweek datemonth daterange group
-        // form锛� text number select multiselect link switch checkbox radio checkcard
-        //       fileupload date datemonth datetime textarea hint color funcvar
-        if (res.copyType === 'form') {
-          if (['number', 'switch', 'textarea', 'checkcard', 'fileupload', 'hint', 'color', 'funcvar'].includes(res.type)) {
-            res.type = 'text'
-          } else if (res.type === 'radio') {
-            res.type = 'select'
-          } else if (res.type === 'checkbox') {
-            res.type = 'multiselect'
-          } else if (res.type === 'datetime') {
-            res.type = 'date'
-          }
-        }
-        res.copyType = 'search'
 
         _config.search.push(res)
 
@@ -206,20 +183,10 @@
             config: _config
           })
         })
-      } else if (options.includes('form') && (res.copyType === 'form' || res.copyType === 'search')) {
+      } else if (options.includes('form') && res.copyType === 'form') {
         let fields = []
         let labels = []
         res.uuid = Utils.getuuid()
-
-        // search锛� text select multiselect link date dateweek datemonth daterange group
-        // form锛� text number select multiselect link switch checkbox radio checkcard
-        //       fileupload date datemonth datetime textarea hint color funcvar
-        if (res.copyType === 'search') {
-          if (res.type === 'dateweek' || res.type === 'daterange' || res.type === 'group') {
-            res.type = 'date'
-          }
-        }
-        res.copyType = 'form'
 
         _config.fields.forEach(item => {
           item.field && fields.push(item.field.toLowerCase())
@@ -262,33 +229,32 @@
     })
   }
 
+  handleMenuClick = e => {
+    if (e.key === 'thaw') {
+      this.handleThaw()
+    } else if (e.key === 'paste') {
+      this.setState({pasteVisible: true})
+    }
+  }
+
   render() {
     const { MenuID } = this.props
     const { dict } = this.state
-    const menu = (
-      <Menu onClick={this.handleMenuClick}>
-        {MenuID ? <Menu.Item key="thaw"><Icon type="unlock" />{dict['header.form.thawbutton']}</Menu.Item> : null}
-        <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item>
-      </Menu>
-    )
 
     return (
       <div style={{display: 'inline-block'}}>
-        <Dropdown overlay={menu} overlayClassName="edit-component-box">
-          <span style={{color: '#1890ff', display: 'inline-block', height: 25}}>
-            {dict['model.edit']} <Icon type="down" />
-          </span>
-        </Dropdown>
+        {MenuID ? <Button className="mk-border-green" onClick={this.handleThaw} icon="unlock">{dict['header.form.thawbutton']}</Button> : null}
+        <Button style={{borderColor: '#40a9ff', color: '#40a9ff'}} onClick={() => this.setState({pasteVisible: true})} icon="snippets">{dict['header.form.paste']}</Button>
         {/* 瑙e喕鎸夐挳妯℃�佹 */}
         <Modal
           title={dict['header.form.thawbutton']}
           visible={this.state.thawVisible}
           onOk={this.thawBtnSubmit}
-          onCancel={() => {this.setState({thawVisible: false, thawbtnlist: null})}}
+          onCancel={() => {this.setState({thawVisible: false, thawbtnlist: null, targetKeys: []})}}
           destroyOnClose
         >
           {!this.state.thawbtnlist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />}
-          {this.state.thawbtnlist && <TransferForm ref="trawmenu" menulist={this.state.thawbtnlist}/>}
+          {this.state.thawbtnlist && <TransferForm onChange={(vals) => this.setState({targetKeys: vals})} menulist={this.state.thawbtnlist}/>}
         </Modal>
         {/* 鎸夐挳閰嶇疆淇℃伅绮樿创澶嶅埗 */}
         <Modal

--
Gitblit v1.8.0