import request from '@/config/axios'

// 巡检计划 VO
export interface IotOperationPlanVO {
  id: number // 主键id
  planTitle: string // 巡检计划标题
  planCode: string // 巡检计划编号
  planCycle: number // 周期
  planUnit: string // 单位
  charge: string // 负责人
  charges: [],
  chargeName: string,
  deviceIds: string // 设备
  remark: string // 备注
  deptId: number // 部门id
  planDevList:[]
}

// 巡检计划 API
export const IotOperationPlanApi = {
  // 查询巡检计划分页
  getIotOperationPlanPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-operation-plan/page`, params })
  },

  // 查询巡检计划详情
  getIotOperationPlan: async (id: number) => {
    return await request.get({ url: `/rq/iot-operation-plan/get?id=` + id })
  },

  // 新增巡检计划
  createIotOperationPlan: async (data: IotOperationPlanVO) => {
    return await request.post({ url: `/rq/iot-operation-plan/create`, data })
  },

  // 修改巡检计划
  updateIotOperationPlan: async (data: IotOperationPlanVO) => {
    return await request.put({ url: `/rq/iot-operation-plan/update`, data })
  },

  // 删除巡检计划
  deleteIotOperationPlan: async (id: number) => {
    return await request.delete({ url: `/rq/iot-operation-plan/delete?id=` + id })
  },

  // 导出巡检计划 Excel
  exportIotOperationPlan: async (params) => {
    return await request.download({ url: `/rq/iot-operation-plan/export-excel`, params })
  },
  updateIotOperationStatus : (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return request.put({ url: '/rq/iot-operation-plan/update-status', data: data })
  }
}
