import request from '@/utils/request';
import { baseURL } from '@/config';
//打卡列表分页查询
export function getClockData(data) {
  let param =
    '?page=' +
    data.page +
    '&size=' +
    data.size +
    '&projectId=' +
    data.projectId;
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  if (data.signUser != '') {
    param += '&signUser=' + data.signUser;
  }
  if (data.start != '') {
    param += '&start=' + data.start;
  }
  if (data.end != '') {
    param += '&end=' + data.end;
  }
  if ((data.type != '' && data.type != 2) || data.type == 0) {
    param += '&type=' + data.type;
  }
  return request({
    url: '/sign/list' + param,
    method: 'get',
    data,
  });
}
//修改打卡位置
export function doEdit(data) {
  return request({
    url: '/sign/updateLocation?id=' + data.id + '&location=' + data.location,
    method: 'post',
    data,
  });
}
//打卡记录删除
export function doDelete(data) {
  return request({
    url: '/sign/remove',
    method: 'post',
    data,
  });
}
//打卡记录导出
export function doExport(data) {
  let param = '?projectId=' + data.projectId;
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  if (data.signUser != '') {
    param += '&signUser=' + data.signUser;
  }
  if (data.start != undefined && data.end != undefined) {
    param += '&start=' + data.start + '&end=' + data.end;
  }
  return baseURL + '/sign/export' + param;
}

// 运动轨迹
export function getTrajectory(data) {
  const param =
    '?userId=' + data.userId + '&start=' + data.start + '&end=' + data.end;
  return request({
    url: '/sign/trajectory' + param,
    method: 'get',
    data,
  });
}
