import request from '@/utils/request';

export default {
  //根据人员id获取部门
  getGroupById: async (id) => {
    const res = await request.get(`/main/user/getById/${id}`);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  getApplyoutsource: async (params) => {
    const res = await request.get(`/mes/applyoutsource/page`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 入库
  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));
  },
  // 入库
  update: async (data) => {
    const res = await request.post('/wms/outintwo/update', 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;
    }
    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));
  },
  // 获取入库详情
  getInboundDetailsByBizNo: async (id) => {
    const res = await request.get(`/wms/outintwo/getInfoByBizNo/${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));
  },
  // 更新出库
  outUpdate: async (data) => {
    const res = await request.post('/wms/outintwo/outUpdate', 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('/wms/applystorage/page', {
      params: data
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 出入库申请列表通过入库申请单查询详情
  getApplystoragedetail: async (data) => {
    const res = await request.get('/wms/applystoragedetail/list', {
      params: data
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 出入库申请列表通过入库申请单查询详情(批量)
  getApplystoragedetails: async (data) => {
    const res = await request.post(
      '/wms/applystoragedetail/listByAppIds',
      data
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 获取物料维度台账列表
  getInfoBySourceBizNo: async (id) => {
    const res = await request.get(`/wms/outintwo/getInfoBySourceBizNo/${id}`);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 质检保存
  qualityInspection: async (data) => {
    const res = await request.post(`/wms/outintwo/qualityInspection`, 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));
  },
  // 动态表头
  fieldModel: async (params) => {
    const res = await request.get(`/main/fieldmodel/list`, {
      params
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 单价维护
  unitPriceMaintenance: async (data) => {
    const res = await request.put(
      '/wms/stockpackingtwo/unitPriceMaintenance',
      data
    );
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 仓库树
  getWarehouseTrees: async (data) => {
    const res = await request.get('/wms/warehouse/getTrees', {
      params: data
    });
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 通过仓库ID获取仓库区域
  getListByWarehouseId: async (id) => {
    const res = await request.get(
      `/wms/warehousearea/getListByWarehouseId/${id}`
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 根据物品ID获取包装维度
  getCategoryPackageDisposition: async (data) => {
    const res = await request.post(
      '/main/categoryPackageDisposition/list',
      data
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 通过入库单号获取入库明细
  getOutInRecordsPage: async (data) => {
    const res = await request.get(
      `/wms/outInDetailRecordTwo/outInRecordsPage`,
      {
        params: data
      }
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 合并拆分包装
  disassemblyPackage: async (data) => {
    const res = await request.post(
      '/wms/outInDetailRecordTwo/disassemblyPackage',
      data
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 通过物品id获取供货商列表
  contactQueryByCategoryIdsAPI: async (data) => {
    const res = await request.post('/eom/contact/queryByCategoryIds', data);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 通过销售发货单获取
  getBySendRecordNo: async (id) => {
    const res = await request.get(
      `/eom/saleordersendrecord/getBySendRecordNo/${id}`
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 调拨保存
  allotApplySave: async (data) => {
    const res = await request.post('/wms/allotApply/save', data);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 库内调拨列表
  getAllotApplyPage: async (data) => {
    const res = await request.get(`/wms/allotApply/page`, {
      params: data
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 库内调拨详情列表
  getAllotDetailList: async (data) => {
    const res = await request.get(`/wms/allotDetail/list`, {
      params: data
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 库内调拨详情
  getAllotDetail: async (id) => {
    const res = await request.get(`/wms/allotApply/getById/${id}`);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 发起库外调拨流程
  submitAllot: async (data) => {
    const res = await request.post('/bpm/outinApprove/submitAllot', data);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  deleteAllot: async (data) => {
    const res = await request.delete('/wms/allotApply/delete', {
      data
    });
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 出入库列表
  getOutinList: async (data) => {
    const res = await request.get(`/wms/outintwo/list`, {
      params: data
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 拆包
  takeApartPackage: async (data) => {
    const res = await request.post(
      '/wms/outInDetailRecordTwo/takeApartPackage',
      data
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 打包
  combinePackage: async (data) => {
    const res = await request.post(
      '/wms/outInDetailRecordTwo/combinePackage',
      data
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 保存拣货单
  savePickgoods: async (data) => {
    const res = await request.post('/wms/pickgoods/save', data);
    console.log(res);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 修改拣货单
  updatePickgoods: async (data) => {
    const res = await request.post('/wms/pickgoods/update', data);
    console.log(res);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 拣货列表
  getPickgoodsList: async (data) => {
    const res = await request.get(`/wms/pickgoods/page`, {
      params: data
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 获取拣货详情
  getPickgoodsDetails: async (id) => {
    const res = await request.get(`/wms/pickgoods/getById/${id}`);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 删除入库详情
  deletePickgoods: async (data) => {
    const res = await request.delete('/wms/pickgoods/delete', {
      data
    });
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 拣货出库
  pickGoodsOutIn: async (data) => {
    const res = await request.post('/wms/outintwo/pickGoodsOutIn', data);
    console.log(res);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 台账详情调拨列表
  getAllotDetails: async (data) => {
    const res = await request.get(`/wms/allotDetail/page`, {
      params: data
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  // 台账详情盘点列表
  getPlandetails: async (data) => {
    const res = await request.get(`/wms/plandetail/page`, {
      params: data
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },

  //江南-仓库入库申请

  //入库申请列表
  getStoreList: async (data) => {
    const res = await request.get(`/wms/applystoragejn/page`, {
      params: data
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //入库申请保存
  saveStoragejn: async (data) => {
    const res = await request.post('/wms/applystoragejn/save', data);
    console.log(res);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //入库申请信息
  getStoragejnDetails: async (id) => {
    const res = await request.get(`/wms/applystoragejn/getById/${id}`);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //入库申请提交
  submitStoragejn: async (data) => {
    const res = await request.post('/wms/applystoragejn/submit', data);
    console.log(res);
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  },
  //验证是否重复入库
  isVerifyRepeatIsStock: async (data) => {
    const res = await request.post(
      '/wms/outindetailtwo/isVerifyRepeatIsStock',
      data
    );
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
};

export const getOutInRecordsPage = async (data) => {
  const res = await request.get(`/wms/outInDetailRecordTwo/outInRecordsPage`, {
    params: data
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
};
