|
|
@@ -4,10 +4,11 @@ import ReactGridLayout from 'react-grid-layout'
|
|
|
import { Modal } from 'antd'
|
|
|
import { connect } from 'dva'
|
|
|
import EmptyContent from '../common/emptyContent/index'
|
|
|
-import DataPreview from '../common/dataPreview/dataPreview'
|
|
|
+import DataPreview from '../common/dataPreview/dataPreview';
|
|
|
+import { hashcode } from '../../utils/baseUtils'
|
|
|
import ViewLayoutItem from './viewLayoutItem';
|
|
|
|
|
|
-class ViewLayout extends React.PureComponent {
|
|
|
+class ViewLayout extends React.Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
@@ -53,8 +54,17 @@ class ViewLayout extends React.PureComponent {
|
|
|
}
|
|
|
|
|
|
onLayoutChange = (layout) => {
|
|
|
- const { dispatch } = this.props;
|
|
|
+ const { dashboardDesigner, dispatch } = this.props;
|
|
|
if(!(layout.length === 1 && layout[0].i === 'default-chartview')) {
|
|
|
+ if(hashcode(layout.map(l => ({
|
|
|
+ x: l.x, y: l.y, w: l.w, h: l.h, maxW: l.maxW, maxH: l.maxH, minW: l.minW, minH: l.minH
|
|
|
+ }))) === hashcode(dashboardDesigner.items.map(t => {
|
|
|
+ let l = t.layout;
|
|
|
+ return { x: l.x, y: l.y, w: l.w, h: l.h, maxW: l.maxW, maxH: l.maxH, minW: l.minW, minH: l.minH }
|
|
|
+ } ))) {
|
|
|
+ // 若未发生位置变化
|
|
|
+ return;
|
|
|
+ }
|
|
|
dispatch({ type: 'dashboardDesigner/changeLayout', layout });
|
|
|
window.clearTimeout(this.layoutChangeKey);
|
|
|
this.layoutChangeKey = window.setTimeout(() => {
|
|
|
@@ -69,7 +79,7 @@ class ViewLayout extends React.PureComponent {
|
|
|
const viewContentRef = this.viewContentRef;
|
|
|
let box = viewContentRef.getBoundingClientRect();
|
|
|
let bottomY = box.y + box.height;
|
|
|
- if(bottomY - e.clientY <= 5) { // 鼠标接近容器底部时滚动条滚到底
|
|
|
+ if(bottomY - e.clientY <= 10) { // 鼠标接近容器底部时滚动条滚到底
|
|
|
window.clearTimeout(this.scrollToBottomKey);
|
|
|
this.scrollToBottomKey = window.setTimeout(this.scrollToBottom, 50);
|
|
|
}
|
|
|
@@ -77,7 +87,7 @@ class ViewLayout extends React.PureComponent {
|
|
|
|
|
|
scrollToBottom = () => {
|
|
|
const viewContentRef = this.viewContentRef;
|
|
|
- viewContentRef.scrollTo && viewContentRef.scrollTo(0, viewContentRef.scrollHeight - viewContentRef.clientHeight)
|
|
|
+ viewContentRef.scrollTo && viewContentRef.scrollTo(0, viewContentRef.scrollHeight - viewContentRef.clientHeight);
|
|
|
}
|
|
|
|
|
|
showPreviewBox = (item) => {
|