From e603c97dbe7a4f1dbd6445e00383ed651182e0fe Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 03 三月 2020 17:09:11 +0800
Subject: [PATCH] 2020-03-03

---
 src/templates/formtabconfig/index.jsx |   92 ++++++++++++++++++++++++++++++++-------------
 1 files changed, 65 insertions(+), 27 deletions(-)

diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx
index 31b1c27..0f47aef 100644
--- a/src/templates/formtabconfig/index.jsx
+++ b/src/templates/formtabconfig/index.jsx
@@ -371,7 +371,7 @@
   }
 
   handleSearch = (card) => {
-    const {menu} = this.props
+    const { menu } = this.props
     const { config } = this.state
     let _inputfields = []
     let _linkableFields = []
@@ -558,7 +558,7 @@
    */
   handleSubmit = () => {
     const { btnTab } = this.props
-    const { config, modaltype, optionLibs } = this.state
+    const { config, modaltype, optionLibs, card } = this.state
 
     if (modaltype === 'search') {
       this.modalFormRef.handleConfirm().then(res => {
@@ -583,19 +583,42 @@
             options: res.options
           })
         }
-        let _groups = config.groups.map(group => {
-          group.sublist = group.sublist.map(item => {
-            if (item.uuid === res.uuid) {
-              return res
-            } else {
-              return item
+
+        let _groups = null
+
+        if (card.iscopy) {
+          _groups = config.groups.map(group => {
+            let _index = null
+            group.sublist.forEach((item, index) => {
+              if (item.uuid === card.originUuid) {
+                _index = index
+              }
+            })
+
+            if (_index !== null) {
+              group.sublist.splice(_index + 1, 0, res)
             }
+
+            if (group.isDefault) {
+              group.sublist = group.sublist.filter(item => !item.origin)
+            }
+            return group
           })
-          if (group.isDefault) {
-            group.sublist = group.sublist.filter(item => !item.origin)
-          }
-          return group
-        })
+        } else {
+          _groups = config.groups.map(group => {
+            group.sublist = group.sublist.map(item => {
+              if (item.uuid === res.uuid) {
+                return res
+              } else {
+                return item
+              }
+            })
+            if (group.isDefault) {
+              group.sublist = group.sublist.filter(item => !item.origin)
+            }
+            return group
+          })
+        }
 
         this.setState({
           config: {...config, groups: _groups},
@@ -711,10 +734,10 @@
           }).then(res => {
             let _LongParam = ''
             if (res.status && res.LongParam) {
-              _LongParam = window.decodeURIComponent(window.atob(res.LongParam))
               try {
-                _LongParam = JSON.parse(_LongParam)
+                _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
               } catch (e) {
+                console.warn('Parse Failure')
                 _LongParam = ''
               }
             }
@@ -1373,9 +1396,9 @@
         
                   if (result.LongParam) {
                     try {
-                      _LongParam = window.decodeURIComponent(window.atob(result.LongParam))
-                      _LongParam = JSON.parse(_LongParam)
+                      _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
                     } catch (e) {
+                      console.warn('Parse Failure')
                       _LongParam = ''
                     }
                   }
@@ -1441,13 +1464,23 @@
         
         let tabParam = { // 娣诲姞鑿滃崟tab椤�
           func: 'sPC_sMenusTab_AddUpt',
-          MenuID: btnTab.uuid,
-          LText: config.tabs.map((item, index) => {
-            return `select '${btnTab.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`
-          })
+          MenuID: btnTab.uuid
         }
-        tabParam.LText = tabParam.LText.join(' union all ')
-        tabParam.LText = Utils.formatOptions(tabParam.LText)
+        
+        let _LText = []
+        let _index = 1
+
+        config.tabgroups.forEach(groupId => {
+          config[groupId].forEach(item => {
+            _LText.push(`select '${btnTab.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_index * 10}' as Sort`)
+            _index++
+          })
+        })
+
+        _LText = _LText.join(' union all ')
+
+        tabParam.LText = Utils.formatOptions(_LText)
+
         tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
         tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp)
   
@@ -1898,10 +1931,10 @@
               })
               let _LongParam = ''
               if (res.LongParam) {
-                _LongParam = window.decodeURIComponent(window.atob(res.LongParam))
                 try {
-                  _LongParam = JSON.parse(_LongParam)
+                  _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
                 } catch (e) {
+                  console.warn('Parse Failure')
                   _LongParam = ''
                 }
               }
@@ -2328,7 +2361,7 @@
         </DndProvider>
         {/* 缂栬緫琛ㄥ崟 */}
         <Modal
-          title={this.state.dict['header.modal.form.edit']}
+          title={this.state.card && this.state.card.iscopy ? this.state.dict['header.modal.form.copy'] : this.state.dict['header.modal.form.edit']}
           visible={modaltype === 'search'}
           width={700}
           maskClosable={false}
@@ -2340,6 +2373,7 @@
             dict={this.state.dict}
             card={this.state.card}
             formlist={this.state.formlist}
+            inputSubmit={this.handleSubmit}
             optionLibs={this.state.optionLibs}
             wrappedComponentRef={(inst) => this.modalFormRef = inst}
           />
@@ -2364,6 +2398,7 @@
             card={this.state.card}
             tabs={this.state.tabviews}
             formlist={this.state.formlist}
+            inputSubmit={this.handleSubmit}
             wrappedComponentRef={(inst) => this.actionFormRef = inst}
           />
         </Modal>
@@ -2383,6 +2418,7 @@
             card={this.state.card}
             tabs={this.state.tabviews}
             formlist={this.state.formlist}
+            inputSubmit={this.handleSubmit}
             wrappedComponentRef={(inst) => this.tabsFormRef = inst}
           />
         </Modal>
@@ -2453,6 +2489,7 @@
             dict={this.state.dict}
             menu={this.props.menu}
             config={this.state.config}
+            inputSubmit={this.settingSave}
             usefulFields={this.props.permFuncField}
             wrappedComponentRef={(inst) => this.settingRef = inst}
           />
@@ -2483,8 +2520,9 @@
         >
           <GroupForm
             groups={config.groups}
-            group={this.state.editgroup}
             dict={this.state.dict}
+            group={this.state.editgroup}
+            inputSubmit={this.handleGroupSave}
             wrappedComponentRef={(inst) => this.groupRef = inst}
           />
         </Modal>

--
Gitblit v1.8.0