king
2024-10-11 6ca240a14ccf55d4e0a94fff77e95f64db2cdfcc
src/views/rolemanage/index.jsx
@@ -1,10 +1,9 @@
import React, {Component} from 'react'
import { fromJS } from 'immutable'
import { Spin, notification, Button, Table, Modal, ConfigProvider, Tree, Input, Empty } from 'antd'
import { Spin, notification, Button, Table, Modal, Tree, Input, Empty } from 'antd'
import moment from 'moment'
import md5 from 'md5'
import zhCN from 'antd/es/locale/zh_CN'
import { ApiOutlined } from '@ant-design/icons'
import { ApiOutlined, SoundOutlined } from '@ant-design/icons'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -27,12 +26,13 @@
    columns: [
      {
        title: '菜单名称', dataIndex: 'MenuName', key: 'MenuName', align: 'center', render: (text, record) => {
          if (record.extra) {
            return <span style={{color: '#1890ff'}}>{text}</span>
          } else if (record.interfaces === 'true') {
            return <span><ApiOutlined style={{color: 'orange', marginRight: '5px'}} title="菜单中使用了外部接口" />{text}</span>
          let className = window.backend && record.backend !== 'level1' ? 'unbackend' : ''
          if (record.extra || this.state.appKeys.includes(record.MenuID)) {
            return <span className={className} style={{color: '#1890ff'}}>{text}</span>
          } else if (record.interfaces === 'true' || record.msg === 'true') {
            return <span className={className}>{record.interfaces === 'true' ? <ApiOutlined style={{color: 'orange', marginRight: '5px'}} title="菜单中使用了外部接口" /> : null}{record.msg === 'true' ? <SoundOutlined style={{color: 'orange', marginRight: '5px'}} title="菜单中发送了消息" /> : null}{text}</span>
          }
          return text
          return <span className={className}>{text}</span>
        }
      },
      {
@@ -75,7 +75,8 @@
    trees: null,
    expandedKeys: [],
    searchkey: '',
    appViewList: []
    appViewList: [],
    appKeys: []
  }
  oriTrees = null
@@ -83,6 +84,10 @@
  UNSAFE_componentWillMount() {
    document.body.className = ''
    let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
    if (param.lang) {
      sessionStorage.setItem('lang', param.lang)
    }
    this.setState({app: param}, () => {
      this.getTreeList()
@@ -115,7 +120,9 @@
        })
        return
      }
      this.setState({appViewList: result.data || []})
      let data = result.data || []
      this.setState({appViewList: data, appKeys: data.map(item => item.keys_id)})
    })
  }
@@ -151,9 +158,15 @@
              let pageParam = JSON.parse(window.decodeURIComponent(window.atob(item.menus_rolelist)))
              item.nodes = pageParam
              item.interfaces = pageParam.interfaces || 'false'
              item.msg = pageParam.msg || 'false'
              item.backend = pageParam.backend || ''
              
              if (pageParam.type) {
                item.type = pageParam.type
              }
              if (item.type === 'navbar' || item.type === 'im') {
                item.backend = 'level1'
              }
              if (pageParam.version !== '1.0') {
@@ -183,10 +196,10 @@
        })
        if (!im) {
          menus.push({nodes: '', type: 'none', extra: true, MenuID: app.instantMessage, MenuName: '即时通信'})
          menus.push({nodes: '', type: 'none', backend: 'level1', extra: true, MenuID: app.instantMessage, MenuName: '即时通信'})
        }
        if (!ub) {
          menus.push({nodes: '', type: 'none', extra: true, MenuID: app.userbind, MenuName: '用户绑定'})
          menus.push({nodes: '', type: 'none', backend: 'level1', extra: true, MenuID: app.userbind, MenuName: '用户绑定'})
        }
        this.setState({
@@ -403,7 +416,7 @@
  deleteMenu = (record) => {
    const { app, appViewList } = this.state
    const _this = this
    const that = this
    let param = {
      func: 'sPC_MainMenu_Del',
@@ -444,7 +457,7 @@
                message: '操作成功!',
                duration: 3
              })
              _this.getMenuList(true)
              that.getMenuList(true)
              if (_param) {
                Api.getCloudConfig(_param).then(res => {
@@ -455,7 +468,7 @@
                      duration: 5
                    })
                  } else {
                    _this.setState({appViewList: _appViewList})
                    that.setState({appViewList: _appViewList})
                  }
                })
              }
@@ -676,12 +689,12 @@
  }
  initTree = () => {
    const _this = this
    const that = this
    confirm({
      content: '权限树会重新生成,确定执行吗?',
      onOk() {
        return new Promise(resolve => {
          _this.getMenuList(true, resolve)
          that.getMenuList(true, resolve)
        })
      },
      onCancel() {}
@@ -689,13 +702,13 @@
  }
  syncTree = () => {
    const _this = this
    const that = this
    confirm({
      content: '同步会根据菜单删除或新增节点,确定执行吗?',
      onOk() {
        return new Promise(resolve => {
          _this.syncMenutree(resolve)
          that.syncMenutree(resolve)
        })
      },
      onCancel() {}
@@ -704,7 +717,7 @@
  saveTree = () => {
    // const { trees } = this.state
    const _this = this
    const that = this
    // if (!trees || trees.length === 0) {
    //   notification.warning({
@@ -719,7 +732,7 @@
      content: '确定执行吗?',
      onOk() {
        return new Promise(resolve => {
          _this.execSave(resolve)
          that.execSave(resolve)
        })
      },
      onCancel() {}
@@ -916,7 +929,6 @@
    return (
      <div className="mk-role-manage">
        <ConfigProvider locale={zhCN}>
          <Header app={app} />
          {loading ?
            <div className="loading-mask">
@@ -970,7 +982,6 @@
          >
            <TransferForm onChange={(vals) => this.setState({targetKeys: vals})} menulist={this.state.thawmenulist}/>
          </Modal>
        </ConfigProvider>
      </div>
    )
  }