import request from '@/utils/request';
// 获取车间下的所有产线
export async function listFactoryLineByParentId (params) {
  const res = await request.get(
    `/main/factoryarea/listFactoryLineByParentId/${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));
}
