Kaynağa Gözat

No longer refresh after QC

reset-do-picking-order
kelvin.yau 2 hafta önce
ebeveyn
işleme
88513e744b
2 değiştirilmiş dosya ile 40 ekleme ve 18 silme
  1. +17
    -9
      src/components/PoDetail/PoInputGrid.tsx
  2. +23
    -9
      src/components/Qc/QcStockInModal.tsx

+ 17
- 9
src/components/PoDetail/PoInputGrid.tsx Dosyayı Görüntüle

@@ -285,15 +285,23 @@ function PoInputGrid({
const stockInLineId = searchParams.get("stockInLineId");
const poLineId = searchParams.get("poLineId");

const closeNewModal = useCallback(() => {
const newParams = new URLSearchParams(searchParams.toString());
newParams.delete("stockInLineId"); // Remove the parameter
router.replace(`${pathname}?${newParams.toString()}`);
fetchPoDetail(itemDetail.purchaseOrderId.toString());
setNewOpen(false); // Close the modal first
// setTimeout(() => {
// }, 300); // Add a delay to avoid immediate re-trigger of useEffect
}, [searchParams, pathname, router]);
const closeNewModal = useCallback((updatedStockInLine?: StockInLine) => {
const newParams = new URLSearchParams(searchParams.toString());
newParams.delete("stockInLineId");
if (typeof window !== "undefined") {
window.history.replaceState({}, "", `${pathname}?${newParams.toString()}`);
}
setNewOpen(false);

if (updatedStockInLine?.id != null) {
setEntries((prev) =>
prev.map((e) => (e.id === updatedStockInLine.id ? { ...e, ...updatedStockInLine } : e))
);
setStockInLine((prev) =>
(prev || []).map((p) => (p.id === updatedStockInLine.id ? { ...p, ...updatedStockInLine } : p))
);
}
}, [pathname, searchParams]);

// Open modal
const openNewModal = useCallback(() => {


+ 23
- 9
src/components/Qc/QcStockInModal.tsx Dosyayı Görüntüle

@@ -55,13 +55,13 @@ const style = {
width: { xs: "90%", sm: "90%", md: "90%" },
height: { xs: "90%", sm: "90%", md: "90%" },
};
interface CommonProps extends Omit<ModalProps, "children"> {
interface CommonProps extends Omit<ModalProps, "children" | "onClose"> {
// itemDetail: StockInLine & { qcResult?: PurchaseQcResult[] } & { escResult?: EscalationResult[] } | undefined;
inputDetail: StockInLineInput | undefined;
session: SessionWithTokens | null;
warehouse?: any[];
printerCombo: PrinterCombo[];
onClose: () => void;
onClose: (updatedStockInLine?: StockInLine) => void;
skipQc?: Boolean;
printSource?: "stockIn" | "productionProcess";
}
@@ -229,7 +229,16 @@ const QcStockInModal: React.FC<Props> = ({
...defaultNewValue,
},
});

const closeWithResult = useCallback(
(updatedStockInLine?: StockInLine) => {
setStockInLineInfo(undefined);
formProps.reset({});
onClose?.(updatedStockInLine);
},
[onClose],
);

const closeHandler = useCallback<NonNullable<ModalProps["onClose"]>>(
() => {
setStockInLineInfo(undefined);
@@ -412,6 +421,9 @@ const QcStockInModal: React.FC<Props> = ({
// const qcData = data;

console.log("QC Data for submission:", qcData);

let qcRes: StockInLine | undefined;
if (data.qcDecision == 3) { // Escalate
if (data.escalationLog?.handlerId == undefined) { alert("請選擇上報負責同事!"); return; }
else if (data.escalationLog?.handlerId < 1) { alert("上報負責同事資料有誤"); return; }
@@ -425,12 +437,14 @@ const QcStockInModal: React.FC<Props> = ({
}
console.log("Escalation Data for submission", escalationLog);

setIsSubmitting(true); //TODO improve
await postStockInLine({...qcData, escalationLog});
setIsSubmitting(true);
const resEscalate = await postStockInLine({...qcData, escalationLog});
qcRes = Array.isArray(resEscalate.entity) ? resEscalate.entity[0] : (resEscalate.entity as StockInLine);

} else {
setIsSubmitting(true); //TODO improve
await postStockInLine(qcData);
setIsSubmitting(true);
const resNormal = await postStockInLine(qcData);
qcRes = Array.isArray(resNormal.entity) ? resNormal.entity[0] : (resNormal.entity as StockInLine);
}

if (qcData.qcAccept) {
@@ -485,10 +499,10 @@ const QcStockInModal: React.FC<Props> = ({
}

}
closeHandler({}, "backdropClick");
closeWithResult(qcRes);
// setTabIndex(1); // Need to go Putaway tab?
} else {
closeHandler({}, "backdropClick");
closeWithResult(qcRes);
}
setIsSubmitting(false);
msg("已更新來貨狀態");


Yükleniyor…
İptal
Kaydet