import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CustomerInfoVO, CustomerInfoForm, CustomerInfoQuery } from '@/api/oa/crm/customerInfo/types';

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

export const listCustomerInfo = (query?: CustomerInfoQuery): AxiosPromise<CustomerInfoVO[]> => {
  return request({
    url: '/oa/crm/customerInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询客户信息详细
 * @param customerId
 */
export const getCustomerInfo = (customerId: string | number): AxiosPromise<CustomerInfoVO> => {
  return request({
    url: '/oa/crm/customerInfo/' + customerId,
    method: 'get'
  });
};

/**
 * 新增客户信息
 * @param data
 */
export const addCustomerInfo = (data: CustomerInfoForm) => {
  return request({
    url: '/oa/crm/customerInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改客户信息
 * @param data
 */
export const updateCustomerInfo = (data: CustomerInfoForm) => {
  return request({
    url: '/oa/crm/customerInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除客户信息
 * @param customerId
 */
export const delCustomerInfo = (customerId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/crm/customerInfo/' + customerId,
    method: 'delete'
  });
};

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