import { request } from '../../boot/axios';
import { Pagination } from '../class';
import { AddOrEditFormData, AreaSearchEntity } from './model/area';
const pathAreaName = 'area/';

class AreaApi {
  // 库区 分页
  getPage = (val?: Pagination<AreaSearchEntity>) => {
    return request.postForPage(`${pathAreaName}page`, val);
  };
  // 库区 新增
  add = (val?: AddOrEditFormData) => {
    return request.post(`${pathAreaName}add`, val);
  };
  // 库区 修改
  edit = (val?: AddOrEditFormData) => {
    return request.put(`${pathAreaName}edit`, val);
  };
  // 库区 删除
  remove = (val?: any) => {
    return request.delete(`${pathAreaName}delete/${val}`);
  };
  listMapper = (val?: any) => {
    return request.get('dateModule/listMapper/' + val);
  };

  ///
  // 联动根据工厂 获取库区集合方法
  // @val1 = 工厂ID
  // @val2 = 搜索参数
  ///
  getAreaList = (val1: string, val2: string) => {
    return request.post(`${pathAreaName}list`, {
      warehouseId: val1,
      areaName: val2
    });
  };
}
const areaApi = new AreaApi();
export { areaApi };
