import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FinAccountReceivableVO, FinAccountReceivableForm, FinAccountReceivableQuery } from '@/api/oa/erp/finAccountReceivable/types';

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

export const listFinAccountReceivable = (query?: FinAccountReceivableQuery): AxiosPromise<FinAccountReceivableVO[]> => {
  return request({
    url: '/oa/erp/finAccountReceivable/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询应收款信息详细
 * @param accountReceivableId
 */
export const getFinAccountReceivable = (accountReceivableId: string | number): AxiosPromise<FinAccountReceivableVO> => {
  return request({
    url: '/oa/erp/finAccountReceivable/' + accountReceivableId,
    method: 'get'
  });
};

/**
 * 新增应收款信息
 * @param data
 */
export const addFinAccountReceivable = (data: FinAccountReceivableForm) => {
  return request({
    url: '/oa/erp/finAccountReceivable',
    method: 'post',
    data: data
  });
};

/**
 * 修改应收款信息
 * @param data
 */
export const updateFinAccountReceivable = (data: FinAccountReceivableForm) => {
  return request({
    url: '/oa/erp/finAccountReceivable',
    method: 'put',
    data: data
  });
};

/**
 * 删除应收款信息
 * @param accountReceivableId
 */
export const delFinAccountReceivable = (accountReceivableId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/finAccountReceivable/' + accountReceivableId,
    method: 'delete'
  });
};

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

/**
 * 编辑时查询应收款节点信息列表,right join 应收款节点信息erp_fin_account_receivable_stage
 * @param query
 * @returns {*}
 */
export function getErpFinAccountReceivableStageList(query) {
  return request({
    url: '/oa/erp/finAccountReceivable/getErpFinAccountReceivableStageList',
    method: 'get',
    params: query
  });
}


/**
 * 新增时查询应收款节点信息列表,right join 应收款节点信息erp_fin_account_receivable_stage
 * @param query
 * @returns {*}
 */
export function getErpContractPaymentMethodJoinList(query) {
  return request({
    url: '/oa/erp/finAccountReceivable/getErpContractPaymentMethodJoinList',
    method: 'get',
    params: query
  });
}


