king
2020-06-19 cd42d41344f0f780e0c0ac0a3625aeb78160f9dd
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>