From cd42d41344f0f780e0c0ac0a3625aeb78160f9dd Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 19 六月 2020 19:58:52 +0800 Subject: [PATCH] 2020-06-19 --- src/views/mobdesign/index.jsx | 67 +++++++++++++++++++++++++++------ 1 files changed, 55 insertions(+), 12 deletions(-) diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx index f22c849..b98baf9 100644 --- a/src/views/mobdesign/index.jsx +++ b/src/views/mobdesign/index.jsx @@ -1,8 +1,10 @@ import React, { Component } from 'react' import { connect } from 'react-redux' import { DndProvider } from 'react-dnd' +import { fromJS } from 'immutable' import HTML5Backend from 'react-dnd-html5-backend' -import { Icon, Tabs } from 'antd' +import { SketchPicker } from 'react-color' +import { Icon, Tabs, notification } from 'antd' import Api from '@/api' import zhCN from '@/locales/zh-CN/mob.js' @@ -23,12 +25,14 @@ dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, appId: this.props.match.params.appId, appType: this.props.match.params.appType, + appConfig: null, saveIng: false, - config: null + config: null, + pageIndex: 0 } UNSAFE_componentWillMount() { - this.getPageParam(this.props.match.params.appId) + this.getAppParam(this.props.match.params.appId) } /** @@ -51,17 +55,54 @@ }) } - getPageParam = (id) => { + getAppParam = (id) => { Api.getSystemConfig({ func: 'sPC_Get_LongParam', MenuID: id }).then(result => { + if (result.status) { + let appConfig = null + if (result.LongParam) { + try { + appConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + } catch (e) { + console.warn('Parse Failure') + appConfig = null + } + } + + if (!appConfig) { + appConfig = { + version: 1.0, + label: '', + uuid: this.props.match.params.appId, + pageIndex: 0, + sourcelist: [], + components: [] + } + } + + this.setState({ + appConfig: appConfig, + config: fromJS(appConfig).toJS() + }) + } else { + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + } }) } - updateConfig = () => { - + + + updateConfig = (config) => { + this.setState({ + config: config + }) } render () { @@ -83,18 +124,20 @@ </div> <div className="mob-tool-other"></div> </div> - <div className="mob-shell"> - <MobShell /> - </div> + {appType === 'mob' && config ? + <div className="mob-shell"> + <MobShell config={config} handleList={this.updateConfig} /> + </div> : null + } <div className="mob-setting"> - <Tabs defaultActiveKey="2" animated={false} size="small"> + {config ? <Tabs defaultActiveKey="2" animated={false} size="small"> <TabPane tab="閰嶇疆" key="1"> - Content of Tab Pane 1 + <SketchPicker /> </TabPane> <TabPane tab="鏁版嵁婧�" key="2"> <DataSource config={config} updateConfig={this.updateConfig} /> </TabPane> - </Tabs> + </Tabs> : null} </div> </div> </DndProvider> -- Gitblit v1.8.0