import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CustomerLevelVO, CustomerLevelForm, CustomerLevelQuery } from '@/api/customer/customerLevel/types';

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

export const listCustomerLevel = (query?: CustomerLevelQuery): AxiosPromise<CustomerLevelVO[]> => {
  return request({
    url: '/system/customerLevel/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询客户等级配置详细
 * @param id
 */
export const getCustomerLevel = (id: string | number): AxiosPromise<CustomerLevelVO> => {
  return request({
    url: '/system/customerLevel/' + id,
    method: 'get'
  });
};

/**
 * 新增客户等级配置
 * @param data
 */
export const addCustomerLevel = (data: CustomerLevelForm) => {
  return request({
    url: '/system/customerLevel',
    method: 'post',
    data: data
  });
};

/**
 * 修改客户等级配置
 * @param data
 */
export const updateCustomerLevel = (data: CustomerLevelForm) => {
  return request({
    url: '/system/customerLevel',
    method: 'put',
    data: data
  });
};

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

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