import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FinInvoiceInfoVO, FinInvoiceInfoForm, FinInvoiceInfoQuery } from '@/api/oa/erp/finInvoiceInfo/types';
import { ContractPaymentMethodVO } from '@/api/oa/erp/contractPaymentMethod/types';
/**
 * 查询开票信息列表
 * @param query
 * @returns {*}
 */

export const listFinInvoiceInfo = (query?: FinInvoiceInfoQuery): AxiosPromise<FinInvoiceInfoVO[]> => {
  return request({
    url: '/oa/erp/finInvoiceInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询基本信息（用户和部门信息）
 */
export const getBaseInfo = (): AxiosPromise<FinInvoiceInfoVO> => {
  return request({
    url: '/oa/erp/finInvoiceInfo/getBaseInfo',
    method: 'get'
  });
};

/**
 * 查询开票信息详细
 * @param invoiceId
 */
export const getFinInvoiceInfo = (invoiceId: string | number): AxiosPromise<FinInvoiceInfoVO> => {
  return request({
    url: '/oa/erp/finInvoiceInfo/' + invoiceId,
    method: 'get'
  });
};

/**
 * 新增开票信息
 * @param data
 */
export const addFinInvoiceInfo = (data: FinInvoiceInfoForm) => {
  return request({
    url: '/oa/erp/finInvoiceInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改开票信息
 * @param data
 */
export const updateFinInvoiceInfo = (data: FinInvoiceInfoForm) => {
  return request({
    url: '/oa/erp/finInvoiceInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除开票信息
 * @param invoiceId
 */
export const delFinInvoiceInfo = (invoiceId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/finInvoiceInfo/' + invoiceId,
    method: 'delete'
  });
};

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

/**
 * 查询开票信息详细
 * @param invoiceId
 */
export const getContractPaymentMethodList = (contractId: string | number): AxiosPromise<ContractPaymentMethodVO[]> => {
  return request({
    url: '/oa/erp/finInvoiceInfo/getContractPaymentMethodList/' + contractId,
    method: 'get'
  });
};

/**
 * 新增开票信息
 * @param data
 */
export const updateInvoiceAttach = (data: FinInvoiceInfoForm) => {
  return request({
    url: '/oa/erp/finInvoiceInfo/updateInvoiceAttach',
    method: 'post',
    data: data
  });
};
