import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FlightBookingVO, FlightBookingForm, FlightBookingQuery } from '@/api/oa/crm/flightBooking/types';

/**
 * 查询机票预订列表
 * @param query
 * @returns {*}
 */

export const listFlightBooking = (query?: FlightBookingQuery): AxiosPromise<FlightBookingVO[]> => {
  return request({
    url: '/oa/crm/flightBooking/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询机票预订详细
 * @param bookingId
 */
export const getFlightBooking = (bookingId: string | number): AxiosPromise<FlightBookingVO> => {
  return request({
    url: '/oa/crm/flightBooking/' + bookingId,
    method: 'get'
  });
};

/**
 * 新增机票预订
 * @param data
 */
export const addFlightBooking = (data: FlightBookingForm) => {
  return request({
    url: '/oa/crm/flightBooking',
    method: 'post',
    data: data
  });
};

/**
 * 修改机票预订
 * @param data
 */
export const updateFlightBooking = (data: FlightBookingForm) => {
  return request({
    url: '/oa/crm/flightBooking',
    method: 'put',
    data: data
  });
};

/**
 * 删除机票预订
 * @param bookingId
 */
export const delFlightBooking = (bookingId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/crm/flightBooking/' + bookingId,
    method: 'delete'
  });
};

/**
 * 下拉框查询机票预订列表
 * @param query
 * @returns {*}
 */
export function getCrmFlightBookingList(query) {
  return request({
    url: '/oa/crm/flightBooking/getCrmFlightBookingList',
    method: 'get',
    params: query
  });
}
/**
 * 机票预订提交并发起流程
 * @param data 表单数据
 */
export const submitAndFlowStart = (data: any) => {
  return request({
    url: '/oa/crm/flightBooking/submitAndFlowStart',
    method: 'post',
    data: data
  });
};
