import request from '@/config/axios'
import {DeptVO} from "@/api/system/dept";

// pms树 VO
export interface IotTreeVO {
  id: number // 主键id
  originId: number // 原id
  parentId: number // 父分类id
  name: string // 分类名称
  type: string // 类型
  sort: number // 分类排序
  status: number // 开启状态
  remark: string // 备注
}

// pms树 API
export const IotTreeApi = {
  getDeviceTree: async (params): Promise<any> => {
    return await request.get({ url: '/rq/iot-tree/device/'+ params})
  },
  getSimpleTreeList: async (): Promise<IotTreeVO[]> => {
    return await request.get({ url: '/rq/iot-tree/simple-list' })
  },
  // 查询pms树分页
  getIotTreePage: async (params: any) => {
    return await request.get({ url: `/rq/iot-tree/page`, params })
  },
  getParentIds: async (params: any) => {
    return await request.get({ url: `/rq/iot-tree/ids/`+ params })
  },

  // 查询pms树详情
  getIotTree: async (id: number) => {
    return await request.get({ url: `/rq/iot-tree/get?id=` + id })
  },

  // 新增pms树
  createIotTree: async (data: IotTreeVO) => {
    return await request.post({ url: `/rq/iot-tree/create`, data })
  },
  createDeptDeal: async (data: DeptVO) => {
    console.log(JSON.stringify(data))
    return await request.post({ url: `/rq/iot-tree/add-dept-deal`, data })
  },
  updateDeptDeal: async (data: DeptVO) => {
    return await request.post({ url: `/rq/iot-tree/update-dept-deal`, data })
  },
  deleteDeptDeal: async (id:number) => {
    return await request.post({ url: `/rq/iot-tree/delete-dept-deal?id=`+id })
  },
  // 修改pms树
  updateIotTree: async (data: IotTreeVO) => {
    return await request.put({ url: `/rq/iot-tree/update`, data })
  },

  // 删除pms树
  deleteIotTree: async (id: number) => {
    return await request.delete({ url: `/rq/iot-tree/delete?id=` + id })
  },

  // 导出pms树 Excel
  exportIotTree: async (params) => {
    return await request.download({ url: `/rq/iot-tree/export-excel`, params })
  },
}
