diff --git a/resources/js/Pages/Inventory/Count/Index.tsx b/resources/js/Pages/Inventory/Count/Index.tsx index 4bb321c..5cb820a 100644 --- a/resources/js/Pages/Inventory/Count/Index.tsx +++ b/resources/js/Pages/Inventory/Count/Index.tsx @@ -31,14 +31,26 @@ import { X, ClipboardCheck, Eye, - Pencil + Pencil, + Trash2 } from 'lucide-react'; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from "@/Components/ui/alert-dialog"; import Pagination from '@/Components/shared/Pagination'; import { Can } from '@/Components/Permission/Can'; export default function Index({ auth, docs, warehouses, filters }: any) { const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false); - const { data, setData, post, processing, reset, errors } = useForm({ + const [deleteId, setDeleteId] = useState(null); + const { data, setData, post, processing, reset, errors, delete: destroy } = useForm({ warehouse_id: '', remarks: '', }); @@ -108,6 +120,19 @@ export default function Index({ auth, docs, warehouses, filters }: any) { }); }; + const confirmDelete = (id: string) => { + setDeleteId(id); + }; + + const handleDelete = () => { + if (deleteId) { + destroy(route('inventory.count.destroy', [deleteId]), { + onSuccess: () => setDeleteId(null), + onError: () => setDeleteId(null), + }); + } + }; + const getStatusBadge = (status) => { switch (status) { case 'draft': @@ -115,7 +140,7 @@ export default function Index({ auth, docs, warehouses, filters }: any) { case 'counting': return 盤點中; case 'completed': - return 已完成; + return 已核准; case 'cancelled': return 已取消; default: @@ -285,12 +310,23 @@ export default function Index({ auth, docs, warehouses, filters }: any) { title={doc.status === 'completed' ? '查閱' : '盤點'} > {doc.status === 'completed' ? ( - + ) : ( - + )} + {doc.status !== 'completed' && ( + + )} @@ -323,6 +359,21 @@ export default function Index({ auth, docs, warehouses, filters }: any) { + + !open && setDeleteId(null)}> + + + 確定要作廢此盤點單嗎? + + 此動作無法復原。作廢後請重新建立盤點單。 + + + + 取消 + 確認作廢 + + + ); diff --git a/resources/js/Pages/Inventory/Count/Show.tsx b/resources/js/Pages/Inventory/Count/Show.tsx index f3ad47c..3bdad7b 100644 --- a/resources/js/Pages/Inventory/Count/Show.tsx +++ b/resources/js/Pages/Inventory/Count/Show.tsx @@ -1,5 +1,5 @@ import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'; -import { Head, useForm, Link } from '@inertiajs/react'; // Added Link +import { Head, useForm, Link, router } from '@inertiajs/react'; // Added Link import { Table, TableBody, @@ -56,11 +56,9 @@ export default function Show({ doc }: any) { }; const handleReopen = () => { - if (confirm('確定要取消核准嗎?單據將回復為盤點中狀態,且庫存異動將被撤回(若已過帳)。')) { - router.visit(route('inventory.count.reopen', [doc.id]), { - method: 'put', - }); - } + router.visit(route('inventory.count.reopen', [doc.id]), { + method: 'put', + }); } const isCompleted = doc.status === 'completed'; @@ -123,16 +121,31 @@ export default function Show({ doc }: any) { {isCompleted && ( - + + + + + + + 確定要取消核准嗎? + + 單據將回復為「盤點中」狀態,若已產生庫存異動將被撤回。此動作可讓您重新編輯盤點數量。 + + + + 取消 + 確認取消核准 + + + )}