king
2024-06-21 2bccb9ec7bdefe23292a22bc153463cfa1479a49
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 enUS from 'antd/es/locale/en_US'
import zhCN from 'antd/es/locale/zh_CN'
import { ApiOutlined } from '@ant-design/icons'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -15,30 +14,43 @@
const { TreeNode } = Tree
const { Search } = Input
const _locale = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
const Header = asyncComponent(() => import('./header'))
const TransferForm = asyncComponent(() => import('@/templates/zshare/basetransferform'))
sessionStorage.setItem('isEditState', 'true')
class RoleManage extends Component {
  state = {
    app: null,
    loading: false,
    menulist: [],
    sortType: '',
    columns: [
      { title: '菜单名称', dataIndex: 'MenuName', key: 'MenuName', align: 'center', render: (text, record) => {
        if (record.extra) {
          return <span style={{color: '#1890ff'}}>{text}</span>
      {
        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>
          }
          return text
        }
        return text
      } },
      },
      {
        title: '菜单参数', dataIndex: 'MenuNo', key: 'MenuNo', align: 'center'
      },
      {
        title: '修改时间', dataIndex: 'modifydate', key: 'modifydate', align: 'center', sorter: true, render: (text, record) => {
          if (window.GLOB.upStatus && record.up_action === 'Y') {
            return <span style={{color: 'orange'}}>{text}</span>
          }
          return text
        }
      },
      {
        title: '操作',
        key: 'action',
        align: 'center',
        render: (text, record) => (
          <div>
          <div style={{minWidth: '125px'}}>
            {record.type !== 'none' ?
              <Button type="link" onClick={() => this.deleteMenu(record)} style={{color: '#ff4d4f'}}>删除</Button> :
              <Button type="link" onClick={() => {
@@ -71,6 +83,10 @@
    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()
      this.getMenuList()
@@ -90,7 +106,7 @@
  getAppViewList = () => {
    const { app } = this.state
    Api.getSystemConfig({
    Api.getCloudConfig({
      func: 's_get_keyids',
      bid: app.ID
    }).then(result => {
@@ -137,6 +153,7 @@
            try {
              let pageParam = JSON.parse(window.decodeURIComponent(window.atob(item.menus_rolelist)))
              item.nodes = pageParam
              item.interfaces = pageParam.interfaces || 'false'
              
              if (pageParam.type) {
                item.type = pageParam.type
@@ -365,7 +382,8 @@
      ParentID: 'mk_app',
      TypeCharOne: app.kei_no,
      typename: app.typename,
      lang: app.lang
      lang: app.lang,
      TYPE: 30
    }).then(res => {
      if (res.status) {
        this.setState({
@@ -401,7 +419,7 @@
    let _param = {
      func: 's_kei_link_keyids_addupt',
      BID: app.ID,
      exec_type: 'y',
      exec_type: 'x',
      LText: ''
    }
@@ -410,7 +428,7 @@
    if (appViewList.length !== _appViewList.length) {
      _param.LText = _appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`)
      _param.LText = _param.LText.join(' union all ')
      _param.LText = Utils.formatOptions(_param.LText)
      _param.LText = Utils.formatOptions(_param.LText, 'x')
  
      _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      _param.secretkey = Utils.encrypt('', _param.timestamp)
@@ -477,7 +495,7 @@
      confirmLoading: true
    })
    Api.getSystemConfig({
    Api.getCloudConfig({
      func: 'sPC_MainMenu_ReDel',
      MenuID: targetKeys.join(','),
      TypeCharOne: app.kei_no,
@@ -544,7 +562,7 @@
            })
            if (app.typename === 'pc' && list.length > 0) {
              Api.getSystemConfig({
              Api.getCloudConfig({
                func: 'sPC_MainMenu_ReDel',
                MenuID: list.join(','),
                TypeCharOne: app.kei_no,
@@ -873,70 +891,87 @@
    window.open(window.location.href.replace(/#.+/ig, `#/${route}/${window.btoa(window.encodeURIComponent(JSON.stringify({...app, MenuID: item.MenuID, type: 'app'})))}`))
  }
  changeTable = (pagination, filters, sorter) => {
    this.setState({sortType: sorter.order || ''})
  }
  render () {
    const { app, loading, columns, menulist, trees, searchkey } = this.state
    let _menulist = menulist
    const { app, loading, columns, menulist, trees, searchkey, sortType } = this.state
    let _menulist = fromJS(menulist).toJS()
    if (searchkey) {
      _menulist = _menulist.filter(item => item.MenuName.toLowerCase().indexOf(searchkey.toLowerCase()) > -1)
    }
    if (sortType === 'ascend') {
      _menulist.sort((a, b) => {
        if (a.modifydate > b.modifydate) return 1
        if (a.modifydate < b.modifydate) return -1
        return 0
      })
    } else if (sortType === 'descend') {
      _menulist.sort((a, b) => {
        if (a.modifydate < b.modifydate) return 1
        if (a.modifydate > b.modifydate) return -1
        return 0
      })
    }
    return (
      <div className="mk-role-manage">
        <ConfigProvider locale={_locale}>
          <Header app={app} />
          {loading ?
            <div className="loading-mask">
              <Spin size="large" />
            </div> : null
          }
          <div className="view-wrap">
            <div className="left-view">
              <div className="app-table">
                <div className="app-action">
                  <Button className="mk-green" onClick={this.triggerThaw}>解冻菜单</Button>
                  <Search placeholder="综合搜索" onSearch={value => this.setState({ searchkey: value })} enterButton />
                </div>
                <Table
                  rowKey="MenuID"
                  columns={columns}
                  dataSource={_menulist}
                  pagination={false}
                />
              </div>
            </div>
            <div className="right-view">
        <Header app={app} />
        {loading ?
          <div className="loading-mask">
            <Spin size="large" />
          </div> : null
        }
        <div className="view-wrap">
          <div className="left-view">
            <div className="app-table">
              <div className="app-action">
                <Button className="mk-primary" onClick={this.initTree}>重置</Button>
                {/* <Button className="mk-purple" onClick={this.syncTree}>同步</Button> */}
                <Button className="mk-green save" onClick={this.saveTree}>保存</Button>
                <Button className="mk-green" onClick={this.triggerThaw}>解冻菜单</Button>
                <Search placeholder="综合搜索" onSearch={value => this.setState({ searchkey: value })} enterButton />
              </div>
              {trees && trees.length ? <Tree
                className="draggable-tree"
                defaultExpandedKeys={this.state.expandedKeys}
                // showLine
                draggable
                blockNode
                onDrop={this.onDrop}
              >
                {this.renderNode(trees)}
              </Tree> : <div className="empty">
                <Empty />
              </div>}
              <Table
                rowKey="MenuID"
                columns={columns}
                dataSource={_menulist}
                pagination={false}
                onChange={this.changeTable}
              />
            </div>
          </div>
          <Modal
            title="解除冻结"
            visible={this.state.visible}
            width={600}
            onOk={this.thawSubmit}
            confirmLoading={this.state.confirmLoading}
            onCancel={() => this.setState({visible: false, targetKeys: []})}
            destroyOnClose
          >
            <TransferForm onChange={(vals) => this.setState({targetKeys: vals})} menulist={this.state.thawmenulist}/>
          </Modal>
        </ConfigProvider>
          <div className="right-view">
            <div className="app-action">
              <Button className="mk-primary" onClick={this.initTree}>重置</Button>
              {/* <Button className="mk-purple" onClick={this.syncTree}>同步</Button> */}
              <Button className="mk-green save" onClick={this.saveTree}>保存</Button>
            </div>
            {trees && trees.length ? <Tree
              className="draggable-tree"
              defaultExpandedKeys={this.state.expandedKeys}
              // showLine
              draggable
              blockNode
              onDrop={this.onDrop}
            >
              {this.renderNode(trees)}
            </Tree> : <div className="empty">
              <Empty />
            </div>}
          </div>
        </div>
        <Modal
          title="解除冻结"
          visible={this.state.visible}
          width={600}
          onOk={this.thawSubmit}
          confirmLoading={this.state.confirmLoading}
          onCancel={() => this.setState({visible: false, targetKeys: []})}
          destroyOnClose
        >
          <TransferForm onChange={(vals) => this.setState({targetKeys: vals})} menulist={this.state.thawmenulist}/>
        </Modal>
      </div>
    )
  }