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 | 101 +++++++++++++++++++++++++++++++++----------------- 1 files changed, 67 insertions(+), 34 deletions(-) diff --git a/src/tabviews/rolemanage/index.jsx b/src/tabviews/rolemanage/index.jsx index fc1a5b4..7e80fd8 100644 --- a/src/tabviews/rolemanage/index.jsx +++ b/src/tabviews/rolemanage/index.jsx @@ -1,14 +1,13 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Card, Col, Row, Icon, Menu, notification, Spin, Input, Tabs, Button, Tree, Empty, Select } from 'antd' +import { Card, Col, Row, Menu, notification, Spin, Input, Tabs, Button, Tree, Empty, Select } from 'antd' +import { BankOutlined } from '@ant-design/icons' import md5 from 'md5' import Api from '@/api' import Utils from '@/utils/utils.js' import MKEmitter from '@/utils/events.js' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' import './index.scss' const { Search } = Input @@ -20,12 +19,10 @@ export default class RoleManage extends Component { static propTpyes = { - MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 MenuID: PropTypes.string // 鑿滃崟Id } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, loading: true, loadingTree: false, loadingAppTree: false, @@ -109,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) @@ -119,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 @@ -149,7 +147,8 @@ let param = { func: 's_rolemenu_get_FunMenu', RoleID: selectRoleId, - SelectedType: '' + SelectedType: '', + version: 1 } let result = await Api.getSystemConfig(param) @@ -163,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 { @@ -218,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) @@ -230,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) @@ -359,7 +368,7 @@ /** * @description 鑾峰彇鏉冮檺鍒嗛厤鏍� */ - getTree = (parents, options) => { + getTree = (parents, options, addSelf) => { parents.forEach(parent => { parent.children = [] @@ -370,7 +379,7 @@ title: option.MenuName, key: option.MenuID, addSelf: option.OnlySelf === 'true', - tabs: option.Tabs + // tabs: option.Tabs }) } }) @@ -378,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) { @@ -395,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 @@ -445,8 +463,8 @@ } } return true - } else if (parent.isSubView) { - return true + // } else if (parent.isSubView) { + // return true } return false }) @@ -555,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, @@ -574,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 }) } @@ -626,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,7 +877,7 @@ const { activeKey, filterRoleList, applist, selectApp, selectSubApp, loading, loadingTree, loadingAppTree, primarykey, menuTrees, appTrees, checkedKeys, appCheckedKeys, menuOpenKeys, selectMenuTrees, selectAppTrees, selectRoleId, selectMenuOpenKeys, selectAppOpenKeys, submitloading, appOpenKeys } = this.state return ( - <div className="rolemanage"> + <div className={'rolemanage' + (applist.length === 0 ? ' manager' : '')}> {loading && <Spin size="large" />} <Tabs activeKey={activeKey} type="card" onChange={this.changeType}> <TabPane tab="绠$悊绯荤粺" key="manage"> @@ -854,7 +887,7 @@ className="role-list" title={ <span className="role-title"> - <Icon type="bank" /> + <BankOutlined /> <span className="title">瑙掕壊</span> <Search placeholder="" value={primarykey} onChange={e => this.setState({primarykey: e.target.value})} onSearch={this.filterRole} /> </span> @@ -921,7 +954,7 @@ className="role-list" title={ <span className="role-title"> - <Icon type="bank" /> + <BankOutlined /> <span className="title">瑙掕壊</span> <Search placeholder="" value={primarykey} onChange={e => this.setState({primarykey: e.target.value})} onSearch={this.filterRole} /> </span> -- Gitblit v1.8.0