import request from '@/config/axios'

// 维修工单 VO
export interface IotMaintainVO {
  id: number // 主键id
  failureCode: string // 故障编码
  failureName: string // 故障名称
  deviceId: number // 设备id
  status: string // 状态
  ifStop: boolean // 是否停机
  failureTime: Date // 故障时间
  failureInfluence: string // 故障影响
  failureSystem: string // 故障系统
  description: string // 故障描述
  pic: string // 图片
  solution: string // 解决办法
  maintainStartTime: Date // 维修开始时间
  maintainEndTime: Date // 维修结束时间
  remark: string // 备注
  deviceName: string // 设备名称
  processInstanceId: string // 流程实例id
  auditStatus: number // 审核状态
  deptId: number // 部门id
  yfDeviceCode: string
  type: string
}

// 维修工单 API
export const IotMaintainApi = {
  //更新维修方式
  maintainMethod: async (data: any) => {
    debugger
    return await request.post({ url: `/rq/iot-maintain/method`, data })
  },
  // 查询维修工单分页
  getIotMaintainPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-maintain/page`, params })
  },

  // 查询维修工单详情
  getIotMaintain: async (id: any) => {
    return await request.get({ url: `/rq/iot-maintain/get?id=` + id })
  },

  // 查询委外申请人
  getApplyUsers: async (id:number) => {
    return await request.get({ url: `/rq/iot-maintain/maintain/applyusers?id=` + id })
  },
  getProjectUsers: async (id:number) => {
    return await request.get({ url: `/rq/iot-maintain/maintain/project?id=` + id })
  },
  // 新增维修工单
  createIotMaintain: async (data: IotMaintainVO) => {
    return await request.post({ url: `/rq/iot-maintain/create`, data })
  },

  // 修改维修工单
  updateIotMaintain: async (data: IotMaintainVO) => {
    return await request.put({ url: `/rq/iot-maintain/update`, data })
  },

  // 删除维修工单
  deleteIotMaintain: async (id: number) => {
    return await request.delete({ url: `/rq/iot-maintain/delete?id=` + id })
  },

  // 导出维修工单 Excel
  exportIotMaintain: async (params) => {
    return await request.download({ url: `/rq/iot-maintain/export-excel`, params })
  },
}
