/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-03 16:31:27
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-12-07 20:53:36
 * @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 getCostshareparamConnectList = (params: any) => {
  return request('/costAccount/costaccountshare/list', {
    method: 'GET',
    params: { ...params },
  });
};

//获取当前成本已用本的分摊参数列表
export const getHasSetParamsList = (id: number) => {
  return request(`/costAccount/costaccountshare/getShareParamById`, {
    method: 'GET',
    params: {
      id: id,
    },
  });
};

//获取可选复制目标列表
export async function getCopyableToList(params: any) {
  return request(`/costAccount/costaccountshare/getResponsibilityCalType`, {
    method: 'GET',
    params: { ...params },
  });
}

//获取添加分摊参数时可选列表
export async function getParamsSelectableList(params: any) {
  return request(`/costAccount/costaccountshare/getAllShareParamStatusById`, {
    method: 'GET',
    params: {
      ...params,
    },
  });
}

//新增
export type AddTableDataType = any;

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

//编辑表格数据

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

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

//保存成本分摊参数
export const saveParamsList = (data: any) => {
  return request(`/costAccount/costaccountshare/updateShareParam`, {
    method: 'POST',
    data,
  });
};

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

//获取责任中心选择列表
export const getResponsibilityCenterSelecterList = () => {
  // const {shareParamName,current,pageSize} = params;
  return request('/costAccount/responsibility/getLevelTwo', {
    method: 'GET',
  });
};

//复制数据
export const copyParamsList = (body: any) => {
  return request(`/costAccount/costaccountshare/copyAccountShareData`, {
    method: 'POST',
    data: body,
  });
};
