From dd2540a2cec5f495db0ce246319a795df45d4535 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 10 八月 2022 14:16:34 +0800
Subject: [PATCH] 2022-08-10

---
 src/views/menudesign/index.jsx |   75 +++++++++++++++++++++++--------------
 1 files changed, 47 insertions(+), 28 deletions(-)

diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx
index 6bc56fd..4d65fa0 100644
--- a/src/views/menudesign/index.jsx
+++ b/src/views/menudesign/index.jsx
@@ -113,9 +113,17 @@
     MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
     MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent)
     setTimeout(() => {
-      this.updateCustomComponent()
+      if (sessionStorage.getItem('app_custom_components')) {
+        let list = sessionStorage.getItem('app_custom_components')
+        list = JSON.parse(list)
+
+        this.setCustomComponent(list)
+      } else {
+        this.updateCustomComponent()
+      }
       this.getAppPictures()
       this.getPrintTemp()
+      this.getRoleFields()
       setGLOBFuncs()
     }, 1000)
 
@@ -274,36 +282,46 @@
       typename: '',
       typecharone: ''
     }).then(res => {
-      let coms = []
-      if (res.cus_list && res.cus_list.length > 0) {
-        res.cus_list.forEach(item => {
-          let config = ''
-
-          try {
-            config = JSON.parse(window.decodeURIComponent(window.atob(item.long_param)))
-          } catch (e) {
-            console.warn('Parse Failure')
-            config = ''
-          }
-
-          if (!config || !item.c_name) return
-
-          window.GLOB.UserComponentMap.set(item.c_id, item.c_name)
-          coms.push({
-            uuid: item.c_id,
-            type: 'menu',
-            title: item.c_name,
-            url: item.images,
-            component: config.type,
-            subtype: config.subtype,
-            width: config.width || 24,
-            config
-          })
+      if (!res.status) {
+        notification.warning({
+          top: 92,
+          message: res.message,
+          duration: 5
         })
+      } else if (res.cus_list) {
+        sessionStorage.setItem('app_custom_components', JSON.stringify(res.cus_list))
+        this.setCustomComponent(res.cus_list)
       }
-      this.setState({customComponents: coms})
-      this.getRoleFields()
     })
+  }
+
+  setCustomComponent = (cus_list) => {
+    let coms = []
+
+    cus_list.forEach(item => {
+      let config = ''
+
+      try {
+        config = JSON.parse(window.decodeURIComponent(window.atob(item.long_param)))
+      } catch (e) {
+        console.warn('Parse Failure')
+        config = ''
+      }
+
+      if (!config || !item.c_name) return
+
+      window.GLOB.UserComponentMap.set(item.c_id, item.c_name)
+      coms.push({
+        uuid: item.c_id,
+        type: 'menu',
+        title: item.c_name,
+        url: item.images,
+        component: config.type,
+        subtype: config.subtype,
+        config
+      })
+    })
+    this.setState({customComponents: coms})
   }
 
   updateComponentStyle = (parentId, keys, style) => {
@@ -891,6 +909,7 @@
   }
 
   getRoleFields = () => {
+    if (sessionStorage.getItem('sysRoles') || sessionStorage.getItem('permFuncField')) return
     Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => {
       if (res.status) {
         let _permFuncField = []

--
Gitblit v1.8.0