-
updateItem(index, 'originCountry', e.target.value.toUpperCase().slice(0, 2))}
- placeholder="產地"
- maxLength={2}
- className="w-16 text-center px-1"
+
+ {/* 統一批號選擇器 */}
+
{
+ if (value === 'new_batch') {
+ const updatedItem = {
+ ...item,
+ batchMode: 'new',
+ inventory_id: undefined,
+ originCountry: 'TW',
+ expiry_date: '',
+ };
+ const newItems = [...data.items];
+ newItems[index] = updatedItem;
+ setData('items', newItems);
+ } else if (value === 'no_batch') {
+ const updatedItem = {
+ ...item,
+ batchMode: 'none',
+ batch_number: 'NO-BATCH',
+ inventory_id: undefined,
+ originCountry: 'TW',
+ expiry_date: '',
+ };
+ const newItems = [...data.items];
+ newItems[index] = updatedItem;
+ setData('items', newItems);
+ } else {
+ // 選擇現有批號 (如果有快照的話,目前架構下先保留 basic 選項)
+ updateItem(index, 'batchMode', 'existing');
+ updateItem(index, 'inventory_id', value);
+ }
+ }}
+ options={[
+ { label: "📦 不使用批號 (自動累加)", value: "no_batch" },
+ { label: "+ 建立新批號", value: "new_batch" },
+ // 若有現有批號列表可在此擴充,目前進貨單主要處理 new/none
+ ]}
+ placeholder="選擇或建立批號"
+ className="border-gray-200"
/>
-
- {getBatchPreview(item.product_id, item.product_code, item.originCountry || 'TW', data.received_date)}
-
+
+ {/* 建立新批號時的附加欄位 */}
+ {item.batchMode === 'new' && (
+
+
updateItem(index, 'originCountry', e.target.value.toUpperCase().slice(0, 2))}
+ placeholder="產地"
+ maxLength={2}
+ className="w-12 h-8 text-center px-1 text-xs"
+ />
+
+ {getBatchPreview(item.product_id, item.product_code, item.originCountry || 'TW', data.received_date)}
+
+
+ )}
+
+ {/* 不使用批號時的提示 */}
+ {item.batchMode === 'none' && (
+
+ 系統將自動累計至該商品的通用庫存紀錄
+
+ )}
@@ -701,8 +890,20 @@ export default function GoodsReceiptCreate({ warehouses, pendingPurchaseOrders,
{/* Subtotal */}
-
- ${itemTotal.toLocaleString()}
+
+ {isNonStandard ? (
+ updateItem(index, 'subtotal', e.target.value)}
+ className="w-full text-right"
+ placeholder="0"
+ />
+ ) : (
+ ${itemTotal.toLocaleString()}
+ )}
{/* Actions */}
@@ -765,10 +966,10 @@ export default function GoodsReceiptCreate({ warehouses, pendingPurchaseOrders,
size="lg"
className="button-filled-primary px-12 h-14 rounded-xl shadow-lg text-lg font-bold transition-all hover:scale-[1.02] active:scale-[0.98]"
onClick={submit}
- disabled={processing || isCheckingDuplicate || (data.type === 'standard' ? !selectedPO : !selectedVendor)}
+ disabled={processing || isCheckingDuplicate || (!isEditMode && (data.type === 'standard' ? !selectedPO : !selectedVendor))}
>
- {processing || isCheckingDuplicate ? '處理中...' : '確認進貨'}
+ {processing || isCheckingDuplicate ? '處理中...' : (isEditMode ? '儲存變更' : '確認進貨')}