From 6e08f763ef252942dff0b7fb994eb9b95bb6fd10 Mon Sep 17 00:00:00 2001 From: "CANCERYS\\kw093" Date: Thu, 2 Oct 2025 01:12:02 +0800 Subject: [PATCH] update --- .../Jodetail/JobPickExecutionForm.tsx | 61 +-- .../Jodetail/JobPickExecutionsecondscan.tsx | 2 +- src/components/Jodetail/JobmatchForm.tsx | 403 ++++++++++++++++++ src/i18n/zh/jo.json | 3 +- 4 files changed, 440 insertions(+), 29 deletions(-) create mode 100644 src/components/Jodetail/JobmatchForm.tsx diff --git a/src/components/Jodetail/JobPickExecutionForm.tsx b/src/components/Jodetail/JobPickExecutionForm.tsx index 7af42b7..e7c79da 100644 --- a/src/components/Jodetail/JobPickExecutionForm.tsx +++ b/src/components/Jodetail/JobPickExecutionForm.tsx @@ -173,18 +173,21 @@ const PickExecutionForm: React.FC = ({ const validateForm = (): boolean => { const newErrors: FormErrors = {}; + const requiredQty = selectedLot?.requiredQty || 0; + const badItemQty = formData.badItemQty || 0; + const missQty = formData.missQty || 0; + if (verifiedQty === undefined || verifiedQty < 0) { newErrors.actualPickQty = t('Qty is required'); } - // ✅ Check if verified qty exceeds received qty - if (verifiedQty > (selectedLot?.actualPickQty || 0)) { - newErrors.actualPickQty = t('Verified quantity cannot exceed received quantity'); - } + // ✅ 移除接收数量检查,因为在 JobPickExecution 阶段 receivedQty 总是 0 + // if (verifiedQty > receivedQty) { ... } ← 删除 - // ✅ Check if verified qty exceeds required qty - if (verifiedQty > (selectedLot?.requiredQty || 0)) { - newErrors.actualPickQty = t('Qty is not allowed to be greater than required qty'); + // ✅ 只检查总和是否等于需求数量 + const totalQty = verifiedQty + badItemQty + missQty; + if (totalQty !== requiredQty) { + newErrors.actualPickQty = t('Total (Verified + Bad + Missing) must equal Required quantity'); } // ✅ Require either missQty > 0 OR badItemQty > 0 @@ -199,7 +202,6 @@ const PickExecutionForm: React.FC = ({ setErrors(newErrors); return Object.keys(newErrors).length === 0; }; - const handleSubmit = async () => { if (!validateForm() || !formData.pickOrderId) { return; @@ -265,30 +267,21 @@ const PickExecutionForm: React.FC = ({ /> - - - + { const newValue = parseFloat(e.target.value) || 0; setVerifiedQty(newValue); handleInputChange('actualPickQty', newValue); }} error={!!errors.actualPickQty} - helperText={errors.actualPickQty || `${t('Max')}: ${Math.min(selectedLot?.actualPickQty || 0, selectedLot?.requiredQty || 0)}`} + helperText={errors.actualPickQty || `${t('Max')}: ${selectedLot?.actualPickQty || 0}`} // ✅ 使用原始接收数量 variant="outlined" /> @@ -299,9 +292,13 @@ const PickExecutionForm: React.FC = ({ label={t('Missing item Qty')} type="number" value={formData.missQty || 0} - onChange={(e) => handleInputChange('missQty', parseFloat(e.target.value) || 0)} + onChange={(e) => { + const newMissQty = parseFloat(e.target.value) || 0; + handleInputChange('missQty', newMissQty); + // ✅ 不要自动修改其他字段 + }} error={!!errors.missQty} - // helperText={errors.missQty || t('Enter missing quantity (required if no bad items)')} + helperText={errors.missQty} variant="outlined" /> @@ -312,9 +309,13 @@ const PickExecutionForm: React.FC = ({ label={t('Bad Item Qty')} type="number" value={formData.badItemQty || 0} - onChange={(e) => handleInputChange('badItemQty', parseFloat(e.target.value) || 0)} + onChange={(e) => { + const newBadItemQty = parseFloat(e.target.value) || 0; + handleInputChange('badItemQty', newBadItemQty); + // ✅ 不要自动修改其他字段 + }} error={!!errors.badItemQty} - // helperText={errors.badItemQty || t('Enter bad item quantity (required if no missing items)')} + helperText={errors.badItemQty} variant="outlined" /> @@ -322,7 +323,7 @@ const PickExecutionForm: React.FC = ({ {/* ✅ Show issue description and handler fields when bad items > 0 */} {(formData.badItemQty && formData.badItemQty > 0) ? ( <> - + = ({ multiline rows={4} value={formData.issueRemark || ''} - onChange={(e) => handleInputChange('issueRemark', e.target.value)} + onChange={(e) => { + handleInputChange('issueRemark', e.target.value); + // ✅ Don't reset badItemQty when typing in issue remark + }} error={!!errors.issueRemark} helperText={errors.issueRemark} //placeholder={t('Describe the issue with bad items')} @@ -343,7 +347,10 @@ const PickExecutionForm: React.FC = ({ {t('handler')} { + handleInputChange('handledBy', e.target.value ? parseInt(e.target.value) : undefined); + // ✅ Don't reset badItemQty when selecting handler + }} + label={t('handler')} + > + {handlers.map((handler) => ( + + {handler.name} + + ))} + + {errors.handledBy && ( + + {errors.handledBy} + + )} + + + + ) : (<>)} + + + + + + + + + ); +}; + +export default PickExecutionForm; \ No newline at end of file diff --git a/src/i18n/zh/jo.json b/src/i18n/zh/jo.json index 70b2997..046bd31 100644 --- a/src/i18n/zh/jo.json +++ b/src/i18n/zh/jo.json @@ -270,5 +270,6 @@ "Submit All Scanned": "提交所有已掃描項目", "Submitting...": "提交中...", "COMPLETED": "已完成", - "success": "成功" + "success": "成功", + "Total (Verified + Bad + Missing) must equal Required quantity": "驗證數量 + 不良數量 + 缺失數量必須等於需求數量" }