import request from '@/utils/request';

// 保存or更新
export async function saveOrEdit(data) {
  const res = await request.post(`/main/asset/saveOrEdit`, data);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 查询实例详情
export async function getAssetInfo(id) {
  const res = await request.get(`main/asset/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 生成批次
export async function getCode(code) {
  const res = await request.get(`/main/codemanage/getCode/${code}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 生成编码
export async function getAssetNum(data) {
  const res = await request.post(`/wms/outin/getAssetNum`, data);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//获取工单下所有周转车数据
export async function getTurnoverList(data) {
  const res = await request.post(
    `/main/asset/listTurnoverCarByWorkOrder`,
    data
  );
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//获取周转车的货位
export async function categoryVehicleList(id) {
  const res = await request.get(`/main/categoryvehicle/getByCategoryId/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
