/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-07 11:12:10
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-11-23 19:32:34
 * @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 { string } from 'mathjs';
import { Key } from 'react';
import { request } from 'umi';

//获取左侧报表数据

export const getOrderList = (orderType?: string) => {
  return request('/costAccount/setting/getOrderList', {
    method: 'GET',
    params: { orderType },
  });
};

//获取左侧医嘱类型

export const getOrderType = () => {
  return request('/costAccount/setting/getOrderType', {
    method: 'GET',
  });
};

//获取表格数据

export type ClolumnTableDataType = {
  id: number;
};

export const getOrderItemList = (params: {
  orderCode: string;
  pageSize: number;
  current: number;
}) => {
  return request('/costAccount/setting/getOrderItemList', {
    method: 'GET',
    params: { ...params },
  });
};

//获取可添加列表
export const getAddableTableData = (type: number, orderCode: string) => {
  return request('/costAccount/setting/getItemDict', {
    method: 'GET',
    params: { type, orderCode },
  });
};

//新增左侧列表

type AddLeftDataType = {
  code: string;
  name: string;
  type: string;
  description: string;
};
export const addLeftList = (data: AddLeftDataType) => {
  return request('/costAccount/setting/addOrder', {
    method: 'POST',
    data,
  });
};

//编辑左侧列表
export const editLeftList = (data: AddLeftDataType & { id: number }) => {
  return request('/costAccount/setting/editOrder', {
    method: 'POST',
    data,
  });
};

//新增表格数据

export const addTableData = (data: any) => {
  return request('/costAccount/setting/addOrderItem', {
    method: 'POST',
    data,
  });
};

//编辑表格数据

export const editTableData = (data: any) => {
  return request('/costAccount/setting/editOrderItem', {
    method: 'POST',
    data,
  });
};

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

//删除左侧报表
export const delLeftList = (id: number) => {
  return request('/costAccount/setting/deleteOrder', {
    method: 'POST',
    params: { id },
  });
};

//批量删除表格数据
export const batchDelTableData = (ids: Key[]) => {
  return request('/costAccount/setting/batchDeleteOrderItem', {
    method: 'POST',
    data: [...ids],
  });
};

//导入左侧列表数据

export const importLeftListData = (data: any) => {
  return request('/costAccount/setting/importOrder', {
    method: 'POST',
    data,
  });
};
