import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SendOrderVO, SendOrderForm, SendOrderQuery } from '@/api/amz/sendOrder/types';

/**
 * 查询供应商创建的发货单列表
 * @param query
 * @returns {*}
 */

export const listSendOrder = (query?: SendOrderQuery): AxiosPromise<SendOrderVO[]> => {
  return request({
    url: '/amz/sendOrder/list',
    method: 'get',
    params: query
  });
};

export const coverSendOrder = (data?: SendOrderQuery) => {
  return request({
    url: '/amz/sendOrder/cover/list',
    method: 'post',
    params: { pageNum: data?.pageNum, pageSize: data?.pageSize },
    data: data
  });
};

/**
 * 查询供应商创建的发货单详细
 * @param id
 */
export const getSendOrder = (id: string | number): AxiosPromise<SendOrderVO> => {
  return request({
    url: '/amz/sendOrder/' + id,
    method: 'get'
  });
};

/**
 * 新增供应商创建的发货单
 * @param data
 */
export const addSendOrder = (data: SendOrderForm) => {
  return request({
    url: '/amz/sendOrder',
    method: 'post',
    data: data
  });
};

export const transferSendOrder = (data: SendOrderVO) => {
  return request({
    url: '/amz/sendOrder/transfer',
    method: 'post',
    data: data
  });
};

/**
 * 修改供应商创建的发货单
 * @param data
 */
export const updateSendOrder = (data: SendOrderForm) => {
  return request({
    url: '/amz/sendOrder',
    method: 'put',
    data: data
  });
};

/**
 * 修改供应商创建的发货单
 * @param data
 */
export const updateSendOrderData = (data: SendOrderForm) => {
  return request({
    url: '/amz/sendOrder/data',
    method: 'post',
    data: data
  });
};

/**
 * 删除供应商创建的发货单
 * @param id
 */
export const delSendOrder = (id: string | number | Array<string | number>) => {
  return request({
    url: '/amz/sendOrder/' + id,
    method: 'delete'
  });
};
