/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-03 16:31:27
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-12-05 15:03:16
 * @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';

//获月成本分摊参数值处理列表
export const getMonthCostShareDataList = (params: any) => {
  return request('/costAccount/shareParamValue/list', {
    method: 'GET',
    params: {
      ...params,
      date: params.computeDate.replace('-', ''),
      computeDate: null,
    },
  });
};

//新增
export type AddTableDataType = {
  date: string;
  shareParamCode: string;
  responsibilityCode: string;
  valueNum: number;
};

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

//编辑表格数据

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

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

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

//计算数据
export const calculateMonthCostShareData = (params: any) => {
  return request('/costAccount/shareParamValue/calcData', {
    method: 'POST',
    params: { ...params },
  });
};

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