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

export interface InstructionsQuery {
  pageNo?: number;
  pageSize?: number;
  current?: number;
  size?: number;
  instructionsTitle?: string;
  materialsTypeId?: number;
  fileType?: string;
  [key: string]: any;
}

export interface InstructionsVO {
  instructionsId?: number;
  instructionsTitle: string;
  materialsTypeId: number;
  fileType: string;
  fileUrl: string;
  /** 与旧版前端一致，列表列 prop 为 orderNum */
  orderNum?: number;
  remark?: string;
  [key: string]: any;
}

export const materialInstructionsApi = {
  listInstructions: (params: InstructionsQuery) =>
    axiosInstance.get('/iscs/materials-instructions/getMaterialsInstructionsPage', { params }),
  getInstructionsInfo: (id: number) =>
    axiosInstance.get('/iscs/materials-instructions/selectMaterialsInstructionsById', {
      params: { id },
    }),
  addInstructions: (data: InstructionsVO) =>
    axiosInstance.post('/iscs/materials-instructions/insertMaterialsInstructions', data),
  updateInstructions: (data: InstructionsVO) =>
    axiosInstance.put('/iscs/materials-instructions/updateMaterialsInstructions', data),
  delInstructions: (ids: number | string) =>
    axiosInstance.delete('/iscs/materials-instructions/deleteMaterialsInstructionsList', {
      params: { ids },
    }),
};
