import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BusinessTripDetailsVO, BusinessTripDetailsForm, BusinessTripDetailsQuery } from '@/api/oa/crm/businessTripDetails/types';

/**
 * 查询出差申请明细列表
 * @param query
 * @returns {*}
 */

export const listBusinessTripDetails = (query?: BusinessTripDetailsQuery): AxiosPromise<BusinessTripDetailsVO[]> => {
  return request({
    url: '/oa/crm/businessTripDetails/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询出差申请明细详细
 * @param tripDetailsId
 */
export const getBusinessTripDetails = (tripDetailsId: string | number): AxiosPromise<BusinessTripDetailsVO> => {
  return request({
    url: '/oa/crm/businessTripDetails/' + tripDetailsId,
    method: 'get'
  });
};

/**
 * 新增出差申请明细
 * @param data
 */
export const addBusinessTripDetails = (data: BusinessTripDetailsForm) => {
  return request({
    url: '/oa/crm/businessTripDetails',
    method: 'post',
    data: data
  });
};

/**
 * 修改出差申请明细
 * @param data
 */
export const updateBusinessTripDetails = (data: BusinessTripDetailsForm) => {
  return request({
    url: '/oa/crm/businessTripDetails',
    method: 'put',
    data: data
  });
};

/**
 * 删除出差申请明细
 * @param tripDetailsId
 */
export const delBusinessTripDetails = (tripDetailsId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/crm/businessTripDetails/' + tripDetailsId,
    method: 'delete'
  });
};

/**
 * 下拉框查询出差申请明细列表
 * @param query
 * @returns {*}
 */
export function getCrmBusinessTripDetailsList (query) {
    return request({
        url: '/oa/crm/businessTripDetails/getCrmBusinessTripDetailsList',
        method: 'get',
        params: query
    });
};
