|
|
@@ -1,12 +1,21 @@
|
|
|
-import React from 'react'
|
|
|
-import { Layout, Tag, Icon } from 'antd'
|
|
|
-import { connect } from 'dva'
|
|
|
-import ViewLayout from './viewLayout'
|
|
|
-import FilterBox from '../common/filterBox/filterBox2'
|
|
|
-import Filter from '../common/filterBox/filter2'
|
|
|
-import ConfigSider from './configSider'
|
|
|
+import React, { Fragment } from 'react';
|
|
|
+import { Layout, Tag, Icon } from 'antd';
|
|
|
+import { connect } from 'dva';
|
|
|
+import ViewLayout from './viewLayout';
|
|
|
+import FilterBox from '../common/filterBox/filterBox2';
|
|
|
+import Filter from '../common/filterBox/filter2';
|
|
|
+import ConfigSider from './configSider';
|
|
|
+import FilterList from './filterList'
|
|
|
|
|
|
-const { Header, Content, Sider } = Layout
|
|
|
+const { Header, Content, Sider } = Layout;
|
|
|
+
|
|
|
+const isMobile = function() {
|
|
|
+ if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)))
|
|
|
+ return true;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
+};
|
|
|
+const esMobile = isMobile();
|
|
|
|
|
|
class DashboardDesignerContent extends React.Component {
|
|
|
constructor(props) {
|
|
|
@@ -18,17 +27,13 @@ class DashboardDesignerContent extends React.Component {
|
|
|
height: 0,
|
|
|
},
|
|
|
visibleFilterBox: false,
|
|
|
- closeFilters: false,
|
|
|
+ visibleFilterList: false,
|
|
|
+ overFilters: false,
|
|
|
};
|
|
|
this.contentRef=React.createRef();
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
- const { dashboardDesigner } = this.props;
|
|
|
- const { filters } = dashboardDesigner;
|
|
|
- this.setState({
|
|
|
- closeFilters: filters.length > 6
|
|
|
- });
|
|
|
this.refreshContentSize();
|
|
|
window.addEventListener("resize", this.refreshContentSize);
|
|
|
}
|
|
|
@@ -54,6 +59,12 @@ class DashboardDesignerContent extends React.Component {
|
|
|
*/
|
|
|
refreshContentSize = () => {
|
|
|
let viewLayoutEl = this.contentRef.current;
|
|
|
+ let header = viewLayoutEl.getElementsByClassName('ant-layout-header')[0];
|
|
|
+ let overFilters = false;
|
|
|
+ if(!!header) {
|
|
|
+ let filterBar = header.getElementsByClassName('filters')[0].getElementsByClassName('content')[0];
|
|
|
+ overFilters = filterBar.scrollHeight > filterBar.offsetHeight;
|
|
|
+ }
|
|
|
let viewContentEl = viewLayoutEl.getElementsByClassName('dashboard-viewcontent')[0];
|
|
|
let _scroll = viewContentEl.scrollHeight > viewContentEl.clientHeight;
|
|
|
let padding = 0;
|
|
|
@@ -63,7 +74,8 @@ class DashboardDesignerContent extends React.Component {
|
|
|
contentSize: {
|
|
|
width,
|
|
|
height
|
|
|
- }
|
|
|
+ },
|
|
|
+ overFilters
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -94,7 +106,7 @@ class DashboardDesignerContent extends React.Component {
|
|
|
render() {
|
|
|
const { dashboardDesigner, isOwner, isShareView, isShareKeyView, isViewMode } = this.props;
|
|
|
const { dataSources, editMode, filters, relationColumns } = dashboardDesigner;
|
|
|
- const { visibleFilterBox, contentSize, closeFilters } = this.state;
|
|
|
+ const { visibleFilterBox, visibleFilterList, contentSize, overFilters } = this.state;
|
|
|
|
|
|
return <Layout className='content'>
|
|
|
<Content className={`dashboard-content${(isShareView || isShareKeyView || isViewMode) ? ' nomargin' : ''}`}>
|
|
|
@@ -103,12 +115,12 @@ class DashboardDesignerContent extends React.Component {
|
|
|
<ConfigSider/>
|
|
|
</Sider>}
|
|
|
{/**
|
|
|
- 这里直接用main标签而不用antd的Header组件是为了让ref能够定位到对应的dom元素
|
|
|
+ 这里直接用main标签而不用antd组件是为了让ref能够定位到对应的dom元素
|
|
|
*/}
|
|
|
<main ref={this.contentRef} className='viewlayout ant-layout-content'>
|
|
|
{(editMode || (filters && filters.length > 0) )&& <Header>
|
|
|
{/* <div className='toggle'><Icon type="caret-up" /></div> */}
|
|
|
- <div className={`filters${closeFilters ? ' closed': ''}`}>
|
|
|
+ <div className={`filters`}>
|
|
|
<div className='content'>
|
|
|
{isOwner && editMode && !isShareView && !isShareKeyView && !isViewMode && <Tag
|
|
|
onClick={this.showFilterBox}
|
|
|
@@ -124,17 +136,34 @@ class DashboardDesignerContent extends React.Component {
|
|
|
/>
|
|
|
))}
|
|
|
</div>
|
|
|
- <div className='right' style={{ display: filters.length > 0 ? 'block' : 'none' }}>
|
|
|
- <Icon title={closeFilters ? '展开' : '收起'} type={closeFilters ? 'caret-up' : 'caret-down'} onClick={() => {
|
|
|
+ {overFilters && <div className='right' style={{ display: filters.length > 0 ? 'block' : 'none' }}>
|
|
|
+ <Fragment>
|
|
|
+ <span style={{ cursor: 'pointer' }} onClick={() => {
|
|
|
+ this.setState({
|
|
|
+ visibleFilterList: true
|
|
|
+ });
|
|
|
+ }}>{esMobile ? '' : '更多'}</span>
|
|
|
+ <Icon title={'更多'} type={'ellipsis'} onClick={() => {
|
|
|
+ this.setState({
|
|
|
+ visibleFilterList: true
|
|
|
+ });
|
|
|
+ }}/>
|
|
|
+ </Fragment>
|
|
|
+ </div>}
|
|
|
+ {visibleFilterList && <FilterList
|
|
|
+ visible={visibleFilterList}
|
|
|
+ onCancel={() => {
|
|
|
this.setState({
|
|
|
- closeFilters: !closeFilters
|
|
|
- });
|
|
|
- }}/>
|
|
|
- </div>
|
|
|
+ visibleFilterList: false
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ filters={filters}
|
|
|
+ changeFilterValue={this.changeFilterValue}
|
|
|
+ />}
|
|
|
</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} editMode={editMode}/>
|
|
|
+ <ViewLayout isOwner={isOwner} isShareView={isShareView} isShareKeyView={isShareKeyView} isViewMode={isViewMode} contentSize={contentSize} editMode={editMode} esMobile={esMobile}/>
|
|
|
</main>
|
|
|
</Layout>
|
|
|
</Content>
|