import request from '@/utils/request';

export default {
  //列表
  list: async (params) => {
    const res = await request.get('/wms/outin/page', { params });
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  //列表
  getAssetNum: async (data) => {
    const res = await request.post('/wms/outin/getAssetNum', data);
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  //保存
  save: async (data) => {
    const res = await request.post('/wms/outin/save', data);
    if (res.data.code == 0) {
      return res.data;
    }
  },
  //新保存
  saveNew: async (data) => {
    const res = await request.post('/wms/outin/saveNew', data);
    if (res.data.code == 0) {
      return res.data;
    }
  },
  //删除
  delete: async (data) => {
    const res = await request.delete('/wms/outintwo/delete', { data });
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //出库实时库存
  getRealTimeInventory: async (params) => {
    const res = await request.get(`/wms/outin/getRealTimeInventory`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  //出库实时库存
  pageeLedger: async (params) => {
    const res = await request.get(`/wms/outin/getOutStock`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  //出库物品实时库存
  getoutDetail: async (params) => {
    const res = await request.get(`/wms/outin/getOutDetail`, {
      params
    });
    if (res.data.code == 0) {
      return res.data;
    }
  },
  //详情
  getById: async (id) => {
    const res = await request.get(`/wms/outin/getById/${id}`);
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  //出入库单-新增入库单信息
  addInOut: async (data) => {
    const res = await request.post('/wms/inout/addInOut', data);
    if (res.data.code == 0) {
      return res.data;
    }
  },
  //列表
  pageWms: async (params) => {
    const res = await request.get('/wms/inout/page', { params });
    if (res.data.code == 0) {
      return res.data.data;
    }
  },

  //入库详情
  getWms: async (id) => {
    const res = await request.get(`/wms/inout/getInfoById/${id}`);
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  //库存台账-基本信息
  getBasicInformation: async (categoryId) => {
    const res = await request.get(
      `/wms/outin/getBasicInformation/${categoryId}`
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
  },

  //库存台账-库存明细

  getInventoryDetails: async (params) => {
    const res = await request.get(`/wms/outin/getInventoryDetails`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  //库存台账-库存明细-物料维度

  getMaterielDetails: async (params) => {
    const res = await request.get(`/wms/outin/getMaterielDetails`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  outApproveQuality: async (params) => {
    const res = await request.post(
      `/bpm/outinApprove/qualityInspection`,
      params
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  outApprove: async (params) => {
    const res = await request.post(`/bpm/outApprove/submit`, params);
    if (res.data.code == 0) {
      return res.data
    }
  },
  outApproves: async (params) => {
    const res = await request.post(`/bpm/outinApprove/submit`, params);
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  outApprovesInside: async (params) => {
    const res = await request.post(`/bpm/outApprove/submitInside`, params);
    if (res.data.code == 0) {
      return res.data.data;
    }
  },
  update: async (params) => {
    const res = await request.put(`/wms/outin/update`, params);
    if (res.data.code == 0) {
      return res.data;
    }
  },
  updateOutInRecord: async (params) => {
    const res = await request.post(`/wms/outin/updateOutInRecord`, params);
    if (res.data.code == 0) {
      return res.data;
    }
  },
  getDetailByCode: async (params) => {
    const res = await request.post(`/wms/outin/getDetailByCode`, params);
    if (res.data.code == 0) {
      return res.data;
    }
  },
  getListByNameOrModeType: async (data) => {
    const res = await request.post(
      `/main/category/getListByNameOrModeType`,
      data
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
  }
};
