import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DmsBaseDevicePurchaseVO, DmsBaseDevicePurchaseForm, DmsBaseDevicePurchaseQuery } from '@/api/dms/dmsBaseDevicePurchase/types';

/**
 * 查询设备采购信息列表
 * @param query
 * @returns {*}
 */

export const listDmsBaseDevicePurchase = (query?: DmsBaseDevicePurchaseQuery): AxiosPromise<DmsBaseDevicePurchaseVO[]> => {
  return request({
    url: '/dms/dmsBaseDevicePurchase/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备采购信息详细
 * @param devicePurchaseId
 */
export const getDmsBaseDevicePurchase = (devicePurchaseId: string | number): AxiosPromise<DmsBaseDevicePurchaseVO> => {
  return request({
    url: '/dms/dmsBaseDevicePurchase/' + devicePurchaseId,
    method: 'get'
  });
};

/**
 * 新增设备采购信息
 * @param data
 */
export const addDmsBaseDevicePurchase = (data: DmsBaseDevicePurchaseForm) => {
  return request({
    url: '/dms/dmsBaseDevicePurchase',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备采购信息
 * @param data
 */
export const updateDmsBaseDevicePurchase = (data: DmsBaseDevicePurchaseForm) => {
  return request({
    url: '/dms/dmsBaseDevicePurchase',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备采购信息
 * @param devicePurchaseId
 */
export const delDmsBaseDevicePurchase = (devicePurchaseId: string | number | Array<string | number>) => {
  return request({
    url: '/dms/dmsBaseDevicePurchase/' + devicePurchaseId,
    method: 'delete'
  });
};

/**
 * Get purchase count
 * @returns
 */
export const getPurchaseCount = (params: any): AxiosPromise<number> => {
  return request({
    url: '/dms/dmsBaseDevicePurchase/count',
    method: 'get',
    params
  });
};


/**
 * 下拉框查询设备采购信息列表
 * @param query
 * @returns {*}
 */
export function getDmsBaseDevicePurchaseList (query) {
    return request({
        url: '/dms/dmsBaseDevicePurchase/getDmsBaseDevicePurchaseList',
        method: 'get',
        params: query
    });
};
