FPSMS-frontend
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

59 righe
1.7 KiB

  1. "use server";
  2. // import { serverFetchBlob } from "@/app/utils/fetchUtil";
  3. // import { BASE_API_URL } from "@/config/api";
  4. import { serverFetchBlob, serverFetchWithNoContent } from "../../utils/fetchUtil";
  5. import { BASE_API_URL } from "../../../config/api";
  6. export interface FileResponse {
  7. filename: string;
  8. blobValue: Uint8Array;
  9. }
  10. export const fetchPoQrcode = async (data: any) => {
  11. const reportBlob = await serverFetchBlob<FileResponse>(
  12. `${BASE_API_URL}/stockInLine/download-label`,
  13. {
  14. method: "POST",
  15. body: JSON.stringify(data),
  16. headers: { "Content-Type": "application/json" },
  17. },
  18. );
  19. return reportBlob;
  20. };
  21. export interface LotLineToQrcode {
  22. inventoryLotLineId: number
  23. }
  24. export const fetchQrCodeByLotLineId = async (data: LotLineToQrcode) => {
  25. const reportBlob = await serverFetchBlob<FileResponse>(
  26. `${BASE_API_URL}/inventoryLotLine/download-label`,
  27. {
  28. method: "POST",
  29. body: JSON.stringify(data),
  30. headers: { "Content-Type": "application/json" },
  31. },
  32. );
  33. return reportBlob;
  34. }
  35. export interface PrintLabelForInventoryLotLineRequest {
  36. inventoryLotLineId: number;
  37. printerId: number;
  38. printQty?: number;
  39. }
  40. export async function printLabelForInventoryLotLine(data: PrintLabelForInventoryLotLineRequest) {
  41. const params = new URLSearchParams();
  42. params.append("inventoryLotLineId", data.inventoryLotLineId.toString());
  43. params.append("printerId", data.printerId.toString());
  44. if (data.printQty != null && data.printQty !== undefined) {
  45. params.append("printQty", data.printQty.toString());
  46. }
  47. return serverFetchWithNoContent(
  48. `${BASE_API_URL}/inventoryLotLine/print-label?${params.toString()}`,
  49. { method: "GET" }
  50. );
  51. }