import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CrmSupplierInfoVO, CrmSupplierInfoForm, CrmSupplierInfoQuery } from '@/api/oa/crm/crmSupplierInfo/types';

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

export const listCrmSupplierInfo = (query?: CrmSupplierInfoQuery): AxiosPromise<CrmSupplierInfoVO[]> => {
  return request({
    url: '/oa/crm/crmSupplierInfo/list',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增供应商信息
 * @param data
 */
export const addCrmSupplierInfo = (data: CrmSupplierInfoForm) => {
  return request({
    url: '/oa/crm/crmSupplierInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改供应商信息
 * @param data
 */
export const updateCrmSupplierInfo = (data: CrmSupplierInfoForm) => {
  return request({
    url: '/oa/crm/crmSupplierInfo',
    method: 'put',
    data: data
  });
};

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

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