import type { List } from '@/model';
import type { EquirementModel, DeviceManageModel, DeviceReportModel } from '@/model/device.model';
import request from '@/request/alova';
// 设备登记分页列表
export function getDeviceRegisterMethod(page: number, size: number, query?: Record<string, any>) {
  return request.Post<List<EquirementModel>>('/fdhb-pc/deviceManage/device/register/page', query ?? {}, {
    hitSource: /plan$/, // 匹配失效源
    params: { pageNum: page, pageSize: size },
  });
}

// 新增和编辑设备登记
export function addDeviceRegisterMethod(data: Partial<EquirementModel>) {
  return data?.id
    ? request.Post(`/fdhb-pc/deviceManage/device/register/update`, { ...data, id: data.id }, { name: 'edit-device-register' })
    : request.Post(`/fdhb-pc/deviceManage/device/register/add`, data.deviceIds, { name: 'add-device-register', params: data });
}
// 删除设备登记
export function deleteDeviceRegisterMethod(data: Partial<EquirementModel>) {
  return request.Post(`/fdhb-pc/deviceManage/device/register/delete/${data.id}`, {
    name: 'delete-device-register',
    cacheFor: null,
  });
}

// 根据设备登记id获取设备登记详情
export function getDeviceRegisterDetailMethod(data: Partial<EquirementModel>) {
  return request.Post(`/fdhb-pc/deviceManage/device/register/detail/${data.id}`, {
    name: 'get-device-register-detail',
    cacheFor: null,
  });
}

// 批量修改设备登记组织
export function updateDeviceRegisterOrganizationMethod(data: any) {
  return request.Post(`/fdhb-pc/deviceManage/device/register/batchUpdateDept`, data.deviceIds, {
    name: 'update-device-register-organization',
    cacheFor: null,
    params: { orgId: data.orgId, institutionId: data.institutionId },
  });
}

// 一体机配置分页列表
export function deviceManageMethod(page: number, size: number, query?: Record<string, any>) {
  return request.Post<List<DeviceManageModel>>('/fdhb-pc/deviceManage/tablet/sets/page', query ?? {}, {
    hitSource: /plan$/, // 匹配失效源
    params: { pageNum: page, pageSize: size },
  });
}
// 根据一体机id获取一体机配置详情
export function getDeviceManageDetailMethod(data: Partial<DeviceManageModel>) {
  return request.Post(`/fdhb-pc/deviceManage/tablet/sets/detail/${data.id}`, {
    name: 'get-device-manage-detail',
    cacheFor: null,
  });
}
// 修改一体机配置
export function updateDeviceManageMethod(data: Partial<DeviceManageModel>) {
  return request.Post(`/fdhb-pc/deviceManage/tablet/sets/update`, data, {
    name: 'update-device-manage',
    cacheFor: null,
  });
}
// 批量修改一体机配置
export function batchUpdateDeviceManageMethod(data: Partial<DeviceManageModel>) {
  return request.Post(`/fdhb-pc/deviceManage/tablet/sets/batchUpdate`, data, {
    name: 'batch-update-device-manage',
    cacheFor: null,
  });
}
// 一体机报告分页列表
export function deviceReportMethod(page: number, size: number, query?: Record<string, any>) {
  return request.Post<List<DeviceReportModel>>('/fdhb-pc/deviceManage/tablet/report/page', query ?? {}, {
    hitSource: /plan$/, // 匹配失效源
    params: { pageNum: page, pageSize: size },
  });
}
