import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { deviceForm, deviceQuery, deviceVO } from './types';
/**
 * 查询设备列表
 * @param query
 */
export const deviceList = (query: deviceQuery): AxiosPromise<deviceVO[]> => {
  return request({
    url: '/api/device',
    method: 'get',
    params: query
  });
};
// *********新增设备列表*************
export const addDevice = (data: any): AxiosPromise<deviceVO[]> => {
  return request({
    url: '/api/device/add',
    method: 'post',
    data: data
  });
};

// 修改
export const updateDevice = (data: any): AxiosPromise<deviceVO[]> => {
  return request({
    url: '/api/device/update',
    method: 'put',
    data
  })
}
// 删除
export const deleteDevice = (ids: any): AxiosPromise<deviceVO[]> => {
  return request({
    url: '/api/device/delete',
    method: 'delete',
    data: ids
  })
}
// 设备下拉框
export const deviceTypeAll = () => {
  return request({
    url: '/api/deviceType/all',
    method: 'get',

  })
}

// 设备类型
export const getCommunicationMode = (params: any) => {
  return request({
    url: '/api/deviceType/communicationMode',
    method: 'get',
    params
  })
}
// 分配客户
export const deviceAssignCustomer = (data: any) => {
  return request({
    url: '/api/device/assignCustomer',
    method: 'put',
    data
  })
}
// 客户下拉框
export const userAllCustomerAll = () => {
  return request({
    url: '/api/customers/allCustomer',
    method: 'get',

  })
}

// 解绑
export const deviceUnbind = (params: any) => {
  return request({
    url: '/api/device/unbind',
    method: 'delete',
    params
  })
}
// 撤回
export const withdrawDevice = (data: any) => {
  return request({
    url: '/api/device/withdraw',
    method: 'post',
    data
  })
}
// 下载模板
export const deviceTemplate = () => {
  return request({
    url: '/api/device/template',
    method: ' GET',
  })
}
// 导入文件excel
export const devicDeimport = () => {
  return `${import.meta.env.VITE_APP_BASE_API}/api/device/import`
}
export default { deviceList, addDevice, updateDevice, deleteDevice, deviceTypeAll, getCommunicationMode, userAllCustomerAll, deviceAssignCustomer, deviceUnbind, withdrawDevice, deviceTemplate, devicDeimport }

