/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-03 16:31:27
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-05-18 14:25:32
 * @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 CostIncomeTableItemDataType = {
  "id": number, //主键
  "code": string, //流转功能code
  "hospId": number, //医院id
  "name": string, //名称
  "opdFlag": number, //门诊可用标志  0否 1是
  "opdFlagName": string, //门诊可用标志显示名称
  "inpFlag": number, //住院可用标志  0否 1是
  "inpFlagName": string, //住院可用标志显示名称
  "statFlag": number, //统计标志 0否 1是
  "seqNo": number //序号
}


export const getCostIncomeProjectTable = (params?: any) => {
  return request<{
    current: number;
    list: CostIncomeTableItemDataType[];
    pageSize: number;
    totalCount: number;
    totalPage: number;
  }>('/performance/item/getIncomeList', {
    method: 'GET',
    params: { ...params }
  });
};


//新增收入项目表格数据
export type AddIncomeTableDataType = {
  "name": string, //名称
  "opdFlag": number, //门诊可用标志  0否 1是
  "inpFlag": number, //住院可用标志  0否 1是
  "statFlag": number, //统计标志 0否 1是
  "seqNo": number //序号
}
export const addIncomeData = (data: AddIncomeTableDataType) => {
  return request('/performance/item/addIncome', {
    method: 'POST',
    data
  });
};



//编辑表格数据

export const editIncomeData = (data: AddIncomeTableDataType & { id: number }) => {
  return request('/performance/item/editIncome', {
    method: 'POST',
    data
  });
};




//获取成本项目table列表数据

export type CostTableItemDataType = {
  "id": number, //主键
  "hospId": number, //医院id
  "code": string, //项目代码
  "name": string, //项目名称
  "parentCode": number,
  "itemType": number, //项目类型
  "itemTypeName": string, //项目类型名称
  "summaryFlag": number, //汇总标志  0否 1是
  "ctrlFlag": number, //可控标志  0否 1是
  "statFlag": number, //统计标志 0否 1是
  "seqNo": number //序号
  "children": CostTableItemDataType[]
}


export const getCostProjectTable = (params?: any) => {
  return request<CostTableItemDataType[]>('/performance/item/getCostList', {
    method: 'GET',
    params: { ...params }
  });
};

//新增成本项目表格数据
export type AddCostTableDataType = {

  "name":string, //名称
  "parentCode": number, //父级代码 最上级传0 非最上级传上级code
  "itemType": number, //项目类型 1人事成本 2变动成本 3固定成本
  "summaryFlag": number, //汇总标志  0否 1是
  "ctrlFlag": number, //可控标志  0否 1是
  "statFlag": number, //统计标志 0否 1是
  "seqNo": number //序号
}
export const addCostData = (data: AddCostTableDataType) => {
  return request('/performance/item/addCost', {
    method: 'POST',
    data
  });
};

//编辑成本表格数据

export const editCostData = (data: AddCostTableDataType & { id: number }) => {
  return request('/performance/item/editCost', {
    method: 'POST',
    data
  });
};

//删除表格操作
export const delData = (id: string,tabKey:string) => {

  if(tabKey == '1'){
    return request('/performance/item/deleteIncome', {
      method: 'POST',
      params: { id }
    });
  }
  if(tabKey == '2'){
    return request('/performance/item/deleteCost', {
      method: 'POST',
      params: { id }
    });
  }
  
};




