import request from '@/config/axios'

// 巡检工单 VO
export interface IotInspectOrderVO {
  id: number // 主键id
  inspectOrderTitle: string // 巡检工单名
  inspectOrderCode: string // 巡检工单编码
  status: string // 巡检工单状态
  remark: string // 备注
  deptId: number // 部门id
  deviceIds: string // 设备id
  details:[]
}

// 巡检工单 API
export const IotInspectOrderApi = {
  // 查询巡检工单分页
  getIotInspectOrderPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order/page`, params })
  },
  getIotInspectDeviceStatusPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order/device`, params })
  },
  getDeviceIotInspectOrderPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-inspect-order/device/page`, params })
  },

  // 查询巡检工单详情
  getIotInspectOrder: async (id: number):Promise<IotInspectOrderVO> => {
    return await request.get({ url: `/rq/iot-inspect-order/get?id=` + id })
  },
  getIotInspectOrderDetail: async (id: number) => {
    return await request.get({ url: `/rq/iot-inspect-order/get/details?id=` + id })
  },
  // 新增巡检工单
  createIotInspectOrder: async (data: IotInspectOrderVO) => {
    return await request.post({ url: `/rq/iot-inspect-order/create`, data })
  },

  // 修改巡检工单
  updateIotInspectOrder: async (data: IotInspectOrderVO) => {
    return await request.put({ url: `/rq/iot-inspect-order/update`, data })
  },

  // 删除巡检工单
  deleteIotInspectOrder: async (id: number) => {
    return await request.delete({ url: `/rq/iot-inspect-order/delete?id=` + id })
  },

  // 导出巡检工单 Excel
  exportIotInspectOrder: async (params) => {
    return await request.download({ url: `/rq/iot-inspect-order/export-excel`, params })
  },
  //填写巡检工单
  writeIotInspectOrder: async (data: any, orderId) => {
    return await request.post({ url: `/rq/iot-inspect-order/write/`+orderId, data })
  },
}
