import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialTransferRecordForm, MaterialTransferRecordQuery, MaterialTransferRecordVO } from '@/api/wms/materialTransferRecord/types';

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

export const listMaterialTransferRecord = (query?: MaterialTransferRecordQuery): AxiosPromise<MaterialTransferRecordVO[]> => {
  return request({
    url: '/wms/materialTransferRecord/list',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增物料调拨
 * @param data
 */
export const addMaterialTransferRecord = (data: MaterialTransferRecordForm | MaterialTransferRecordForm[]) => {
  return request({
    url: '/wms/materialTransferRecord',
    method: 'post',
    data: data
  });
};

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

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

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