|
- import { serverFetchJson } from "@/app/utils/fetchUtil";
- import { BASE_API_URL } from "@/config/api";
- import { cache } from "react";
-
- export interface BomCombo {
- id: number;
- value: number;
- label: string;
- outputQty: number;
- outputQtyUom: string;
- description: string;
- }
-
- export interface BomFormatFileGroup {
- fileName: string;
- problems: string[];
- }
-
- /** Format-check 回傳:正確檔名列表 + 失敗列表 */
- export interface BomFormatCheckResponse {
- correctFileNames: string[];
- failList: BomFormatFileGroup[];
- issueLogFileId: string;
- }
-
- export interface BomUploadResponse {
- batchId: string;
- fileNames: string[];
- }
-
- export interface ImportBomItemPayload {
- fileName: string;
- isAlsoWip: boolean;
- isDrink: boolean;
- }
-
- export const preloadBomCombo = (() => {
- fetchBomCombo()
- })
- export interface BomScoreResult {
- id: number;
- code: string;
- name: string;
- baseScore: number | string | { value?: number; [key: string]: any };
- }
-
-
-
- export const fetchBomCombo = cache(async () => {
- return serverFetchJson<BomCombo[]>(`${BASE_API_URL}/bom/combo`, {
- next: { tags: ["bomCombo"] },
- });
- });
-
- export const fetchBomScores = cache(async () => {
- return serverFetchJson<BomScoreResult[]>(`${BASE_API_URL}/bom/scores`, {
- next: { tags: ["boms"] },
- });
- });
-
- export interface BomMaterialDto {
- itemCode?: string;
- itemName?: string;
- baseQty?: number;
- baseUom?: string;
- stockQty?: number;
- stockUom?: string;
- salesQty?: number;
- salesUom?: string;
- }
-
- export interface BomProcessDto {
- seqNo?: number;
- processName?: string;
- processDescription?: string;
- equipmentName?: string;
- durationInMinute?: number;
- prepTimeInMinute?: number;
- postProdTimeInMinute?: number;
- }
-
- export interface BomDetailResponse {
- id: number;
- itemCode?: string;
- itemName?: string;
- isDark?: number;
- isFloat?: number;
- isDense?: number;
- isDrink?: boolean;
- scrapRate?: number;
- allergicSubstances?: number;
- timeSequence?: number;
- complexity?: number;
- baseScore?: number;
- description?: string;
- outputQty?: number;
- outputQtyUom?: string;
- materials: BomMaterialDto[];
- processes: BomProcessDto[];
- }
|