import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ReturnOrderVO, ReturnOrderForm, ReturnOrderQuery } from '@/api/wms/returnOrder/types';

/**
 * 查询退库工单列表
 * @param query
 * @returns {*}
 */

export const listReturnOrder = (query?: ReturnOrderQuery): AxiosPromise<ReturnOrderVO[]> => {
  return request({
    url: '/wms/returnOrder/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询退库工单详细
 * @param roId
 */
export const getReturnOrder = (roId: string | number): AxiosPromise<ReturnOrderVO> => {
  return request({
    url: '/wms/returnOrder/' + roId,
    method: 'get'
  });
};

/**
 * 新增退库工单
 * @param data
 */
export const addReturnOrder = (data: ReturnOrderForm) => {
  return request({
    url: '/wms/returnOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改退库工单
 * @param data
 */
export const updateReturnOrder = (data: ReturnOrderForm) => {
  return request({
    url: '/wms/returnOrder',
    method: 'put',
    data: data
  });
};

/**
 * 删除退库工单
 * @param roId
 */
export const delReturnOrder = (roId: string | number | Array<string | number>) => {
  return request({
    url: '/wms/returnOrder/' + roId,
    method: 'delete'
  });
};

/**
 * 审批退库工单
 * @param data
 */
export const auditReturnOrder = (data: ReturnOrderForm) => {
  return request({
    url: '/wms/returnOrder/audit',
    method: 'post',
    data: data
  });
};
