king
2020-03-11 590a8198e9fcb503aaeb04f6d550c65bf30c0566
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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>
    )
  }
}