import { request } from '../../boot/axios';
import { Pagination } from '../class';
import {
  WriteOffSearchEntity,
  WriteOffDetailSearchEntity,
  WriteOffProofSearchEntity,
  WriteOffPutawayEntity
} from './model/writeOff';
const pathName = 'busWriteOff/';
const pathWriteOffRowName = 'busWriteOffRow/';

class WriteOffApi {
  // 分页查询
  getPage = (val: Pagination<WriteOffSearchEntity>) => {
    return request.postForPage(`${pathName}page`, val);
  };
  // 通过 物料凭证、物料凭证年份查询 冲销单信息
  getWriteOffData = (val: any) => {
    return request.post(`${pathName}getWriteOffData`, val);
  };
  // 新增 冲销单
  add = (val: any) => {
    return request.post(`${pathName}addWriteOff`, val);
  };
  //   edit = (val: any) => {
  //     return request.put(`${pathName}edit`, val);
  //   };
  // 删除冲销单
  remove = (val: string) => {
    return request.get(`${pathName}removeWriteOff/${val}`);
  };
  //   finishEdit = (val: string) => {
  //     return request.post(`${pathName}finishEdit`, val);
  //   };
  // 执行冲销
  execute = (val: string) => {
    return request.get(`${pathName}execute/${val}`);
  };
  // 分页查询 物料凭证
  getWriteOffProofPage = (val: Pagination<WriteOffProofSearchEntity>) => {
    return request.postForPage(`${pathName}getWriteOffProof`, val);
  };
  // 冲销单 上架
  putaway = (val: WriteOffPutawayEntity) => {
    return request.post(`${pathName}putaway`, val);
  };
}
const writeOffApi = new WriteOffApi();
class WriteOffRowApi {
  // 分页查询
  getPage = (val: Pagination<WriteOffDetailSearchEntity>) => {
    return request.postForPage(`${pathWriteOffRowName}page`, val);
  };
}
const writeOffRowApi = new WriteOffRowApi();

export { writeOffApi, writeOffRowApi };
