feat(Inventory): 同步調撥管理權限邏輯至盤點管理標準
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout";
|
||||
import { Head, router, Link } from "@inertiajs/react";
|
||||
@@ -37,8 +36,10 @@ import { Plus, Save, Trash2, ArrowLeft, CheckCircle, Package, ArrowLeftRight, Pr
|
||||
import { toast } from "sonner";
|
||||
import axios from "axios";
|
||||
import { Can } from '@/Components/Permission/Can';
|
||||
import { usePermission } from '@/hooks/usePermission';
|
||||
|
||||
export default function Show({ order }: any) {
|
||||
const { can } = usePermission();
|
||||
const [items, setItems] = useState(order.items || []);
|
||||
const [remarks, setRemarks] = useState(order.remarks || "");
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
@@ -181,7 +182,8 @@ export default function Show({ order }: any) {
|
||||
});
|
||||
};
|
||||
|
||||
const isReadOnly = order.status !== 'draft';
|
||||
const canEdit = can('inventory_transfer.edit');
|
||||
const isReadOnly = order.status !== 'draft' || !canEdit;
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout
|
||||
@@ -234,7 +236,7 @@ export default function Show({ order }: any) {
|
||||
|
||||
{!isReadOnly && (
|
||||
<div className="flex items-center gap-2">
|
||||
<Can permission="inventory.view">
|
||||
<Can permission="inventory_transfer.delete">
|
||||
<AlertDialog open={!!deleteId} onOpenChange={(open) => !open && setDeleteId(null)}>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button variant="outline" size="sm" className="button-outlined-error" onClick={() => setDeleteId(order.id)}>
|
||||
@@ -255,7 +257,9 @@ export default function Show({ order }: any) {
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</Can>
|
||||
|
||||
<Can permission="inventory_transfer.edit">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
|
||||
Reference in New Issue
Block a user