king
2020-02-14 27f12ae6cbc056470fa8291322a75676f806b54c
src/components/sidemenu/editthdmenu/index.jsx
@@ -5,16 +5,19 @@
import HTML5Backend from 'react-dnd-html5-backend'
import { notification, Modal, Button, Spin, Icon, Col, Card, Tabs, Row, Input } from 'antd'
import moment from 'moment'
import Api from '@/api'
import { sysTemps } from '@/utils/option.js'
import zhCN from '@/locales/zh-CN/header.js'
import enUS from '@/locales/en-US/header.js'
import nortable from '@/assets/img/normaltable.jpg'
import Preview from './preview'
import MenuForm from './menuform'
import TransferForm from '@/components/transferform'
import Utils from '@/utils/utils.js'
import DragElement from '../menuelement'
import asyncLoadComponent from '@/utils/asyncLoadComponent'
import { sysTemps } from '@/utils/option.js'
import Api from '@/api'
import zhCN from '@/locales/zh-CN/header.js'
import enUS from '@/locales/en-US/header.js'
import nortable from '@/assets/img/normaltable.jpg'
import './index.scss'
const ComTableConfig = asyncLoadComponent(() => import('@/templates/comtableconfig'))
@@ -63,7 +66,9 @@
    subTabConfig: null,     // 子标签配置信息
    subConfig: null,        // 子配置信息
    btnTab: null,           // 打开新标签或当前页面刷新的按钮
    btnTabConfig: null      // 打开新标签按钮配置
    btnTabConfig: null,     // 打开新标签按钮配置
    handleMVisible: false,  // 添加或修改菜单模态框(角色权限分配等)
    sysMenu: false          // 添加或编辑菜单(角色权限分配等)
  }
  /**
@@ -83,7 +88,7 @@
   */
  handleMenu = (menu) => {
    const _this = this
    console.log(menu)
    if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) {
      notification.warning({
        top: 92,
@@ -117,6 +122,23 @@
      })
    } else if (menu.type === 'edit') {
      let _menu = menu.card
      if (_menu.PageParam && _menu.PageParam.Template === 'RolePermission') { // 单页面修改
        let _menu_ = {
          ..._menu,
          ParentID: this.props.supMenu.MenuID,
          Template: _menu.PageParam.Template
        }
        this.setState({
          handleMVisible: true,
          sysMenu: _menu_
        })
        return
      }
      let param = {
        func: 'sPC_Get_LongParam',
        MenuID: _menu.MenuID
@@ -351,6 +373,22 @@
  useTemplate = (template, useType) => {
    const { editMenu } = this.state
    if (useType === 'sys' && template.type === 'RolePermission') { // 独立页面
      let _menu = {
        ...template,
        MenuID: Utils.getuuid(),
        MenuName: template.title,
        Template: template.type,
        ParentID: this.props.supMenu.MenuID,
      }
      this.setState({
        handleMVisible: true,
        sysMenu: _menu
      })
      return
    }
    new Promise(resolve => {
      if (useType === 'sys') {
        resolve(true)
@@ -427,17 +465,39 @@
  }
  getUsedTemplate = () => {
    Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'menu'}).then(res => {
      this.setState({
        usedTemplates: res.UserTemp.map(temp => {
    let { sysTemplates } = this.state
          return {
            uuid: temp.MenuID,
            title: temp.MenuName,
            type: temp.Template,
            url: illust[temp.Template]
          }
    Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'menu'}).then(res => {
      let _templates = []
      let hasRolePermission = false
      res.UserTemp.forEach(temp => {
        if (temp.Template === 'RolePermission') {
          hasRolePermission = true
          return
        }
        _templates.push({
          uuid: temp.MenuID,
          title: temp.MenuName,
          type: temp.Template,
          url: illust[temp.Template]
        })
      })
      if (!hasRolePermission) {
        sysTemplates = sysTemplates.map(temp => {
          if (temp.type === 'RolePermission') {
            temp.hidden = false
          }
          return temp
        })
      }
      this.setState({
        usedTemplates: _templates,
        sysTemplates: sysTemplates
      })
    })
  }
@@ -459,6 +519,67 @@
      }
    })
  }
  /**
   * @description 三级菜单添加或修改
   */
  memuSubmit = () => {
    const { sysMenu } = this.state
    let sysTemplates = JSON.parse(JSON.stringify(this.state.sysTemplates))
    if (sysMenu.isSystem) {
      sysTemplates = sysTemplates.map(temp => {
        if (temp.type === sysMenu.type) {
          temp.hidden = true
        }
        return temp
      })
    }
    this.menuFormRef.handleConfirm().then(res => {
      let param = {
        func: 'sPC_TrdMenu_AddUpt',
        ParentID: res.ParentID,
        MenuID: sysMenu.MenuID,
        MenuNo: res.MenuNo,
        Template: sysMenu.Template,
        MenuName: res.MenuName,
        Sort: (this.props.supMenuList.length + 1) * 10,
        PageParam: JSON.stringify({Template: sysMenu.Template, OpenType: 'newtab'}),
        LongParam: ''
      }
      this.setState({
        confirmLoading: true
      })
      console.log(param)
      Api.getSystemConfig(param).then(response => {
        if (response.status) {
          this.setState({
            sysTemplates: sysTemplates,
            confirmLoading: false,
            handleMVisible: false,
            sysMenu: '',
            tabview: ''
          })
          this.props.reload()
        } else {
          this.setState({
            confirmLoading: false
          })
          notification.warning({
            top: 92,
            message: response.message,
            duration: 10
          })
        }
      })
    })
  }
  UNSAFE_componentWillMount () {
    this.getUsedTemplate()
@@ -528,6 +649,8 @@
              <TabPane tab="系统模板" key="1">
                <Row>
                  {this.state.sysTemplates.map((template, index) => {
                    if (template.hidden) return ''
                    return (
                      <Col key={`${index}`} span={8}>
                        <Card
@@ -624,10 +747,29 @@
          onOk={this.thawMemuSubmit}
          confirmLoading={this.state.confirmLoading}
          onCancel={this.thawMemuCancel}
          destroyOnClose
        >
          {!this.state.thawmenulist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />}
          {this.state.thawmenulist && <TransferForm ref="trawmenu" dict={this.state.dict} menulist={this.state.thawmenulist}/>}
        </Modal>
        {/* 解冻菜单模态框 */}
        <Modal
          title={this.state.sysMenu && this.state.sysMenu.isSystem ? this.state.dict['header.menu.tadd'] : this.state.dict['header.menu.tupdate']}
          okText={this.state.dict['header.confirm']}
          cancelText={this.state.dict['header.cancel']}
          visible={this.state.handleMVisible}
          onOk={this.memuSubmit}
          confirmLoading={this.state.confirmLoading}
          onCancel={() => {this.setState({handleMVisible: false})}}
          destroyOnClose
        >
          <MenuForm
            menu={this.state.sysMenu}
            dict={this.state.dict}
            supMenuList={this.props.supMenuList}
            wrappedComponentRef={(inst) => this.menuFormRef = inst}
          />
        </Modal>
        {this.state.loading && <Spin className="loading-thdmenu" size="large" />}
      </div>
    )