import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CostMappingVO, CostMappingForm, CostMappingQuery } from '@/api/bfs/costMapping/types';

/**
 * 查询成本中心映射列表
 * @param query
 * @returns {*}
 */

export const listCostMapping = (query?: CostMappingQuery): AxiosPromise<CostMappingVO[]> => {
  return request({
    url: '/bfs/costMapping/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询成本中心映射详细
 * @param id
 */
export const getCostMapping = (id: string | number): AxiosPromise<CostMappingVO> => {
  const data = {
    id
  };
  return request({
    url: '/bfs/costMapping/getInfo',
    method: 'post',
    data: data
  });
};

/**
 * 新增成本中心映射
 * @param data
 */
export const addCostMapping = (data: CostMappingForm) => {
  return request({
    url: '/bfs/costMapping/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改成本中心映射
 * @param data
 */
export const updateCostMapping = (data: CostMappingForm) => {
  return request({
    url: '/bfs/costMapping/edit',
    method: 'post',
    data: data
  });
};

/**
 * 删除成本中心映射
 * @param id
 */
export const delCostMapping = (id: string | number) => {
  const data = {
    id
  };
  return request({
    url: '/bfs/costMapping/del',
    method: 'post',
    data: data
  });
};
