refactor(sales): remove import template download and update dialog instructions
This commit is contained in:
@@ -30,10 +30,6 @@ class SalesImportController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function template()
|
|
||||||
{
|
|
||||||
return Excel::download(new \App\Modules\Sales\Exports\SalesImportTemplateExport, 'sales_import_template.xlsx');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Modules\Sales\Exports;
|
|
||||||
|
|
||||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
||||||
use Maatwebsite\Excel\Concerns\WithStyles;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
|
||||||
|
|
||||||
class SalesImportTemplateExport implements WithHeadings, WithTitle, WithStyles
|
|
||||||
{
|
|
||||||
public function headings(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'機台編號',
|
|
||||||
'交易時間',
|
|
||||||
'商品代號',
|
|
||||||
'數量',
|
|
||||||
'單價',
|
|
||||||
'總金額',
|
|
||||||
'貨道', // 新增欄位
|
|
||||||
'狀態', // 原始狀態
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function title(): string
|
|
||||||
{
|
|
||||||
return '銷售單匯入範本';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function styles(Worksheet $sheet)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
1 => ['font' => ['bold' => true]],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,6 @@ Route::middleware(['auth', 'verified'])->prefix('sales')->name('sales-imports.')
|
|||||||
});
|
});
|
||||||
|
|
||||||
Route::post('/imports', [SalesImportController::class, 'store'])->middleware('permission:sales_imports.create')->name('store');
|
Route::post('/imports', [SalesImportController::class, 'store'])->middleware('permission:sales_imports.create')->name('store');
|
||||||
Route::get('/imports/template', [SalesImportController::class, 'template'])->middleware('permission:sales_imports.create')->name('template');
|
|
||||||
|
|
||||||
Route::post('/imports/{import}/confirm', [SalesImportController::class, 'confirm'])->middleware('permission:sales_imports.confirm')->name('confirm');
|
Route::post('/imports/{import}/confirm', [SalesImportController::class, 'confirm'])->middleware('permission:sales_imports.confirm')->name('confirm');
|
||||||
Route::delete('/imports/{import}', [SalesImportController::class, 'destroy'])->middleware('permission:sales_imports.delete')->name('destroy');
|
Route::delete('/imports/{import}', [SalesImportController::class, 'destroy'])->middleware('permission:sales_imports.delete')->name('destroy');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DialogD
|
|||||||
import { Button } from "@/Components/ui/button";
|
import { Button } from "@/Components/ui/button";
|
||||||
import { Input } from "@/Components/ui/input";
|
import { Input } from "@/Components/ui/input";
|
||||||
import { Label } from "@/Components/ui/label";
|
import { Label } from "@/Components/ui/label";
|
||||||
import { Upload, AlertCircle, Info, FileSpreadsheet } from "lucide-react";
|
import { Upload, AlertCircle, Info } from "lucide-react";
|
||||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/Components/ui/accordion";
|
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/Components/ui/accordion";
|
||||||
import { useForm } from "@inertiajs/react";
|
import { useForm } from "@inertiajs/react";
|
||||||
import { Alert, AlertDescription } from "@/Components/ui/alert";
|
import { Alert, AlertDescription } from "@/Components/ui/alert";
|
||||||
@@ -49,32 +49,11 @@ export default function SalesImportDialog({ open, onOpenChange }: SalesImportDia
|
|||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<form onSubmit={handleSubmit} className="space-y-6">
|
<form onSubmit={handleSubmit} className="space-y-6">
|
||||||
{/* 下載範本區域 */}
|
|
||||||
<div className="space-y-2 p-4 bg-gray-50 rounded-lg border border-gray-100">
|
|
||||||
<Label className="font-medium flex items-center gap-2">
|
|
||||||
<FileSpreadsheet className="w-4 h-4 text-green-600" />
|
|
||||||
步驟 1:取得 Excel 範本
|
|
||||||
</Label>
|
|
||||||
<div className="text-sm text-gray-500 mb-2">
|
|
||||||
下載標準範本以確保資料格式正確。請勿修改欄位名稱。
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => window.location.href = route('sales-imports.template')}
|
|
||||||
className="w-full sm:w-auto button-outlined-primary"
|
|
||||||
>
|
|
||||||
<Upload className="w-4 h-4 mr-2 rotate-180" />
|
|
||||||
下載範本 (.xlsx)
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 上傳檔案區域 */}
|
{/* 上傳檔案區域 */}
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label className="font-medium flex items-center gap-2">
|
<Label className="font-medium flex items-center gap-2">
|
||||||
<Upload className="w-4 h-4 text-blue-600" />
|
<Upload className="w-4 h-4 text-blue-600" />
|
||||||
步驟 2:上傳檔案
|
上傳銷售單檔案
|
||||||
</Label>
|
</Label>
|
||||||
|
|
||||||
<div className="grid w-full max-w-sm items-center gap-1.5">
|
<div className="grid w-full max-w-sm items-center gap-1.5">
|
||||||
@@ -98,21 +77,29 @@ export default function SalesImportDialog({ open, onOpenChange }: SalesImportDia
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 匯入說明 - 使用 Accordion 收合 */}
|
{/* 匯入說明 - 使用 Accordion 收合 */}
|
||||||
<Accordion type="single" collapsible className="w-full border rounded-lg px-2">
|
<Accordion type="single" collapsible className="w-full border rounded-lg px-2" defaultValue="item-1">
|
||||||
<AccordionItem value="item-1" className="border-b-0">
|
<AccordionItem value="item-1" className="border-b-0">
|
||||||
<AccordionTrigger className="text-sm text-gray-500 hover:no-underline py-3">
|
<AccordionTrigger className="text-sm text-gray-500 hover:no-underline py-3">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Info className="h-4 w-4" />
|
<Info className="h-4 w-4" />
|
||||||
匯入與欄位說明
|
支援欄位說明 (系統自動識別)
|
||||||
</div>
|
</div>
|
||||||
</AccordionTrigger>
|
</AccordionTrigger>
|
||||||
<AccordionContent>
|
<AccordionContent>
|
||||||
<div className="text-sm text-gray-600 space-y-2 pb-2 pl-6">
|
<div className="text-sm text-gray-600 space-y-2 pb-2 pl-6">
|
||||||
<ul className="list-disc space-y-1">
|
<p className="mb-2">請確保 Excel 檔案包含以下關鍵欄位資訊(依序或對應位置):</p>
|
||||||
<li><span className="font-medium text-gray-700">檔案格式</span>:請使用統一的 Excel 格式(商品銷貨單)。</li>
|
<ul className="list-disc space-y-1 text-xs">
|
||||||
<li><span className="font-medium text-gray-700">自動解析</span>:系統將自動解析機台編號、商品代號與交易時間。</li>
|
<li><span className="font-medium text-gray-700">A 欄 (0)</span>:交易序號 (Serial)</li>
|
||||||
<li><span className="font-medium text-gray-700">後續動作</span>:匯入後請至「待確認」清單檢查內容,確認無誤後再執行扣庫。</li>
|
<li><span className="font-medium text-gray-700">B 欄 (1)</span>:機台編號 (Machine ID)</li>
|
||||||
|
<li><span className="font-medium text-gray-700">E 欄 (4)</span>:交易狀態 (Status)</li>
|
||||||
|
<li><span className="font-medium text-gray-700">H 欄 (7)</span>:商品代號 (Product Code)</li>
|
||||||
|
<li><span className="font-medium text-gray-700">J 欄 (9)</span>:交易時間 (Transaction Date)</li>
|
||||||
|
<li><span className="font-medium text-gray-700">L 欄 (11)</span>:金額 (Amount)</li>
|
||||||
|
<li><span className="font-medium text-gray-700">T 欄 (19)</span>:貨道 (Slot)</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<div className="mt-2 pt-2 border-t text-xs text-gray-500">
|
||||||
|
注意:系統將從第 4 列開始讀取資料。
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</AccordionContent>
|
</AccordionContent>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
|
|||||||
Reference in New Issue
Block a user