Selaa lähdekoodia

jo edit

reset-do-picking-order
CANCERYS\kw093 6 päivää sitten
vanhempi
commit
77ad12967b
2 muutettua tiedostoa jossa 15 lisäystä ja 5 poistoa
  1. +1
    -0
      src/app/api/jo/index.ts
  2. +14
    -5
      src/components/JoSearch/JoSearch.tsx

+ 1
- 0
src/app/api/jo/index.ts Näytä tiedosto

@@ -21,6 +21,7 @@ export interface JobOrder {
reqQty: number;
item: Item;
itemName: string;
bomId: number;
// uom: Uom;
pickLines?: JoDetailPickLine[];
status: JoStatus;


+ 14
- 5
src/components/JoSearch/JoSearch.tsx Näytä tiedosto

@@ -161,11 +161,20 @@ const JoSearch: React.FC<Props> = ({ defaultInputs, bomCombo, printerCombo, jobT
const fetchBomForJo = useCallback(async (jo: JobOrder): Promise<BomCombo | null> => {
try {
const detailedJo = detailedJos.get(jo.id) || await fetchJoDetailClient(jo.id);
const matchingBom = bomCombo.find(bom => {
return true; // 临时占位
});
return matchingBom || null;
// 若列表的 jo 已有 bomId(之後若 API 有回傳),可直接用
const bomId = (jo as { bomId?: number }).bomId;
if (bomId != null) {
const matchingBom = bomCombo.find(bom => bom.id === bomId);
if (matchingBom) return matchingBom;
}
// 否則打明細 API,明細會帶 bomId
const detailedJo = detailedJos.get(jo.id) ?? await fetchJoDetailClient(jo.id);
const detailBomId = (detailedJo as { bomId?: number }).bomId;
if (detailBomId != null) {
const matchingBom = bomCombo.find(bom => bom.id === detailBomId);
if (matchingBom) return matchingBom;
}
return null;
} catch (error) {
console.error("Error fetching BOM for JO:", error);
return null;


Ladataan…
Peruuta
Tallenna