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

/**
 * 查询客户合同列表
 * @param query
 * @returns {*}
 */

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

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

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

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

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