feat: add void action to inventory count index
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Successful in 1m9s
Koori-ERP-Deploy-System / deploy-production (push) Has been skipped

This commit is contained in:
2026-01-29 13:12:02 +08:00
parent 56e30a85bb
commit a31c8d6052
2 changed files with 85 additions and 21 deletions

View File

@@ -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<string | null>(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 <Badge className="bg-blue-500 hover:bg-blue-600"></Badge>;
case 'completed':
return <Badge className="bg-green-500 hover:bg-green-600"></Badge>;
return <Badge className="bg-green-500 hover:bg-green-600"></Badge>;
case 'cancelled':
return <Badge variant="destructive"></Badge>;
default:
@@ -285,12 +310,23 @@ export default function Index({ auth, docs, warehouses, filters }: any) {
title={doc.status === 'completed' ? '查閱' : '盤點'}
>
{doc.status === 'completed' ? (
<Eye className="w-4 h-4" />
<Eye className="w-4 h-4 ml-0.5" />
) : (
<Pencil className="w-4 h-4" />
<Pencil className="w-4 h-4 ml-0.5" />
)}
</Button>
</Link>
{doc.status !== 'completed' && (
<Button
variant="outline"
size="sm"
className="button-outlined-error"
title="作廢"
onClick={() => confirmDelete(doc.id)}
>
<Trash2 className="w-4 h-4 ml-0.5" />
</Button>
)}
</Can>
</div>
</TableCell>
@@ -323,6 +359,21 @@ export default function Index({ auth, docs, warehouses, filters }: any) {
</div>
<Pagination links={docs.links} />
</div>
<AlertDialog open={!!deleteId} onOpenChange={(open) => !open && setDeleteId(null)}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle></AlertDialogTitle>
<AlertDialogDescription>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel></AlertDialogCancel>
<AlertDialogAction onClick={handleDelete} className="bg-red-600 hover:bg-red-700"></AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
</AuthenticatedLayout>
);