Files
star-erp/resources/js/Pages/Sales/Import/Create.tsx
sky121113 b6fe9ad9f3
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 1m8s
feat: 實作銷售單匯入管理、貨道扣庫優化及 UI 細節調整
2026-02-09 14:36:47 +08:00

91 lines
4.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout';
import { Head, useForm, Link } from '@inertiajs/react';
import { Button } from '@/Components/ui/button';
import { Input } from '@/Components/ui/input';
import { Label } from '@/Components/ui/label';
import { Upload, ArrowLeft, FileSpreadsheet } from 'lucide-react';
import React from 'react';
export default function SalesImportCreate() {
const { data, setData, post, processing, errors } = useForm({
file: null as File | null,
});
const submit = (e: React.FormEvent) => {
e.preventDefault();
post(route('sales-imports.store'));
};
return (
<AuthenticatedLayout
breadcrumbs={[
{ label: '銷售管理', href: '#' },
{ label: '銷售單匯入', href: route('sales-imports.index') },
{ label: '新增匯入', href: route('sales-imports.create'), isPage: true },
]}
>
<Head title="新增銷售匯入" />
<div className="container mx-auto p-6 max-w-3xl">
<div className="mb-6">
<Link href={route('sales-imports.index')}>
<Button variant="outline" type="button" className="gap-2 mb-4">
<ArrowLeft className="h-4 w-4" />
</Button>
</Link>
<h1 className="text-2xl font-bold text-gray-900 flex items-center gap-2">
<FileSpreadsheet className="h-6 w-6 text-primary-main" />
</h1>
</div>
<div className="bg-white rounded-lg border shadow-sm p-8">
<form onSubmit={submit} className="space-y-6">
<div className="space-y-2">
<Label htmlFor="file" className="text-lg font-medium"> Excel </Label>
<div className="border-2 border-dashed border-gray-300 rounded-xl p-10 flex flex-col items-center justify-center bg-gray-50 hover:bg-gray-100 transition-colors cursor-pointer relative">
<Input
id="file"
type="file"
accept=".xlsx,.xls,.csv"
onChange={(e) => setData('file', e.target.files ? e.target.files[0] : null)}
className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
/>
<Upload className="h-10 w-10 text-gray-400 mb-4" />
<div className="text-center">
<p className="text-sm font-medium text-gray-700">
{data.file ? data.file.name : '點擊或拖曳檔案至此'}
</p>
<p className="text-xs text-gray-500 mt-1"> .xlsx, .xls, .csv</p>
</div>
</div>
{errors.file && <p className="text-red-500 text-sm">{errors.file}</p>}
</div>
<div className="flex justify-end pt-4">
<Button
type="submit"
size="lg"
className="button-filled-primary w-full md:w-auto px-8"
disabled={processing}
>
{processing ? '處理中...' : '開始匯入'}
</Button>
</div>
</form>
</div>
<div className="mt-8 bg-blue-50 p-6 rounded-lg border border-blue-100">
<h3 className="font-bold text-blue-800 mb-2"></h3>
<ul className="list-disc list-inside text-sm text-blue-700 space-y-1">
<li>使 Excel </li>
<li></li>
<li></li>
</ul>
</div>
</div>
</AuthenticatedLayout>
);
}