From e9640ccdc9fe57f91919e3f51462c780e44fadb0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 23 十二月 2020 13:14:20 +0800 Subject: [PATCH] 2020-12-23 --- src/views/menudesign/index.jsx | 63 +++++++++++++++++++++++++------ 1 files changed, 51 insertions(+), 12 deletions(-) diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 54c8363..2dfb63e 100644 --- a/src/views/menudesign/index.jsx +++ b/src/views/menudesign/index.jsx @@ -13,6 +13,7 @@ import enUS from '@/locales/en-US/mob.js' import antdEnUS from 'antd/es/locale/en_US' import antdZhCN from 'antd/es/locale/zh_CN' +import MKEmitter from '@/utils/events.js' import asyncComponent from '@/utils/asyncComponent' import { modifyCustomMenu } from '@/store/action' @@ -32,10 +33,10 @@ const PaddingController = asyncComponent(() => import('@/menu/padcontroller')) const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller')) +const PopviewController = asyncComponent(() => import('@/menu/popview/controller')) const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) sessionStorage.setItem('isEditState', 'true') -sessionStorage.setItem('delButtons', JSON.stringify([])) class MenuDesign extends Component { state = { @@ -46,6 +47,7 @@ MenuName: '', MenuNo: '', tableFields: [], + delButtons: [], activeKey: 'basedata', menuloading: false, oriConfig: null, @@ -79,6 +81,10 @@ return !is(fromJS(this.state), fromJS(nextState)) } + componentDidMount () { + MKEmitter.addListener('delButtons', this.delButtons) + } + /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 */ @@ -86,6 +92,11 @@ this.setState = () => { return } + MKEmitter.removeListener('delButtons', this.delButtons) + } + + delButtons = (items) => { + this.setState({delButtons: [...this.state.delButtons, ...items]}) } closeView = () => { @@ -149,7 +160,6 @@ backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px' }, - MenuType: MenuType } if (MenuType === 'billPrint') { config.style.paddingTop = '50px' @@ -160,7 +170,6 @@ } else { config.uuid = MenuId config.MenuID = MenuId - config.MenuType = config.MenuType || MenuType } if (MenuType === 'billPrint') { @@ -263,24 +272,24 @@ } submitConfig = () => { - const { openEdition } = this.state + const { openEdition, MenuType, delButtons } = this.state let config = fromJS(this.state.config).toJS() - if (config.MenuType === 'billPrint' && (!config.firstCount || !config.everyPCount)) { + if (MenuType === 'billPrint' && (!config.firstCount || !config.everyPCount)) { notification.warning({ top: 92, message: '璇峰畬鍠勫熀鏈俊鎭紒', duration: 5 }) return - } else if (config.MenuType === 'home' && (config.cacheUseful === 'true' && !config.cacheTime)) { + } else if (MenuType === 'home' && (config.cacheUseful === 'true' && !config.cacheTime)) { notification.warning({ top: 92, message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', duration: 5 }) return - } else if (config.MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId || (config.cacheUseful === 'true' && !config.cacheTime))) { + } else if (MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId || (config.cacheUseful === 'true' && !config.cacheTime))) { notification.warning({ top: 92, message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', @@ -333,7 +342,7 @@ LText: [] } - if (config.MenuType !== 'billPrint') { + if (MenuType !== 'billPrint') { btnParam.LText = this.getMenuMessage() btnParam.LText = btnParam.LText.join(' union all ') btnParam.LText = Utils.formatOptions(btnParam.LText) @@ -347,7 +356,7 @@ menuloading: true }, () => { new Promise(resolve => { - if (config.MenuType === 'billPrint') { + if (MenuType === 'billPrint') { html2canvas(document.getElementById('menu-shell-inner')).then(canvas => { let img = canvas.toDataURL('image/png') // 鑾峰彇鐢熸垚鐨勫浘鐗� Api.fileuploadbase64(img, 'cloud').then(result => { @@ -392,7 +401,36 @@ }).then(res => { if (!res) return - return Api.getSystemConfig(param) + if (delButtons.length === 0) { + return { + status: true + } + } else { + let _param = { + func: 'sPC_MainMenu_Del', + MenuID: delButtons.join(',') + } + return Api.getSystemConfig(_param) + } + }).then(res => { + if (!res) return + + if (res.status) { + this.setState({ + delButtons: [] + }) + return Api.getSystemConfig(param) + } else { + this.setState({ + menuloading: false + }) + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + return false + } }).then(res => { if (!res) return @@ -495,7 +533,7 @@ } verifyConfig = (show) => { - const { config } = this.state + const { config, MenuType } = this.state let error = '' config.components.forEach(item => { @@ -507,7 +545,7 @@ error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒` } else if (item.setting.interType === 'system' && item.setting.execute === 'false' && item.scripts.length === 0) { error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒` - } else if (item.setting.interType && !item.setting.primaryKey && config.MenuType !== 'billPrint') { + } else if (item.setting.interType && !item.setting.primaryKey && MenuType !== 'billPrint') { error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婚敭锛乣 } } @@ -619,6 +657,7 @@ </DndProvider> <StyleController /> <ModalController /> + <PopviewController /> </div> </ConfigProvider> ) -- Gitblit v1.8.0