12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import {SET_ASSESS_DATA,SET_INDEX_DATA,SET_SAVE_ASSESS_DATA,SET_INDEX_SUB_TYPE} from '@types/assessResult';
- import config from "@config";
- const init = {
- data:[], //评估模块数据
- indexData:{}, //评估图表数据
- saveData:[], //保存的评估数据-点确定时保存
- saveIndexData:{}, //保存的评估图表数据-点确定时保存
- indexTimeTypes:{}, //单个图表选中的维度
- };
- export default (state=init,action)=>{
- const res = Object.assign({},state);
- const {data,range,index,rangeType} = action;
- switch (action.type){
- case SET_ASSESS_DATA:
- res.data = action.data;
- return res;
- case SET_INDEX_DATA:
- res.indexData[range[0]+range[1]] = data;
- Object.keys(data).map((i)=>{
- if(i===index){
- res.indexTimeTypes[i]=rangeType;
- }else{
- res.indexTimeTypes[i]=config.chartDismen;
- }
- });
- res.update = Math.random(); //对象更新
- return res;
- case SET_INDEX_SUB_TYPE:
- if(!index){
- return res;
- }
- res.indexTimeTypes[index] = rangeType;
- res.update = Math.random(); //对象更新
- return res;
- case SET_SAVE_ASSESS_DATA:
- res.saveData = action.data;
- res.saveIndexData = action.indexData;
- return res;
- default:
- return res;
- }
- }
|