king
2019-11-24 7d206112a4ca1930639907a7cb131d0c1e6525a6
src/tabviews/commontable/index.jsx
@@ -1,11 +1,12 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { BackTop } from 'antd'
import { BackTop, notification} from 'antd'
import Api from '@/api'
import MainSearch from './modules/mainSearch'
import MainAction from './modules/mainAction'
import MainTable from './modules/mainTable'
import MainSearch from './mainSearch'
// import MainAction from './mainAction'
// import MainTable from './mainTable'
import NotFount from '@/components/404'
import Loading from '@/components/loading'
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
@@ -19,6 +20,9 @@
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    loadingview: true,
    viewlost: false,
    config: {},
    searchlist: null,
    actions: null,
    columns: null,
@@ -43,31 +47,36 @@
      MenuID: this.props.MenuID
    }
    let result = await Api.getSystemConfig(param)
    if (result.status) {
      let newconfig = {}
      if (result.searches && result.searches.length > 0) {
        newconfig.searchlist = result.searches.map(search => {
          search.DynOptions = search.DynOptions ? JSON.parse(search.DynOptions) : ''
          return search
    if (result.status && result.LongParam) {
      let config = window.decodeURIComponent(window.atob(result.LongParam))
      try {
        config = JSON.parse(config)
        this.setState({
          loadingview: false
        })
      } catch (e) {
        this.setState({
          loadingview: false,
          viewlost: true
        })
        notification.warning({
          top: 92,
          message: result.message || '页面配置错误',
          duration: 10
        })
      }
      if (result.actions && result.actions.length > 0) {
        newconfig.actions = result.actions.map(action => {
          return action
        })
      }
      if (result.columns && result.columns.length > 0) {
        newconfig.columns = result.columns.map(column => {
          return column
        })
        newconfig.columns.length = 3
      }
      newconfig.fixed = {
        fixaction: true,
        fixtable: true
      }
      newconfig.select = result.select
      this.setState(newconfig)
      this.setState({config})
    } else {
      this.setState({
        loadingview: false,
        viewlost: true
      })
      notification.warning({
        top: 92,
        message: result.message || '页面配置错误',
        duration: 10
      })
    }
  }
@@ -143,7 +152,7 @@
  UNSAFE_componentWillMount () {
    // 组件加载时,获取菜单数据
    this.loadconfig()
    this.loadmaindata()
    // this.loadmaindata()
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -151,17 +160,19 @@
  }
  render() {
    const { config, loadingview, viewlost } = this.state
    return (
      <div className="commontable">
        {!this.state.searchlist && <Loading />}
        {this.state.searchlist &&
        {loadingview && <Loading />}
        {config.search && config.search.length > 0 ?
          <MainSearch
            refreshdata={this.refreshbysearch}
            searchlist={this.state.searchlist}
            searchlist={config.search}
            dict={this.state.dict}
          />
          /> : null
        }
        {this.state.actions &&
        {/* {this.state.actions &&
          <MainAction
            MenuNo={this.props.MenuNo}
            fixed={this.state.fixed.fixaction}
@@ -184,7 +195,7 @@
            loading={this.state.loading}
            dict={this.state.dict}
          />
        }
        } */}
        <BackTop>
          <div className="ant-back-top">
            <div className="ant-back-top-content">
@@ -192,6 +203,7 @@
            </div>
          </div>
        </BackTop>
        {viewlost ? <NotFount /> : null}
      </div>
    )
  }