Przeglądaj źródła

质检试验切换修改

duy 2 lat temu
rodzic
commit
08d3014b4b
1 zmienionych plików z 65 dodań i 10 usunięć
  1. 65 10
      src/views/manager/projectinfo/detail.vue

+ 65 - 10
src/views/manager/projectinfo/detail.vue

@@ -601,7 +601,7 @@ export default {
       isFirst:false,
       rightTreeData:[],//存储右边的试验树数据
       rightTreeData1:[],//存储右边的质检树数据
-      nowrefId:''
+      nowref:{}
      
     }
   },
@@ -1035,6 +1035,7 @@ export default {
       if(this.templateType==1){
         this.selectData.referenceWbsTemplateId=value
 
+
       }else{
           this.selectData.referenceWbsTemplateIdTrial=value
       }
@@ -1261,6 +1262,8 @@ export default {
               this.wbsId = list[i].wbsId + ',' + list[i].projectId;
               priv.wbsId = list[i].wbsId;
               priv.projectId = list[i].projectId;
+              priv.value= list[i].value
+              priv.pkeyId= list[i].pkeyId
               break;
             }
           }
@@ -1274,7 +1277,10 @@ export default {
         }else{
           this.selectData.referenceWbsTemplateIdTrial=this.wbsId
         }
-        this.nowrefId=refId
+        this.nowref={
+          value:priv.value,
+          id:  priv.pkeyId 
+        }
         let projectTree = await findProjectTree(this.projectForm.id, refId) //查询的右边的数据
         if (Array.isArray(projectTree.data.data)) {
           this.leftloading = true;
@@ -1372,13 +1378,61 @@ export default {
 
     getRightTree() {
       this.rightloading = true;
-      // let WbsId = this.templateType === 1 ? this.selectData.referenceWbsTemplateId : this.selectData.referenceWbsTemplateIdTrial
-        let WbsId = this.templateType === 1 ? this.nowrefId : this.selectData.referenceWbsTemplateIdTrial
-      if (this.projectForm.referenceWbsTemplateType == 'private' && WbsId != null && WbsId.toString().length > 0) {
-          let ids = WbsId.toString().split(",");
-          WbsId = ids[0]
+      console.log(this.nowref,'nowrefId');
+
+      let refId =  this.templateType === 1 ? this.selectData.referenceWbsTemplateId : this.selectData.referenceWbsTemplateIdTrial;
+      console.log(refId,'refId');
+      let WbsId=''
+      if (this.projectForm.referenceWbsTemplateType === 'private' && refId != null && refId.toString().length > 0) {
+        // 私有库右边树形数据是通过 pkeyId 查询的
+        let ids = refId.toString().split(",");
+        if (ids.length > 1) {
+          refId = ids[0]
+          let list = this.treeList[1].options;
+          refId = list.filter(e => e.projectId == ids[1])[0].pkeyId;
+          console.log(refId,'refId');
+         
+        }
       }
-    findProjectTree(this.projectForm.id, WbsId).then((res) => {
+      //引用被删会出现 wbsType -1
+      if (refId && refId > 0 && Number(this.projectForm.wbsType) > 0) {
+        let priv = {};
+        if (this.projectForm.referenceWbsTemplateType == 'private') {
+          //私有
+          let list = this.treeList[1].options;
+          for (let i = 0; i < list.length; i++) {
+            if (list[i].pkeyId == refId) {
+              refId = list[i].wbsId + ',' + list[i].projectId;
+              priv.wbsId = list[i].wbsId;
+              priv.projectId = list[i].projectId;
+              priv.value= list[i].value
+              priv.pkeyId= list[i].pkeyId
+           
+              break;
+            }
+          }
+        } else {
+          //公有
+          WbsId = refId;
+        }
+
+
+      if(this.nowref.value===refId){
+        WbsId=this.nowref.id
+      }else{
+        if (this.projectForm.referenceWbsTemplateType == 'private' && refId != null && refId.toString().length > 0) {
+            WbsId = priv.pkeyId||this.selectData.referenceWbsTemplateIdTrial 
+        }
+        else {//公有
+          WbsId=this.templateType === 1 ?this.selectData.referenceWbsTemplateId: this.selectData.referenceWbsTemplateIdTrial 
+        }
+     }
+     
+  
+       console.log(WbsId,'WbsId'); 
+   
+    // findProjectTree(this.projectForm.id,  this.templateType === 1 ? WbsId : this.selectData.referenceWbsTemplateIdTrial).then((res) => {
+     findProjectTree(this.projectForm.id, WbsId).then((res) => {
       if (this.rightTreeData.length>0&&this.templateType===2) {
          this.$refs.treetotree.setRightTree(this.rightTreeData);
       }else if(this.rightTreeData1.length>0&&this.templateType===1){
@@ -1395,8 +1449,9 @@ export default {
        
       })
     
-   this.rightloading = false;    
-
+       
+      }
+      this.rightloading = false;
     },
 
   }