import request from '@/utils/request';



export const allocateOrderlList = (query) => {
  return request({
    url: '/wms/allocateOrder/list',
    method: 'get',
    params: query
  });
};

export const allocateOrderDetailList = (query) => {
  return request({
    url: '/wms/allocateOrderDetail/list',
    method: 'get',
    params: query
  });
};

export const allocateOrderUpdate = (query) => {
  return request({
    url: '/wms/allocateOrder',
    method: 'put',
    data: query
  });
};

export const allocateOrder = (aoId) => {
  return request({
    url: '/wms/allocateOrder/' + aoId,
    method: 'delete'
  });
};

export const viewAllocateOrder = (aoId) => {
  return request({
    url: '/wms/allocateOrder/' + aoId,
    method: 'get'
  });
};

export const addAllocateOrder = (data) => {
  return request({
    url: '/wms/allocateOrder',
    method: 'post',
    data,
  });
};

export const getMaterialList = (query) => {
  return request({
    url: '/wms/inventory/getMaterialInfoList',
    method: 'get',
    params: query
  });
};
export const getInstockMaterialList = (query) => {
  return request({
    url: '/wms/baseMaterialInfo/materialList',
    method: 'get',
    params: query
  });
};

export const addAllocateOrderDetail = (data) => {
  return request({
    url: '/wms/allocateOrderDetail',
    method: 'post',
    data,
  });
};

export const viewAllocateOrderDetail = (aoId) => {
  return request({
    url: '/wms/allocateOrderDetail/' + aoId,
    method: 'get'
  });
};

export const delAllocateOrderDetail = (aoDId) => {
  return request({
    url: '/wms/allocateOrderDetail/removeDetail/' + aoDId,
    method: 'delete'
  });
};


/*以下为新增测试*/

// 调拨分包打印
export const allocatePackagePrint = (data) => {
  return request({
    url: '/wms/wmsAllocateTask/packagePrint',
    method: 'post',
    data
  });
};

// 根据调拨明细ID查询任务列表
export const queryTasksByDetailId = (aoDId) => {
  return request({
    url: '/wms/wmsAllocateTask/queryTasksByDetailId/' + aoDId,
    method: 'get'
  });
};

// 验证是否可打印（基于业务逻辑的前端验证）
export const validatePrintable = (data) => {
  return request({
    url: '/wms/wmsAllocateTask/validatePrintable',
    method: 'post',
    data
  });
};

// 触发打印条码
export const triggerPrint = (allocateTaskId) => {
  return request({
    url: '/wms/wmsAllocateTask/triggerPrint/' + allocateTaskId,
    method: 'post'
  });
};

// 重新创建调拨任务
export const recreateAllocateTasks = (data) => {
  return request({
    url: '/wms/wmsAllocateTask/recreateTasks',
    method: 'post',
    data
  });
};

// 更新调拨任务条码
export const updateTaskBarcode = (data) => {
  return request({
    url: '/wms/wmsAllocateTask/updateBarcode',
    method: 'put',
    data
  });
};

// 根据调拨明细ID删除所有任务
export const deleteTasksByDetailId = (aoDId) => {
  return request({
    url: '/wms/wmsAllocateTask/deleteTasksByDetailId/' + aoDId,
    method: 'delete'
  });
};

// 调拨工单审批
export const approveAllocateOrder = (data) => {
  return request({
    url: '/wms/allocateOrder/approveAllocateOrder',
    method: 'put',
    data: data
  });
};
