From ca5a4e0093a967a62b1bdd49c802bc92e88bbc11 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 21 四月 2025 12:13:32 +0800
Subject: [PATCH] 2025-04-21

---
 src/tabviews/rolemanage/index.jsx |   96 +++++++++++++++++++++++++++++++----------------
 1 files changed, 63 insertions(+), 33 deletions(-)

diff --git a/src/tabviews/rolemanage/index.jsx b/src/tabviews/rolemanage/index.jsx
index 6292715..7e80fd8 100644
--- a/src/tabviews/rolemanage/index.jsx
+++ b/src/tabviews/rolemanage/index.jsx
@@ -6,7 +6,6 @@
 import md5 from 'md5'
 
 import Api from '@/api'
-import options from '@/store/options.js'
 import Utils from '@/utils/utils.js'
 import MKEmitter from '@/utils/events.js'
 import './index.scss'
@@ -20,7 +19,6 @@
 
 export default class RoleManage extends Component {
   static propTpyes = {
-    MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟
     MenuID: PropTypes.string  // 鑿滃崟Id
   }
 
@@ -75,8 +73,6 @@
   }
 
   getAppList = () => {
-    if (options.sysType !== 'local') return
-
     let param = {
       func: 's_get_kei'
     }
@@ -110,7 +106,8 @@
    */
   getMainMenuList = async () => {
     let param = {
-      func: 's_rolemenu_get_FstMenu'
+      func: 's_rolemenu_get_FstMenu',
+      version: 1
     }
     let result = await Api.getSystemConfig(param)
 
@@ -120,7 +117,7 @@
         loading: false,
         mainMenus: result.data.map(item => {
           return {
-            title: item.MenuName,
+            title: item.langname ? item.MenuName + '(' + item.langname + ')' : item.MenuName,
             key: item.MenuID,
             children: [],
             selected: true
@@ -150,7 +147,8 @@
     let param = {
       func: 's_rolemenu_get_FunMenu',
       RoleID: selectRoleId,
-      SelectedType: ''
+      SelectedType: '',
+      version: 1
     }
 
     let result = await Api.getSystemConfig(param)
@@ -164,9 +162,19 @@
       //     item.ParentID = item.TypeCharOne
       //   }
       // })
+      // let map = new Map() // 鍘婚噸
+
+      // result.data = result.data.filter(item => {
+      //   if (map.has(item.ParentID + item.MenuID)) return false
+
+      //   map.set(item.ParentID + item.MenuID, true)
+        
+      //   return true
+      // })
+
       let _tree = this.getTree(fromJS(mainMenus).toJS(), result.data)
       if (_tree[0]) {
-        if (_tree[0].key === 'PC' && _tree[0].children) {
+        if (_tree[0].key.indexOf('PC') > -1 && _tree[0].children) {
           // _openKeys = _tree[0].children.map(cell => cell.key)
           this.getOpenNode(_tree[0].children[0], _openKeys)
         } else {
@@ -219,7 +227,7 @@
       this.getCheckedKeys(fromJS(menuTrees).toJS(), _initKeys)
 
       if (menuTrees[0]) {
-        if (menuTrees[0].key === 'PC' && menuTrees[0].children) {
+        if (menuTrees[0].key.indexOf('PC') > -1 && menuTrees[0].children) {
           this.getOpenNode(menuTrees[0].children[0], _openKeys)
         } else {
           this.getOpenNode(menuTrees[0], _openKeys)
@@ -231,7 +239,7 @@
       let _tree = this.getSelectTree(fromJS(menuTrees).toJS(), Keys)
 
       if (_tree[0]) {
-        if (_tree[0].key === 'PC' && _tree[0].children) {
+        if (_tree[0].key.indexOf('PC') > -1 && _tree[0].children) {
           this.getOpenNode(_tree[0].children[0], _openkeys)
         } else {
           this.getOpenNode(_tree[0], _openkeys)
@@ -360,7 +368,7 @@
   /**
    * @description 鑾峰彇鏉冮檺鍒嗛厤鏍�
    */
-  getTree = (parents, options) => {
+  getTree = (parents, options, addSelf) => {
     parents.forEach(parent => {
       parent.children = []
 
@@ -371,7 +379,7 @@
             title: option.MenuName,
             key: option.MenuID,
             addSelf: option.OnlySelf === 'true',
-            tabs: option.Tabs
+            // tabs: option.Tabs
           })
         }
       })
@@ -379,13 +387,13 @@
       if (parent.children.length === 0) {
         parent.children = null
         // 閽堝鏍囩锛岀敓鎴愭柊鐨刬d锛屽苟淇濆瓨鍏宠仈鍏崇郴锛堟爣绛句笉鍞竴锛�
-        if (parent.tabs) {
-          let _uuid = Utils.getuuid()
-          linkMap.set(_uuid, parent.key)
+        // if (parent.tabs) {
+        //   let _uuid = Utils.getuuid()
+        //   linkMap.set(_uuid, parent.key)
 
-          parent.originKey = parent.key
-          parent.key = _uuid
-        }
+        //   parent.originKey = parent.key
+        //   parent.key = _uuid
+        // }
       } else {
         // 涓夌骇鑿滃崟鍒涘缓瀛愰」
         if (parent.addSelf) {
@@ -396,20 +404,29 @@
           parent.children.unshift({
             title: parent.title + '(浠呴〉闈�)',
             key: _uuid,
-            isSubView: true
+            // isSubView: true
+          })
+        } else if (addSelf) {
+          let _uuid = Utils.getuuid()
+          linkMap.set(_uuid, parent.key)
+          parent.subKey = _uuid
+
+          parent.children.unshift({
+            title: parent.title + '(琛ㄦ牸)',
+            key: _uuid,
           })
         }
 
         // 閽堝鏍囩锛岀敓鎴愭柊鐨刬d锛屽苟淇濆瓨鍏宠仈鍏崇郴锛堟爣绛句笉鍞竴锛�
-        if (parent.tabs) {
-          let _uuid = Utils.getuuid()
-          linkMap.set(_uuid, parent.key)
+        // if (parent.tabs) {
+        //   let _uuid = Utils.getuuid()
+        //   linkMap.set(_uuid, parent.key)
           
-          parent.originKey = parent.key
-          parent.key = _uuid
-        }
+        //   parent.originKey = parent.key
+        //   parent.key = _uuid
+        // }
 
-        parent.children = this.getTree(parent.children, options)
+        parent.children = this.getTree(parent.children, options, parent.addSelf)
       }
     })
     return parents
@@ -446,8 +463,8 @@
           }
         }
         return true
-      } else if (parent.isSubView) {
-        return true
+      // } else if (parent.isSubView) {
+      //   return true
       }
       return false
     })
@@ -556,9 +573,10 @@
           submitloading: false
         }, () => {
           this.getSelectMenuList()
+          this.clearBackSqlCache()
         })
         if (window.GLOB.mainSystemApi) {
-          Api.getLocalConfig(localParam).then(res => {
+          Api.genericInterface(localParam).then(res => {
             if (!res.status) {
               notification.warning({
                 top: 92,
@@ -575,6 +593,20 @@
         notification.warning({
           top: 92,
           message: result.message,
+          duration: 5
+        })
+      }
+    })
+  }
+
+  clearBackSqlCache = () => {
+    if (!window.backend) return
+
+    Api.cacheInterface({}).then(res => {
+      if (!res.status) {
+        notification.warning({
+          top: 92,
+          message: res.message || '缂撳瓨娓呯┖澶辫触锛�',
           duration: 5
         })
       }
@@ -627,7 +659,7 @@
         })
         
         if (window.GLOB.mainSystemApi) {
-          Api.getLocalConfig(localParam).then(res => {
+          Api.genericInterface(localParam).then(res => {
             if (!res.status) {
               notification.warning({
                 top: 92,
@@ -844,10 +876,8 @@
   render() {
     const { activeKey, filterRoleList, applist, selectApp, selectSubApp, loading, loadingTree, loadingAppTree, primarykey, menuTrees, appTrees, checkedKeys, appCheckedKeys, menuOpenKeys, selectMenuTrees, selectAppTrees, selectRoleId, selectMenuOpenKeys, selectAppOpenKeys, submitloading, appOpenKeys } = this.state
 
-    let ismanage = options.sysType !== 'local'
-    
     return (
-      <div className={'rolemanage' + (ismanage ? ' manager' : '')}>
+      <div className={'rolemanage' + (applist.length === 0 ? ' manager' : '')}>
         {loading && <Spin size="large" />}
         <Tabs activeKey={activeKey} type="card" onChange={this.changeType}>
           <TabPane tab="绠$悊绯荤粺" key="manage">

--
Gitblit v1.8.0