import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CustomerContactVO, CustomerContactForm, CustomerContactQuery } from '@/api/oa/crm/customerContact/types';

/**
 * 查询客户联系人信息列表
 * @param query
 * @returns {*}
 */

export const listCustomerContact = (query?: CustomerContactQuery): AxiosPromise<CustomerContactVO[]> => {
  return request({
    url: '/oa/crm/customerContact/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询客户联系人信息详细
 * @param contactId
 */
export const getCustomerContact = (contactId: string | number): AxiosPromise<CustomerContactVO> => {
  return request({
    url: '/oa/crm/customerContact/' + contactId,
    method: 'get'
  });
};

/**
 * 新增客户联系人信息
 * @param data
 */
export const addCustomerContact = (data: CustomerContactForm) => {
  return request({
    url: '/oa/crm/customerContact',
    method: 'post',
    data: data
  });
};

/**
 * 修改客户联系人信息
 * @param data
 */
export const updateCustomerContact = (data: CustomerContactForm) => {
  return request({
    url: '/oa/crm/customerContact',
    method: 'put',
    data: data
  });
};

/**
 * 删除客户联系人信息
 * @param contactId
 */
export const delCustomerContact = (contactId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/crm/customerContact/' + contactId,
    method: 'delete'
  });
};

/**
 * 下拉框查询客户联系人信息列表
 * @param query
 * @returns {*}
 */
export function getCrmCustomerContactList(query) {
  return request({
    url: '/oa/crm/customerContact/getCrmCustomerContactList',
    method: 'get',
    params: query
  });
}
