| | |
| | | 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' |
| | |
| | | oriConfig: null, |
| | | openEdition: '', |
| | | config: null, |
| | | editElem: null, |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | |
| | | } |
| | | } |
| | | |
| | | reloadTab = () => { |
| | | |
| | | } |
| | | |
| | | closeView = () => { |
| | | const { oriConfig, config } = this.state |
| | | |
| | |
| | | } |
| | | |
| | | 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: '请完善菜单基本信息!', |
| | |
| | | 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', |
| | |
| | | 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 '), |
| | |
| | | |
| | | 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) { |
| | |
| | | MenuID: MenuId, |
| | | parentId: ParentId, |
| | | Template: 'CustomPage', |
| | | MenuType: MenuType, |
| | | easyCode: '', |
| | | enabled: false, |
| | | MenuName: MenuName, |
| | |
| | | } 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({ |
| | |
| | | this.props.modifyCustomMenu(config) |
| | | } |
| | | |
| | | editCard = (element) => { |
| | | this.setState({ |
| | | editElem: element |
| | | }) |
| | | } |
| | | |
| | | onEnabledChange = () => { |
| | | const { config } = this.state |
| | | |
| | |
| | | } |
| | | |
| | | verifyConfig = (show) => { |
| | | const { config, MenuType } = this.state |
| | | const { config } = this.state |
| | | let error = '' |
| | | |
| | | if (!config.MenuID) { |
| | |
| | | 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: '请完善菜单基本信息!', |
| | |
| | | } |
| | | |
| | | 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}> |
| | |
| | | {/* 基本信息 */} |
| | | <Panel header={dict['mob.basemsg']} key="basedata"> |
| | | {/* 菜单信息 */} |
| | | {MenuType === 'custom' ? <MenuForm |
| | | {config && MenuType === 'custom' ? <MenuForm |
| | | dict={dict} |
| | | config={config} |
| | | MenuId={MenuId} |
| | |
| | | </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} |
| | |
| | | </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} |