import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BillRecordVO, BillRecordForm, BillRecordQuery } from '@/api/finance/billRecord/types';

/**
 * 查询报销单列表
 * @param query
 * @returns {*}
 */

export const listBillRecord = (query?: BillRecordQuery): AxiosPromise<{ records:BillRecordVO[]}> => {
  return request({
    url: '/finance/reimburse/list_page',
    method: 'post',
    data: query
  });
};

/**
 * 查询报销单详细
 * @param id
 */
export const getBillRecord = (id: string | number): AxiosPromise<BillRecordVO> => {
  return request({
    url: '/finance/billRecord/' + id,
    method: 'get'
  });
};

/**
 * 新增报销单
 * @param data
 */
export const addBillRecord = (data: BillRecordForm) => {
  return request({
    url: '/finance/billRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改报销单
 * @param data
 */
export const updateBillRecord = (data: BillRecordForm) => {
  return request({
    url: '/finance/billRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除报销单
 * @param id
 */
export const delBillRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/finance/billRecord/' + id,
    method: 'delete'
  });
};
