import request from '@/utils/request';
// 获取车间下的所有产线
export async function listFactoryLine(params) {
  const res = await request.post(`/main/factoryarea/listFactoryLine`, params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 获取工厂下的所有车间
export async function listWorkshopByParentId(params) {
  const res = await request.get(
    `/main/factoryarea/listWorkshopByParentId/${params}`,
    {}
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 保存
export async function saveOrUpdate(params) {
  const res = await request.post(`/main/factoryarea/saveOrUpdate`, params);
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
// 查询工厂列表-分页
export async function getFactoryarea(params) {
  const res = await request.get(`/main/factoryarea/page`, {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 删除
export async function deletefactoryarea(params) {
  const res = await request.get(`/main/factoryarea/delete/${params}`);
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
// 保存修改工位
export async function saveOrUpdate_gw(params) {
  const res = await request.post(
    `/main/factoryworkstation/saveOrUpdate`,
    params
  );
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
// 工位分页查询
export async function getFactoryworkstation(params) {
  const res = await request.get(`/main/factoryworkstation/page`, {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 工位删除
export async function deleteFactoryworkstation(params) {
  const res = await request.delete(`/main/factoryworkstation/delete/${params}`);
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
// 工位详情
export async function getById(params) {
  const res = await request.get(`/main/factoryworkstation/getById/${params}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 工艺路线工序实例-列表(查询所有)
export async function getProduceList(params) {
  const res = await request.get(
    `/main/producerouting/taskinstance/getAllList`,
    { params }
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 所有在工位的设备
export async function allDeviceList(params) {
  const res = await request.get(`/main/factoryworkstation/allDeviceList`, {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 工种列表查询
export async function getProfessionPageList(params) {
  const res = await request.get(`/main/profession/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 新增工种
export async function saveJobTypes(data) {
  const res = await request.post(`/main/profession/save`, data);
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

// 通过id查询工种详情
export async function getProfessiongetById(id) {
  const res = await request.get(`/main/profession/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 删除工种
export async function deleteProfessiongetById(data) {
  const res = await request.delete(`/main/profession/delete`, { data });
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

// 修改工种
export async function updateProfessiongetById(data) {
  const res = await request.put(`/main/profession/update`, data);
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

// 资质列表查询
export async function getProfessionCertificationPageList(params) {
  const res = await request.get(`/main/professionCertification/page`, {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 新增资质
export async function saveProfessionCertification(data) {
  const res = await request.post(`/main/professionCertification/save`, data);
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

// 通过id查询资质详情
export async function getProfessionCertificationById(id) {
  const res = await request.get(`/main/professionCertification/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 删除资质
export async function deleteProfessionCertificationById(data) {
  const res = await request.delete(`/main/professionCertification/delete`, {
    data
  });
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

// 修改资质
export async function updateProfessionCertificationById(data) {
  const res = await request.put(`/main/professionCertification/update`, data);
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

// 获取供应商/客户列表
export async function getVendorPageList(params) {
  const res = await request.get(`/eom/contact/page`, {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
