前端框架vue:用vue实现的一个axios请求

if(this.DEV.currentPathInfo.subprojectType == 98 || this.DEV.currentPathInfo.subprojectType == 99 || this.DEV.currentPathInfo.subprojectType == 2002) {
          // list view search
          let tempData = [];
          let queryParam = {
              "ShowStoryOption": 0,
              "ShowAll": false,
              "GetCount": true,
              "PageSize": pageSize,
              "PageIndex": 1,
              "SortFieldId":0,
              "Condition": {
                "TaskId": "",
                "Keyword": searchValue,
                "Subproject": {
                  "SubIds": [subProjectId],
                  "IncludeChildren": true,
                  "IncludeClosed": true,
                  "IncludeBacklog": false
                },
                "Status": statusArr,
                "Owner": ownerArr
              },
              "ProjectId": projectId,
              "FieldIds": [601,101,108,104,606,607,620,621]
          };
          var queryTask = DevTrackApi + 'Task/Query';
          this.axios.post(queryTask,queryParam).then(res=>{
            if(res.data.Data.Tasks != undefined && res.data.Data.Tasks.length >0) {
              var tasks = res.data.Data.Tasks;
              this.DEV.taskTotal = res.data.Data.Total;
              tasks.forEach(task =>{
                  let totalTime = 0,percent=0;
                  let timeSpent = Number(task.Values[6].Value.replace(/\D/,' '));
                  let timeRemain = Number(task.Values[7].Value.replace(/\D/,' ')); 
                  totalTime = timeSpent + timeRemain;
                  
                  if (totalTime !== 0) {
                    percent = (timeSpent/totalTime).toFixed(2)*100;
                  }else {
                    percent = 0;
                  };

                  let taskObj = {
                      "ID":task.ItemId.Id,
                      "Title":task.Values[1].Value,
                      "Status":task.Values[0].Value,
                      "Assigned To":task.Values[2].Value,
                      "Priority":task.Values[3].Value,
                      "Percent": percent
                  };
                  tempData.push(taskObj)
              })
              this.changeDevListData(tempData);
            }else {
              // no task
              this.changeDevListData(tempData);
            }
          },err=>{ 
            console.log(err)
          })
        }else if(this.DEV.currentPathInfo.subprojectType == 33){
          // search in backlog 
          this.getDevelopBackLogTask();
        }else {
          // query task according 
          var devOption = this.DEV.devOption;
          let param =  {
            searchValue: searchValue,
            ownerArr: ownerArr,
            statusArr:statusArr
          };
          switch(devOption) {
            case 0:
              _this.getBoardViewTask();
            break;
            case 1: 
              _this.getColumnLeadingTasks(param);
            break; 
            case 2:
              _this.getBoardViewTask();
            break;
            case 3: 
              _this.getColumnLeadingTasks(param);
            break; 
            case 4:
              _this.getDevelopGroupSetting(param);
            break;
            case 5: 
              _this.getDevelopGroupSetting(param);
            break;
            case 6:
              _this.getDevelopGroupSetting(param);
            break;
            case 7: 
              _this.getDevelopGroupSetting(param);
            break; 
            case 8:
              _this.getDevSatusGroupTasks();
            break;
            case 9: 
              _this.getDevSatusGroupTasks();
            break; 
            case 10:
              _this.getDevSatusGroupTasks();
            break;
            case 11: 
              _this.getDevSatusGroupTasks();
            break;
            case 12:
              _this.getDevelopGroupSetting(param);
            break;
            case 13: 
              _this.getDevelopGroupSetting(param);
            break;
            case 14:
              _this.getDevelopGroupSetting(param);
            break;
            case 15: 
              _this.getDevelopGroupSetting(param);
            break;
            case 18: 
              _this.getDevelopGroupSetting(param);
            break;
            case 19: 
              _this.developAllGetTask(param);
            break;
          }
        }

//请自行将这段代码封装成一个function

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值