import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CostRecordVO, CostRecordForm, CostRecordQuery } from '@/api/finance/costRecord/types';

/**
 * 查询费用列表
 * @param query
 * @returns {*}
 */

export const listCostRecord = (query?: CostRecordQuery): AxiosPromise<{records:CostRecordVO[]}> => {
  return request({
    url: '/finance/rost/list_page',
    method: 'post',
    data: query
  });
};

/**
 * 查询费用详细
 * @param id
 */
export const getCostRecord = (id: string | number): AxiosPromise<CostRecordVO> => {
  return request({
    url: '/finance/rost/get_detial',
    method: 'post',
      data: {id:id}
  });
};

/**
 * 新增费用
 * @param data
 */
export const addCostRecord = (data: CostRecordForm) => {
  return request({
    url: '/finance/rost/save',
    method: 'post',
    data: data
  });
};

/**
 * 修改费用
 * @param data
 */
export const updateCostRecord = (data: CostRecordForm) => {
  return request({
    url: '/finance/rost/save',
    method: 'post',
    data: data
  });
};

/**
 * 删除费用
 * @param id
 */
export const delCostRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/finance/rost/delete',
    method: 'post',
      data: {id}
  });
};
