import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InstockOrderVO, InstockOrderForm, InstockOrderQuery } from '@/api/wms/instockOrder/types';

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

export const listInstockOrder = (query?: InstockOrderQuery): AxiosPromise<InstockOrderVO[]> => {
  return request({
    url: '/wms/instockOrder/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询入库单详细
 * @param instockId
 */
export const getInstockOrder = (instockId: string | number): AxiosPromise<InstockOrderVO> => {
  return request({
    url: '/wms/instockOrder/' + instockId,
    method: 'get'
  });
};

/**
 * 新增入库单
 * @param data
 */
export const addInstockOrder = (data: InstockOrderForm) => {
  return request({
    url: '/wms/instockOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改入库单
 * @param data
 */
export const updateInstockOrder = (data: InstockOrderForm) => {
  return request({
    url: '/wms/instockOrder',
    method: 'put',
    data: data
  });
};

/**
 * 入库单审批
 * @param data
 */
export const approveInstockOrder = (data: InstockOrderForm) => {
  return request({
    url: '/wms/instockOrder/approveInstockOrder',
    method: 'put',
    data: data
  });
};

/**
 * 删除入库单
 * @param instockId
 */
export const delInstockOrder = (instockId: string | number | Array<string | number>) => {
  return request({
    url: '/wms/instockOrder/' + instockId,
    method: 'delete'
  });
};
