From 5df578ff69f6b02e821d59a8883bc75d78695a62 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 10 十一月 2020 11:07:31 +0800 Subject: [PATCH] 2020-11-10 --- src/views/menudesign/index.jsx | 221 ++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 145 insertions(+), 76 deletions(-) diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 894a4a9..0312098 100644 --- a/src/views/menudesign/index.jsx +++ b/src/views/menudesign/index.jsx @@ -4,7 +4,8 @@ import { is, fromJS } from 'immutable' import moment from 'moment' import HTML5Backend from 'react-dnd-html5-backend' -import { ConfigProvider, notification, Modal, Collapse, Card, Icon, Switch, Button } from 'antd' +import { ConfigProvider, notification, Modal, Collapse, Card, Switch, Button } from 'antd' +import html2canvas from 'html2canvas' import Api from '@/api' import Utils from '@/utils/utils.js' @@ -48,7 +49,6 @@ oriConfig: null, openEdition: '', config: null, - editElem: null, } UNSAFE_componentWillMount() { @@ -86,10 +86,6 @@ } } - reloadTab = () => { - - } - closeView = () => { const { oriConfig, config } = this.state @@ -108,16 +104,16 @@ } submitConfig = () => { - const { config, MenuType, openEdition } = this.state + const { config, openEdition } = this.state - if (!config.MenuID) { + if (config.MenuType === 'billPrint' && (!config.MenuName || !config.MenuNo)) { notification.warning({ top: 92, - message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', + message: '璇峰畬鍠勫熀鏈俊鎭紒', duration: 5 }) return - } else if (MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId)) { + } else if (config.MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId)) { notification.warning({ top: 92, message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', @@ -137,17 +133,19 @@ delete _config.tableFields let funcs = [] - _config.components.forEach(component => { - if (component.setting && component.setting.innerFunc) { - funcs.push(`select '${_config.uuid}' as MenuID,'${component.setting.innerFunc}' as ProcName,'${component.setting.name}' as MenuName`) - } - if (component.action) { - component.action.forEach(item => { - if (!item.innerFunc) return - funcs.push(`select '${_config.uuid}' as MenuID,'${item.innerFunc}' as ProcName,'${item.label}' as MenuName`) - }) - } - }) + if (config.MenuType !== 'billPrint') { + _config.components.forEach(component => { + if (component.setting && component.setting.innerFunc) { + funcs.push(`select '${_config.uuid}' as MenuID,'${component.setting.innerFunc}' as ProcName,'${component.setting.name}' as MenuName`) + } + if (component.action) { + component.action.forEach(item => { + if (!item.innerFunc) return + funcs.push(`select '${_config.uuid}' as MenuID,'${item.innerFunc}' as ProcName,'${item.label}' as MenuName`) + }) + } + }) + } let param = { func: 'sPC_TrdMenu_AddUpt', @@ -155,10 +153,10 @@ SndID: _config.parentId, ParentID: _config.parentId, MenuID: _config.uuid, - MenuNo: _config.MenuNo, - EasyCode: _config.easyCode, + MenuNo: _config.MenuNo || '', + EasyCode: _config.easyCode || '', Template: 'CustomPage', - MenuName: _config.MenuName, + MenuName: _config.MenuName || '', PageParam: JSON.stringify({Template: 'CustomPage', OpenType: 'newtab'}), LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config))), LText: funcs.join(' union all '), @@ -175,51 +173,123 @@ this.setState({ menuloading: true + }, () => { + new Promise(resolve => { + if (config.MenuType === 'billPrint') { + html2canvas(document.getElementById('menu-shell-inner')).then(canvas => { + let img = canvas.toDataURL('image/png') // 鑾峰彇鐢熸垚鐨勫浘鐗� + Api.fileuploadbase64(img, 'cloud').then(result => { + if (result.status) { + Api.getSystemConfig({ + func: 's_PrintTemplateMSub', + ID: _config.uuid, + Images: Utils.getcloudurl(result.Images), + Remark: '', + temp_type: 'billprint', + }).then(response => { + if (response.status) { + resolve(true) + } else { + notification.warning({ + top: 92, + message: response.message, + duration: 5 + }) + this.setState({ + menuloading: false + }) + resolve(false) + } + }) + } else { + notification.warning({ + top: 92, + message: result.ErrMesg, + duration: 5 + }) + this.setState({ + menuloading: false + }) + resolve(false) + } + }) + }) + } else { + resolve(true) + } + }).then(res => { + if (!res) return + + Api.getSystemConfig(param).then(response => { + if (response.status) { + this.setState({ + oriConfig: fromJS(config).toJS(), + openEdition: response.open_edition || '', + menuloading: false + }) + notification.success({ + top: 92, + message: '淇濆瓨鎴愬姛', + duration: 2 + }) + } else { + this.setState({ + openEdition: response.open_edition || '', + menuloading: false + }) + notification.warning({ + top: 92, + message: response.message, + duration: 5 + }) + } + }) + }) }) - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - oriConfig: fromJS(config).toJS(), - openEdition: response.open_edition || '', - menuloading: false - }) - notification.success({ - top: 92, - message: '淇濆瓨鎴愬姛', - duration: 2 - }) - } else { - this.setState({ - openEdition: response.open_edition || '', - menuloading: false - }) - notification.warning({ - top: 92, - message: response.message, - duration: 5 - }) - } - }) + // Api.getSystemConfig(param).then(response => { + // if (response.status) { + // this.setState({ + // oriConfig: fromJS(config).toJS(), + // openEdition: response.open_edition || '', + // menuloading: false + // }) + // notification.success({ + // top: 92, + // message: '淇濆瓨鎴愬姛', + // duration: 2 + // }) + // } else { + // this.setState({ + // openEdition: response.open_edition || '', + // menuloading: false + // }) + // notification.warning({ + // top: 92, + // message: response.message, + // duration: 5 + // }) + // } + // }) } getMenuParam = () => { - const { MenuId, ParentId, MenuName, MenuNo } = this.state - - Api.getSystemConfig({ + const { MenuId, ParentId, MenuName, MenuNo, MenuType } = this.state + + let param = { func: 'sPC_Get_LongParam', MenuID: MenuId - }).then(result => { + } + + Api.getSystemConfig(param).then(result => { if (result.status) { let config = null - if (result.LongParam) { - try { - config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - } catch (e) { - console.warn('Parse Failure') - config = null - } + try { + config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + } catch (e) { + console.warn('Parse Failure') + config = null } if (!config) { @@ -229,6 +299,7 @@ MenuID: MenuId, parentId: ParentId, Template: 'CustomPage', + MenuType: MenuType, easyCode: '', enabled: false, MenuName: MenuName, @@ -243,6 +314,13 @@ } else { config.uuid = MenuId config.MenuID = MenuId + config.MenuType = config.MenuType || MenuType + } + + if (MenuType === 'billPrint') { + config.FstID = 'BillPrintTemp' + config.SndID = 'BillPrintTemp' + config.ParentID = 'BillPrintTemp' } this.setState({ @@ -302,12 +380,6 @@ this.props.modifyCustomMenu(config) } - editCard = (element) => { - this.setState({ - editElem: element - }) - } - onEnabledChange = () => { const { config } = this.state @@ -321,7 +393,7 @@ } verifyConfig = (show) => { - const { config, MenuType } = this.state + const { config } = this.state let error = '' if (!config.MenuID) { @@ -331,7 +403,7 @@ duration: 5 }) return - } else if (MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId)) { + } else if (config.MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId)) { notification.warning({ top: 92, message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', @@ -397,7 +469,7 @@ } render () { - const { activeKey, MenuType, dict, MenuId, config, ParentId, MenuName, MenuNo } = this.state + const { activeKey, MenuType, dict, MenuId, config, ParentId, MenuName, MenuNo, menuloading } = this.state return ( <ConfigProvider locale={_locale}> @@ -410,7 +482,7 @@ {/* 鍩烘湰淇℃伅 */} <Panel header={dict['mob.basemsg']} key="basedata"> {/* 鑿滃崟淇℃伅 */} - {MenuType === 'custom' ? <MenuForm + {config && MenuType === 'custom' ? <MenuForm dict={dict} config={config} MenuId={MenuId} @@ -425,7 +497,7 @@ </Panel> {/* 缁勪欢娣诲姞 */} <Panel header={dict['mob.component']} key="component"> - <SourceWrap /> + <SourceWrap MenuType={MenuType} /> </Panel> <Panel header={'鑳屾櫙'} key="background"> {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null} @@ -435,16 +507,13 @@ </Panel> </Collapse> </div> - <div className="menu-view"> + <div className={'menu-view ' + (menuloading ? 'saving' : '')}> <Card title={ - <div> - {config && config.MenuName} - <Icon type="redo" style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={() => this.reloadTab()} /> - </div> + <div> {config && config.MenuName} </div> } bordered={false} extra={ <div> {config ? <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config.enabled} onChange={this.onEnabledChange} /> : null} - <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{dict['mob.save']}</Button> + <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button> </div> } style={{ width: '100%' }}> {config && config.components ? <MenuShell menu={config} handleList={this.updateConfig} /> : null} -- Gitblit v1.8.0