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 } 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 檔案包含以下關鍵欄位資訊(依序或對應位置):

  • A 欄 (0):交易序號 (Serial)
  • B 欄 (1):機台編號 (Machine ID)
  • E 欄 (4):交易狀態 (Status)
  • H 欄 (7):商品代號 (Product Code)
  • J 欄 (9):交易時間 (Transaction Date)
  • L 欄 (11):金額 (Amount)
  • T 欄 (19):貨道 (Slot)
注意:系統將從第 4 列開始讀取資料。
); }