Преглед на файлове

分配wbs模板初始化

duy преди 2 години
родител
ревизия
fa9f5cdc6c
променени са 1 файла, в които са добавени 76 реда и са изтрити 72 реда
  1. 76 72
      src/views/manager/projectinfo/detail.vue

+ 76 - 72
src/views/manager/projectinfo/detail.vue

@@ -679,10 +679,6 @@ export default {
       }
     },
     beforeLeave (activeName, oldActiveName) {
-      console.log("---------------- beforeLeave ----------------------")
-
-      console.log(activeName, "---------------- beforeLeave-activeName")
-      console.log(oldActiveName, "---------------- beforeLeave-oldActiveName")
       return new Promise((resolve, reject) => {
         if (oldActiveName == '1' && !this.projectForm.id) {
           this.$message({
@@ -1238,6 +1234,10 @@ export default {
         this.treeList = arr;
 
         this.wbsId = this.templateType == 1 ? this.selectData.referenceWbsTemplateId : this.selectData.referenceWbsTemplateIdTrial
+        console.log(this.wbsId===-1);
+        if(this.wbsId===-1){
+          this.wbsId=''
+        }
         this.wbsChange(this.wbsId, true)
 
         // if(this.treeList[0].options.length > 0){
@@ -1429,76 +1429,80 @@ export default {
 
       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');
-         
-        }
-      }
-      //引用被删会出现 wbsType -1
-      if (refId && refId > 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
+      if(!refId){
+        console.log('不存在refId');
+         this.$refs.treetotree.setRightTree([]);
       }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'); 
-      console.log(this.rightObj1,'this.rightObj111111111');
-        console.log(this.rightObj,'this.rightObj000000000000');
-    // 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.rightObj.wbsId==WbsId) {
-         this.$refs.treetotree.setRightTree(this.rightTreeData);
-      }else if(this.rightTreeData1.length>0&&this.templateType===1&&this.rightObj1.wbsId==WbsId){
-          this.$refs.treetotree.setRightTree(this.rightTreeData1);
-      }
-      else{
-        if (Array.isArray(res.data.data)) {
-          this.$refs.treetotree.setRightTree(res.data.data);
-        } else {
-          this.$refs.treetotree.setRightTree([]);
-        }
-      }
-        
-       
-      })
-    
-       
+              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');
+                
+                }
+              }
+              //引用被删会出现 wbsType -1
+              if (refId && refId > 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.rightObj.wbsId==WbsId) {
+                this.$refs.treetotree.setRightTree(this.rightTreeData);
+              }else if(this.rightTreeData1.length>0&&this.templateType===1&&this.rightObj1.wbsId==WbsId){
+                  this.$refs.treetotree.setRightTree(this.rightTreeData1);
+              }
+              else{
+                if (Array.isArray(res.data.data)) {
+                  this.$refs.treetotree.setRightTree(res.data.data);
+                } else {
+                  this.$refs.treetotree.setRightTree([]);
+                }
+              }
+                
+              
+              })
+            
+              
+              }
       }
+
       this.rightloading = false;
     },