|
|
@@ -2,8 +2,6 @@ import React from 'react'
|
|
|
import { connect } from 'dva'
|
|
|
import { Icon, Layout, Spin } from 'antd'
|
|
|
import './layout.less'
|
|
|
-import html2canvas from 'html2canvas'
|
|
|
-import jsPDF from 'jspdf'
|
|
|
import DashboardDesignerHeader from './header'
|
|
|
import DashboardDesignerContent from './content'
|
|
|
const { Header, Content } = Layout
|
|
|
@@ -17,34 +15,31 @@ class DashboardDesigner extends React.Component {
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
- const { code, dispatch, isShareView, isShareKeyView, afterLoad } = this.props;
|
|
|
+ const { code, dispatch, isShareView, isShareKeyView, afterLoad, config } = this.props;
|
|
|
|
|
|
let url;
|
|
|
if (code !== 'create') {
|
|
|
url = isShareView ? 'dashboard/remoteShareDetail' : ( isShareKeyView ? 'dashboard/remoteShareKeyDetail' : 'dashboard/remoteDetail');
|
|
|
}
|
|
|
- dispatch({ type: url, code: code }).then((data) => {
|
|
|
- if(afterLoad && typeof afterLoad === 'function') {
|
|
|
- afterLoad(data)
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
- saveToPNG = (element) => {
|
|
|
- html2canvas(element).then(function (canvas) {
|
|
|
- let pageData = canvas.toDataURL('image/png', 1.0);
|
|
|
-
|
|
|
- //方向默认竖直,尺寸ponits,格式a4[595.28,841.89]
|
|
|
- let pdf = new jsPDF('', 'pt', 'a4');
|
|
|
-
|
|
|
- //addImage后两个参数控制添加图片的尺寸,此处将页面高度按照a4纸宽高比列进行压缩
|
|
|
- pdf.addImage(pageData, 'PNG', 0, 0, 595.28, 592.28 / canvas.width * canvas.height);
|
|
|
-
|
|
|
- pdf.save('stone.pdf');
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
isOwner = () => {
|
|
|
const { dashboardDesigner, main } = this.props;
|
|
|
const { creatorCode } = dashboardDesigner;
|
|
|
@@ -53,14 +48,14 @@ class DashboardDesigner extends React.Component {
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- const { dashboardDesigner, isShareView, isShareKeyView, isViewMode } = this.props;
|
|
|
+ const { dashboardDesigner, isShareView, isShareKeyView, isViewMode, afterRefresh } = this.props;
|
|
|
const { loading } = dashboardDesigner;
|
|
|
return <Layout className='dashboarddesigner-layout'>
|
|
|
{!isShareView && !isShareKeyView && !isViewMode && <Header>
|
|
|
<DashboardDesignerHeader updateThumbnail={this.updateThumbnail} />
|
|
|
</Header>}
|
|
|
<Content>
|
|
|
- <DashboardDesignerContent isOwner={this.isOwner()} isShareView={isShareView} isShareKeyView={isShareKeyView} isViewMode={isViewMode}/>
|
|
|
+ <DashboardDesignerContent isOwner={this.isOwner()} isShareView={isShareView} isShareKeyView={isShareKeyView} isViewMode={isViewMode} afterRefresh={afterRefresh}/>
|
|
|
</Content>
|
|
|
<div style={{ display: loading ? 'block' : 'none', position: 'absolute', height: '100%', width: '100%', zIndex: '4', background: 'rgba(51,51,51,.1)' }}>
|
|
|
<Spin style={{ display: 'inline-block', position: 'absolute', top: '50%', left: '50%', margin: '-10px' }} indicator={<Icon type="loading" style={{ fontSize: 24 }} spin />} />
|