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, AlertCircle, Info, FileSpreadsheet } from "lucide-react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/Components/ui/accordion"; import { useForm } from "@inertiajs/react"; import { Alert, AlertDescription } from "@/Components/ui/alert"; import React from "react"; interface SalesImportDialogProps { open: boolean; onOpenChange: (open: boolean) => void; } export default function SalesImportDialog({ open, onOpenChange }: SalesImportDialogProps) { 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("sales-imports.store"), { onSuccess: () => { reset(); onOpenChange(false); }, }); }; return ( 匯入銷售單 請上傳統一格式的銷售單 Excel 檔案。系統將自動解析內容。
{/* 下載範本區域 */}
下載標準範本以確保資料格式正確。請勿修改欄位名稱。
{/* 上傳檔案區域 */}
{errors.file && ( {errors.file} )}

支援格式:.xlsx, .xls, .csv

{/* 匯入說明 - 使用 Accordion 收合 */}
匯入與欄位說明
  • 檔案格式:請使用統一的 Excel 格式(商品銷貨單)。
  • 自動解析:系統將自動解析機台編號、商品代號與交易時間。
  • 後續動作:匯入後請至「待確認」清單檢查內容,確認無誤後再執行扣庫。
); }