| | |
| | | import Utils, { setGLOBFuncs } from '@/utils/utils.js' |
| | | import antdZhCN from 'antd/es/locale/zh_CN' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import { getTables } from '@/utils/utils-custom.js' |
| | | import SourceElement from '@/templates/zshare/dragsource' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Source from './source' |
| | |
| | | const _locale = antdZhCN |
| | | |
| | | const MenuForm = asyncComponent(() => import('./menuform')) |
| | | const PopView = asyncComponent(() => import('./popview')) |
| | | const TableNodes = asyncComponent(() => import('@/menu/tablenodes')) |
| | | const TableSource = asyncComponent(() => import('./tablesource')) |
| | | const Header = asyncComponent(() => import('@/menu/header')) |
| | |
| | | config: null, |
| | | comloading: false, |
| | | settingshow: true, |
| | | view: null, |
| | | popConfig: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | |
| | | |
| | | let node = document.getElementById('save-modal-config') |
| | | if (!node) { |
| | | node = document.getElementById('save-pop-config') |
| | | } |
| | | if (!node) { |
| | | node = document.getElementById('save-config') |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | triggerMenuSave = () => { |
| | | if (this.state.view === 'popview') return |
| | | |
| | | this.submitConfig() |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | initPopview = (card, btn) => { |
| | | const { oriConfig, config } = this.state |
| | | const { config } = this.state |
| | | |
| | | if (!is(fromJS(oriConfig), fromJS(config))) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '配置已修改,请保存!', |
| | | duration: 5 |
| | | }) |
| | | if (!this.checkBase()) { |
| | | return |
| | | } |
| | | |
| | | let _btn = fromJS(btn).toJS() |
| | | _btn.MenuName = config.MenuName + '-' + card.name + '-' + btn.label |
| | | _btn.ParentMenuID = config.uuid |
| | | |
| | | this.props.history.push('/popdesign/' + window.btoa(window.encodeURIComponent((JSON.stringify(_btn))))) |
| | | if (_btn.config) { |
| | | _btn.config.uuid = _btn.uuid |
| | | _btn.config.MenuID = _btn.uuid |
| | | _btn.config.ParentId = card.uuid |
| | | _btn.config.MenuName = _btn.label |
| | | } else { |
| | | _btn.config = { |
| | | uuid: _btn.uuid, |
| | | MenuID: _btn.uuid, |
| | | ParentId: card.uuid, |
| | | enabled: false, |
| | | MenuName: _btn.label, |
| | | tables: config.tables || [], |
| | | Template: 'BaseTable', |
| | | components: [{ |
| | | uuid: Utils.getuuid(), |
| | | type: 'table', |
| | | width: 24, |
| | | name: '主表', |
| | | subtype: 'basetable', |
| | | isNew: true |
| | | }], |
| | | viewType: 'popview', |
| | | style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } |
| | | } |
| | | } |
| | | |
| | | this.setState({view: 'popview', popConfig: _btn}) |
| | | } |
| | | |
| | | submitPopConfig = (btnconfig) => { |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | config.components.forEach(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | if (btnconfig.ParentId !== tab.components[0].uuid) return |
| | | |
| | | tab.components[0].action.forEach(btn => { |
| | | if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | tab.components[0].cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | tab.components[0].$tables = getTables(tab.components[0]) |
| | | }) |
| | | } else if (item.uuid === btnconfig.ParentId) { |
| | | item.action.forEach(btn => { |
| | | if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | item.$tables = getTables(item) |
| | | } |
| | | }) |
| | | |
| | | this.setState({ config }, () => { |
| | | this.submitConfig() |
| | | }) |
| | | } |
| | | |
| | | closePop = () => { |
| | | const { config } = this.state |
| | | |
| | | sessionStorage.setItem('editMenuType', 'menu') |
| | | |
| | | window.GLOB.urlFields = config.urlFields || [] |
| | | window.GLOB.customMenu = config |
| | | |
| | | this.setState({view: '', popConfig: null}) |
| | | } |
| | | |
| | | closeView = () => { |
| | |
| | | return buttons |
| | | } |
| | | |
| | | submitConfig = () => { |
| | | let config = fromJS(this.state.config).toJS() |
| | | checkBase = () => { |
| | | const { config } = this.state |
| | | |
| | | if (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId) { |
| | | notification.warning({ |
| | |
| | | message: '请完善菜单基本信息!', |
| | | duration: 5 |
| | | }) |
| | | return false |
| | | } |
| | | return true |
| | | } |
| | | |
| | | submitConfig = () => { |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | if (!this.checkBase()) { |
| | | return |
| | | } |
| | | |
| | |
| | | localStorage.setItem('menuUpdate', new Date().getTime()) |
| | | } |
| | | config.open_edition = res.open_edition || '' |
| | | |
| | | this.setState({ |
| | | config, |
| | | oriConfig: fromJS(config).toJS(), |
| | |
| | | } |
| | | |
| | | render () { |
| | | const { activeKey, comloading, MenuId, config, settingshow, ParentId, menuloading } = this.state |
| | | const { view, activeKey, comloading, MenuId, config, settingshow, ParentId, menuloading } = this.state |
| | | |
| | | return ( |
| | | <ConfigProvider locale={_locale}> |
| | | <div className="pc-table-view"> |
| | | <Header /> |
| | | <DndProvider backend={HTML5Backend}> |
| | | <Header /> |
| | | <DndProvider backend={HTML5Backend}> |
| | | {view !== 'popview' ? <div className="pc-table-view"> |
| | | <div className="menu-body"> |
| | | <div className={'menu-setting ' + (!settingshow ? 'hidden' : '')}> |
| | | <div className="draw"> |
| | |
| | | </Card> |
| | | </div> |
| | | </div> |
| | | </DndProvider> |
| | | <StyleController /> |
| | | <ModalController /> |
| | | </div> |
| | | </div> : <PopView btn={this.state.popConfig} save={this.submitPopConfig} cancel={this.closePop}/>} |
| | | </DndProvider> |
| | | <StyleController /> |
| | | <ModalController /> |
| | | </ConfigProvider> |
| | | ) |
| | | } |