import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FinAccountInstallmentVO, FinAccountInstallmentForm, FinAccountInstallmentQuery } from '@/api/oa/erp/finAccountInstallment/types';

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

export const listFinAccountInstallment = (query?: FinAccountInstallmentQuery): AxiosPromise<FinAccountInstallmentVO[]> => {
  return request({
    url: '/oa/erp/finAccountInstallment/list',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增分款信息
 * @param data
 */
export const addFinAccountInstallment = (data: FinAccountInstallmentForm) => {
  return request({
    url: '/oa/erp/finAccountInstallment',
    method: 'post',
    data: data
  });
};

/**
 * 修改分款信息
 * @param data
 */
export const updateFinAccountInstallment = (data: FinAccountInstallmentForm) => {
  return request({
    url: '/oa/erp/finAccountInstallment',
    method: 'put',
    data: data
  });
};

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

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