import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InfoVO, InfoForm, InfoQuery } from '@/api/supplier/info/types';

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

export const listInfo = (query?: InfoQuery): AxiosPromise<InfoVO[]> => {
  return request({
    url: '/customer/info/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询供应商信息详细
 * @param id
 */
export const getInfo = (id: string | number): AxiosPromise<InfoVO> => {
  return request({
    url: '/system/info/' + id,
    method: 'get'
  });
};

/**
 * 新增供应商信息
 * @param data
 */
export const addInfo = (data: InfoForm) => {
  return request({
    url: '/system/info',
    method: 'post',
    data: data
  });
};

/**
 * 修改供应商信息
 * @param data
 */
export const updateInfo = (data: InfoForm) => {
  return request({
    url: '/system/info',
    method: 'put',
    data: data
  });
};

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

/**
 * 获取供应商类型列表
 */
export const getComSupTyList = () => {
  return request({
    url: '/system/type/getComSupTyList',
    method: 'get'
  });
};
