From 27f12ae6cbc056470fa8291322a75676f806b54c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 14 二月 2020 14:26:13 +0800 Subject: [PATCH] 2020-02-14 --- src/components/sidemenu/editthdmenu/index.jsx | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 158 insertions(+), 16 deletions(-) diff --git a/src/components/sidemenu/editthdmenu/index.jsx b/src/components/sidemenu/editthdmenu/index.jsx index 026d4eb..0ffe016 100644 --- a/src/components/sidemenu/editthdmenu/index.jsx +++ b/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> + {/* 瑙e喕鑿滃崟妯℃�佹 */} + <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> ) -- Gitblit v1.8.0