浏览代码

点确定才保存图表维度值

zhouna 6 年之前
父节点
当前提交
7678ea1a58
共有 2 个文件被更改,包括 11 次插入4 次删除
  1. 8 1
      src/components/AssessResult/ChartItem/index.jsx
  2. 3 3
      src/containers/AssessResult.js

+ 8 - 1
src/components/AssessResult/ChartItem/index.jsx

@@ -12,6 +12,9 @@ import config from "@config";
 class ChartItem extends Component {
 class ChartItem extends Component {
   constructor(props) {
   constructor(props) {
     super(props);
     super(props);
+    this.state={
+      timeDismen:props.timeTypes
+    };
     this.getContainers = this.getContainers.bind(this);
     this.getContainers = this.getContainers.bind(this);
     this.rangChange = this.rangChange.bind(this);
     this.rangChange = this.rangChange.bind(this);
     this.getXAxisArr = this.getXAxisArr.bind(this);
     this.getXAxisArr = this.getXAxisArr.bind(this);
@@ -71,10 +74,14 @@ class ChartItem extends Component {
     const {initFn} = this.props;
     const {initFn} = this.props;
     const times = this.getXAxisArr(type);
     const times = this.getXAxisArr(type);
     const range = [times[0],times[times.length-1]];
     const range = [times[0],times[times.length-1]];
+    const temp=this.state.timeDismen;
+    this.setState({
+      timeDismen:Object.assign(temp,{[index]:type})
+    });
     initFn&&initFn({range,rangeType:type,index});
     initFn&&initFn({range,rangeType:type,index});
   }
   }
   getContainers(){
   getContainers(){
-    const {timeTypes} = this.props;
+    const timeTypes = this.state.timeDismen;
     const range = this.getXAxisArr(config.chartDismen);
     const range = this.getXAxisArr(config.chartDismen);
     const obj = this.props.data[range[0]+range[range.length-1]];
     const obj = this.props.data[range[0]+range[range.length-1]];
     let arr = [];
     let arr = [];

+ 3 - 3
src/containers/AssessResult.js

@@ -49,13 +49,13 @@ function mapDispatchToProps(dispatch) {
       const {range,rangeType,index} = param;
       const {range,rangeType,index} = param;
       const indexData = state.assessResult.indexData;
       const indexData = state.assessResult.indexData;
       const obj = indexData[range[0]+range[range.length-1]];
       const obj = indexData[range[0]+range[range.length-1]];
-      if(obj&&Object.keys(obj).length!=0){
+      if(obj&&Object.keys(obj).length!=0){      //该维度已获取过数据
         //console.log(obj,rangeType,index);
         //console.log(obj,rangeType,index);
-        dispatch({
+        /*dispatch({
           type:SET_INDEX_SUB_TYPE,
           type:SET_INDEX_SUB_TYPE,
           index,
           index,
           rangeType
           rangeType
-        });
+        });*/
         return ;
         return ;
       }
       }
       dispatch(getIndexData(range)).then((res)=>{
       dispatch(getIndexData(range)).then((res)=>{