king
2025-05-13 609477f87ab12645b26793467f8edea8b398507e
src/tabviews/rolemanage/index.jsx
@@ -1,14 +1,13 @@
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
@@ -20,12 +19,10 @@
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,
@@ -80,7 +77,7 @@
      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 || []
@@ -109,7 +106,8 @@
   */
  getMainMenuList = async () => {
    let param = {
      func: 's_rolemenu_get_FstMenu'
      func: 's_rolemenu_get_FstMenu',
      version: 1
    }
    let result = await Api.getSystemConfig(param)
@@ -119,7 +117,7 @@
        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
@@ -149,7 +147,8 @@
    let param = {
      func: 's_rolemenu_get_FunMenu',
      RoleID: selectRoleId,
      SelectedType: ''
      SelectedType: '',
      version: 1
    }
    let result = await Api.getSystemConfig(param)
@@ -163,9 +162,19 @@
      //     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 {
@@ -199,7 +208,8 @@
    let param = {
      func: 's_rolemenu_get_Menulist',
      RoleID: selectRoleId
      RoleID: selectRoleId,
      version: 1
    }
    this.setState({
@@ -218,7 +228,7 @@
      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)
@@ -230,7 +240,7 @@
      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)
@@ -270,7 +280,8 @@
      RoleID: selectRoleId,
      TypeCharOne: selectApp.kei_no,
      typename: selectSubApp.typename,
      lang: selectSubApp.lang
      lang: selectSubApp.lang,
      version: 1
    }
    this.setState({
@@ -359,7 +370,7 @@
  /**
   * @description 获取权限分配树
   */
  getTree = (parents, options) => {
  getTree = (parents, options, addSelf) => {
    parents.forEach(parent => {
      parent.children = []
@@ -370,7 +381,7 @@
            title: option.MenuName,
            key: option.MenuID,
            addSelf: option.OnlySelf === 'true',
            tabs: option.Tabs
            // tabs: option.Tabs
          })
        }
      })
@@ -378,13 +389,13 @@
      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) {
@@ -395,20 +406,29 @@
          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
@@ -445,8 +465,8 @@
          }
        }
        return true
      } else if (parent.isSubView) {
        return true
      // } else if (parent.isSubView) {
      //   return true
      }
      return false
    })
@@ -555,9 +575,10 @@
          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,
@@ -574,6 +595,20 @@
        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
        })
      }
@@ -626,7 +661,7 @@
        })
        
        if (window.GLOB.mainSystemApi) {
          Api.getLocalConfig(localParam).then(res => {
          Api.genericInterface(localParam).then(res => {
            if (!res.status) {
              notification.warning({
                top: 92,
@@ -709,7 +744,7 @@
    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: []})
@@ -844,7 +879,7 @@
    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">
@@ -854,7 +889,7 @@
                  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>
@@ -921,7 +956,7 @@
                  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>