From 5381ad80e8246b515bfe1bad287381d597cf38a4 Mon Sep 17 00:00:00 2001 From: "MSI\\derek" Date: Wed, 13 Aug 2025 18:04:32 +0800 Subject: [PATCH] update --- src/components/PoDetail/PoDetail.tsx | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/PoDetail/PoDetail.tsx b/src/components/PoDetail/PoDetail.tsx index b7780cf..a258c5a 100644 --- a/src/components/PoDetail/PoDetail.tsx +++ b/src/components/PoDetail/PoDetail.tsx @@ -355,13 +355,34 @@ const PoDetail: React.FC = ({ po, qc, warehouse }) => { acceptedQty: secondReceiveQty || 0, // acceptedQty: row.acceptedQty, }; - if (postData.acceptedQty === 0) return + if (secondReceiveQty === 0) return const res = await createStockInLine(postData); console.log(res); }, 200); }, [], ); + + const handleChange = (e: React.ChangeEvent) => { + const raw = e.target.value; + + // Allow empty input + if (raw.trim() === '') { + setSecondReceiveQty(undefined); + return; + } + + // Keep digits only + const cleaned = raw.replace(/[^\d]/g, ''); + if (cleaned === '') { + // If the user typed only non-digits, keep previous value + return; + } + + // Parse and clamp to non-negative integer + const next = Math.max(0, Math.floor(Number(cleaned))); + setSecondReceiveQty(next); +}; return ( <> = ({ po, qc, warehouse }) => { type="text" // Use type="text" to allow validation in the change handler variant="outlined" value={secondReceiveQty} - // onChange={handleChange} + onChange={handleChange} InputProps={{ inputProps: { min: 0, // Optional: set a minimum value