import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FinInvoiceDetailVO, FinInvoiceDetailForm, FinInvoiceDetailQuery } from '@/api/oa/erp/finInvoiceDetail/types';

/**
 * 查询开票明细列表
 * @param query
 * @returns {*}
 */

export const listFinInvoiceDetail = (query?: FinInvoiceDetailQuery): AxiosPromise<FinInvoiceDetailVO[]> => {
  return request({
    url: '/oa/erp/finInvoiceDetail/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询开票明细详细
 * @param invoiceDetailId
 */
export const getFinInvoiceDetail = (invoiceDetailId: string | number): AxiosPromise<FinInvoiceDetailVO> => {
  return request({
    url: '/oa/erp/finInvoiceDetail/' + invoiceDetailId,
    method: 'get'
  });
};

/**
 * 新增开票明细
 * @param data
 */
export const addFinInvoiceDetail = (data: FinInvoiceDetailForm) => {
  return request({
    url: '/oa/erp/finInvoiceDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改开票明细
 * @param data
 */
export const updateFinInvoiceDetail = (data: FinInvoiceDetailForm) => {
  return request({
    url: '/oa/erp/finInvoiceDetail',
    method: 'put',
    data: data
  });
};

/**
 * 删除开票明细
 * @param invoiceDetailId
 */
export const delFinInvoiceDetail = (invoiceDetailId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/finInvoiceDetail/' + invoiceDetailId,
    method: 'delete'
  });
};

/**
 * 下拉框查询开票明细列表
 * @param query
 * @returns {*}
 */
export function getErpFinInvoiceDetailList (query) {
    return request({
        url: '/oa/erp/finInvoiceDetail/getErpFinInvoiceDetailList',
        method: 'get',
        params: query
    });
};
