From 5b94d171aea661d000509a32448921363c77af9b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 02 四月 2020 11:13:56 +0800
Subject: [PATCH] 2020-04-02

---
 src/templates/comtableconfig/index.jsx |  100 ++++++++++++++++++++++++++++++++++---------------
 1 files changed, 69 insertions(+), 31 deletions(-)

diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx
index 65c1575..6a898c4 100644
--- a/src/templates/comtableconfig/index.jsx
+++ b/src/templates/comtableconfig/index.jsx
@@ -4,7 +4,7 @@
 import { is, fromJS } from 'immutable'
 import { DndProvider } from 'react-dnd'
 import HTML5Backend from 'react-dnd-html5-backend'
-import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty, Switch, Tooltip } from 'antd'
+import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty, Switch, Tooltip, message } from 'antd'
 import moment from 'moment'
 
 import Api from '@/api'
@@ -2653,6 +2653,27 @@
     })
   }
 
+  copycolumn = () => {
+    const { config } = this.state
+
+    let oInput = document.createElement('input')
+    let val = {
+      copyType: 'columns',
+      columns: config.columns
+    }
+
+    oInput.value = window.btoa(window.encodeURIComponent(JSON.stringify(val)))
+    document.body.appendChild(oInput)
+    oInput.select()
+    document.execCommand('Copy')
+    oInput.className = 'oInput'
+    oInput.style.display = 'none'
+
+    message.success('澶嶅埗鎴愬姛銆�')
+
+    document.body.removeChild(oInput)
+  }
+
   /**
    * @description 閫夋嫨涓嶄繚瀛樻椂锛屽鏈夊鍒舵寜閽紝鍒欏垹闄�
    */
