import request from '@/config/axios'

// 保养计划 VO
export interface IotMaintenancePlanVO {
  id: number // 主键id
  deptId: number // 组织id
  serialNumber: string // 计划编号 自动生成
  name: string // 计划名称 默认以队伍名称生成
  responsiblePerson: string // 负责人id 多个以逗号分隔
  responsiblePersonName: string // 负责人id 多个以逗号分隔
  remark: string // 备注
  status: number // 状态 0启用  1停用
}

// 保养计划 API
export const IotMaintenancePlanApi = {
  // 查询保养计划分页
  getIotMaintenancePlanPage: async (params: any) => {
    return await request.get({ url: `/rq/iot-maintenance-plan/page`, params })
  },

  // 查询保养计划详情
  getIotMaintenancePlan: async (id: number) => {
    return await request.get({ url: `/rq/iot-maintenance-plan/get?id=` + id })
  },

  // 新增保养计划
  createIotMaintenancePlan: async (data: any) => {
    return await request.post({ url: `/rq/iot-maintenance-plan/create`, data })
  },

  // 修改保养计划
  updateIotMaintenancePlan: async (data: IotMaintenancePlanVO) => {
    return await request.put({ url: `/rq/iot-maintenance-plan/update`, data })
  },

  // 修改保养计划 主表+明细
  updatePlan: async (data: any) => {
    return await request.post({ url: `/rq/iot-maintenance-plan/updatePlan`, data })
  },

  updatePlanStatus: (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return request.put({ url: '/rq/iot-maintenance-plan/update-status', data: data })
  },

  // 删除保养计划
  deleteIotMaintenancePlan: async (id: number) => {
    return await request.delete({ url: `/rq/iot-maintenance-plan/delete?id=` + id })
  },

  // 导出保养计划 Excel
  exportIotMaintenancePlan: async (params) => {
    return await request.download({ url: `/pms/iot-maintenance-bom/exportPlans`, params })
  }
}
