import { request } from '../../boot/axios';
import { Pagination } from '../class';
import {
  DnSearchEntity,
  DnOutWarehouseEntity,
  DnRowSearchEntity,
  dnSaleSearchEntity
} from './model/outbound';
const pathName = 'dn';
const pathNameDnRow = 'dnRow';
class DnApi {
  getPage = (val?: Pagination<DnSearchEntity>) => {
    return request.postForPage(`${pathName}/page`, val);
  };
  // 新增出库单
  add = (val?: any) => {
    return request.post(`${pathName}/add`, val);
  };
  // 编辑完成出库单
  finishEdit = (val?: any) => {
    return request.put(`${pathName}/finishEdit/${val}`);
  };
  // 删除出库单
  remove = (val?: any) => {
    return request.delete(`${pathName}/removeById/${val}`);
  };
  // 更新出库单
  update = (val?: any) => {
    return request.put(`${pathName}/update`, val);
  };
  // 下架
  pick = (val?: any) => {
    return request.post(`${pathName}/pick`, val);
  };
  // 出库
  outWarehouse = (val?: any) => {
    return request.post(`${pathName}/outWarehouse`, val);
  };
  // 出库查询
  getPageForDnOutWarehouseForm = (val?: Pagination<DnOutWarehouseEntity>) => {
    return request.postForPage(`${pathName}/pageForDnOutWarehouseForm`, val);
  };
  // 获取移动类型
  // @model:''
  // @direction: 0 方向出库单入参为 1
  getMoveType = (val?: any) => {
    return request.post(`${pathName}/getMoveType`, val);
  };
  // 获得冲销移动类型
  getWriteOffMoveType = () => {
    return request.get(`${pathName}/getWriteOffMoveType`);
  };
  // 获取销售订单
  getDelivery = (val: dnSaleSearchEntity) => {
    return request.post(`${pathName}/getDelivery`, val);
  };
  // 用于 出库单 重新上架
  putaway = (val: any) => {
    return request.post(`${pathName}/putaway`, val);
  };
}
const dnApi = new DnApi();

class DnRowApi {
  getPage = (val: Pagination<DnRowSearchEntity>) => {
    return request.postForPage(`${pathNameDnRow}/page`, val);
  };
  // 查询出库单 草稿
  getListForUpdateForm = (val?: number) => {
    return request.get(`${pathNameDnRow}/listForUpdateForm/${val}`);
  };
  // 查询下架单 行数据
  getListForPickForm = (val?: number) => {
    return request.get(`${pathNameDnRow}/listForPickForm/${val}`);
  };
  // 查询 出库单 下架列表
  // 未开始0，下架中1
  getPickList = (val: any) => {
    return request.post(`${pathNameDnRow}/listForPickForm/pickForm`, val);
  };
}

const dnRowApi = new DnRowApi();

export { dnApi, dnRowApi };
