/**
 *Created by WY on 2019/10/13
 */
import * as http from '@/request'
export function getAllTask() {
  return http.ajax({
    url: '/task/selectAll/',
    method: 'get'
  }).then(response => {
    if (response.data.status == "401") {
      that.$alert(response.data.message);
      that.$router.push({ path: "/login" });
    } else {
      const data = response.data
      if (data) { return Promise.resolve(data) } else { return Promise.reject('未找到任何任务') }
    }
  })
}
/* 任务下的所有人员 */
export function getTaskWorker(listQuery) {
  /* return http.service.post('/route/getWorkerForTask/',listQuery) */
  return http.ajax({
    url: '/route/getWorkerForTask?taskId=' + Number(listQuery.taskId),
    method: 'get'
  }).then(response => {
    if (response.data.status == "401") {
      that.$alert(response.data.message);
      that.$router.push({ path: "/login" });
    } else {
      const data = response.data
      if (data) { return Promise.resolve(data) } else { return Promise.reject('未找到任何任务人员') }
    }
  })
}
export function getRoute(listQuery) {
  /* return http.service.post('route/getRouteByUserId',listQuery) */
  return http.ajax({
    url: '/route/getRouteByUserId?taskId=' + Number(listQuery.taskId) + '&userId=' + Number(listQuery.userId) + '&beginTime=' + listQuery.beginTime + '&stopTime=' + listQuery.stopTime,
    method: 'get'
  }).then(response => {
    if (response.data.status == "401") {
      that.$alert(response.data.message);
      that.$router.push({ path: "/login" });
    } else {
      const data = response.data
      if (data) { return Promise.resolve(data) } else { return Promise.reject('未找到任何轨迹') }
    }
  })
}
