import request from '@/utils/request';
// 物品信息列表
export async function getList(data) {
  const res = await request.get(
    `/main/category/getList?categoryLevelId=${data.categoryLevelId}&pageNum=${data.pageNum}&size=${data.size}&searchKey=${data.searchKey}`
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 物品信息保存
export async function informationAdd(data) {
  const res = await request.post('/main/category/add', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 物品信息编辑
export async function informationEdit(data) {
  const res = await request.post('/main/category/edit', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 物品信息详情
export async function getDetails(id) {
  const res = await request.get(`/main/category/info/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 物品信息删除
export async function removeItem(id) {
  const res = await request.get(`/main/category/remove/${id}`, {});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 物品信息获取编码
export async function getOrderNo(prefix) {
  const res = await request.get(`/main/category/createOrderNo/${prefix}`, {});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 查询仓库下拉列表
export async function getWarehouseList() {
  const res = await request.post(`/wms/warehouse/getWarehouseList`, {});
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 查询库存台账首页列表
export async function pageeLedgerMain(params) {
  const res = await request.get(`/wms/inout/pageeLedgerMain`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 库存台账-详情-基本信息
export async function getCateInfo(id) {
  const res = await request.get(`/wms/ledger/getCateInfo/${id}`, {});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 分页
export async function ledgerdetailPage(params) {
  const res = await request.get(`/wms/ledgerdetail/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//库存台账-详情-出库单分页
export async function ledgerPage(params) {
  const res = await request.get(`/wms/ledger/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//库存台账详情出入单分页
export async function inventorybookPage(params) {
  const res = await request.get(`/wms/inventorybook/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
