/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2022-07-06 11:46:24
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2025-02-21 14:14:47
 * @FilePath: /KC-MiddlePlatform/src/service/dictionary.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { request } from 'umi';

//获取平台字典
export type PlatformPubDirDataType = {
  code: string;
  value: string | number;
  dataVoList: {
    name: any;
    code: string;
    value: string | number;
    sort: number;
    defaultValue: number;
  }[];
};

export const getPlatformDictionary = async (key?: string) => {
  return request<PlatformPubDirDataType[]>('/centerSys/sysdictdata/getDictData', {
    method: 'GET',
    params: { dictType: key },
  });
};

//获取指标相关字典
export type IndicatorDictionaryDataType = {
  type: number;
  status: string;
  parentId: number;
  name: string;
  id: number;
  dictSort: number;
  code: string;
  children: IndicatorDictionaryDataType[];
};

export const getIndicatorDictionary = async () => {
  return request<IndicatorDictionaryDataType[]>('/centerSys/indicator/getDict', {
    method: 'GET',
  });
};

export const getDictByDictTypeAndSysid = async (systemId: string, dictType: string) => {
  return request('/centerSys/sysdictdata/getDictByDictType', {
    method: 'GET',
    params: { dictType, systemId },
  });
};
