import request from '@/config/axios'

export interface CheckLogVO {
  recordId?: number
  planId: number
  equipmentId: number
  operator: number
  checkTime: string
  finishTime?: string
  status: string
  resultSummary?: string
  abnormalDesc?: string
  photos?: string[]
  approver?: number
  approveTime?: string
  // 其他字段可根据实际表结构补充
}

export const CheckLogApi = {
  // 分页查询
  getCheckLogPage: (params: any) => {
    return request.get({ url: '/iot/check-record/page', params })
  },
  // 新增
  createCheckLog: (data: CheckLogVO) => {
    return request.post({ url: '/iot/check-record/create', data })
  },
  // 修改
  updateCheckLog: (data: CheckLogVO) => {
    return request.put({ url: '/iot/check-record/update', data })
  },
  // 删除
  deleteCheckLog: (recordId: number) => {
    return request.delete({ url: '/iot/check-record/delete', params: { recordId } })
  },
  // 详情（如有需要）
  getCheckLog: (recordId: number) => {
    return request.get({ url: '/iot/check-record/get', params: { recordId } })
  },
  // 图片上传
  uploadImage: async (file: File) => {
    const formData = new FormData();
    formData.append('file', file);
    // 假设和report一致，使用通用文件上传接口
    const res = await request.post({ url: '/safe/danger-image/upload', data: formData, headers: { 'Content-Type': 'multipart/form-data' } });
    // 返回格式兼容report.vue
    return {
      url: res.data || res.url,
      name: file.name
    };
  }
} 
