import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialTransferBillsVO, MaterialTransferBillsForm, MaterialTransferBillsQuery } from '@/api/wms/materialTransferBills/types';

/**
 * 查询物料调拨单列表
 * @param query
 * @returns {*}
 */

export const listMaterialTransferBills = (query?: MaterialTransferBillsQuery): AxiosPromise<MaterialTransferBillsVO[]> => {
  return request({
    url: '/wms/materialTransferBills/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料调拨单详细
 * @param transferBillsId
 */
export const getMaterialTransferBills = (transferBillsId: string | number): AxiosPromise<MaterialTransferBillsVO> => {
  return request({
    url: '/wms/materialTransferBills/' + transferBillsId,
    method: 'get'
  });
};

/**
 * 新增物料调拨单
 * @param data
 */
export const addMaterialTransferBills = (data: MaterialTransferBillsForm) => {
  return request({
    url: '/wms/materialTransferBills',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料调拨单
 * @param data
 */
export const updateMaterialTransferBills = (data: MaterialTransferBillsForm) => {
  return request({
    url: '/wms/materialTransferBills',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料调拨单
 * @param transferBillsId
 */
export const delMaterialTransferBills = (transferBillsId: string | number | Array<string | number>) => {
  return request({
    url: '/wms/materialTransferBills/' + transferBillsId,
    method: 'delete'
  });
};

/**
 * 下拉框查询物料调拨单列表
 * @param query
 * @returns {*}
 */
export function getWmsMaterialTransferBillsList (query) {
    return request({
        url: '/wms/materialTransferBills/getWmsMaterialTransferBillsList',
        method: 'get',
        params: query
    });
};
