import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PaymentAccountVO, PaymentAccountForm, PaymentAccountQuery } from '@/api/oa/crm/paymentAccount/types';

/**
 * 查询付款账户信息列表
 * @param query
 * @returns {*}
 */

export const listPaymentAccount = (query?: PaymentAccountQuery): AxiosPromise<PaymentAccountVO[]> => {
  return request({
    url: '/oa/crm/paymentAccount/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询付款账户信息详细
 * @param paymentAccountId
 */
export const getPaymentAccount = (paymentAccountId: string | number): AxiosPromise<PaymentAccountVO> => {
  return request({
    url: '/oa/crm/paymentAccount/' + paymentAccountId,
    method: 'get'
  });
};

/**
 * 新增付款账户信息
 * @param data
 */
export const addPaymentAccount = (data: PaymentAccountForm) => {
  return request({
    url: '/oa/crm/paymentAccount',
    method: 'post',
    data: data
  });
};

/**
 * 修改付款账户信息
 * @param data
 */
export const updatePaymentAccount = (data: PaymentAccountForm) => {
  return request({
    url: '/oa/crm/paymentAccount',
    method: 'put',
    data: data
  });
};

/**
 * 删除付款账户信息
 * @param paymentAccountId
 */
export const delPaymentAccount = (paymentAccountId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/crm/paymentAccount/' + paymentAccountId,
    method: 'delete'
  });
};

/**
 * 下拉框查询付款账户信息列表
 * @param query
 * @returns {*}
 */
export function getCrmPaymentAccountList (query) {
    return request({
        url: '/oa/crm/paymentAccount/getCrmPaymentAccountList',
        method: 'get',
        params: query
    });
};
