import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OutStockBillForm, OutStockBillQuery, OutStockBillVO } from '@/api/wms/outStockBill/types';

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

export const listOutStockBill = (query?: OutStockBillQuery): AxiosPromise<OutStockBillVO[]> => {
  return request({
    url: '/wms/outStockBill/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询出库单详细
 * @param outStockBillId
 */
export const getOutStockBill = (outStockBillId: string | number): AxiosPromise<OutStockBillVO> => {
  return request({
    url: '/wms/outStockBill/' + outStockBillId,
    method: 'get'
  });
};

/**
 * 新增出库单
 * @param data
 */
export const addOutStockBill = (data: OutStockBillForm) => {
  return request({
    url: '/wms/outStockBill',
    method: 'post',
    data: data
  });
};

/**
 * 修改出库单
 * @param data
 */
export const updateOutStockBill = (data: OutStockBillForm) => {
  return request({
    url: '/wms/outStockBill',
    method: 'put',
    data: data
  });
};

/**
 * 删除出库单
 * @param outStockBillId
 */
export const delOutStockBill = (outStockBillId: string | number | Array<string | number>) => {
  return request({
    url: '/wms/outStockBill/' + outStockBillId,
    method: 'delete'
  });
};
/**
 * 发货出库单
 * @param outStockBillId
 */
export const deliverOutStockBill = (outStockBillId: string | number) => {
  return request({
    url: '/wms/outStockBill/deliver/' + outStockBillId,
    method: 'put'
  });
};
/**
 * 下拉框查询出库单列表
 * @param query
 * @returns {*}
 */
export function getWmsOutStockBillList(query) {
  return request({
    url: '/wms/outStockBill/getWmsOutStockBillList',
    method: 'get',
    params: query
  });
}
/**
 * 修改出库单关联项目
 * @param query
 * @returns {*}
 */
export function updateOutStockBillProject(query) {
  return request({
    url: '/wms/outStockBill/updateOutStockBillProject',
    method: 'get',
    params: query
  });
}
