/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-03 16:31:27
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-09-14 18:15:35
 * @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 PubDicTypeData = {
  id:number;
  name:string;
  description:string;
  value:string;
  unit:string;
  hospId:string;
  hospName:string;
  systemId:string;
  systemName:string;
  status:number;
  systemPath:string;
}


export const getParamsManaTableData = (params:{
  systemId?:number;
  hospId?:number;
  parameterName?:string;
  current?:number,
  pageSize?:number

}) => {
  return request<{
       current:number;
       list:PubDicTypeData[];
       pageSize:number;
       totalCount:number;
       totalPage:number;
  }>('/centerSys/parameter/getList', {
    method: 'GET',
    params:{...params}
  });
};


//获取所有系统列表
export const getSysLists = () => {
  const currentHosp = localStorage.getItem('currentSelectedSubHop');
  if(currentHosp){
    const { id } = JSON.parse(currentHosp);
    return request('/centerSys/hospital/getSystemList', {
      method: 'GET',
      params:{hospId:id}
    });
  }
};



//新增表格数据
export type AddTableData = {
  name:string;
  description:string;
  hospId:string;
  hospName:string;
  status:number;
  systemId:string;
  value:string;
  unit:string;
}
export const addData = (data:AddTableData) => {
  return request('/centerSys/parameter/add', {
    method: 'POST',
    data
  });
};



//编辑表格数据
export type EditTableDataType = {
  name:string;
  description:string;
  hospId:string;
  hospName:string;
  status:number;
  systemId:string;
  value:string;
  unit:string;
  id:number;
}

export const editData = (data:EditTableDataType) => {
  return request('/centerSys/parameter/edit', {
    method: 'POST',
    data
  });
};

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









