/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-03 16:31:27
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2024-03-21 10:23:18
 * @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 SQLTableDataType = {
  id: number;
  hospId: number;
  code: number;
  sqlCode: string;
  sql: string;
  sqlDefinition: string;
  sqlType: string;
  sqlTypeName: string;
  sort: number;
};

export const getSqlListTableData = (params?: any) => {
  return request<any[]>('/costAccount/report/getSql', {
    method: 'GET',
    params: { ...params },
  });
};

//新增报表
export type AddSqlTableDataType = {
  sqlCode: string;
  sql: string;
  sqlDefinition: string;
  sqlType: string;
  sort: number;
  status: number;
};

export const addData = (data: AddSqlTableDataType) => {
  return request('/costAccount/report/addSql', {
    method: 'POST',
    data,
  });
};

//编辑表格数据

export type EditSqlTableDataType = {
  id: number;
  sql: string;
  sqlDefinition: string;
  sqlType: string;
  sort: number;
  status: number;
  [key: string]: any;
};

export const editData = (data: EditSqlTableDataType) => {
  return request('/costAccount/report/editSql', {
    method: 'POST',
    data,
  });
};

export const updateTableSort = (data: EditSqlTableDataType[]) => {
  return request('/costAccount/report/sortSql', {
    method: 'POST',
    data,
  });
};

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

//获取sql类型
export const getSqlTypeList = (params?: any) => {
  return request(
    '/costAccount/report/getSqlType?current=1&pageSize=1000&typeCode=10',
    {
      method: 'GET',
    },
  );
};
