import {
  ASS_INDEX_TYPE,
  AssIndexTreeItemType,
  IManageIndexDetail,
  IPerformanceRank,
  IRepoDetail,
  IRepoListParams,
} from "@/types";
import { requestByGet, requestByPost } from "@dage/service";

// 指标分析-指标列表
export const getPerNormListApi = (type: ASS_INDEX_TYPE) => {
  return requestByGet<AssIndexTreeItemType[]>(
    `/api/cms/normAnalyse/getList/${type}`
  );
};

export const getPerRankApi = (normId: number, type?: "dept") => {
  return requestByGet<IPerformanceRank[]>(
    `/api/cms/normAnalyse/rank/${normId}`,
    {
      type,
    }
  );
};

// 考核报告列表
export const getReportListApi = (params: IRepoListParams) => {
  return requestByPost("/api/cms/report/pageList", params);
};

// 考核单列表
export const getReportAssessListApi = (searchKey?: string) => {
  return requestByGet<IManageIndexDetail[]>("/api/cms/report/assessList", {
    searchKey,
  });
};

// 生成报告
export const createReportApi = (assessId: number | string) => {
  return requestByGet<IRepoDetail>(`/api/cms/report/create/${assessId}`);
};

export const saveReportApi = (params: {
  id?: number;
  name: string;
  rtf: string;
}) => {
  return requestByPost("/api/cms/report/save", params);
};

export const getReportApi = (id: number | string) => {
  return requestByGet(`/api/cms/report/detail/${id}`);
};

export const deleteReportApi = (id: number | string) => {
  return requestByGet(`/api/cms/report/remove/${id}`);
};
