/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-03 16:31:27
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2024-04-26 11:31:11
 * @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 getIdleCostTableList = (params: any) => {
  return request('/costAccount/freeCost/getList', {
    method: 'GET',
    params: { ...params },
  });
};

//获取会计科目
export const getAccountList = (params: any) => {
  return request('/costAccount/freeCost/getAccountList', {
    method: 'GET',
    params: { ...params },
  });
};

//获取分摊参数
export const getShareParamList = (params: any) => {
  return request('/costAccount/freeCost/getShareParamList', {
    method: 'GET',
    params: { ...params },
  });
};

//获取闲置责任中心
export const getIdleResponsibleList = (params: any) => {
  return request('/costAccount/freeCost/getResponsibilityList', {
    method: 'GET',
    params: { ...params },
  });
};

//新增
export type AddTableDataType = {
  freeAccountCode: string; //闲置成本代码
  freeAccountName: string; //闲置成本名称
  accountCode: string; //成本代码
  accountName: string; //成本名称
  canParamCode: string; //可检查时间参数代码
  canParamName: string; //可检查时间参数名称
  actualParamCode: string; //实际检查时间参数代码
  actualParamName: string; //实际检查时间参数名称
};

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

//编辑表格数据

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

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

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