|
@@ -60,36 +60,65 @@ export default (state = initWrapModal, action) => {
|
|
|
|
|
|
return newState;
|
|
|
}
|
|
|
- if (action.type == SELECT_WARING) {
|
|
|
+ if (action.type == SELECT_WARING) {//选中异常值
|
|
|
const newState = Object.assign({}, state);
|
|
|
let listWrap = JSON.parse(JSON.stringify(newState.hospitalInspectObj))
|
|
|
+ let listWrapLen = listWrap&&listWrap.lisExcelWrapper.length
|
|
|
let tmpGroup = JSON.parse(JSON.stringify(newState.selectGroupList))
|
|
|
let tmpCheckedLis = JSON.parse(JSON.stringify(newState.checkedList))
|
|
|
- let warArr = [],checked = [],numS=0
|
|
|
+ let warArr = [],checked = [],numS=0,selectNum=0;
|
|
|
+ // console.log(action,listWrap,tmpCheckedLis)
|
|
|
for(let m =0;m < listWrap.lisExcelWrapper.length;m++){
|
|
|
+ let tmpName = listWrap.lisExcelWrapper[m].itemName
|
|
|
+ let tmpType = listWrap.lisExcelWrapper[m].type
|
|
|
for(let n = 0;n < tmpCheckedLis.length;n++){
|
|
|
- if(listWrap.lisExcelWrapper[m].type == 0 && listWrap.lisExcelWrapper[m].itemName == tmpCheckedLis[n]){
|
|
|
+ if(tmpType == 0 && tmpName == tmpCheckedLis[n]){//已选的正常的选项要保留
|
|
|
warArr.push(listWrap.lisExcelWrapper[m])
|
|
|
- checked.push(listWrap.lisExcelWrapper[m].itemName)
|
|
|
+ checked.push(tmpName)
|
|
|
}
|
|
|
}
|
|
|
- if(listWrap.lisExcelWrapper[m].type != 0){
|
|
|
- warArr.push(listWrap.lisExcelWrapper[m])
|
|
|
- checked.push(listWrap.lisExcelWrapper[m].itemName)
|
|
|
+ if(tmpType != 0 && (tmpCheckedLis.filter(item=>item == tmpName)).length == 0){
|
|
|
+ ++selectNum
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // console.log(selectNum)
|
|
|
+ for(let m =0;m < listWrap.lisExcelWrapper.length;m++){
|
|
|
+ let tmpName = listWrap.lisExcelWrapper[m].itemName
|
|
|
+ let tmpType = listWrap.lisExcelWrapper[m].type
|
|
|
+ if(selectNum>0){
|
|
|
+ if(listWrap.lisExcelWrapper[m].type != 0){//没有选中的选项要加上,有一个异常未选中就选中
|
|
|
+ warArr.push(listWrap.lisExcelWrapper[m])
|
|
|
+ checked.push(tmpName)
|
|
|
+ }
|
|
|
+ }else{//全部的选中就去掉所有异常选中的
|
|
|
+ for(let n = 0;n < tmpCheckedLis.length;n++){
|
|
|
+ if(tmpType == 0 && tmpName == tmpCheckedLis[n]){//已选的正常的选项要保留
|
|
|
+ checked=[]
|
|
|
+ warArr=[]
|
|
|
+ warArr.push(listWrap.lisExcelWrapper[m])
|
|
|
+ checked.push(tmpName)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
for(let i = 0;i < tmpGroup.length;i++){
|
|
|
if(tmpGroup[i].groupName == listWrap.groupName){//右侧有选中相同组的明细
|
|
|
- tmpGroup[i].lisExcelWrapper = warArr
|
|
|
+ if(warArr.length == 0){
|
|
|
+ tmpGroup.splice(i,1)
|
|
|
+ }else{
|
|
|
+ tmpGroup[i].lisExcelWrapper = warArr
|
|
|
+ }
|
|
|
}else{//右侧没有选中相同组的明细
|
|
|
++numS
|
|
|
}
|
|
|
}
|
|
|
if(numS == tmpGroup.length){//直接添加到右侧
|
|
|
- listWrap.lisExcelWrapper = warArr
|
|
|
- tmpGroup.push(listWrap)
|
|
|
+ if(warArr.length > 0){
|
|
|
+ listWrap.lisExcelWrapper = warArr
|
|
|
+ tmpGroup.push(listWrap)
|
|
|
+ }
|
|
|
}
|
|
|
- if(checked.length == listWrap.lisExcelWrapper.length){
|
|
|
+ if(checked.length == listWrapLen){
|
|
|
newState.allCheck = true;
|
|
|
}else{
|
|
|
newState.allCheck = false;
|