import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WmsPurchaseOrderDetailVO, WmsPurchaseOrderDetailForm, WmsPurchaseOrderDetailQuery } from '@/api/wms/wmsPurchaseOrderDetail/types';

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

export const listWmsPurchaseOrderDetail = (query?: WmsPurchaseOrderDetailQuery): AxiosPromise<WmsPurchaseOrderDetailVO[]> => {
  return request({
    url: '/wms/wmsPurchaseOrderDetail/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询采购订单-物料详细
 * @param poDId
 */
export const getWmsPurchaseOrderDetail = (poDId: string | number): AxiosPromise<WmsPurchaseOrderDetailVO> => {
  return request({
    url: '/wms/wmsPurchaseOrderDetail/' + poDId,
    method: 'get'
  });
};

/**
 * 新增采购订单-物料
 * @param data
 */
export const addWmsPurchaseOrderDetail = (data: WmsPurchaseOrderDetailForm) => {
  return request({
    url: '/wms/wmsPurchaseOrderDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改采购订单-物料
 * @param data
 */
export const updateWmsPurchaseOrderDetail = (data: WmsPurchaseOrderDetailForm) => {
  return request({
    url: '/wms/wmsPurchaseOrderDetail',
    method: 'put',
    data: data
  });
};

/**
 * 删除采购订单-物料
 * @param poDId
 */
export const delWmsPurchaseOrderDetail = (poDId: string | number | Array<string | number>) => {
  return request({
    url: '/wms/wmsPurchaseOrderDetail/' + poDId,
    method: 'delete'
  });
};


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

/**
 * 查询采购订单-物料列表（带已入库数量统计）
 * @param query
 * @returns {*}
 */
export const getWmsPurchaseOrderDetailWithStatistics = (query?: WmsPurchaseOrderDetailQuery): AxiosPromise<WmsPurchaseOrderDetailVO[]> => {
  return request({
    url: '/wms/wmsPurchaseOrderDetail/listWithInstockedQty',
    method: 'get',
    params: query
  });
};
