import axiosInstance from '../../utils/axios';

export interface CabinetQuery {
  pageNo?: number;
  pageSize?: number;
  current?: number;
  size?: number;
  cabinetName?: string;
  cabinetCode?: string;
  status?: number;
  /** 所属区域/岗位，与列表左侧区域树联动 */
  workstationId?: number;
  [key: string]: any;
}

export interface CabinetVO {
  cabinetId?: number;
  cabinetName: string;
  cabinetCode: string;
  cabinetType?: string;
  cabinetIcon?: string;
  cabinetPicture?: string;
  status?: number;
  remark?: string;
  workstationId?: number;
  workstationCode?: string;
  workstationName?: string;
  /** 异常类型（接口字段 exReason，可为字符串）：0 正常 1 物资异常 2 物资柜异常 3 错还柜子 4 物资借出 5 超时未关门 */
  exReason?: number | string;
  exceptionType?: number;
  /** 异常类型描述（若后端返回） */
  exceptionTypeName?: string;
  exceptionName?: string;
  exceptionDesc?: string;
  abnormalTypeName?: string;
  [key: string]: any;
}

export const materialLockerApi = {
  listMaterialsCabinet: (params: CabinetQuery) =>
    axiosInstance.get('/iscs/materials-cabinet/getMaterialsCabinetPage', { params }),
  getMaterialsCabinetInfo: (id: number) =>
    axiosInstance.get('/iscs/materials-cabinet/selectMaterialsCabinetById', { params: { id } }),
  addMaterialsCabinet: (data: CabinetVO) =>
    axiosInstance.post('/iscs/materials-cabinet/insertMaterialsCabinet', data),
  updateMaterialsCabinet: (data: CabinetVO) =>
    axiosInstance.put('/iscs/materials-cabinet/updateMaterialsCabinet', data),
  deleteMaterialsCabinet: (ids: number) =>
    axiosInstance.delete('/iscs/materials-cabinet/deleteMaterialsCabinetList', { params: { ids } }),
};
