import request from '@/utils/request';
import { baseURL } from '@/config';
//报修分页查询
export function getList(data) {
  let param =
    '?page=' +
    data.page +
    '&size=' +
    data.size +
    '&projectId=' +
    data.projectId;
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  if (data.repairPersonName != '') {
    param += '&repairPersonName=' + data.repairPersonName;
  }
  if (data.deviceType != '') {
    param += '&deviceType=' + data.deviceType;
  }
  if (data.repairItem != '') {
    param += '&repairItem=' + data.repairItem;
  }
  if (data.repairType != '') {
    param += '&repairType=' + data.repairType;
  }
  return request({
    url: '/repair/list' + param,
    method: 'get',
    data,
  });
}

//相关字典数据查询
export function getDictData(data) {
  return request({
    url: '/repair/dict',
    method: 'get',
    data,
  });
}
//该站点下设备列表
export function getEquipments(data) {
  return request({
    url: '/repair/equipments?deviceCode=' + data.deviceCode,
    method: 'get',
    data,
  });
}
//报修添加
export function doAdd(data) {
  return request({
    url: '/repair/add',
    method: 'post',
    data,
  });
}
//报修修改
export function doEdit(data) {
  return request({
    url: '/repair/update',
    method: 'post',
    data,
  });
}
//报修删除
export function doDelete(data) {
  return request({
    url: '/repair/remove',
    method: 'post',
    data,
  });
}
//导出
export function doExport(data) {
  var param = '?projectId=' + data.projectId;
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  if (data.repairPersonName != '') {
    param += '&repairPersonName=' + data.repairPersonName;
  }
  if (data.deviceType != '') {
    param += '&deviceType=' + data.deviceType;
  }
  if (data.equipmentName != '') {
    param += '&equipmentName=' + data.equipmentName;
  }
  if (data.repairType != '') {
    param += '&repairType=' + data.repairType;
  }
  return baseURL + 'repair/export' + param;
}
//报修转任务
export function toTask(data) {
  return request({
    url: '/repair/toTask',
    method: 'post',
    data,
  });
}
