From 0da0262bc236cfce928429fc4c48e1666eab3402 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 07 一月 2021 17:12:04 +0800
Subject: [PATCH] 2021-01-07

---
 src/templates/menuconfig/editthdmenu/index.jsx |  110 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 87 insertions(+), 23 deletions(-)

diff --git a/src/templates/menuconfig/editthdmenu/index.jsx b/src/templates/menuconfig/editthdmenu/index.jsx
index 9c74867..1dc074d 100644
--- a/src/templates/menuconfig/editthdmenu/index.jsx
+++ b/src/templates/menuconfig/editthdmenu/index.jsx
@@ -21,6 +21,7 @@
 import MenuForm from './menuform'
 import TransferForm from '@/templates/zshare/basetransferform'
 import Utils from '@/utils/utils.js'
+import MenuUtils from '@/menu/utils/menuUtils.js'
 import DragElement from '../menuelement'
 import asyncLoadComponent from '@/utils/asyncLoadComponent'
 import './index.scss'
@@ -627,9 +628,7 @@
         OpenType: 'newtab'
       }
 
-      if (sysMenu.OriginMenuId && sysMenu.Template === 'CustomPage') {
-        PageParam.originMenuId = sysMenu.OriginMenuId
-      } else if (sysMenu.Template === 'NewPage') {
+      if (sysMenu.Template === 'NewPage') {
         PageParam.OpenType = 'NewPage'
         PageParam.url = res.url
       }
@@ -660,28 +659,93 @@
         confirmLoading: true
       })
 
-      Api.getSystemConfig(param).then(response => {
-        if (response.status) {
-          this.setState({
-            sysTemplates: sysTemplates,
-            confirmLoading: false,
-            handleMVisible: false,
-            sysMenu: '',
-            tabview: ''
-          })
+      if (sysMenu.Template === 'CustomPage' && sysMenu.OriginMenuId) {
+        this.copyMenu(param, sysMenu.OriginMenuId)
+      } else {
+        Api.getSystemConfig(param).then(response => {
+          if (response.status) {
+            this.setState({
+              sysTemplates: sysTemplates,
+              confirmLoading: false,
+              handleMVisible: false,
+              sysMenu: '',
+              tabview: ''
+            })
+  
+            this.props.reload()
+          } else {
+            this.setState({
+              confirmLoading: false
+            })
+            notification.warning({
+              top: 92,
+              message: response.message,
+              duration: 5
+            })
+          }
+        })
+      }
+    })
+  }
 
-          this.props.reload()
-        } else {
-          this.setState({
-            confirmLoading: false
-          })
-          notification.warning({
-            top: 92,
-            message: response.message,
-            duration: 5
-          })
+  copyMenu = (param, MenuId) => {
+    Api.getSystemConfig({
+      func: 'sPC_Get_LongParam',
+      MenuID: MenuId
+    }).then(result => {
+      if (result.status) {
+        let config = null
+  
+        try {
+          config = result.LongParam ? JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) : null
+        } catch (e) {
+          console.warn('Parse Failure')
+          config = null
         }
-      })
+  
+        if (config) {
+          config.uuid = param.MenuID
+          config.MenuID = param.MenuID
+          config.parentId = param.ParentID
+          config.MenuName = param.MenuName
+          config.MenuNo = param.MenuNo
+          config.easyCode = ''
+          config.components = MenuUtils.resetConfig(config.components)
+
+          param.LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(config)))
+        }
+
+        Api.getSystemConfig(param).then(response => {
+          if (response.status) {
+            this.setState({
+              confirmLoading: false,
+              handleMVisible: false,
+              sysMenu: '',
+              tabview: ''
+            })
+  
+            this.props.reload()
+          } else {
+            this.setState({
+              confirmLoading: false
+            })
+            notification.warning({
+              top: 92,
+              message: response.message,
+              duration: 5
+            })
+          }
+        })
+      } else {
+        this.setState({
+          confirmLoading: false
+        })
+        notification.warning({
+          top: 92,
+          message: result.message,
+          duration: 5
+        })
+      }
     })
   }
 

--
Gitblit v1.8.0