/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-03 16:31:27
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-07-21 17:04:23
 * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/service.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */



import { request } from 'umi';

//获取table列表数据

export type SecondaryDistriProjectTableItemDataType = {
  id: number,
  hospId: number,
  code: string,
  name: string,
  evaluation: number,
  evaluationName: string,
  dataType: number,
  dataTypeName: string,
  source: number,
  sourceName: string,
  sql: string
}


export const getSecondaryProjectDistriData = (params?: any) => {
  return request<{
    current: number;
    list: SecondaryDistriProjectTableItemDataType[];
    pageSize: number;
    totalCount: number;
    totalPage: number;
  }>('/performance/secondSetting/getList', {
    method: 'GET',
    params: { ...params }
  });
};

export const gainData = (params?: any) => {
  return request('/performance/item/auto', {
    method: 'GET',
    params: { ...params }
  });
};




//新增表格数据
export type AddTableDataType = {
  "name":string, //功能名称
  "evaluation":number, //评价方式 1评分 2评级
  "dataType": number, //数据格式 1数值 2百分比
  "source": number, //数据来源 1填报 2自动获取 3导入
  "sql":string //sql
}
export const addData = (data: AddTableDataType) => {
  return request('/performance/secondSetting/add', {
    method: 'POST',
    data
  });
};



//编辑表格数据

export const editData = (data: AddTableDataType & { id: number }) => {
  return request('/performance/secondSetting/edit', {
    method: 'POST',
    data
  });
};

//删除表格操作
export const delData = (id: string) => {
  return request('/performance/secondSetting/delete', {
    method: 'POST',
    params: { id }
  });
};


//根据项目code获取评级列表
export const getDefaultIndicator = (secondItemCode:string) => {
  return request<any[]>('/performance/secondSetting/getItemLevel', {
    method: 'GET',
    params:{secondItemCode}
  });
};

//添加评级设定  addLevelSets
export const addLevelSets = (secondItemCode:string,itemLevels:any[]) => {
  return request<any[]>('/performance/secondSetting/saveItemLevel', {
    method: 'POST',
    data:{secondItemCode,itemLevels}
  });
};












