import request from '@/config/axios'

export interface PermitVO {
  id?: number
  certificateName?: string
  certificateNumber?: string
  issuingAuthority?: string
  issueDate?: Date
  renewalDate?: Date
  expiryDate?: Date
  responsiblePerson?: string
  attachments?: string
  remark?: string
}

// 许可证照 API
export const PermitApi = {
  // 查询许可证照分页
  getPermitPage: async (params: any) => {
    return await request.get({ url: `/safe/permit/page`, params })
  },

  // 查询许可证照详情
  getPermit: async (id: number) => {
    return await request.get({ url: `/safe/permit/get?id=` + id })
  },

  // 新增许可证照
  createPermit: async (data: PermitVO) => {
    return await request.post({ url: `/safe/permit/create`, data })
  },

  // 修改许可证照
  updatePermit: async (data: PermitVO) => {
    return await request.put({ url: `/safe/permit/update`, data })
  },

  // 删除许可证照
  deletePermit: async (id: number) => {
    return await request.delete({ url: `/safe/permit/delete?id=` + id })
  },

  // 导出许可证照 Excel
  exportPermit: async (params) => {
    return await request.download({ url: `/safe/permit/export-excel`, params })
  },

  // 下载许可证照导入模板
  importPermitTemplate: () => {
    return request.download({ url: '/safe/permit/get-import-template' })
  }
}