import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContractPaymentStageVO, ContractPaymentStageForm, ContractPaymentStageQuery } from '@/api/oa/erp/contractPaymentStage/types';

/**
 * 查询合同回款阶段列表
 * @param query
 * @returns {*}
 */

export const listContractPaymentStage = (query?: ContractPaymentStageQuery): AxiosPromise<ContractPaymentStageVO[]> => {
  return request({
    url: '/oa/erp/contractPaymentStage/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询合同回款阶段详细
 * @param contractStageId
 */
export const getContractPaymentStage = (contractStageId: string | number): AxiosPromise<ContractPaymentStageVO> => {
  return request({
    url: '/oa/erp/contractPaymentStage/' + contractStageId,
    method: 'get'
  });
};

/**
 * 新增合同回款阶段
 * @param data
 */
export const addContractPaymentStage = (data: ContractPaymentStageForm) => {
  return request({
    url: '/oa/erp/contractPaymentStage',
    method: 'post',
    data: data
  });
};

/**
 * 修改合同回款阶段
 * @param data
 */
export const updateContractPaymentStage = (data: ContractPaymentStageForm) => {
  return request({
    url: '/oa/erp/contractPaymentStage',
    method: 'put',
    data: data
  });
};

/**
 * 删除合同回款阶段
 * @param contractStageId
 */
export const delContractPaymentStage = (contractStageId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/erp/contractPaymentStage/' + contractStageId,
    method: 'delete'
  });
};

/**
 * 下拉框查询合同回款阶段列表
 * @param query
 * @returns {*}
 */
export function getErpContractPaymentStageList (query) {
    return request({
        url: '/oa/erp/contractPaymentStage/getErpContractPaymentStageList',
        method: 'get',
        params: query
    });
};
