king
2020-03-11 590a8198e9fcb503aaeb04f6d550c65bf30c0566
src/tabviews/rolemanage/index.jsx
@@ -1,11 +1,14 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Card, Col, Row, Icon } from 'antd'
// import Api from '@/api'
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 = {
@@ -14,11 +17,61 @@
  }
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
    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) {
@@ -26,14 +79,38 @@
  }
  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
              title={<span className="role-title"><Icon type="bank" /> {this.state.dict['role.title']}</span>}
              bordered={false}>
              Card content
              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}>