|
|
@@ -12,7 +12,7 @@ class DashboardDesignerContent extends React.Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
- lastContentSize: {
|
|
|
+ contentSize: {
|
|
|
scroll: false,
|
|
|
width: 0,
|
|
|
height: 0,
|
|
|
@@ -24,12 +24,12 @@ class DashboardDesignerContent extends React.Component {
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
- // this.refreshContentSize();
|
|
|
const { dashboardDesigner } = this.props;
|
|
|
const { filters } = dashboardDesigner;
|
|
|
this.setState({
|
|
|
closeFilters: filters.length > 6
|
|
|
});
|
|
|
+ this.refreshContentSize();
|
|
|
window.addEventListener("resize", this.refreshContentSize);
|
|
|
}
|
|
|
|
|
|
@@ -53,40 +53,20 @@ class DashboardDesignerContent extends React.Component {
|
|
|
* 重设容器宽度
|
|
|
*/
|
|
|
refreshContentSize = () => {
|
|
|
+ let viewLayoutEl = this.contentRef.current;
|
|
|
+ let viewContentEl = viewLayoutEl.getElementsByClassName('dashboard-viewcontent')[0];
|
|
|
+ let _scroll = viewContentEl.scrollHeight > viewContentEl.clientHeight;
|
|
|
+ let padding = 0;
|
|
|
+ let width = viewContentEl.offsetWidth - padding * 2 - (_scroll ? 10 : 2); // 有滚动条时需要减去滚动条的宽度
|
|
|
+ let height = viewContentEl.clientHeight;
|
|
|
this.setState({
|
|
|
- refresh: true
|
|
|
+ contentSize: {
|
|
|
+ width,
|
|
|
+ height
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- getContentSize = () => {
|
|
|
- const { lastContentSize } = this.state;
|
|
|
- let contentEl = this.contentRef.current;
|
|
|
- if(!contentEl) {
|
|
|
- return {
|
|
|
- width: 0,
|
|
|
- height: 0
|
|
|
- };
|
|
|
- }
|
|
|
- let viewcontent = contentEl.getElementsByClassName('dashboard-viewcontent')[0];
|
|
|
- let _scroll = viewcontent.scrollHeight > viewcontent.clientHeight;
|
|
|
- let padding = 0;
|
|
|
-
|
|
|
- let width = contentEl.offsetWidth - padding * 2 - (_scroll ? 10 : 2) // 有滚动条时需要减去滚动条的宽度
|
|
|
- if(width > 0 && width !== lastContentSize.width) {
|
|
|
- this.setState({
|
|
|
- lastContentSize: {
|
|
|
- width,
|
|
|
- height: contentEl.clientHeight,
|
|
|
- scroll: _scroll
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- return {
|
|
|
- width: width,
|
|
|
- height: contentEl.clientHeight
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
createFilters = (filters) => {
|
|
|
const { dispatch, afterRefresh } = this.props;
|
|
|
dispatch({ type: 'dashboardDesigner/changeFilters', filters }).then(() => {
|
|
|
@@ -114,9 +94,7 @@ class DashboardDesignerContent extends React.Component {
|
|
|
render() {
|
|
|
const { dashboardDesigner, isOwner, isShareView, isShareKeyView, isViewMode } = this.props;
|
|
|
const { dataSources, editMode, filters, relationColumns } = dashboardDesigner;
|
|
|
- const { visibleFilterBox, lastContentSize, closeFilters } = this.state;
|
|
|
-
|
|
|
- const contentSize = this.getContentSize();
|
|
|
+ const { visibleFilterBox, contentSize, closeFilters } = this.state;
|
|
|
|
|
|
return <Layout className='content'>
|
|
|
<Content className={`dashboard-content${(isShareView || isShareKeyView || isViewMode) ? ' nomargin' : ''}`}>
|
|
|
@@ -156,7 +134,7 @@ class DashboardDesignerContent extends React.Component {
|
|
|
</div>
|
|
|
{visibleFilterBox && <FilterBox key={Math.random()} dataSources={dataSources} relationColumns={relationColumns} filterData={filters} visibleFilterBox={visibleFilterBox} showFilterBox={this.showFilterBox} hideFilterBox={this.hideFilterBox} createFilters={this.createFilters} />}
|
|
|
</Header>}
|
|
|
- <ViewLayout isOwner={isOwner} isShareView={isShareView} isShareKeyView={isShareKeyView} isViewMode={isViewMode} contentSize={contentSize} lastContentSize={lastContentSize} editMode={editMode}/>
|
|
|
+ <ViewLayout isOwner={isOwner} isShareView={isShareView} isShareKeyView={isShareKeyView} isViewMode={isViewMode} contentSize={contentSize} editMode={editMode}/>
|
|
|
</main>
|
|
|
</Layout>
|
|
|
</Content>
|