@@ -2668,37 +2689,53 @@
   }
 
   pasteSubmit = () => {
+    const { config } = this.state
+
     this.pasteFormRef.handleConfirm().then(res => {
-      if (res.copyType !== 'action') {
+      if (res.copyType === 'action') {
+        this.setState({
+          modaltype: ''
+        }, () => {
+          this.handleAction(res, 'copy')
+        })
+      } else if (res.copyType === 'columns') {
+        if (config.columns && config.columns.length > 0) {
+          notification.warning({
+            top: 92,
+            message: '鏄剧ず鍒楀凡瀛樺湪锛�',
+            duration: 10
+          })
+          return
+        }
+        
+        this.setState({
+          modaltype: '',
+          config: {...config, columns: res.columns}
+        })
+      } else {
         notification.warning({
           top: 92,
           message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�',
           duration: 10
         })
-        return
       }
-
-      this.setState({
-        modaltype: ''
-      }, () => {
-        this.handleAction(res, 'copy')
-      })
     })
   }
 
   render () {
-    const { modaltype, activeKey } = this.state
-    const configAction = this.state.config.action.filter(_action =>
+    const { modaltype, activeKey, config } = this.state
+
+    const configAction = config.action.filter(_action =>
       !_action.origin && (_action.OpenType === 'pop' || _action.OpenType === 'popview' || _action.OpenType === 'blank' || _action.OpenType === 'tab')
     )
 
     let configTabs = []
-    this.state.config.tabgroups.forEach(group => {
-      configTabs.push(...this.state.config[group])
+    config.tabgroups.forEach(group => {
+      configTabs.push(...config[group])
     })
 
     let hasbtncrtinter = false
-    if (modaltype === 'actionEdit' && this.state.config.setting.interType === 'inner' && !this.state.config.setting.innerFunc && this.state.config.setting.dataresource) {
+    if (modaltype === 'actionEdit' && config.setting.interType === 'inner' && !config.setting.innerFunc && config.setting.dataresource) {
       hasbtncrtinter = true
     }
 
@@ -2856,7 +2893,7 @@
                 </Tooltip>
                 <DragElement
                   type="search"
-                  list={this.state.config.search}
+                  list={config.search}
                   handleList={this.handleList}
                   handleMenu={this.handleSearch}
                   deleteMenu={this.deleteElement}
@@ -2872,8 +2909,8 @@
                 </div>
                 <DragElement
                   type="action"
-                  list={this.state.config.action}
-                  setting={this.state.config.setting}
+                  list={config.action}
+                  setting={config.setting}
                   handleList={this.handleList}
                   handleMenu={this.handleAction}
                   copyElement={(val) => this.handleAction(val, 'copy')}
@@ -2888,12 +2925,13 @@
                 <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃樉绀哄垪銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬樉绀哄垪鎷栬嚦姝ゅ娣诲姞锛涙垨鐐瑰嚮銆婃坊鍔犳樉绀哄垪銆嬫寜閽壒閲忔坊鍔狅紝閫夋嫨鎵归噺娣诲姞鏃讹紝闇�鎻愬墠閫夋嫨浣跨敤琛ㄣ�傛敞锛氭坊鍔犲悎骞跺垪鏃讹紝闇�璁剧疆鍙�夊垪銆�">
                   <Icon type="question-circle" />
                 </Tooltip>
+                {config.columns && config.columns.length > 0 ? <Icon className="column-copy" title="copy" type="copy" onClick={this.copycolumn} /> : null}
                 <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showColumnName} onChange={this.onColumnNameChange} />
                 <DragElement
                   type="columns"
-                  list={this.state.config.columns}
-                  setting={this.state.config.setting}
-                  gridBtn={this.state.config.gridBtn}
+                  list={config.columns}
+                  setting={config.setting}
+                  gridBtn={config.gridBtn}
                   handleList={this.handleList}
                   handleMenu={this.handleColumn}
                   deleteMenu={this.deleteElement}
@@ -2903,13 +2941,13 @@
                 />
               </div>
               {/* 鏍囩缁� */}
-              {this.state.config.tabgroups.map((groupId, index) => {
+              {config.tabgroups.map((groupId, index) => {
                 return (
                   <div key={index} className="tab-list">
                     {index === 0 ? <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃爣绛鹃〉銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬爣绛鹃〉鎷栬嚦姝ゅ娣诲姞銆�">
                       <Icon type="question-circle" />
                     </Tooltip> : null}
-                    {index !== (this.state.config.tabgroups.length - 1) ?
+                    {index !== (config.tabgroups.length - 1) ?
                       <Icon type="arrow-down" onClick={() => {this.handleGroup(index, 'down')}} /> : null
                     }
                     {index !== 0 ? <Icon type="arrow-up" onClick={() => {this.handleGroup(index, 'up')}} /> : null}
@@ -2918,7 +2956,7 @@
                     <TabDragElement
                       type="tabs"
                       groupId={groupId}
-                      list={this.state.config[groupId]}
+                      list={config[groupId]}
                       handleList={this.handleList}
                       handleMenu={this.handleTab}
                       deleteMenu={this.deleteElement}
@@ -2970,7 +3008,7 @@
             tabs={this.state.tabviews}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}
-            setting={this.state.config.setting}
+            setting={config.setting}
             wrappedComponentRef={(inst) => this.actionFormRef = inst}
           />
         </Modal>
@@ -3006,7 +3044,7 @@
             dict={this.state.dict}
             card={this.state.card}
             inputSubmit={this.handleSubmit}
-            columns={this.state.config.columns}
+            columns={config.columns}
             wrappedComponentRef={(inst) => this.columnFormRef = inst}
           />
         </Modal>
@@ -3023,7 +3061,7 @@
           <GridBtnForm
             dict={this.state.dict}
             inputSubmit={this.handleSubmit}
-            card={this.state.config.gridBtn}
+            card={config.gridBtn}
             wrappedComponentRef={(inst) => this.gridBtnFormRef = inst}
           />
         </Modal>
@@ -3088,7 +3126,7 @@
             <VerifyCard
               card={this.state.card}
               dict={this.state.dict}
-              columns={this.state.config.columns}
+              columns={config.columns}
               wrappedComponentRef={(inst) => this.verifyRef = inst}
             /> : null
           }
@@ -3096,7 +3134,7 @@
             <VerifyCardPrint
               card={this.state.card}
               dict={this.state.dict}
-              columns={this.state.config.columns}
+              columns={config.columns}
               wrappedComponentRef={(inst) => this.verifyRef = inst}
             /> : null
           }
@@ -3104,7 +3142,7 @@
             <VerifyCardExcelIn
               card={this.state.card}
               dict={this.state.dict}
-              columns={this.state.config.columns}
+              columns={config.columns}
               wrappedComponentRef={(inst) => this.verifyRef = inst}
             /> : null
           }
@@ -3139,8 +3177,8 @@
             dict={this.state.dict}
             menu={this.props.menu}
             inputSubmit={this.settingSave}
-            data={this.state.config.setting}
-            columns={this.state.config.columns}
+            data={config.setting}
+            columns={config.columns}
             usefulFields={this.props.permFuncField}
             wrappedComponentRef={(inst) => this.settingRef = inst}
           />

--
Gitblit v1.8.0