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

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

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

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

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

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

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


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