import request from '@/config/axios'

// 设备类型 VO
export interface DeviceTypeVO {
  id: number // id
  code: string // 编码
  name: string // 名称
  remark: string // 备注
  sort: number // 排序
  parentId?: number
  parentChain?: string
  createTime?: string
}

export interface DeviceTypeTreeVO extends DeviceTypeVO {
  parentId?: number
  parentChain?: string
  createTime?: string
  children?: DeviceTypeTreeVO[]
  leaf?: boolean
}

// 设备类型 API
export const DeviceTypeApi = {
  // 查询设备类型分页
  getDeviceTypePage: async (params: any) => {
    return await request.get({ url: `/mes/device-type/page`, params })
  },

  getDeviceTypeTree: async (params: any) => {
    return await request.get({ url: `/mes/device-type/tree`, params })
  },

  // 查询设备类型详情
  getDeviceType: async (id: number) => {
    return await request.get({ url: `/mes/device-type/get?id=` + id })
  },

  // 新增设备类型
  createDeviceType: async (data: DeviceTypeVO) => {
    return await request.post({ url: `/mes/device-type/create`, data })
  },

  // 修改设备类型
  updateDeviceType: async (data: DeviceTypeVO) => {
    return await request.put({ url: `/mes/device-type/update`, data })
  },

  // 删除设备类型
  deleteDeviceType: async (id: number) => {
    return await request.delete({ url: `/mes/device-type/delete?id=` + id })
  },

  // 导出设备类型 Excel
  exportDeviceType: async (params) => {
    return await request.download({ url: `/mes/device-type/export-excel`, params })
  }
}
