import request from '@/utils/request'

const companys = (data) => {
  return request({
    url: `/listByPage?id=${data.id}&name=${data.name}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`,
    method: 'get',
  })
}
const addCompanys = (pairs) => {
  return request({
    url: `/companys`,
    method: 'post',
    data: pairs,
  })
}
const deleteCompanys = (data) => {
  return request({
    url: `/remove-companys/${data.id}`,
    method: 'delete',
  })
}
const lines = (data) => {
  return request({
    url: `/line/listByPage?id=${data.id}&name=${encodeURIComponent(
      data.name
    )}&pagenum=${data.pageNum}&pagesize=${data.pageSize}`,
    method: 'get',
  })
}

const regionList = (data) => {
  return request({
    url: `/region/List?companyid=${data.companyid}&name=${data.name}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`,
    method: 'get',
  })
}
const addRegion = (pairs) => {
  return request({
    url: `/region/save`,
    method: 'post',
    data: pairs,
  })
}
const deleteRegion = (data) => {
  return request({
    url: `/region/${data.id}`,
    method: 'delete',
  })
}

const windpowerstationList = (data) => {
  return request({
    url: `/windpowerstation/List?id=${data.id}&code=${data.code}&companyid=${data.companyid}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`,
    method: 'get',
  })
}
const addWindpowerstation = (pairs) => {
  return request({
    url: `/windpowerstation/add`,
    method: 'post',
    data: pairs,
  })
}
const deleteWindpowerstation = (data) => {
  return request({
    url: `/windpowerstation/${data.id}`,
    method: 'delete',
  })
}
const projectList = (data) => {
  return request({
    url: `/project/List?windpowerstationid=${data.windpowerstationid}&name=${data.name}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`,
    method: 'get',
  })
}
const addProject = (pairs) => {
  return request({
    url: `/project/add`,
    method: 'post',
    data: pairs,
  })
}
const deleteProject = (data) => {
  return request({
    url: `/project/${data.id}`,
    method: 'delete',
  })
}
const addLine = (pairs) => {
  return request({
    url: `/line/add-Line`,
    method: 'post',
    data: pairs,
  })
}
const deleteLine = (data) => {
  return request({
    url: `/line/remove-lines/${data.id}`,
    method: 'delete',
  })
}

const windturbine = (data) => {
  return request({
    url: `/windturbine/companys?pageNum=${data.pageNum}&pageSize=${
      data.pageSize
    }&name=${encodeURIComponent(data.name)}`,
    method: 'get',
  })
}
const addWindturbine = (pairs) => {
  return request({
    url: `/windturbine/add`,
    method: 'post',
    data: pairs,
  })
}
const deleteWindturbine = (data) => {
  return request({
    url: `/windturbine/${data.id}`,
    method: 'delete',
  })
}
const newtreeTreels = (data) => {
  return request({
    url: `/newtree/treels?tag=${data.tag}`,
    method: 'get',
  })
}
const equipmentmodel = (data) => {
  return request({
    url: `/equipmentmodel/listByPage?name=${encodeURIComponent(
      data.name
    )}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`,
    method: 'get',
  })
}
const addEquipmentmodel = (pairs) => {
  return request({
    url: `/equipmentmodel/save`,
    method: 'post',
    data: pairs,
  })
}
const deleteEquipmentmodel = (data) => {
  return request({
    url: `/equipmentmodel/remove-manufacturer?ids=${data.id}`,
    method: 'delete',
  })
}

const meterpoint = (data) => {
  return request({
    url: `/meterpoint/listByPage?name=${encodeURIComponent(
      data.name
    )}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`,
    method: 'get',
  })
}
const addMeterpoint = (pairs) => {
  return request({
    url: `/meterpoint/save`,
    method: 'post',
    data: pairs,
  })
}
const deleteMeterpoint = (data) => {
  return request({
    url: `/meterpoint/remove-meterpoint/${data.id}`,
    method: 'delete',
  })
}

const getStationPersis = (data) => {
  return request({
    url: `/windpowerstation/getStationPersis?station=${data.station}&startdate=${data.startdate}&enddate=${data.enddate}`,
    method: 'get',
  })
}
const getAdmList = (data) => {
  return request({
    url: `/windpowerstation/getAdmList?companyid=${data.companyid}&regionid=${data.regionid}`,
    method: 'get',
  })
}
// 区域保存 post：http://localhost:7020/region/save2
// 区域更新 Put：http://localhost:7020/region/editRegions
const addSave = (pairs) => {
  return request({
    url: `/region/save2`,
    method: 'post',
    data: [pairs],
  })
}
const editSave = (pairs) => {
  return request({
    url: `/region/editRegions`,
    method: 'put',
    data: [pairs],
  })
}
const standardpoint = (data) => {
  return request({
    url: `/standardpoint/list?pageNum=${data.pageNum}&pageSize=${data.pageSize}`,
    method: 'get',
  })
}
export default {
  addSave,
  editSave,
  companys,
  addCompanys,
  deleteCompanys,
  lines,
  regionList,
  addRegion,
  deleteRegion,
  windpowerstationList,
  addWindpowerstation,
  deleteWindpowerstation,
  projectList,
  addProject,
  deleteProject,
  addLine,
  deleteLine,
  windturbine,
  addWindturbine,
  deleteWindturbine,
  newtreeTreels,
  equipmentmodel,
  addEquipmentmodel,

  deleteEquipmentmodel,
  meterpoint,
  addMeterpoint,

  deleteMeterpoint,
  getStationPersis,
  getAdmList,
  standardpoint,
}
