import React from 'react' import { connect } from 'dva' import { Icon, Layout, Spin } from 'antd' import './layout.less' import DashboardDesignerHeader from './header' import DashboardDesignerContent from './content' const { Header, Content } = Layout class DashboardDesigner extends React.Component { constructor(props) { super(props); props.dispatch({ type: 'dashboardDesigner/reset' }); } componentDidMount() { const { code, dispatch, isShareView, isShareKeyView, afterLoad, config } = this.props; let url; if (code !== 'create') { url = isShareView ? 'dashboard/remoteShareDetail' : ( isShareKeyView ? 'dashboard/remoteShareKeyDetail' : 'dashboard/remoteDetail'); } if(config) { // 首页打开的报表会保存报表配置,不需要后台再请求 let fields = []; for(let key in config) { fields.push({ name: key, value: config[key] }) } dispatch({ type: 'dashboardDesigner/silentSetFields', fields: fields }); }else { dispatch({ type: url, code: code }).then((data) => { if(afterLoad && typeof afterLoad === 'function') { afterLoad(data) } }); } } isOwner = () => { const { dashboardDesigner, main } = this.props; const { creatorCode } = dashboardDesigner; const { currentUser } = main; return currentUser.code === creatorCode; } render() { const { dashboardDesigner, isShareView, isShareKeyView, isViewMode, afterRefresh } = this.props; const { loading } = dashboardDesigner; return {!isShareView && !isShareKeyView && !isViewMode &&
}
} />
} } function mapStateToProps(state) { const { main } = state.present; return { main } } export default connect(mapStateToProps)(DashboardDesigner)