| | |
| | | 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 |
| | |
| | | |
| | | 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, |
| | |
| | | func: 's_get_kei' |
| | | } |
| | | |
| | | Api.getCloudConfig(param).then(result => { |
| | | Api.getSystemConfig(param).then(result => { |
| | | if (result.status) { |
| | | let applist = result.data.map(item => { |
| | | item.sublist = item.data_detail || [] |
| | |
| | | */ |
| | | getMainMenuList = async () => { |
| | | let param = { |
| | | func: 's_rolemenu_get_FstMenu' |
| | | func: 's_rolemenu_get_FstMenu', |
| | | version: 1 |
| | | } |
| | | let result = await Api.getSystemConfig(param) |
| | | |
| | |
| | | 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 |
| | |
| | | let param = { |
| | | func: 's_rolemenu_get_FunMenu', |
| | | RoleID: selectRoleId, |
| | | SelectedType: '' |
| | | SelectedType: '', |
| | | version: 1 |
| | | } |
| | | |
| | | let result = await Api.getSystemConfig(param) |
| | |
| | | // 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 { |
| | |
| | | |
| | | let param = { |
| | | func: 's_rolemenu_get_Menulist', |
| | | RoleID: selectRoleId |
| | | RoleID: selectRoleId, |
| | | version: 1 |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | 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) |
| | |
| | | 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) |
| | |
| | | RoleID: selectRoleId, |
| | | TypeCharOne: selectApp.kei_no, |
| | | typename: selectSubApp.typename, |
| | | lang: selectSubApp.lang |
| | | lang: selectSubApp.lang, |
| | | version: 1 |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | /** |
| | | * @description 获取权限分配树 |
| | | */ |
| | | getTree = (parents, options) => { |
| | | getTree = (parents, options, addSelf) => { |
| | | parents.forEach(parent => { |
| | | parent.children = [] |
| | | |
| | |
| | | title: option.MenuName, |
| | | key: option.MenuID, |
| | | addSelf: option.OnlySelf === 'true', |
| | | tabs: option.Tabs |
| | | // tabs: option.Tabs |
| | | }) |
| | | } |
| | | }) |
| | |
| | | if (parent.children.length === 0) { |
| | | parent.children = null |
| | | // 针对标签,生成新的id,并保存关联关系(标签不唯一) |
| | | 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) { |
| | |
| | | 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, |
| | | }) |
| | | } |
| | | |
| | | // 针对标签,生成新的id,并保存关联关系(标签不唯一) |
| | | 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 |
| | |
| | | } |
| | | } |
| | | return true |
| | | } else if (parent.isSubView) { |
| | | return true |
| | | // } else if (parent.isSubView) { |
| | | // return true |
| | | } |
| | | return false |
| | | }) |
| | |
| | | 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, |
| | |
| | | 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 |
| | | }) |
| | | } |
| | |
| | | }) |
| | | |
| | | if (window.GLOB.mainSystemApi) { |
| | | Api.getLocalConfig(localParam).then(res => { |
| | | Api.genericInterface(localParam).then(res => { |
| | | if (!res.status) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | |
| | | this.setState({loadingAppTree: true}) |
| | | |
| | | Api.getCloudConfig(param).then(result => { |
| | | Api.getSystemConfig(param).then(result => { |
| | | if (result.status) { |
| | | if (!result.data || result.data.length === 0) { |
| | | this.setState({loadingAppTree: false, appTrees: [], appInitCheckKeys: null, appCheckedKeys: [], appOpenKeys: [], selectAppTrees: [], selectAppOpenKeys: []}) |
| | |
| | | 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"> |
| | |
| | | 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> |
| | |
| | | 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> |