From c54724b0590729c677057736bd2d04715dc0c3fb Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 22 一月 2020 14:43:24 +0800
Subject: [PATCH] 2020-01-22

---
 src/components/sidemenu/editthdmenu/index.jsx |  128 +++++++++++++++++++++++-------------------
 1 files changed, 71 insertions(+), 57 deletions(-)

diff --git a/src/components/sidemenu/editthdmenu/index.jsx b/src/components/sidemenu/editthdmenu/index.jsx
index 65d02ee..de89cd2 100644
--- a/src/components/sidemenu/editthdmenu/index.jsx
+++ b/src/components/sidemenu/editthdmenu/index.jsx
@@ -41,23 +41,24 @@
 
   state = {
     dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS,
-    thawmenulist: null,    // 宸插喕缁撶殑浜岀骇鑿滃崟
-    type: '',              // 鎿嶄綔绫诲瀷锛屾柊寤烘垨缂栬緫鑿滃崟
-    tabview: '',           // 閫夋嫨妯℃澘绐楀彛锛坱emplate锛夈�佸熀纭�琛ㄦ牸閰嶇疆锛圕ommonTable锛夈�佽〃鍗曪紙Modal锛夈�佸瓙琛紙SubTable锛�
-    editMenu: null,        // 缂栬緫鑿滃崟
-    editAction: null,      // 缂栬緫鎸夐挳
-    editTab: null,         // 缂栬緫鏍囩
-    thawMvisible: false,   // 瑙i櫎鍐荤粨妯℃�佹
-    confirmLoading: false, // 鎻愪氦涓�傘�傘��
-    selectTemp: '',        // 閫夋嫨妯℃澘
-    usedTemplates: null,   // 宸蹭娇鐢ㄦā鏉垮垪琛�
-    tempSearchKey: '',     // 鑿滃崟鍚嶇О杩囨护鍊�
-    loading: false,        // 缂栬緫鑿滃崟鎴栦娇鐢ㄥ凡浣跨敤妯℃澘鏃讹紝鑾峰彇閰嶇疆淇℃伅
-    preview: null,         // 鍥剧墖棰勮url
-    pretemplate: null,     // 棰勮妯℃澘
-    btnParam: null,        // 缂栬緫鎸夐挳鐨勯厤缃俊鎭�
-    menulist: null,        // 缂栬緫涓殑鑿滃崟
-    sysTemplates: sysTemps // 绯荤粺妯℃澘
+    thawmenulist: null,     // 宸插喕缁撶殑浜岀骇鑿滃崟
+    type: '',               // 鎿嶄綔绫诲瀷锛屾柊寤烘垨缂栬緫鑿滃崟
+    thawMvisible: false,    // 瑙i櫎鍐荤粨妯℃�佹
+    confirmLoading: false,  // 鎻愪氦涓�傘�傘��
+    selectTemp: '',         // 閫夋嫨妯℃澘
+    usedTemplates: null,    // 宸蹭娇鐢ㄦā鏉垮垪琛�
+    tempSearchKey: '',      // 鑿滃崟鍚嶇О杩囨护鍊�
+    loading: false,         // 缂栬緫鑿滃崟鎴栦娇鐢ㄥ凡浣跨敤妯℃澘鏃讹紝鑾峰彇閰嶇疆淇℃伅
+    preview: null,          // 鍥剧墖棰勮url
+    pretemplate: null,      // 棰勮妯℃澘
+    btnParam: null,         // 缂栬緫鎸夐挳鐨勯厤缃俊鎭�
+    menulist: null,         // 缂栬緫涓殑鑿滃崟
+    sysTemplates: sysTemps, // 绯荤粺妯℃澘
+    tabview: '',            // 閫夋嫨妯℃澘绐楀彛锛坱emplate锛夈�佸熀纭�琛ㄦ牸閰嶇疆锛圕ommonTable锛夈�佽〃鍗曪紙Modal锛夈�佸瓙琛紙SubTable锛�
+    editMenu: null,         // 缂栬緫鑿滃崟
+    editAction: null,       // 缂栬緫鎸夐挳
+    editTab: null,          // 缂栬緫鏍囩
+    subConfig: null         // 瀛愰厤缃俊鎭�
   }
 
   /**
@@ -177,7 +178,19 @@
         })
         return
       }
-      this.setState({tabview: 'template', type: 'add'})
+      this.setState({
+        tabview: 'template',
+        editMenu: {
+          MenuID: '',
+          MenuName: '',
+          MenuNo: '',
+          type: '',
+          PageParam: '',
+          LongParam: '',
+          isSubtable: '', // 鏄惁涓轰富瀛愯〃
+          ParentID: this.props.supMenu.MenuID
+        }
+      })
       document.getElementById('root').style.overflowY = 'hidden'
     } else if (type === 'thaw') {
       if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) {
@@ -325,8 +338,13 @@
     })
   }
 
+  /**
+   * @description 浣跨敤妯℃澘
+   * 1銆佷娇鐢ㄧ郴缁熸ā鏉挎椂锛屼娇鐢ㄧ郴缁熼厤缃�
+   * 2銆佷娇鐢ㄥ凡鏈夎彍鍗曟ā鏉挎椂锛岃幏鍙栬彍鍗曢厤缃俊鎭紝鏍囪涓簎ser锛堝鍒惰彍鍗曟寜閽級
+   */
   useTemplate = (template, useType) => {
-    const { type, editMenu } = this.state
+    const { editMenu } = this.state
 
     new Promise(resolve => {
       if (useType === 'sys') {
@@ -375,41 +393,30 @@
         })
       }
     }).then(res => {
-      if (!res) {
+      if (!res) { // 閿欒鏃讹紝閲嶇疆鐘舵��
         this.setState({
           loading: false
         })
         return
       }
 
-      // 閫夋嫨妯℃澘锛氭坊鍔犺彍鍗曟椂
-      if (type === 'add') {
-        this.setState({
-          tabview: template.type,
-          loading: false,
-          editMenu: {
-            MenuID: Utils.getuuid(),
-            MenuName: '',
-            MenuNo: '',
-            id: this.props.menulist.length,
-            src: '',
-            text: '',
-            type: template.type,
-            PageParam: {OpenType: 'newtab', Template: template.type},
-            LongParam: template.baseconfig,
-            isSubtable: template.isSubtable, // 鏄惁涓轰富瀛愯〃
-            ParentID: this.props.supMenu.MenuID
-          }
-        })
-      } else {
-        let _PageParam = {OpenType: editMenu.PageParam.OpenType || 'newtab', Template: template.type}
-
-        this.setState({
-          loading: false,
-          tabview: template.type,
-          editMenu: {...editMenu, LongParam: template.baseconfig, PageParam: _PageParam, type: template.type}
-        })
+      // 閫夋嫨妯℃澘锛氭坊鍔犺彍鍗曟椂(涓嶅瓨鍦╩enuId)
+      let _PageParam = {
+        OpenType: editMenu.PageParam ? editMenu.PageParam.OpenType : 'newtab',
+        Template: template.type
       }
+
+      this.setState({
+        loading: false,
+        tabview: template.type,
+        editMenu: {
+          ...editMenu,
+          type: template.type,
+          PageParam: _PageParam,
+          LongParam: template.baseconfig,
+          isSubtable: template.isSubtable
+        }
+      })
       document.getElementById('root').style.overflowY = 'hidden'
     })
   }
@@ -444,8 +451,17 @@
     }
   }
 
