import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CustomerTypeVO, CustomerTypeForm, CustomerTypeQuery } from '@/api/customer/customerType/types';

/**
 * 查询客户类型配置列表
 * @param query
 * @returns {*}
 */

export const listCustomerType = (query?: CustomerTypeQuery): AxiosPromise<CustomerTypeVO[]> => {
  return request({
    url: '/system/customerType/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询客户类型配置详细
 * @param id
 */
export const getCustomerType = (id: string | number): AxiosPromise<CustomerTypeVO> => {
  return request({
    url: '/system/customerType/' + id,
    method: 'get'
  });
};

/**
 * 新增客户类型配置
 * @param data
 */
export const addCustomerType = (data: CustomerTypeForm) => {
  return request({
    url: '/system/customerType',
    method: 'post',
    data: data
  });
};

/**
 * 修改客户类型配置
 * @param data
 */
export const updateCustomerType = (data: CustomerTypeForm) => {
  return request({
    url: '/system/customerType',
    method: 'put',
    data: data
  });
};

/**
 * 删除客户类型配置
 * @param id
 */
export const delCustomerType = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/customerType/' + id,
    method: 'delete'
  });
};

export function changeShowStatus(id: string | number, isShow: string) {
  const data = {
    id,
    isShow
  };
  return request({
    url: '/system/customerType/changeStatus',
    method: 'put',
    data: data
  });
}
