import { http } from "@/utils/http";
// 指标列表
type templateInfo = {
  code: number;
  msg: string;
  data: boolean;
};
type templateInfoList = {
  code: number;
  msg: string;
  data: Array<any>;
};
type templateInfoData = {
  code: number;
  msg: string;
  data: addTemplate;
};
type addTemplate = {
  tpName: string;
  id: string;
};
// 分页查询
export const getTemplateInfoList = params => {
  return http.request<templateInfoList>("get", "/templateInfo/page", {
    params
  });
};
// 考核模版所有数据
export const getTemplateInfoAllList = (params = {}) => {
  return http.request<templateInfoList>("get", "/templateInfo/getAllTemplate", {
    params
  });
};
// 添加
export const postAddTemplate = data => {
  return http.request<templateInfoData>("post", "/templateInfo/addTemplate", {
    data
  });
};
// 复制
export const getCopyTemplate = params => {
  return http.request<templateInfo>("get", "/templateInfo/copyTemplate", {
    params
  });
};
// 删除
export const getDeleteTemplate = id => {
  return http.request<templateInfo>("get", `/templateInfo/remove/${id}`);
};
// 根据模板id获取维度
export const getListBy = params => {
  return http.request<templateInfoList>("get", `/dimensionInfo/getListBy`, {
    params
  });
};
//  根据维度id获取指标
export const getInfo = id => {
  return http.request<templateInfoList>("get", `/dimensionInfo/getInfo/${id}`);
};
//  根据模板指标关联表主键获取详细信息
export const getIndexInfo = id => {
  return http.request<templateInfoList>(
    "get",
    `/templateIndicatorRelation/getInfo/${id}`
  );
};
//  根据主键更新考核模板表
export const postUpdateTemplateIn = data => {
  return http.request<templateInfoList>("post", `/templateInfo/update`, {
    data
  });
};
//  根据主键更新模板指标关联表
export const postUpdate = data => {
  return http.request<templateInfoList>(
    "post",
    `/templateIndicatorRelation/update`,
    {
      data
    }
  );
};
//  根据条件计算得分
export const calculateScoreByConditionMoCondition = data => {
  return http.request<templateInfoList>(
    "post",
    `/assessment/calculateScoreByConditionMoCondition`,
    {
      data
    }
  );
};
// 删除指标
export const deleteIndicator = id => {
  return http.request<templateInfoList>(
    "get",
    `/templateIndicatorRelation/remove/${id}`
  );
};
