import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { Card, Col, Row, Icon, Menu, notification, Spin, Input } from 'antd'
|
|
import Api from '@/api'
|
import zhCN from '@/locales/zh-CN/role.js'
|
import enUS from '@/locales/en-US/role.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,
|
loadingview: true,
|
roleList: null,
|
primarykey: ''
|
}
|
|
getRoleList = async () => {
|
let param = {
|
func: 's_rolemenu_get_list'
|
}
|
let result = await Api.getSystemConfig(param)
|
|
if (result.status) {
|
this.setState({
|
roleList: result.data
|
})
|
} else {
|
this.setState({
|
loadingview: false
|
})
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
}
|
}
|
|
getMenuList = async () => {
|
let param = {
|
func: 's_rolemenu_get_FstMenu'
|
}
|
let result = await Api.getSystemConfig(param)
|
|
if (result.status) {
|
|
} else {
|
this.setState({
|
loadingview: false
|
})
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
}
|
}
|
|
changeRole = () => {
|
|
}
|
|
UNSAFE_componentWillMount () {
|
this.getRoleList()
|
this.getMenuList()
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
render() {
|
const { roleList, loadingview, primarykey } = this.state
|
|
let _roleList = []
|
|
if (roleList && roleList.length > 0) {
|
_roleList = roleList.filter(role => role.RoleName.toLowerCase().indexOf(primarykey.toLowerCase()) >= 0)
|
}
|
|
return (
|
<div className="rolemanage">
|
{loadingview && <Spin size="large" />}
|
<Row gutter={16}>
|
<Col span={6}>
|
<Card
|
className="role-list"
|
title={
|
<span className="role-title">
|
<Icon type="bank" />
|
<span className="title">{this.state.dict['role.title']}</span>
|
<Search placeholder="" onSearch={value => this.setState({primarykey: value})} />
|
</span>
|
}
|
bordered={false}
|
>
|
<Menu
|
onClick={this.handleClick}
|
mode="inline"
|
>
|
{_roleList.map((role, index) =>
|
<Menu.Item key={index} onClick={() => this.changeRole(role)}>{role.RoleName}</Menu.Item>
|
)}
|
</Menu>
|
</Card>
|
</Col>
|
<Col span={18}>
|
<Card title="Card title" bordered={false}>
|
Card content
|
</Card>
|
</Col>
|
</Row>
|
</div>
|
)
|
}
|
}
|