import { request } from '@/plugins/http-fetch';

/**
 * 新 查询自定义指标
 * @param query 查询参数
 * @returns object
 */
export async function listCustom(query?: Record<string, any>) {
  // 发起请求
  const result = await request({
    url: `/pm/kpiC/title/totalList`,
    method: 'GET',
    params: query,
  });
  return result;
}

/**
 * 查询自定义指标详细
 * @param id 网元ID
 * @returns object
 */
export async function getCustom(id: string | number) {
  return request({
    url: `/pm/kpiC/title/${id}`,
    method: 'GET',
  });
}

/**
 * 新增自定义指标
 * @param data 网元对象
 * @returns object
 */
export function addCustom(data: Record<string, any>) {
  return request({
    url: `/pm/kpiC/title`,
    method: 'POST',
    data: data,
  });
}

/**
 * 修改自定义指标
 * @param data 网元对象
 * @returns object
 */
export function updateCustom(data: Record<string, any>) {
  return request({
    url: `/pm/kpiC/title/${data.id}`,
    method: 'PUT',
    data: data,
  });
}

/**
 * 删除自定义指标
 * @returns object
 */
export async function delCustom(data: Record<string, any>) {
  return request({
    url: `/pm/kpiC/title/${data.id}`,
    method: 'DELETE',
  });
}
