import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseSupplierInfoVO, BaseSupplierInfoForm, BaseSupplierInfoQuery } from '@/api/mes/baseSupplierInfo/types';

/**
 * 查询供应商信息列表
 * @param query
 * @returns {*}
 */

export const listBaseSupplierInfo = (query?: BaseSupplierInfoQuery): AxiosPromise<BaseSupplierInfoVO[]> => {
  return request({
    url: '/mes/baseSupplierInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询供应商信息详细
 * @param supplierId
 */
export const getBaseSupplierInfo = (supplierId: string | number): AxiosPromise<BaseSupplierInfoVO> => {
  return request({
    url: '/mes/baseSupplierInfo/' + supplierId,
    method: 'get'
  });
};

/**
 * 新增供应商信息
 * @param data
 */
export const addBaseSupplierInfo = (data: BaseSupplierInfoForm) => {
  return request({
    url: '/mes/baseSupplierInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改供应商信息
 * @param data
 */
export const updateBaseSupplierInfo = (data: BaseSupplierInfoForm) => {
  return request({
    url: '/mes/baseSupplierInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除供应商信息
 * @param supplierId
 */
export const delBaseSupplierInfo = (supplierId: string | number | Array<string | number>) => {
  return request({
    url: '/mes/baseSupplierInfo/' + supplierId,
    method: 'delete'
  });
};


/**
 * 下拉框查询供应商信息列表
 * @param query
 * @returns {*}
 */
export function getBaseSupplierInfoList (query) {
    return request({
        url: '/mes/baseSupplierInfo/getBaseSupplierInfoList',
        method: 'get',
        params: query
    });
};
