feat: 實作銷售單匯入權限控管並全面精簡權限顯示名稱
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Successful in 59s
Koori-ERP-Deploy-System / deploy-production (push) Has been skipped

This commit is contained in:
2026-02-09 15:04:08 +08:00
parent b6fe9ad9f3
commit 65eb1a1b64
10 changed files with 227 additions and 141 deletions

View File

@@ -26,6 +26,7 @@ import { Badge } from "@/Components/ui/badge";
import { ArrowLeft, CheckCircle, Trash2, Printer } from 'lucide-react';
import { format } from 'date-fns';
import Pagination from "@/Components/shared/Pagination";
import { usePermission } from "@/hooks/usePermission";
interface ImportItem {
id: number;
@@ -76,6 +77,7 @@ interface Props {
}
export default function SalesImportShow({ import: batch, items, filters = {} }: Props) {
const { can } = usePermission();
const { post, processing } = useForm({});
const [perPage, setPerPage] = useState(filters?.per_page?.toString() || "10");
@@ -139,65 +141,74 @@ export default function SalesImportShow({ import: batch, items, filters = {} }:
{batch.status === 'confirmed' ? '已確認' : '待確認'}
</Badge>
{batch.status === 'pending' && (
<>
<AlertDialog>
<AlertDialogTrigger asChild>
<Button
variant="outline"
className="gap-2 button-outlined-error"
>
<Trash2 className="h-4 w-4" />
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle></AlertDialogTitle>
<AlertDialogDescription>
#{batch.id}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel></AlertDialogCancel>
<AlertDialogAction
className="bg-red-600 hover:bg-red-700"
onClick={handleDelete}
<div className="flex gap-3">
{can('sales_imports.delete') && (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button
variant="outline"
className="button-outlined-error gap-2 h-10 px-6"
>
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<Trash2 className="h-4 w-4" />
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle></AlertDialogTitle>
<AlertDialogDescription>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel></AlertDialogCancel>
<AlertDialogAction
className="bg-red-600 hover:bg-red-700"
onClick={handleDelete}
>
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)}
<AlertDialog>
<AlertDialogTrigger asChild>
<Button
className="button-filled-primary gap-2"
disabled={processing}
>
<CheckCircle className="h-4 w-4" />
{processing ? '處理中...' : '確認並扣庫'}
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle></AlertDialogTitle>
<AlertDialogDescription>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel></AlertDialogCancel>
<AlertDialogAction
className="button-filled-primary"
onClick={handleConfirm}
{can('sales_imports.confirm') && (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button
className="button-filled-primary gap-2 h-10 px-8 shadow-md hover:shadow-lg transition-all"
disabled={processing}
>
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</>
<CheckCircle className="h-4 w-4" />
{processing ? '處理中...' : '確認扣庫並入帳'}
</Button>
</AlertDialogTrigger>
<AlertDialogContent className="sm:max-w-md">
<AlertDialogHeader>
<AlertDialogTitle></AlertDialogTitle>
<AlertDialogDescription className="text-gray-600 leading-relaxed">
<div className="bg-amber-50 border-l-4 border-amber-400 p-4 mt-3 rounded">
<p className="text-amber-800 text-sm font-medium">
</p>
</div>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter className="mt-4">
<AlertDialogCancel></AlertDialogCancel>
<AlertDialogAction
className="bg-primary-main hover:bg-primary-dark text-white px-8"
onClick={handleConfirm}
>
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)}
</div>
)}
{batch.status === 'confirmed' && (
<Button variant="outline" className="gap-2 button-outlined-primary">