import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseMeasurementUnitInfoVO, BaseMeasurementUnitInfoForm, BaseMeasurementUnitInfoQuery } from '@/api/mes/baseMeasurementUnitInfo/types';

/**
 * 查询计量单位信息列表
 * @param query
 * @returns {*}
 */

export const listBaseMeasurementUnitInfo = (query?: BaseMeasurementUnitInfoQuery): AxiosPromise<BaseMeasurementUnitInfoVO[]> => {
  return request({
    url: '/mes/baseMeasurementUnitInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询计量单位信息详细
 * @param unitId
 */
export const getBaseMeasurementUnitInfo = (unitId: string | number): AxiosPromise<BaseMeasurementUnitInfoVO> => {
  return request({
    url: '/mes/baseMeasurementUnitInfo/' + unitId,
    method: 'get'
  });
};

/**
 * 新增计量单位信息
 * @param data
 */
export const addBaseMeasurementUnitInfo = (data: BaseMeasurementUnitInfoForm) => {
  return request({
    url: '/mes/baseMeasurementUnitInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改计量单位信息
 * @param data
 */
export const updateBaseMeasurementUnitInfo = (data: BaseMeasurementUnitInfoForm) => {
  return request({
    url: '/mes/baseMeasurementUnitInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除计量单位信息
 * @param unitId
 */
export const delBaseMeasurementUnitInfo = (unitId: string | number | Array<string | number>) => {
  return request({
    url: '/mes/baseMeasurementUnitInfo/' + unitId,
    method: 'delete'
  });
};


/**
 * 下拉框查询计量单位信息列表
 * @param query
 * @returns {*}
 */
export function getBaseMeasurementUnitInfoList (query) {
    return request({
        url: '/mes/baseMeasurementUnitInfo/getBaseMeasurementUnitInfoList',
        method: 'get',
        params: query
    });
};
