|
@@ -78,12 +78,30 @@ export default (state=init,action)=>{
|
|
|
res.wholeAssess[action.index] = action.data;
|
|
|
let arr = res.wholeIndexs[action.index];
|
|
|
res.wholeIndexs[action.index] = arr?[...arr,action.subIndex]:[action.subIndex];
|
|
|
- action.id?res.addedScaleIds.push(action.id):'';
|
|
|
+ //已从全部量表中加入过,加入新的,删除原来的
|
|
|
+ if(res.addedScaleIds.includes(action.id)){
|
|
|
+ delete res.wholeScaleItems[action.id];
|
|
|
+ }else{
|
|
|
+ action.id?res.addedScaleIds.push(action.id):'';
|
|
|
+ }
|
|
|
res.update1 = Math.random(); //对象更新,与其他字段名不同因为绑定在pushItems,避免不必要的渲染
|
|
|
return res;
|
|
|
- case ADD_WHOLE_SCALE_ITEMS:
|
|
|
+ case ADD_WHOLE_SCALE_ITEMS: //从全部量表中加入量表
|
|
|
res.wholeScaleItems[action.id] = action.data;
|
|
|
- res.addedScaleIds.push(action.id);
|
|
|
+ //已从指标推送中添加过该量表,加入新的,删除原来的
|
|
|
+ let inx = -1,subInx = -1;
|
|
|
+ if(res.addedScaleIds.includes(action.id)){
|
|
|
+ const inx = res.wholeAssess.findIndex((it)=>{
|
|
|
+ subInx = it.details.findIndex((i)=>{
|
|
|
+ return i.type==1&&i.content.conceptId==action.id;
|
|
|
+ });
|
|
|
+ return subInx!=-1;
|
|
|
+ });
|
|
|
+ const trueInx = res.wholeIndexs[inx].findIndex((i)=>i==subInx);
|
|
|
+ res.wholeIndexs[inx].splice(trueInx,1);
|
|
|
+ }else{
|
|
|
+ res.addedScaleIds.push(action.id);
|
|
|
+ }
|
|
|
res.update1 = Math.random();
|
|
|
return res;
|
|
|
case REMOVE_ASSESS_ITEMS:
|