import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WmsPurchaseOrderVO, WmsPurchaseOrderForm, WmsPurchaseOrderQuery } from '@/api/wms/wmsPurchaseOrder/types';

/**
 * 查询采购订单列表
 * @param query
 * @returns {*}
 */

export const listWmsPurchaseOrder = (query?: WmsPurchaseOrderQuery): AxiosPromise<WmsPurchaseOrderVO[]> => {
  return request({
    url: '/wms/wmsPurchaseOrder/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询采购订单详细
 * @param poId
 */
export const getWmsPurchaseOrder = (poId: string | number): AxiosPromise<WmsPurchaseOrderVO> => {
  return request({
    url: '/wms/wmsPurchaseOrder/' + poId,
    method: 'get'
  });
};

/**
 * 新增采购订单
 * @param data
 */
export const addWmsPurchaseOrder = (data: WmsPurchaseOrderForm) => {
  return request({
    url: '/wms/wmsPurchaseOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改采购订单
 * @param data
 */
export const updateWmsPurchaseOrder = (data: WmsPurchaseOrderForm) => {
  return request({
    url: '/wms/wmsPurchaseOrder',
    method: 'put',
    data: data
  });
};

/**
 * 删除采购订单
 * @param poId
 */
export const delWmsPurchaseOrder = (poId: string | number | Array<string | number>) => {
  return request({
    url: '/wms/wmsPurchaseOrder/' + poId,
    method: 'delete'
  });
};


/**
 * 下拉框查询采购订单列表
 * @param query
 * @returns {*}
 */
export function getWmsPurchaseOrderList (query) {
    return request({
        url: '/wms/wmsPurchaseOrder/getWmsPurchaseOrderList',
        method: 'get',
        params: query
    });
};
