import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrderAssignmentVO, OrderAssignmentForm, OrderAssignmentQuery, OrderSplitAssignForm } from '@/api/order/orderAssignmentLog/types';

/**
 * 查询订单分配记录列表
 * @param query
 * @returns {*}
 */

export const listOrderAssignment = (query?: OrderAssignmentQuery): AxiosPromise<OrderAssignmentVO[]> => {
  return request({
    url: '/order/orderAssignment/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询订单分配记录详细
 * @param id
 */
export const getOrderAssignment = (id: string | number): AxiosPromise<OrderAssignmentVO> => {
  return request({
    url: '/order/orderAssignment/' + id,
    method: 'get'
  });
};

/**
 * 新增订单分配记录------整单
 * @param data
 */
export const addOrderAssignment = (data: OrderAssignmentForm) => {
  return request({
    url: '/order/orderAssignment',
    method: 'post',
    data: data
  });
};

/**
 * 新增订单分配记录------拆单
 * @param data
 */
export const addOrderSplitAssign = (data: OrderSplitAssignForm) => {
  return request({
    url: '/order/orderAssignment/splitAssign',
    method: 'post',
    data: data
  });
};

/**
 * 修改订单分配记录
 * @param data
 */
export const updateOrderAssignment = (data: OrderAssignmentForm) => {
  return request({
    url: '/order/orderAssignment',
    method: 'put',
    data: data
  });
};

/**
 * 删除订单分配记录
 * @param id
 */
export const delOrderAssignment = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/orderAssignment/' + id,
    method: 'delete'
  });
};
