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




import { request } from 'umi';



//获取表格数据

export type PubDicRelaTbaleDataType = {
    dictType:string;
    current?:number;
    pageSize?:number;
    typeName?:string;
    hospId?:string;
}

export const getPubDicRelaTbaleData = (params:PubDicRelaTbaleDataType,pageType:number) => {
    return request(pageType == 1?'/centerSys/sysdictdata/getDictDataList':'/centerSys/sysdictdata/getHospDict', {
      method: 'GET',
      params:{...params}
    });
};


//获取左侧列表数据

export const getLeftData = (pageType:number) => {
  return request(pageType == 1?'/centerSys/sysdictdata/getSystemDictTypeList':'/centerSys/sysdictdata/getHospSystemDictTypeList', {
    method: 'GET',
  });
};



//新增表格数据

export type AddPubDicRelaTbaleDataType = {
    dictSort:number;
    dictType:string;
    dictDefault:number;
    code:string;
    name:string;
    value:string;
    hospId:number;
}

export const addPubDicRelaTbaleData = (data:AddPubDicRelaTbaleDataType,pageType:number) => {
    return request(pageType == 1?'/centerSys/sysdictdata/addData':'/centerSys/sysdictdata/addHospDict', {
      method: 'POST',
      data
    });
};

//编辑表格数据

export type EditPubDicRelaTbaleDataType = {
    dictDataId:string;
    dictSort:number;
    dictType:string;
    dictDefault:number;
    code:string;
    name:string;
    value:string;
    hospId:number;
}

export const editPubDicRelaTbaleData = (data:EditPubDicRelaTbaleDataType,pageType:number) => {
    return request(pageType == 1?'/centerSys/sysdictdata/editData':'/centerSys/sysdictdata/editHospDict', {
      method: 'POST',
      data
    });
};


//删除表格操作
export const delData = (dictDataId:string,pageType:number) => {
    return request(pageType == 1?'/centerSys/sysdictdata/deleteData':'/centerSys/sysdictdata/deleteHospDict', {
      method: 'POST',
      params:pageType == 1?{dictDataId}:{id:dictDataId}
    });
};

//初始化
export const initReq = (systemId:string,dictType:string) => {
  return request('/centerSys/sysdictdata/initHospDict', {
    method: 'POST',
    params:{systemId,dictType}
  });
};

