import { request } from '../../boot/axios';
import { Pagination } from '../class';
import { AddOrEditFormData, WarehouseSearchEntity } from './model/warehouse';

const pathName = 'warehouse/';

class WarehouseApi {
  getPage = (val?: Pagination<WarehouseSearchEntity>) => {
    return request.postForPage('warehouse/page', val);
  };
  add = (val: AddOrEditFormData) => {
    return request.post('warehouse/add', val);
  };
  edit = (val: AddOrEditFormData) => {
    return request.put('warehouse/update', val);
  };
  remove = (val: string) => {
    return request.delete('warehouse/del/' + val);
  };
  // 根据工厂 公司编码 获取 成本中心下拉
  getCostCenter = (companyCode: string) => {
    return request.get('warehouse/getCostCenter/' + companyCode);
  };

  //filterOption
  getWarehouseList = (val: string) => {
    return request.post('warehouse/getWarehouseList', { warehouseName: val });
  };

  // 获取状态字典
  getDnStatus = () => {
    return request.get('/dict/type/dn_status');
  };
  //  获取包装单位
  gePackUnitMap = () => {
    return request.get('materialsunit/getUnitList/1/');
  };
  // 获取记账单位
  getRecordUnitMap = () => {
    return request.get('materialsunit/getUnitList/2/');
  };
  // 获取客户列表
  getCustomerList = () => {
    return request.get('customer/customer-list');
  };
  getStock = (val?: any) => {
    return request.post(`${pathName}getStock/${val}`, {});
  };
  getStockPage = (val?: any) => {
    return request.post('stock/getStockPage/', val);
  };
  // 根据工厂ID查询 库区库位树形菜单
  tree = (val: any) => {
    return request.get(`${pathName}tree/${val}`);
  };
}
const warehouseApi = new WarehouseApi();
export { warehouseApi };
