import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DialogDescription } from "@/Components/ui/dialog"; import { Button } from "@/Components/ui/button"; import { Input } from "@/Components/ui/input"; import { Label } from "@/Components/ui/label"; import { Upload, Download, FileSpreadsheet, AlertCircle, Info } from "lucide-react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/Components/ui/accordion"; import { useForm, router } from "@inertiajs/react"; import { Alert, AlertDescription } from "@/Components/ui/alert"; interface TransferImportDialogProps { open: boolean; onOpenChange: (open: boolean) => void; orderId: number; } export default function TransferImportDialog({ open, onOpenChange, orderId }: TransferImportDialogProps) { const { data, setData, post, processing, errors, reset, clearErrors } = useForm<{ file: File | null; }>({ file: null, }); const handleFileChange = (e: React.ChangeEvent) => { if (e.target.files && e.target.files[0]) { setData("file", e.target.files[0]); clearErrors("file"); } }; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); post(route("inventory.transfer.import-items", orderId), { forceFormData: true, onSuccess: () => { reset(); onOpenChange(false); router.reload(); }, }); }; const handleDownloadTemplate = () => { window.location.href = route('inventory.transfer.template'); }; return ( 匯入調撥明細 請先下載範本,填寫後上傳。系統將自動附加明細至本調撥單。
{/* 步驟 1: 下載範本 */}
下載標準範本以確保資料格式正確。請勿修改欄位名稱。
{/* 步驟 2: 上傳檔案 */}
{errors.file && ( {errors.file} )}
{/* 欄位說明 */}
欄位填寫規則
  • 商品代碼:必填,請填寫系統中已存在的商品代號。
  • 數量:必填,必須為大於 0 的數字。
  • 批號:選填,若不填寫將自動對應「無批號 (NO-BATCH)」的庫存。
  • 備註:選填,可填寫該筆明細的備註說明。
  • 附加模式:匯入的明細將附加至現有明細,不會覆蓋原有資料。
); }