import { request } from '../../boot/axios';
import { Pagination } from '../class';
import { InventorySearchEntity } from './model/inventory';
import { InventoryDetailSearchEntity } from './model/inventoryDetail';
import { InventoryDetailMaterialSearchEntity } from './model/inventoryDetailMaterial';
const pathName = 'inventory';
const pathNameDetail = 'inventoryDetail';
const pathNameDetailMaterial = 'inventoryDetailMaterial';

// 盘点
class InventoryApi {
  getPage = (val?: Pagination<InventorySearchEntity>) => {
    return request.postForPage(`${pathName}/page`, val);
  };
  add = (val: any) => {
    return request.post(`${pathName}/add`, val);
  };
  edit = (val: any) => {
    return request.post(`${pathName}/edit`, val);
  };
  getUpdateTree = (val: any) => {
    return request.get(`${pathName}/getUpdateTree/${val}`);
  };
  submitInventory = (val: any) => {
    return request.get(`${pathName}/submitInventory/${val}`);
  };
  check = (val: any) => {
    return request.post(`${pathName}/check`, val);
  };
  del = (val: any) => {
    return request.delete(`${pathName}/del/${val}`);
  };
  // 导出
  export = (val: any) => {
    return request.get(`${pathName}/export/${val}`, {
      responseType: 'blob'
    });
  };
  //   delete = (val: number) => {
  //     return request.delete(`${pathName}/del/${val}`);
  //   };
  //   // 根据 asnId 查询 asnRow列表
  //   getListByAsnId = (val?: number) => {
  //     return request.get(`${pathName}/listByAsnId/${val}`);
  //   };
  //   // 查询 asnRow列表
  //   // 必传 asnId
  //   // 新增 keyword 模糊搜索 （物料名称、规格型号）
  //   getListByKeyword = (val?: any) => {
  //     return request.post(`${pathName}/listByKeyword`, val);
  //   };
  //   // 删除 入库单草稿
  //   removeById = (val: number) => {
  //     return request.delete(`${pathName}/removeById/${val}`);
  //   };

  //   // 完成收货 修改状态
  //   overReceiving = (val: number) => {
  //     return request.put(`${pathName}/overReceiving/${val}`);
  //   };
}

// 盘点详情
class InventoryDetailApi {
  getPage = (val?: Pagination<InventoryDetailSearchEntity>) => {
    return request.postForPage(`${pathNameDetail}/page`, val);
  };
}

// 盘点项
class InventoryDetailMaterialApi {
  getPage = (val?: Pagination<InventoryDetailMaterialSearchEntity>) => {
    return request.postForPage(`${pathNameDetailMaterial}/page`, val);
  };
}

const inventoryApi = new InventoryApi();
const inventoryDetailApi = new InventoryDetailApi();
const inventoryDetailMaterialApi = new InventoryDetailMaterialApi();
export { inventoryApi, inventoryDetailApi, inventoryDetailMaterialApi };
