import request from '@/utils/request';

// 获取工厂下的所有车间
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 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 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 factoryworkstation(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 listByProductionLineId(params) {
  const res = await request.get(
    `/main/factoryworkstation/listByProductionLineId/` + params,
    {}
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
