Browse Source

新增自定义数据完善

zhouna 3 years ago
parent
commit
1beb709b13
1 changed files with 20 additions and 22 deletions
  1. 20 22
      src/components/DataManager/AddData.js

+ 20 - 22
src/components/DataManager/AddData.js

@@ -161,19 +161,16 @@ function AddData(props) {
   //医生选中
   function checkDoctEvent(selectedRowKeys) {
     const formData = form.getFieldsValue();
-    const tempAuthData = formData.softwareVOS[tabIndex].dataAuthDetails;
-    let arr = tempAuthData ? tempAuthData : []
-    let tag = [],docIds=[];
+    //const tempAuthData = formData.softwareVOS[tabIndex].dataAuthDetails;
+    let arr = [];
+    let docIds=[];
     selectedRowKeys.forEach(it => {
       arr.push({
+        id: it.split('-')[0],
         dataType: 7,
         detailId: it.split('-')[0],
-        detailType: 3
-      })
-      tag.push({
-          id: it.split('-')[0],
-          name: it.split('-')[1],
-          type: 3
+        detailType: 3,
+        name: it.split('-')[1],
       })
       docIds.push(it);
     });
@@ -184,7 +181,7 @@ function AddData(props) {
       softwareVOS: formData.softwareVOS
     });
     //保存需要展示的已选中标签数据
-    setCheckedUser(tag)
+    setCheckedUser(docArr)
     setCheckedUserIds(docIds);
   }
   //树形结构选中事件
@@ -196,17 +193,17 @@ function AddData(props) {
             return a.pos.length-b.pos.length;
         });
         //console.log('排序后:',posArr);
-        const checkedDepts = structureDeptTag(posArr);
-        const {deptIds,deptObj,hosIds,hosObj,paramHos,paramDept} = checkedDepts;
+        const structDepts = structureDeptTag(posArr);
+        const {deptIds,hosIds,paramHos,paramDept} = structDepts;console.log('选中:',checkedDepts)
         let deptIdsArr=[...deptIds];
-        let deptArr=[...deptObj];
+        let deptArr=[...paramDept];
         let hosIdsArr=[...hosIds];
-        let hosArr=[...hosObj];
+        let hosArr=[...paramHos];
         setCheckedDepts(hosArr.concat(deptArr));        //显示的排序可能需要再考虑一下
         setCheckedDeptIds(deptIdsArr);
         setCheckedHosIds(hosIdsArr);
         const tempFormData = form.getFieldsValue();
-        tempFormData.softwareVOS[tabIndex].dataAuthDetail=[...checkedUser,...paramHos,...paramDept];
+        tempFormData.softwareVOS[tabIndex].dataAuthDetails=[...checkedUser,...hosArr,...deptArr];
         form.setFieldsValue(tempFormData);
     }
     //格式化选中科室数据
@@ -219,10 +216,11 @@ function AddData(props) {
             tempKey=it.node.key;
             if(it.pos==='0-0'){     //全选了平台,终止遍历
                 temp = tempKey.split("-");
-                hosArr.push({id:temp[0],name:temp[1],key:tempKey});
+                //hosArr.push({key:tempKey});
+                paramHos.push({id:temp[0],detailId:temp[0],detailType:1,name:temp[1],dataType:7,key:tempKey});
                 hosIds.push(temp[0]);
                 setCheckedTreeItems([tempKey]);
-                return {hosIds:hosIds,hosObj:hosArr,deptIds:deptIds,deptObj:deptArr};
+                return {hosIds:hosIds,deptIds:deptIds,deptObj:deptArr};
             }
             //如果当前节点的pos包含了tempPos里的某个数据,说明该节点的父节点已被选中并记录,自身则不需要记录
             if(!(tempPos.includes(it.pos.substr(0,5))||tempPos.includes(it.pos.substr(0,7)))){
@@ -234,18 +232,18 @@ function AddData(props) {
                 setCheckedTreeItems(checks);
                 //医院id存入sendHospitals,科室id存入sendDepts
                 if(len===2){
-                    hosArr.push({id:temp[0],name:temp[1],key:tempKey});
-                    paramHos.push({detailId:temp[0],detailType:1,dataType:7,key:tempKey});
+                    //hosArr.push({key:tempKey});
+                    paramHos.push({id:temp[0],detailId:temp[0],name:temp[1],detailType:1,dataType:7,key:tempKey});
                     hosIds.push(temp[0]);
                 }else{
-                    deptArr.push({id:temp[2],name:temp[1]+"-"+temp[3],key:tempKey});
-                    paramDept.push({detailId:temp[2],detailType:2,dataType:7,key:tempKey});
+                    //deptArr.push({key:tempKey});
+                    paramDept.push({id:temp[2],detailId:temp[2],detailType:2,name:temp[1]+"-"+temp[3],dataType:7,key:tempKey});
                     deptIds.push(temp[2]);
                 }
 
             }
         }
-        return {hosIds:hosIds,hosObj:hosArr,deptIds:deptIds,deptObj:deptArr,paramDept,paramHos};
+        return {hosIds:hosIds,deptIds:deptIds,paramDept,paramHos};
     }
     //删除已选用户/科室
     function handleTagDel(idx,type){ //type=1可看意思,type=2可看科室