import request from '@/config/axios'

// 故障上报 VO
export interface IotFailureReportVO {
  id: number // 主键id
  failureCode: string // 故障编码
  failureName: string // 故障名称
  deviceId: number // 设备id
  status: string // 状态
  ifStop: boolean // 是否停机
  failureTime: Date // 故障时间
  failureInfluence: string // 故障影响
  failureSystem: string // 故障系统
  description: string // 故障描述
  pic: string // 图片
  ifDeal: boolean // 是否解决
  needHelp: boolean // 是否需要协助
  solution: string // 解决办法
  remark: string // 备注
}

// 故障上报 API
export const IotFailureReportApi = {

  // 提交审核
  submitForApproval: async (id: number) => {
    return await request.put({ url: `/rq/iot-failure-report/submitForApproval?id=${id}`})
  },
  // 查询故障上报分页
  getIotFailureReportPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-failure-report/page`, params })
  },

  // 查询故障上报详情
  getIotFailureReport: async (id: number) => {
    return await request.get({ url: `/rq/iot-failure-report/get?id=` + id })
  },

  getApproval: async () => {
    return await request.get({ url: `/rq/iot-failure-report/get/approval`})
  },

  // 新增故障上报
  createIotFailureReport: async (data: IotFailureReportVO) => {
    return await request.post({ url: `/rq/iot-failure-report/create`, data })
  },

  // 修改故障上报
  updateIotFailureReport: async (data: IotFailureReportVO) => {
    return await request.put({ url: `/rq/iot-failure-report/update`, data })
  },

  // 删除故障上报
  deleteIotFailureReport: async (id: number) => {
    return await request.delete({ url: `/rq/iot-failure-report/delete?id=` + id })
  },

  // 导出故障上报 Excel
  exportIotFailureReport: async (params) => {
    return await request.download({ url: `/rq/iot-failure-report/export-excel`, params })
  },
  updateIotMaintainProcess: async (processId:any,id:any, type:any,assigneeUserId:any, trans:any) => {
    return await request.put({ url: `/rq/iot-failure-report/process-info?processId=`+processId+`&id=`+id+`&type=`+type+`&assigneeUserId=`+assigneeUserId+`&trans=`+ trans})
  },
}
