| | |
| | | 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' |
| | |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | loadingview: true, |
| | | viewlost: false, |
| | | config: {}, |
| | | searchlist: null, |
| | | actions: null, |
| | | columns: null, |
| | |
| | | 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 |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | UNSAFE_componentWillMount () { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | | this.loadmaindata() |
| | | // this.loadmaindata() |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | } |
| | | |
| | | 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} |
| | |
| | | loading={this.state.loading} |
| | | dict={this.state.dict} |
| | | /> |
| | | } |
| | | } */} |
| | | <BackTop> |
| | | <div className="ant-back-top"> |
| | | <div className="ant-back-top-content"> |
| | |
| | | </div> |
| | | </div> |
| | | </BackTop> |
| | | {viewlost ? <NotFount /> : null} |
| | | </div> |
| | | ) |
| | | } |