/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-03 16:31:27
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2024-09-13 14:24:40
 * @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 { Key } from 'react';
import { request } from 'umi';

//获取table列表数据
export const getReportProjectSettingList = (params: any) => {
  return request(
    '/costAccount/costdepartmentprofit/getBatchComputeProfitList',
    {
      method: 'GET',
      params: { ...params },
    },
  );
};

//获取年度损益数据
export const getBatchComputeProfitListByYear = (params: any) => {
  return request(
    '/costAccount/costdepartmentprofit/getBatchComputeProfitListByYear',
    {
      method: 'GET',
      params: { ...params },
    },
  );
};

//获取下钻表格数据
export const getNextLevelTableData = (params: any) => {
  return request('/costAccount/costdepartmentprofit/getRedirectData', {
    method: 'GET',
    params: { ...params },
  });
};

//新增
export type AddTableDataType = {
  calcFormula?: string;
  calcType?: number;
  isLoss?: number;
  parentId?: number;
  reportName?: string;
  reportType?: number;
  sort?: number;
};

export const addData = (data: AddTableDataType) => {
  return request('/costAccount/reportForm/save', {
    method: 'POST',
    data: { ...data },
  });
};

//编辑表格数据

export type TableRowEditType = {
  id: number;
} & AddTableDataType;

export const editData = (data: any) => {
  return request('/costAccount/reportForm/edit', {
    method: 'POST',
    data,
  });
};

//删除表格操作
export const delData = (ids: Key[]) => {
  return request('/costAccount/reportForm/delete', {
    method: 'POST',
    data: ids,
  });
};

//根据关系类型，获取已绑定的关系数据
export const getHasSetReportRelation = (params: any) => {
  return request('/costAccount/reportForm/getRelationList', {
    method: 'GET',
    params: { ...params },
  });
};

//保存对应设置
export const saveReportRelation = (body: any) => {
  return request('/costAccount/reportForm/saveReportRelation', {
    method: 'POST',
    data: { ...body },
  });
};

//复制数据
export const copyDataToSelectedType = (body: any) => {
  return request('/costAccount/reportForm/copyReport', {
    method: 'POST',
    data: { ...body },
  });
};

//获取执行责任中心
export const getResponsibleCenters = (reportType: string) => {
  return request('/costAccount/costdepartmentprofit/getProfitResponsibility', {
    method: 'GET',
    params: { reportType },
  });
};

//获取报表数据
export const getReportDataReq = (reportType: string, computeDate: string) => {
  return request('/costAccount/costdepartmentprofit/computeProfitReport', {
    method: 'GET',
    params: { reportType, computeDate },
  });
};

//损益计算

export const computeProfitReq = (computeDate: string, reportType: string) => {
  return request('/costAccount/costdepartmentprofit/computeProfit', {
    method: 'POST',
    params: { computeDate, reportType },
  });
};
