import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContractVO, ContractForm, ContractQuery } from '@/api/supplier/contract/types';

/**
 * 查询合同管理列表
 * @param query
 * @returns {*}
 */

export const listContract = (query?: ContractQuery): AxiosPromise<ContractVO[]> => {
  return request({
    url: '/customer/supplierContract/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询合同管理详细
 * @param id
 */
export const getContract = (id: string | number): AxiosPromise<ContractVO> => {
  return request({
    url: '/customer/supplierContract/' + id,
    method: 'get'
  });
};

/**
 * 新增合同管理
 * @param data
 */
export const addContract = (data: ContractForm) => {
  return request({
    url: '/customer/supplierContract',
    method: 'post',
    data: data
  });
};

/**
 * 修改合同管理
 * @param data
 */
export const updateContract = (data: ContractForm) => {
  return request({
    url: '/customer/supplierContract',
    method: 'put',
    data: data
  });
};

/**
 * 删除合同管理
 * @param id
 */
export const delContract = (id: string | number | Array<string | number>) => {
  return request({
    url: '/customer/supplierContract/' + id,
    method: 'delete'
  });
};
