FPSMS-frontend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

86 lines
1.7 KiB

  1. "server=only";
  2. import { serverFetchJson } from "@/app/utils/fetchUtil";
  3. import { BASE_API_URL } from "@/config/api";
  4. import { cache } from "react";
  5. import { Item } from "../settings/item";
  6. import { Uom } from "../settings/uom";
  7. export type JoStatus = "planning" | "pending" | "processing" | "packaging" | "storing" | "completed"
  8. export type JoBomMaterialStatus = "pending" | "completed"
  9. export interface Operator {
  10. id: number;
  11. name: string;
  12. username: string;
  13. }
  14. export interface JobOrder {
  15. id: number;
  16. code: string;
  17. reqQty: number;
  18. item: Item;
  19. itemName: string;
  20. // uom: Uom;
  21. pickLines?: JoDetailPickLine[];
  22. status: JoStatus;
  23. planStart?: number[];
  24. planEnd?: number[];
  25. type: string;
  26. // TODO pack below into StockInLineInfo
  27. stockInLineId?: number;
  28. stockInLineStatus?: string;
  29. silHandlerId?: number;
  30. }
  31. export interface Machine {
  32. id: number;
  33. name: string;
  34. code: string;
  35. qrCode: string;
  36. }
  37. export interface JoDetail {
  38. id: number;
  39. code: string;
  40. itemCode: string;
  41. itemName?: string;
  42. name: string;
  43. reqQty: number;
  44. // itemId: number;
  45. uom: string;
  46. pickLines: JoDetailPickLine[];
  47. status: JoStatus;
  48. planStart: number[];
  49. planEnd: number[];
  50. type: string;
  51. // item?: Item;
  52. }
  53. export interface JoDetailPickLine {
  54. id: number;
  55. code: string;
  56. name: string;
  57. pickedLotNo?: JoDetailPickedLotNo[];
  58. reqQty: number;
  59. uom: string;
  60. status: JoBomMaterialStatus;
  61. shortUom: string;
  62. }
  63. export interface JoDetailPickedLotNo {
  64. lotNo: string;
  65. qty: number;
  66. isScanned: boolean;
  67. }
  68. export const fetchJoDetail = cache(async (id: number) => {
  69. return serverFetchJson<JobOrder>(`${BASE_API_URL}/jo/detail/${id}`,
  70. {
  71. method: "GET",
  72. headers: { "Content-Type": "application/json"},
  73. next: {
  74. tags: ["jo"]
  75. }
  76. })
  77. })