From 76a4300654a18d228838c3f27455dc8e7a8cd616 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 15 一月 2021 17:04:42 +0800 Subject: [PATCH] Merge branch 'master' into bms --- src/menu/popview/index.jsx | 95 ++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 89 insertions(+), 6 deletions(-) diff --git a/src/menu/popview/index.jsx b/src/menu/popview/index.jsx index a90b4c0..97061ff 100644 --- a/src/menu/popview/index.jsx +++ b/src/menu/popview/index.jsx @@ -24,7 +24,9 @@ const SourceWrap = asyncComponent(() => import('@/menu/modelsource')) const MenuShell = asyncComponent(() => import('@/menu/menushell')) const BgController = asyncComponent(() => import('@/menu/bgcontroller')) +const PasteController = asyncComponent(() => import('@/menu/pastecontroller')) const PaddingController = asyncComponent(() => import('@/menu/padcontroller')) +const StyleCombControlButton = asyncComponent(() => import('@/menu/stylecombcontrolbutton')) const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) sessionStorage.setItem('isEditState', 'true') @@ -47,6 +49,7 @@ oriConfig: null, openEdition: '', config: null, + customComponents: [] } UNSAFE_componentWillMount() { @@ -61,6 +64,9 @@ componentDidMount () { MKEmitter.addListener('delButtons', this.delButtons) + MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) + MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent) + this.updateCustomComponent() } shouldComponentUpdate (nextProps, nextState) { @@ -75,6 +81,64 @@ return } MKEmitter.removeListener('delButtons', this.delButtons) + MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) + MKEmitter.removeListener('updateCustomComponent', this.updateCustomComponent) + } + + updateCustomComponent = () => { + Api.getSystemConfig({ + func: 's_get_custom_components', + typecharone: '' + }).then(res => { + let coms = [] + if (res.cus_list && res.cus_list.length > 0) { + res.cus_list.forEach(item => { + let config = '' + + try { + config = JSON.parse(window.decodeURIComponent(window.atob(item.long_param))) + } catch (e) { + console.warn('Parse Failure') + config = '' + } + + if (!config || !item.c_name) return + + window.GLOB.UserComponentMap.set(item.c_id, item.c_name) + coms.push({ + uuid: item.c_id, + type: 'menu', + title: item.c_name, + url: item.images, + component: config.type, + subtype: config.subtype, + config + }) + }) + } + this.setState({customComponents: coms}) + }) + } + + updateComponentStyle = (parentId, keys, style) => { + const { config } = this.state + + if (config.uuid !== parentId) return + + let components = config.components.map(item => { + if (keys.includes(item.uuid)) { + item.style = {...item.style, ...style} + } + return item + }) + + this.setState({ + config: {...config, components: []} + }, () => { + this.setState({ + config: {...config, components: components} + }) + }) } delButtons = (items) => { @@ -147,6 +211,7 @@ } else { config.uuid = MenuId config.MenuID = MenuId + config.Template = 'CustomPage' } this.setState({ @@ -154,6 +219,8 @@ config: fromJS(config).toJS(), openEdition: result.open_edition || '', }) + + this.props.modifyCustomMenu(config) } else { notification.warning({ top: 92, @@ -241,6 +308,7 @@ } submitConfig = () => { + const { btn } = this.props const { openEdition, delButtons } = this.state let config = fromJS(this.state.config).toJS() @@ -262,14 +330,15 @@ let _config = fromJS(config).toJS() delete _config.tableFields + let _name = (btn.component.name ? btn.component.name + '-' : '') + btn.label + let param = { - func: 'sPC_Tab_AddUpt', + func: 'sPC_ButtonParam_AddUpt', + ParentID: btn.config.uuid, MenuID: _config.uuid, - MenuNo: _config.MenuNo, + MenuNo: _config.MenuNo || '', Template: 'CustomPage', - MenuName: _config.MenuName, - Remark: '', - Sort: 0, + MenuName: _name, PageParam: JSON.stringify({Template: 'CustomPage'}), LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config))) } @@ -459,9 +528,18 @@ this.props.modifyCustomMenu(config) } + insert = (item) => { + let config = fromJS(this.state.config).toJS() + + config.components.push(item) + + this.setState({config}) + this.props.modifyCustomMenu(config) + } + render () { const { btn } = this.props - const { activeKey, MenuType, dict, config, menuloading } = this.state + const { activeKey, MenuType, dict, config, menuloading, customComponents } = this.state return ( <DndProvider backend={HTML5Backend}> @@ -479,6 +557,9 @@ <Panel header={dict['mob.component']} key="component"> <SourceWrap MenuType={MenuType} /> </Panel> + {customComponents && customComponents.length ? <Panel header="鑷畾涔夌粍浠�" key="cuscomponent"> + <SourceWrap components={customComponents} MenuType={MenuType} /> + </Panel> : null} <Panel header={'鑳屾櫙'} key="background"> {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null} </Panel> @@ -492,6 +573,8 @@ <div> {config && config.MenuName} </div> } bordered={false} extra={ <div> + <StyleCombControlButton menu={config} /> + <PasteController type="menu" Tab={null} insert={this.insert} /> {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={menuloading}>{dict['mob.save']}</Button> <Button type="default" onClick={this.closeView}>{dict['mob.return']}</Button> -- Gitblit v1.8.0