Explorar el Código

Refresh the production list in the background after QC and search.

Finishing QC or putaway moves the job order to Put Awayed without a full-page spinner, and Search refetches even when the criteria are unchanged.

Co-authored-by: Cursor <[email protected]>
item_tracing
CANCERYS\kw093 hace 2 semanas
padre
commit
027a4d641b
Se han modificado 2 ficheros con 33 adiciones y 15 borrados
  1. +25
    -8
      src/components/ProductionProcess/ProductionProcessList.tsx
  2. +8
    -7
      src/components/Qc/QcStockInModal.tsx

+ 25
- 8
src/components/ProductionProcess/ProductionProcessList.tsx Ver fichero

@@ -29,6 +29,7 @@ import {
import ChevronLeft from "@mui/icons-material/ChevronLeft"; import ChevronLeft from "@mui/icons-material/ChevronLeft";
import ChevronRight from "@mui/icons-material/ChevronRight"; import ChevronRight from "@mui/icons-material/ChevronRight";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import type { StockInLine } from "@/app/api/stockIn";
import { fetchItemForPutAway } from "@/app/api/stockIn/actions"; import { fetchItemForPutAway } from "@/app/api/stockIn/actions";
import QcStockInModal from "../Qc/QcStockInModal"; import QcStockInModal from "../Qc/QcStockInModal";
import { useSession } from "next-auth/react"; import { useSession } from "next-auth/react";
@@ -178,7 +179,7 @@ function isWaitingQcPutAway(
return s !== "completed" && s !== "rejected"; return s !== "completed" && s !== "rejected";
} }


