/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2023-03-07 11:12:10
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2023-11-30 10:34:32
 * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicMana/service.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { string } from 'mathjs';
import { Key } from 'react';
import { request } from 'umi';

//获取左侧数据
export const getAccountingList = (accountingName: string, type: number) => {
  return request('/costAccount/setting/getAccountingList', {
    method: 'GET',
    params: { accountingName, type },
  });
};

//获取右侧表格数据

export const getAccountingItemMap = (params: {
  accountingCode: string;
  itemName?: string;
  pageSize: number;
  current: number;
}) => {
  return request('/costAccount/setting/getAccountingItemMap', {
    method: 'GET',
    params: { ...params },
  });
};

//获取可添加列表
export const getAddableTableData = (type: number, name?: string) => {
  return request('/costAccount/setting/getAccountingItemDictList', {
    method: 'GET',
    params: { type, name },
  });
};

//新增表格数据

export const addTableData = (data: any) => {
  return request('/costAccount/setting/addAccountingItemMap', {
    method: 'POST',
    data,
  });
};

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

//批量删除表格数据
export const batchDelTableData = (ids: Key[]) => {
  return request('/costAccount/setting/batchDeleteAccountingItemMap', {
    method: 'POST',
    data: [...ids],
  });
};
