import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContractPaymentMethodVO, ContractPaymentMethodForm, ContractPaymentMethodQuery } from '@/api/oa/erp/contractPaymentMethod/types';

/**
 * 查询合同付款方式列表
 * @param query
 * @returns {*}
 */

export const listContractPaymentMethod = (query?: ContractPaymentMethodQuery): AxiosPromise<ContractPaymentMethodVO[]> => {
  return request({
    url: '/oa/erp/contractPaymentMethod/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询合同付款方式详细
 * @param paymentMethodId
 */
export const getContractPaymentMethod = (paymentMethodId: string | number): AxiosPromise<ContractPaymentMethodVO> => {
  return request({
    url: '/oa/erp/contractPaymentMethod/' + paymentMethodId,
    method: 'get'
  });
};

/**
 * 新增合同付款方式
 * @param data
 */
export const addContractPaymentMethod = (data: ContractPaymentMethodForm) => {
  return request({
    url: '/oa/erp/contractPaymentMethod',
    method: 'post',
    data: data
  });
};

/**
 * 修改合同付款方式
 * @param data
 */
export const updateContractPaymentMethod = (data: ContractPaymentMethodForm) => {
  return request({
    url: '/oa/erp/contractPaymentMethod',
    method: 'put',
    data: data
  });
};

/**
 * 删除合同付款方式
 * @param paymentMethodId
 */
export const delContractPaymentMethod = (paymentMethodId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/contractPaymentMethod/' + paymentMethodId,
    method: 'delete'
  });
};

/**
 * 下拉框查询合同付款方式列表
 * @param query
 * @returns {*}
 */
export function getErpContractPaymentMethodList (query) {
    return request({
        url: '/oa/erp/contractPaymentMethod/getErpContractPaymentMethodList',
        method: 'get',
        params: query
    });
};

/**
 * 查询合同付款方式列表,left join base_payment_stage
 * @param query
 * @returns {*}
 */
export function getErpContractPaymentMethodJoinList (query) {
  return request({
    url: '/oa/erp/contractPaymentMethod/getErpContractPaymentMethodJoinList',
    method: 'get',
    params: query
  });
};
