import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FinAccountInstallmentDetailVO, FinAccountInstallmentDetailForm, FinAccountInstallmentDetailQuery } from '@/api/oa/erp/finAccountInstallmentDetail/types';

/**
 * 查询分款明细信息列表
 * @param query
 * @returns {*}
 */

export const listFinAccountInstallmentDetail = (query?: FinAccountInstallmentDetailQuery): AxiosPromise<FinAccountInstallmentDetailVO[]> => {
  return request({
    url: '/oa/erp/finAccountInstallmentDetail/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询分款明细信息详细
 * @param installmentDetailId
 */
export const getFinAccountInstallmentDetail = (installmentDetailId: string | number): AxiosPromise<FinAccountInstallmentDetailVO> => {
  return request({
    url: '/oa/erp/finAccountInstallmentDetail/' + installmentDetailId,
    method: 'get'
  });
};

/**
 * 新增分款明细信息
 * @param data
 */
export const addFinAccountInstallmentDetail = (data: FinAccountInstallmentDetailForm) => {
  return request({
    url: '/oa/erp/finAccountInstallmentDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改分款明细信息
 * @param data
 */
export const updateFinAccountInstallmentDetail = (data: FinAccountInstallmentDetailForm) => {
  return request({
    url: '/oa/erp/finAccountInstallmentDetail',
    method: 'put',
    data: data
  });
};

/**
 * 删除分款明细信息
 * @param installmentDetailId
 */
export const delFinAccountInstallmentDetail = (installmentDetailId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/finAccountInstallmentDetail/' + installmentDetailId,
    method: 'delete'
  });
};

/**
 * 下拉框查询分款明细信息列表
 * @param query
 * @returns {*}
 */
export function getErpFinAccountInstallmentDetailList (query) {
    return request({
        url: '/oa/erp/finAccountInstallmentDetail/getErpFinAccountInstallmentDetailList',
        method: 'get',
        params: query
    });
};


/**
 * 删除分款明细信息
 * @param data
 */
export const deleteInstallmentDetailByBo = (data: FinAccountInstallmentDetailForm) => {
  return request({
    url: '/oa/erp/finAccountInstallmentDetail/deleteInstallmentDetailByBo',
    method: 'post',
    data: data
  });
};
