import request from '@/utils/request';

export default {
  // 入库
  storage: async (data) => {
    const res = await request.post('/wms/outintwo/inStorage', data);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 批量获取包装编码
  getAssetNum: async (data) => {
    const res = await request.post('/wms/outintwo/getAssetNum', data);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 提交流程(入库)
  submitTwo: async (data) => {
    const res = await request.post('/bpm/outinApprove/submitTwo', data);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 提交流程(出库)
  submitInsideTwo: async (data) => {
    const res = await request.post('/bpm/outApprove/submitInsideTwo', data);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },

  // 提交质检流程
  qualityInspectionTwo: async (data) => {
    const res = await request.post(
      '/bpm/outinApprove/qualityInspectionTwo',
      data
    );
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 获取入库列表
  getList: async (params) => {
    const res = await request.get(`/wms/outintwo/page`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 获取入库详情
  getInboundList: async (params) => {
    const res = await request.get(`/wms/outintwo/page`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 获取入库详情
  getInboundDetailsById: async (id) => {
    const res = await request.get(`/wms/outintwo/getById/${id}`);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 删除入库详情
  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));
  },
  // 物品维度台账列表
  getProductList: async (params) => {
    const res = await request.get(`/wms/outindetailtwo/page`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 批次维度台账列表
  getBatchList: async (params) => {
    const res = await request.get(`/wms/outindetailtwo/batchPage`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 包装维度台账列表
  getPackingList: async (params) => {
    const res = await request.get(`/wms/outInDetailRecordTwo/page`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 获取物料维度台账列表
  getMaterialList: async (params) => {
    const res = await request.get(`/wms/materialDetail/page`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 通过台账id获取出库物品详情
  getHierarchyList: async (params) => {
    const res = await request.get(`/wms/outintwo/getHierarchyList`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  getHierarchyFifo: async (data) => {
    const res = await request.post('/wms/outintwo/getHierarchyFifo', data);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 出库
  outStorage: async (data) => {
    const res = await request.post('/wms/outintwo/outStorage', data);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  outStorage: async (data) => {
    const res = await request.post('/wms/outintwo/outStorage', data);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 包装维度流水
  outInRecordsPage: async (params) => {
    const res = await request.get(
      `/wms/outInDetailRecordTwo/outInRecordsPage`,
      {
        params
      }
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 上下架
  upperLowerShelves: async (data) => {
    const res = await request.post('/wms/outintwo/listing', data);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 入库申请列表
  getinboundRequestsList: async (data) => {
    const res = await request.get('/mes/applystorage/page', {
      params: data
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 通过入库申请单查询详情
  getApplystorageDetailById: async (id) => {
    const res = await request.get(`/mes/applystorage/getById/${id}`);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
};
