From 4614a540b53edbd83a0a9a483414cfdec0f5d321 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 02 四月 2020 14:52:58 +0800
Subject: [PATCH] 2020-04-02

---
 src/templates/modalconfig/index.jsx |   92 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 91 insertions(+), 1 deletions(-)

diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx
index a1d9d59..c6004f6 100644
--- a/src/templates/modalconfig/index.jsx
+++ b/src/templates/modalconfig/index.jsx
@@ -14,6 +14,7 @@
 import { queryTableSql } from '@/utils/option.js'
 
 import ModalForm from '@/templates/zshare/modalform'
+import PasteForm from '@/templates/zshare/pasteform'
 import DragElement from './dragelement'
 import SourceElement from './dragelement/source'
 import SettingForm from './settingform'
@@ -65,7 +66,8 @@
     groupVisible: false,   // 鍏ㄥ眬閰嶇疆妯℃�佹
     curgroup: null,        // 褰撳墠缁勶紝鏂板缓鎴栫紪杈�
     optionLibs: null,      // 鑷畾涔変笅鎷夐�夐」搴�
-    sources: null          // 琛ㄥ崟绫诲瀷
+    sources: null,         // 琛ㄥ崟绫诲瀷
+    pasteVisible: null     // 琛ㄥ崟绮樿创
   }
 
   /**
@@ -393,6 +395,21 @@
       card.originUuid = card.uuid
       card.uuid = Utils.getuuid()
       card.focus = true
+
+      // 澶嶅埗鍒板壀鍒囨澘
+      let oInput = document.createElement('input')
+      let val = JSON.parse(JSON.stringify(card))
+      val.copyType = 'form'
+
+      delete val.originUuid
+
+      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'
+      document.body.removeChild(oInput)
     }
 
     const { config } = this.state
@@ -1137,6 +1154,63 @@
     }
   }
 
+  pasteSubmit = () => {
+    let _config = JSON.parse(JSON.stringify(this.state.config))
+
+    this.pasteFormRef.handleConfirm().then(res => {
+      if (res.copyType === 'form') {
+        let repeat = false
+        if (_config.groups.length > 0) {
+          _config.groups.forEach(group => {
+            let item = group.sublist.filter(cell => cell.field === res.field)[0]
+            if (item) {
+              repeat = true
+            }
+
+            if (group.default) {
+              group.sublist.push(res)
+            }
+          })
+        } else {
+          let item = _config.fields.filter(cell => cell.field === res.field)[0]
+          if (item) {
+            repeat = true
+          }
+          _config.fields.push(res)
+        }
+
+        if (!this.props.editTab && res.type === 'linkMain') {
+          notification.warning({
+            top: 92,
+            message: '涓嶆敮鎸佹琛ㄥ崟绫诲瀷锛�',
+            duration: 10
+          })
+          return
+        } else if (repeat) {
+          notification.warning({
+            top: 92,
+            message: '姝よ〃鍗曞瓧娈靛凡瀛樺湪锛�',
+            duration: 10
+          })
+          return
+        }
+
+        this.setState({
+          config: _config,
+          pasteVisible: null
+        }, () => {
+          this.handleForm(res, 'edit')
+        })
+      } else {
+        notification.warning({
+          top: 92,
+          message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�',
+          duration: 10
+        })
+      }
+    })
+  }
+
   render () {
     const { config, source } = this.state
 
@@ -1202,6 +1276,7 @@
               </div>
             } style={{ width: '100%' }}>
               <Icon type="setting" onClick={this.changeSetting} />
+              <Icon type="snippets" title={this.state.dict['header.form.paste']} onClick={() => {this.setState({pasteVisible: true})}} />
               <div className="ant-modal-content" style={{width: config.setting.width + '%'}}>
                 <button type="button" className="ant-modal-close">
                   <span className="ant-modal-close-x"><Icon type="close"/></span>
@@ -1344,6 +1419,21 @@
             wrappedComponentRef={(inst) => this.groupRef = inst}
           />
         </Modal>
+        {/* 鎸夐挳閰嶇疆淇℃伅绮樿创澶嶅埗 */}
+        <Modal
+          title={this.state.dict['header.form.paste']}
+          visible={this.state.pasteVisible}
+          width={600}
+          maskClosable={false}
+          onOk={this.pasteSubmit}
+          onCancel={() => {this.setState({pasteVisible: null})}}
+          destroyOnClose
+        >
+          <PasteForm
+            dict={this.state.dict}
+            wrappedComponentRef={(inst) => this.pasteFormRef = inst}
+          />
+        </Modal>
       </div>
     )
   }

--
Gitblit v1.8.0