import request from '@/config/axios'

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

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

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

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

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

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

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