import {
  ASS_INDEX_TYPE,
  AssIndexTreeItemType,
  IAssIndexDetail,
  IFileTemplateFormParams,
  IFileTemplateFormResponse,
} from "@/types";
import { requestByGet, requestByPost } from "@dage/service";

/**
 * 获取指标设置列表树
 * @param {ASS_INDEX_TYPE} type (ASS_INDEX_TYPE.FIXED)
 */
export const getAssIndexTreeApi = (type = ASS_INDEX_TYPE.FIXED) => {
  return requestByGet<AssIndexTreeItemType[]>(`/api/cms/norm/getTree/${type}`);
};

export const getAssIndexDetailApi = (id: number) => {
  return requestByGet<IAssIndexDetail>(`/api/cms/norm/detail/${id}`);
};

export const createAssIndexApi = (params: any) => {
  return requestByPost("/api/cms/norm/save", params);
};

export const saveAssEntityApi = (params: IFileTemplateFormParams) => {
  return requestByPost<IFileTemplateFormResponse>(
    "/api/cms/norm/file/saveEntity",
    params
  );
};

export const saveAssIndexApi = (params: any) => {
  return requestByPost("/api/cms/norm/save", params);
};

export const deleteAssIndexApi = (ids: string | number) => {
  return requestByGet(`/api/cms/norm/removes/${ids}`);
};