/** FP-MTMS Version Checklist | Functions Ref. No. 40 | v1.0.9 | 2026-08-10 */
/** FP-MTMS Version Checklist | Functions Ref. No. 40 | v1.0.10 | 2026-10-15 */
const ProductProcessList: React.FC<ProductProcessListProps> = ({ const ProductProcessList: React.FC<ProductProcessListProps> = ({
onSelectProcess, onSelectProcess,
printerCombo, printerCombo,
@@ -191,6 +192,8 @@ const ProductProcessList: React.FC<ProductProcessListProps> = ({
const { data: session } = useSession() as { data: SessionWithTokens | null }; const { data: session } = useSession() as { data: SessionWithTokens | null };
const sessionToken = session as SessionWithTokens | null; const sessionToken = session as SessionWithTokens | null;
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
/** Bumps on Search/Reset so the same criteria still refetch. */
const [listReloadKey, setListReloadKey] = useState(0);
const [productionCache, setProductionCache] = useState< const [productionCache, setProductionCache] = useState<
AllJoborderProductProcessInfoResponse[] AllJoborderProductProcessInfoResponse[]
>([]); >([]);
@@ -234,6 +237,8 @@ const ProductProcessList: React.FC<ProductProcessListProps> = ({
() => printerOptions[0] ?? null, () => printerOptions[0] ?? null,
); );
const printInFlightRef = useRef(false); const printInFlightRef = useRef(false);
const loadSeqRef = useRef(0);
const hasLoadedOnceRef = useRef(false);
const [printingSilId, setPrintingSilId] = useState<number | null>(null); const [printingSilId, setPrintingSilId] = useState<number | null>(null);


useEffect(() => { useEffect(() => {
@@ -328,6 +333,7 @@ const ProductProcessList: React.FC<ProductProcessListProps> = ({
const handleApplySearch = useCallback( const handleApplySearch = useCallback(
(inputs: Record<SearchParam | `${SearchParam}To`, string>) => { (inputs: Record<SearchParam | `${SearchParam}To`, string>) => {
const selectedProcessType = (inputs.processType || "all") as ProcessFilter; const selectedProcessType = (inputs.processType || "all") as ProcessFilter;
setListReloadKey((k) => k + 1);
onListPersistedStateChange((prev) => ({ onListPersistedStateChange((prev) => ({
...prev, ...prev,
filter: selectedProcessType, filter: selectedProcessType,
@@ -342,6 +348,7 @@ const ProductProcessList: React.FC<ProductProcessListProps> = ({
); );


const handleResetSearch = useCallback(() => { const handleResetSearch = useCallback(() => {
setListReloadKey((k) => k + 1);
onListPersistedStateChange((prev) => ({ onListPersistedStateChange((prev) => ({
...prev, ...prev,
filter: "all", filter: "all",
@@ -355,8 +362,10 @@ const ProductProcessList: React.FC<ProductProcessListProps> = ({
}, [disableDateFilter, onListPersistedStateChange]); }, [disableDateFilter, onListPersistedStateChange]);


/** Load all tab datasets once per search; tab switches use cache only. */ /** Load all tab datasets once per search; tab switches use cache only. */
const loadAllCaches = useCallback(async () => {
setLoading(true);
const loadAllCaches = useCallback(async (options?: { silent?: boolean }) => {
const silent = options?.silent === true;
const seq = ++loadSeqRef.current;
if (!silent) setLoading(true);
try { try {
const typeParam = filter === "all" ? undefined : filter; const typeParam = filter === "all" ? undefined : filter;
const base = { const base = {
@@ -391,6 +400,8 @@ const ProductProcessList: React.FC<ProductProcessListProps> = ({
}), }),
]); ]);


if (seq !== loadSeqRef.current) return;

const prodContent = (prod?.content || []).filter((p) => !isPutawayCompleted(p)); const prodContent = (prod?.content || []).filter((p) => !isPutawayCompleted(p));
const qcContent = (pendingQc?.content || []).filter((p) => !isPutawayCompleted(p)); const qcContent = (pendingQc?.content || []).filter((p) => !isPutawayCompleted(p));
const putawayContent = putawayed?.content || []; const putawayContent = putawayed?.content || [];
@@ -405,6 +416,7 @@ const ProductProcessList: React.FC<ProductProcessListProps> = ({
setCarriedOverCount(prod?.carriedOverCount ?? 0); setCarriedOverCount(prod?.carriedOverCount ?? 0);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
if (seq !== loadSeqRef.current || silent) return;
setProductionCache([]); setProductionCache([]);
setPendingQcCache([]); setPendingQcCache([]);
setPutawayedCache([]); setPutawayedCache([]);
@@ -413,12 +425,14 @@ const ProductProcessList: React.FC<ProductProcessListProps> = ({
setPutawayedCount(0); setPutawayedCount(0);
setCarriedOverCount(0); setCarriedOverCount(0);
} finally { } finally {
setLoading(false);
if (seq === loadSeqRef.current) setLoading(false);
} }
}, [appliedSearch, disableDateFilter, filter]);
}, [appliedSearch, disableDateFilter, filter, listReloadKey]);


useEffect(() => { useEffect(() => {
void loadAllCaches();
const silent = hasLoadedOnceRef.current;
hasLoadedOnceRef.current = true;
void loadAllCaches(silent ? { silent: true } : undefined);
}, [loadAllCaches]); }, [loadAllCaches]);


const offPlanRows = useMemo(() => { const offPlanRows = useMemo(() => {
@@ -670,9 +684,12 @@ const ProductProcessList: React.FC<ProductProcessListProps> = ({
closeConfirm(); closeConfirm();
} }
}, [pendingConfirmAction, closeConfirm]); }, [pendingConfirmAction, closeConfirm]);
const closeNewModal = useCallback(() => {
const closeNewModal = useCallback((updatedStockInLine?: StockInLine) => {
setOpenModal(false); setOpenModal(false);
}, []);
if (updatedStockInLine) {
void loadAllCaches({ silent: true });
}
}, [loadAllCaches]);


const handlePrintLabel = useCallback( const handlePrintLabel = useCallback(
async (process: AllJoborderProductProcessInfoResponse) => { async (process: AllJoborderProductProcessInfoResponse) => {


+ 8
- 7
src/components/Qc/QcStockInModal.tsx Ver fichero

@@ -77,7 +77,7 @@ interface Props extends CommonProps {
// itemDetail: StockInLine & { qcResult?: PurchaseQcResult[] } & { escResult?: EscalationResult[] }; // itemDetail: StockInLine & { qcResult?: PurchaseQcResult[] } & { escResult?: EscalationResult[] };
} }


/** FP-MTMS Version Checklist | Functions Ref. No. 56 | v1.0.5 | 2026-09-18 */
/** FP-MTMS Version Checklist | Functions Ref. No. 56 | v1.0.7 | 2026-10-15 */
const QcStockInModal: React.FC<Props> = ({ const QcStockInModal: React.FC<Props> = ({
open, open,
onClose, onClose,
@@ -617,10 +617,10 @@ const QcStockInModal: React.FC<Props> = ({


} }
closeWithResult(qcRes);
closeWithResult(qcRes ?? stockInLineInfo);
// setTabIndex(1); // Need to go Putaway tab? // setTabIndex(1); // Need to go Putaway tab?
} else { } else {
closeWithResult(qcRes);
closeWithResult(qcRes ?? stockInLineInfo);
} }
setIsSubmitting(false); setIsSubmitting(false);
qcSubmitInFlightRef.current = false; qcSubmitInFlightRef.current = false;
@@ -700,11 +700,12 @@ const QcStockInModal: React.FC<Props> = ({
// Handle putaway submission logic here // Handle putaway submission logic here
const res = await postStockInLine(putawayData); const res = await postStockInLine(putawayData);
console.log("result ", res); console.log("result ", res);
// Close modal after successful putaway
closeHandler({}, "backdropClick");
const updated = Array.isArray(res.entity) ? res.entity[0] : res.entity;

// Close modal after successful putaway and tell the parent to refresh.
closeWithResult(updated ?? stockInLineInfo);
}, },
[closeHandler],
[closeWithResult, postStockInLine, stockInLineInfo],
); );
// Print handler // Print handler
useEffect(() => { useEffect(() => {


Cargando…
Cancelar
Guardar