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.
 
 

95 lines
1.9 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. bomId: number;
  21. // uom: Uom;
  22. pickLines?: JoDetailPickLine[];
  23. status: JoStatus;
  24. planStart?: number[];
  25. planStartTo?: string;
  26. planEnd?: number[];
  27. type: string;
  28. jobTypeId: number;
  29. jobTypeName: string;
  30. sufficientCount: number;
  31. insufficientCount: number;
  32. productionPriority: number;
  33. // TODO pack below into StockInLineInfo
  34. stockInLineId?: number;
  35. stockInLineStatus?: string;
  36. silHandlerId?: number;
  37. lotNo?: string;
  38. }
  39. export interface Machine {
  40. id: number;
  41. name: string;
  42. code: string;
  43. qrCode: string;
  44. }
  45. export interface JoDetail {
  46. id: number;
  47. code: string;
  48. itemCode: string;
  49. itemName?: string;
  50. name: string;
  51. reqQty: number;
  52. // itemId: number;
  53. uom: string;
  54. pickLines: JoDetailPickLine[];
  55. status: JoStatus;
  56. planStart: number[];
  57. planEnd: number[];
  58. type: string;
  59. // item?: Item;
  60. }
  61. export interface JoDetailPickLine {
  62. id: number;
  63. code: string;
  64. name: string;
  65. type: string;
  66. pickedLotNo?: JoDetailPickedLotNo[];
  67. reqQty: number;
  68. uom: string;
  69. status: JoBomMaterialStatus;
  70. shortUom: string;
  71. }
  72. export interface JoDetailPickedLotNo {
  73. lotNo: string;
  74. qty: number;
  75. isScanned: boolean;
  76. }
  77. export const fetchJoDetail = cache(async (id: number) => {
  78. return serverFetchJson<JobOrder>(`${BASE_API_URL}/jo/detail/${id}`,
  79. {
  80. method: "GET",
  81. headers: { "Content-Type": "application/json"},
  82. next: {
  83. tags: ["jo"]
  84. }
  85. })
  86. })