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.
 
 

100 lines
2.1 KiB

  1. import { serverFetchJson } from "@/app/utils/fetchUtil";
  2. import { BASE_API_URL } from "@/config/api";
  3. import { cache } from "react";
  4. export interface BomCombo {
  5. id: number;
  6. value: number;
  7. label: string;
  8. outputQty: number;
  9. outputQtyUom: string;
  10. description: string;
  11. }
  12. export interface BomFormatFileGroup {
  13. fileName: string;
  14. problems: string[];
  15. }
  16. /** Format-check 回傳:正確檔名列表 + 失敗列表 */
  17. export interface BomFormatCheckResponse {
  18. correctFileNames: string[];
  19. failList: BomFormatFileGroup[];
  20. issueLogFileId: string;
  21. }
  22. export interface BomUploadResponse {
  23. batchId: string;
  24. fileNames: string[];
  25. }
  26. export interface ImportBomItemPayload {
  27. fileName: string;
  28. isAlsoWip: boolean;
  29. isDrink: boolean;
  30. }
  31. export const preloadBomCombo = (() => {
  32. fetchBomCombo()
  33. })
  34. export interface BomScoreResult {
  35. id: number;
  36. code: string;
  37. name: string;
  38. baseScore: number | string | { value?: number; [key: string]: any };
  39. }
  40. export const fetchBomCombo = cache(async () => {
  41. return serverFetchJson<BomCombo[]>(`${BASE_API_URL}/bom/combo`, {
  42. next: { tags: ["bomCombo"] },
  43. });
  44. });
  45. export const fetchBomScores = cache(async () => {
  46. return serverFetchJson<BomScoreResult[]>(`${BASE_API_URL}/bom/scores`, {
  47. next: { tags: ["boms"] },
  48. });
  49. });
  50. export interface BomMaterialDto {
  51. itemCode?: string;
  52. itemName?: string;
  53. baseQty?: number;
  54. baseUom?: string;
  55. stockQty?: number;
  56. stockUom?: string;
  57. salesQty?: number;
  58. salesUom?: string;
  59. }
  60. export interface BomProcessDto {
  61. seqNo?: number;
  62. processName?: string;
  63. processDescription?: string;
  64. equipmentName?: string;
  65. durationInMinute?: number;
  66. prepTimeInMinute?: number;
  67. postProdTimeInMinute?: number;
  68. }
  69. export interface BomDetailResponse {
  70. id: number;
  71. itemCode?: string;
  72. itemName?: string;
  73. isDark?: number;
  74. isFloat?: number;
  75. isDense?: number;
  76. isDrink?: boolean;
  77. scrapRate?: number;
  78. allergicSubstances?: number;
  79. timeSequence?: number;
  80. complexity?: number;
  81. baseScore?: number;
  82. description?: string;
  83. outputQty?: number;
  84. outputQtyUom?: string;
  85. materials: BomMaterialDto[];
  86. processes: BomProcessDto[];
  87. }