/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-03 16:31:27
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2024-03-01 15:47:56
 * @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 = {
  dictId: string;
  dictName: string;
  dictType: string;
  hospId: string;
  hospName: string;
  remark: string;
  status: string;
};

export const getData = (params?: any) => {
  return request('/centerSys/sysdictdata/getSystemDict', {
    method: 'GET',
    params: { ...params },
  });
};

//新增表格数据
export type AddTableDataType = {
  dictName: string;
  dictType: string;
  remark: string;
  systemId: string;
  topic: string;
};
export const addData = (data: AddTableDataType) => {
  return request('/centerSys/sysdictdata/addSystemDict', {
    method: 'POST',
    data,
  });
};

//获取左侧系统数据
export const getTreeData = () => {
  const currentHosp = localStorage.getItem('currentSelectedSubHop');
  if (currentHosp) {
    const { id } = JSON.parse(currentHosp);
    return request('/centerSys/hospital/getSystemList', {
      method: 'GET',
      params: { hospId: id },
    });
  }
};

//编辑表格数据
export type EditTableDataType = {
  dictId: number;
  systemId: string;
  dictName: string;
  dictType: string;
  remark: string;
  topic: string;
};

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

//删除表格操作
export const delData = (dictId: string) => {
  return request('/centerSys/sysdictdata/deleteSystemDict', {
    method: 'POST',
    params: { dictId },
  });
};

//字典类型开放操作
export const dicOpenStatHandle = (data: { dictId: string; status: string }) => {
  return request('/centerSys/sysdictdata/editSystemDictStatus', {
    method: 'POST',
    params: { ...data },
  });
};
