|
@@ -1,5 +1,4 @@
|
|
|
import React from 'react'
|
|
import React from 'react'
|
|
|
-import { findDOMNode } from 'react-dom'
|
|
|
|
|
import { Layout, Tooltip, Tag, Icon } from 'antd'
|
|
import { Layout, Tooltip, Tag, Icon } from 'antd'
|
|
|
import { connect } from 'dva'
|
|
import { connect } from 'dva'
|
|
|
import ViewLayout from './viewLayout'
|
|
import ViewLayout from './viewLayout'
|
|
@@ -24,10 +23,6 @@ class DashboardDesignerContent extends React.Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
|
- // 这里延迟等待页面渲染结束,也许有更好的办法。
|
|
|
|
|
- window.setTimeout(() => {
|
|
|
|
|
- this.refreshContentSize(true);
|
|
|
|
|
- }, 1500);
|
|
|
|
|
window.addEventListener("resize", () => {
|
|
window.addEventListener("resize", () => {
|
|
|
this.refreshContentSize(true);
|
|
this.refreshContentSize(true);
|
|
|
});
|
|
});
|
|
@@ -64,23 +59,28 @@ class DashboardDesignerContent extends React.Component {
|
|
|
/**
|
|
/**
|
|
|
* 重设容器宽度
|
|
* 重设容器宽度
|
|
|
*/
|
|
*/
|
|
|
- refreshContentSize = (flag) => {
|
|
|
|
|
- let contentEl = findDOMNode(this.refs.contentEl);
|
|
|
|
|
|
|
+ refreshContentSize = () => {
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ refresh: true
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ getContentSize = () => {
|
|
|
|
|
+ const { dashboardDesigner, isOwner } = this.props;
|
|
|
|
|
+ const { editMode } = dashboardDesigner;
|
|
|
|
|
+ let contentEl = document.getElementsByClassName('viewlayout')[0];
|
|
|
if(!contentEl) {
|
|
if(!contentEl) {
|
|
|
- return;
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ width: 0,
|
|
|
|
|
+ height: 0
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
let _scroll = contentEl.scrollHeight > contentEl.clientHeight;
|
|
let _scroll = contentEl.scrollHeight > contentEl.clientHeight;
|
|
|
|
|
|
|
|
- if(!flag && this.state.contentSize.scroll === _scroll) { // 如果滚动条没有变化则直接退出
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ width: document.body.offsetWidth - 20 - (isOwner && editMode ? 380 : 0) - 10 - (_scroll ? 17 : 2), // 有滚动条时需要减去滚动条的宽度
|
|
|
|
|
+ height: contentEl.clientHeight
|
|
|
}
|
|
}
|
|
|
- this.setState({
|
|
|
|
|
- contentSize: {
|
|
|
|
|
- scroll: _scroll,
|
|
|
|
|
- width: contentEl.offsetWidth - (_scroll ? 28 : 10), // 有滚动条时需要减去滚动条的宽度
|
|
|
|
|
- height: contentEl.clientHeight
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
getRelationFilterColumns = () => {
|
|
getRelationFilterColumns = () => {
|
|
@@ -158,8 +158,9 @@ class DashboardDesignerContent extends React.Component {
|
|
|
render() {
|
|
render() {
|
|
|
const { dashboardDesigner, dispatch, isOwner } = this.props;
|
|
const { dashboardDesigner, dispatch, isOwner } = this.props;
|
|
|
const { code, editMode, filters } = dashboardDesigner;
|
|
const { code, editMode, filters } = dashboardDesigner;
|
|
|
- const { contentSize, visibleChooseChartBox, visibleFilterBox } = this.state;
|
|
|
|
|
|
|
+ const { visibleChooseChartBox, visibleFilterBox } = this.state;
|
|
|
|
|
|
|
|
|
|
+ const contentSize = this.getContentSize();
|
|
|
let tags = filters.map((f, i)=>{
|
|
let tags = filters.map((f, i)=>{
|
|
|
return {
|
|
return {
|
|
|
key: f.key,
|
|
key: f.key,
|
|
@@ -191,13 +192,13 @@ class DashboardDesignerContent extends React.Component {
|
|
|
</Tag>
|
|
</Tag>
|
|
|
</div>
|
|
</div>
|
|
|
{visibleFilterBox && <FilterBox type='dashboard' code={code} columns={this.getRelationFilterColumns()} filterData={filters} visibleFilterBox={visibleFilterBox} showFilterBox={this.showFilterBox} hideFilterBox={this.hideFilterBox} createFilters={this.createFilters} />}
|
|
{visibleFilterBox && <FilterBox type='dashboard' code={code} columns={this.getRelationFilterColumns()} filterData={filters} visibleFilterBox={visibleFilterBox} showFilterBox={this.showFilterBox} hideFilterBox={this.hideFilterBox} createFilters={this.createFilters} />}
|
|
|
- {isOwner && <div className='viewtype'>
|
|
|
|
|
- <Tooltip title="图表">
|
|
|
|
|
|
|
+ {isOwner && editMode && <div className='viewtype'>
|
|
|
|
|
+ <Tooltip placement='bottom' title="图表">
|
|
|
<Icon className='viewtype-icon' type="area-chart" theme="outlined" onClick={(item) => {
|
|
<Icon className='viewtype-icon' type="area-chart" theme="outlined" onClick={(item) => {
|
|
|
this.showBox("create");
|
|
this.showBox("create");
|
|
|
}}/>
|
|
}}/>
|
|
|
</Tooltip >
|
|
</Tooltip >
|
|
|
- <Tooltip title="富文本">
|
|
|
|
|
|
|
+ <Tooltip placement='bottom' title="富文本">
|
|
|
<Icon className='viewtype-icon' type="book" theme="outlined" onClick={() => {
|
|
<Icon className='viewtype-icon' type="book" theme="outlined" onClick={() => {
|
|
|
dispatch({ type: 'dashboardDesigner/addRichText' });
|
|
dispatch({ type: 'dashboardDesigner/addRichText' });
|
|
|
}}/>
|
|
}}/>
|
|
@@ -207,8 +208,8 @@ class DashboardDesignerContent extends React.Component {
|
|
|
</Header>
|
|
</Header>
|
|
|
<Content className='dashboard-content'>
|
|
<Content className='dashboard-content'>
|
|
|
<Layout className='content-layout'>
|
|
<Layout className='content-layout'>
|
|
|
- <Content className='viewlayout' ref='contentEl'>
|
|
|
|
|
- <ViewLayout contentSize={contentSize} reset={this.refreshContentSize} editMode={editMode}/>
|
|
|
|
|
|
|
+ <Content className='viewlayout'>
|
|
|
|
|
+ <ViewLayout contentSize={contentSize} editMode={editMode}/>
|
|
|
</Content>
|
|
</Content>
|
|
|
<Sider className='config-sider' width={(isOwner && editMode) ? 380 : 0}>
|
|
<Sider className='config-sider' width={(isOwner && editMode) ? 380 : 0}>
|
|
|
<ConfigForm/>
|
|
<ConfigForm/>
|