-  tabHandleConfig = () => {
-
+  handleView = (param) => {
+    this.setState({
+      tabview: ''
+    }, () => {
+      if (param) {
+        this.setState(param)
+        document.getElementById('root').style.overflowY = 'hidden'
+      } else {
+        document.getElementById('root').style.overflowY = 'unset'
+      }
+    })
   }
 
   handleSubConfig = (item, originMenu, config, type) => {
@@ -636,12 +652,10 @@
         </div>}
         {this.state.tabview === 'CommonTable' &&
           <ComTableConfig
-            type={this.state.type}
             menu={this.state.editMenu}
             supMenuList={this.props.supMenuList}
-            handleConfig={this.handleConfig}
             reloadmenu={() => {this.props.reload()}}
-            handleSubConfig={this.handleSubConfig}
+            handleView={this.handleView}
           />
         }
         {this.state.tabview === 'Modal' &&
@@ -649,16 +663,16 @@
             menu={this.state.editMenu}
             editTab={this.state.editTab}
             editAction={this.state.editAction}
-            btnParam={this.state.btnParam}
-            handleConfig={this.handleConfig}
+            subConfig={this.state.subConfig}
+            handleView={this.handleView}
           />
         }
         {this.state.tabview === 'SubTable' &&
           <SubTable
-            config={this.state.editTab}
             menu={this.state.editMenu}
-            handleConfig={this.handleConfig}
-            handleSubConfig={this.handleSubConfig}
+            editTab={this.state.editTab}
+            config={this.state.subConfig}
+            handleView={this.handleView}
           />
         }
         {this.state.tabview === 'FormTab' &&

--
Gitblit v1.8.0