feat(inventory): 強化調撥單功能,支援販賣機貨道欄位、開放商品重複加入及優化過帳庫存檢核
This commit is contained in:
145
resources/js/Components/Transfer/TransferImportDialog.tsx
Normal file
145
resources/js/Components/Transfer/TransferImportDialog.tsx
Normal file
@@ -0,0 +1,145 @@
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DialogDescription } from "@/Components/ui/dialog";
|
||||
import { Button } from "@/Components/ui/button";
|
||||
import { Input } from "@/Components/ui/input";
|
||||
import { Label } from "@/Components/ui/label";
|
||||
import { Upload, Download, FileSpreadsheet, AlertCircle, Info } from "lucide-react";
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/Components/ui/accordion";
|
||||
import { useForm, router } from "@inertiajs/react";
|
||||
import { Alert, AlertDescription } from "@/Components/ui/alert";
|
||||
|
||||
interface TransferImportDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
orderId: number;
|
||||
}
|
||||
|
||||
export default function TransferImportDialog({ open, onOpenChange, orderId }: TransferImportDialogProps) {
|
||||
const { data, setData, post, processing, errors, reset, clearErrors } = useForm<{
|
||||
file: File | null;
|
||||
}>({
|
||||
file: null,
|
||||
});
|
||||
|
||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.target.files && e.target.files[0]) {
|
||||
setData("file", e.target.files[0]);
|
||||
clearErrors("file");
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
post(route("inventory.transfer.import-items", orderId), {
|
||||
forceFormData: true,
|
||||
onSuccess: () => {
|
||||
reset();
|
||||
onOpenChange(false);
|
||||
router.reload();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleDownloadTemplate = () => {
|
||||
window.location.href = route('inventory.transfer.template');
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-[500px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>匯入調撥明細</DialogTitle>
|
||||
<DialogDescription>
|
||||
請先下載範本,填寫後上傳。系統將自動附加明細至本調撥單。
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-6">
|
||||
{/* 步驟 1: 下載範本 */}
|
||||
<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:取得 CSV 範本
|
||||
</Label>
|
||||
<div className="text-sm text-gray-500 mb-2">
|
||||
下載標準範本以確保資料格式正確。請勿修改欄位名稱。
|
||||
</div>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleDownloadTemplate}
|
||||
className="w-full sm:w-auto button-outlined-primary"
|
||||
>
|
||||
<Download className="w-4 h-4 mr-2" />
|
||||
下載範本 (.xlsx)
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* 步驟 2: 上傳檔案 */}
|
||||
<div className="space-y-2">
|
||||
<Label className="font-medium flex items-center gap-2">
|
||||
<Upload className="w-4 h-4 text-blue-600" />
|
||||
步驟 2:上傳填寫後的檔案
|
||||
</Label>
|
||||
|
||||
<div className="grid w-full max-w-sm items-center gap-1.5">
|
||||
<Input
|
||||
id="file"
|
||||
type="file"
|
||||
accept=".xlsx, .xls, .csv"
|
||||
onChange={handleFileChange}
|
||||
className="cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
{errors.file && (
|
||||
<Alert variant="destructive" className="mt-2">
|
||||
<AlertCircle className="h-4 w-4" />
|
||||
<AlertDescription className="whitespace-pre-wrap">
|
||||
{errors.file}
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 欄位說明 */}
|
||||
<Accordion type="single" collapsible className="w-full border rounded-lg px-2">
|
||||
<AccordionItem value="item-1" className="border-b-0">
|
||||
<AccordionTrigger className="text-sm text-gray-500 hover:no-underline py-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<Info className="h-4 w-4" />
|
||||
欄位填寫規則
|
||||
</div>
|
||||
</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
<div className="text-sm text-gray-600 space-y-2 pb-2 pl-6">
|
||||
<ul className="list-disc space-y-1">
|
||||
<li><span className="font-medium text-gray-700">商品代碼</span>:必填,請填寫系統中已存在的商品代號。</li>
|
||||
<li><span className="font-medium text-gray-700">數量</span>:必填,必須為大於 0 的數字。</li>
|
||||
<li><span className="font-medium text-gray-700">批號</span>:選填,若不填寫將自動對應「無批號 (NO-BATCH)」的庫存。</li>
|
||||
<li><span className="font-medium text-gray-700">備註</span>:選填,可填寫該筆明細的備註說明。</li>
|
||||
<li><span className="font-medium text-gray-700">附加模式</span>:匯入的明細將附加至現有明細,不會覆蓋原有資料。</li>
|
||||
</ul>
|
||||
</div>
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => onOpenChange(false)}
|
||||
disabled={processing}
|
||||
className="button-outlined-primary"
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit" disabled={!data.file || processing} className="button-filled-primary">
|
||||
{processing ? "匯入中..." : "開始匯入"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import { toast } from "sonner";
|
||||
import axios from "axios";
|
||||
import { Can } from '@/Components/Permission/Can';
|
||||
import { usePermission } from '@/hooks/usePermission';
|
||||
import TransferImportDialog from '@/Components/Transfer/TransferImportDialog';
|
||||
|
||||
export default function Show({ order }: any) {
|
||||
const { can } = usePermission();
|
||||
@@ -45,6 +46,15 @@ export default function Show({ order }: any) {
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null);
|
||||
const [isPostDialogOpen, setIsPostDialogOpen] = useState(false);
|
||||
const [isImportDialogOpen, setIsImportDialogOpen] = useState(false);
|
||||
|
||||
// 當 order prop 變動時 (例如匯入後 router.reload),同步更新內部狀態
|
||||
useEffect(() => {
|
||||
if (order) {
|
||||
setItems(order.items || []);
|
||||
setRemarks(order.remarks || "");
|
||||
}
|
||||
}, [order]);
|
||||
|
||||
// Product Selection
|
||||
const [isProductDialogOpen, setIsProductDialogOpen] = useState(false);
|
||||
@@ -105,26 +115,18 @@ export default function Show({ order }: any) {
|
||||
availableInventory.forEach(inv => {
|
||||
const key = `${inv.product_id}-${inv.batch_number}`;
|
||||
if (selectedInventory.includes(key)) {
|
||||
// Check if already added
|
||||
const exists = newItems.find((i: any) =>
|
||||
i.product_id === inv.product_id &&
|
||||
i.batch_number === inv.batch_number
|
||||
);
|
||||
|
||||
if (!exists) {
|
||||
newItems.push({
|
||||
product_id: inv.product_id,
|
||||
product_name: inv.product_name,
|
||||
product_code: inv.product_code,
|
||||
batch_number: inv.batch_number,
|
||||
expiry_date: inv.expiry_date,
|
||||
unit: inv.unit_name,
|
||||
quantity: 1, // Default 1
|
||||
max_quantity: inv.quantity, // Max available
|
||||
notes: "",
|
||||
});
|
||||
addedCount++;
|
||||
}
|
||||
newItems.push({
|
||||
product_id: inv.product_id,
|
||||
product_name: inv.product_name,
|
||||
product_code: inv.product_code,
|
||||
batch_number: inv.batch_number,
|
||||
expiry_date: inv.expiry_date,
|
||||
unit: inv.unit_name,
|
||||
quantity: 1, // Default 1
|
||||
max_quantity: inv.quantity, // Max available
|
||||
notes: "",
|
||||
});
|
||||
addedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -133,8 +135,6 @@ export default function Show({ order }: any) {
|
||||
|
||||
if (addedCount > 0) {
|
||||
toast.success(`已成功加入 ${addedCount} 個項目`);
|
||||
} else {
|
||||
toast.info("選取的商品已在清單中");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -170,6 +170,11 @@ export default function Show({ order }: any) {
|
||||
}, {
|
||||
onSuccess: () => {
|
||||
setIsPostDialogOpen(false);
|
||||
},
|
||||
onError: (errors) => {
|
||||
const message = Object.values(errors).join('\n') || "過帳失敗,請檢查輸入或庫存狀態";
|
||||
toast.error(message);
|
||||
setIsPostDialogOpen(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -184,6 +189,7 @@ export default function Show({ order }: any) {
|
||||
|
||||
const canEdit = can('inventory_transfer.edit');
|
||||
const isReadOnly = order.status !== 'draft' || !canEdit;
|
||||
const isVending = order.to_warehouse_type === 'vending';
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout
|
||||
@@ -312,7 +318,7 @@ export default function Show({ order }: any) {
|
||||
</div>
|
||||
) : (
|
||||
<Input
|
||||
value={remarks}
|
||||
value={remarks || ""}
|
||||
onChange={(e) => setRemarks(e.target.value)}
|
||||
className="h-9 focus:ring-primary-main"
|
||||
placeholder="填寫調撥單備註..."
|
||||
@@ -329,145 +335,157 @@ export default function Show({ order }: any) {
|
||||
</p>
|
||||
</div>
|
||||
{!isReadOnly && (
|
||||
<Dialog open={isProductDialogOpen} onOpenChange={setIsProductDialogOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="outline" className="button-outlined-primary">
|
||||
<Plus className="h-4 w-4 mr-2" />
|
||||
加入商品
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-4xl max-h-[85vh] flex flex-col p-6">
|
||||
<DialogHeader className="flex flex-row items-center justify-between space-y-0 pb-4">
|
||||
<DialogTitle className="text-xl">選擇來源庫存 ({order.from_warehouse_name})</DialogTitle>
|
||||
<div className="relative w-72">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-grey-3" />
|
||||
<Input
|
||||
placeholder="搜尋品名、代號或條碼..."
|
||||
className="pl-9 h-9 border-2 border-grey-3 focus:ring-primary-main"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
<div className="flex-1 overflow-auto pr-1">
|
||||
{loadingInventory ? (
|
||||
<div className="text-center py-12">
|
||||
<Package className="h-10 w-10 animate-bounce mx-auto text-gray-300 mb-2" />
|
||||
<p className="text-grey-2 text-sm">庫存資料載入中...</p>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" className="button-outlined-primary" onClick={() => setIsImportDialogOpen(true)}>
|
||||
<Package className="h-4 w-4 mr-2" />
|
||||
匯入 Excel
|
||||
</Button>
|
||||
<TransferImportDialog
|
||||
open={isImportDialogOpen}
|
||||
onOpenChange={setIsImportDialogOpen}
|
||||
orderId={order.id}
|
||||
/>
|
||||
|
||||
<Dialog open={isProductDialogOpen} onOpenChange={setIsProductDialogOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="outline" className="button-outlined-primary">
|
||||
<Plus className="h-4 w-4 mr-2" />
|
||||
加入商品
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-4xl max-h-[85vh] flex flex-col p-6">
|
||||
<DialogHeader className="flex flex-row items-center justify-between space-y-0 pb-4">
|
||||
<DialogTitle className="text-xl">選擇來源庫存 ({order.from_warehouse_name})</DialogTitle>
|
||||
<div className="relative w-72">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-grey-3" />
|
||||
<Input
|
||||
placeholder="搜尋品名、代號或條碼..."
|
||||
className="pl-9 h-9 border-2 border-grey-3 focus:ring-primary-main"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="border rounded-lg overflow-hidden">
|
||||
<Table>
|
||||
<TableHeader className="bg-gray-50/80 sticky top-0 z-10 shadow-sm">
|
||||
<TableRow>
|
||||
<TableHead className="w-[50px] text-center">
|
||||
<Checkbox
|
||||
checked={availableInventory.length > 0 && (() => {
|
||||
const filtered = availableInventory.filter(inv =>
|
||||
inv.product_name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
inv.product_code.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
(inv.product_barcode && inv.product_barcode.toLowerCase().includes(searchQuery.toLowerCase()))
|
||||
);
|
||||
const filteredKeys = filtered.map(inv => `${inv.product_id}-${inv.batch_number}`);
|
||||
return filteredKeys.length > 0 && filteredKeys.every(k => selectedInventory.includes(k));
|
||||
})()}
|
||||
onCheckedChange={() => toggleSelectAll()}
|
||||
/>
|
||||
</TableHead>
|
||||
</DialogHeader>
|
||||
<div className="flex-1 overflow-auto pr-1">
|
||||
{loadingInventory ? (
|
||||
<div className="text-center py-12">
|
||||
<Package className="h-10 w-10 animate-bounce mx-auto text-gray-300 mb-2" />
|
||||
<p className="text-grey-2 text-sm">庫存資料載入中...</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="border rounded-lg overflow-hidden">
|
||||
<Table>
|
||||
<TableHeader className="bg-gray-50/80 sticky top-0 z-10 shadow-sm">
|
||||
<TableRow>
|
||||
<TableHead className="w-[50px] text-center">
|
||||
<Checkbox
|
||||
checked={availableInventory.length > 0 && (() => {
|
||||
const filtered = availableInventory.filter(inv =>
|
||||
inv.product_name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
inv.product_code.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
(inv.product_barcode && inv.product_barcode.toLowerCase().includes(searchQuery.toLowerCase()))
|
||||
);
|
||||
const filteredKeys = filtered.map(inv => `${inv.product_id}-${inv.batch_number}`);
|
||||
return filteredKeys.length > 0 && filteredKeys.every(k => selectedInventory.includes(k));
|
||||
})()}
|
||||
onCheckedChange={() => toggleSelectAll()}
|
||||
/>
|
||||
</TableHead>
|
||||
|
||||
<TableHead className="font-medium text-grey-600">品名 / 代號</TableHead>
|
||||
<TableHead className="font-medium text-grey-600">批號</TableHead>
|
||||
<TableHead className="font-medium text-grey-600">效期</TableHead>
|
||||
<TableHead className="text-right font-medium text-grey-600 pr-6">現有庫存</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{(() => {
|
||||
const filtered = availableInventory.filter(inv =>
|
||||
inv.product_name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
inv.product_code.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
(inv.product_barcode && inv.product_barcode.toLowerCase().includes(searchQuery.toLowerCase()))
|
||||
);
|
||||
|
||||
if (filtered.length === 0) {
|
||||
return (
|
||||
<TableRow>
|
||||
<TableCell colSpan={5} className="text-center py-12 text-grey-3 italic font-medium">
|
||||
{searchQuery ? `找不到與 "${searchQuery}" 相關的商品` : '尚無庫存資料'}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableHead className="font-medium text-grey-600">品名 / 代號</TableHead>
|
||||
<TableHead className="font-medium text-grey-600">批號</TableHead>
|
||||
<TableHead className="font-medium text-grey-600">效期</TableHead>
|
||||
<TableHead className="text-right font-medium text-grey-600 pr-6">現有庫存</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{(() => {
|
||||
const filtered = availableInventory.filter(inv =>
|
||||
inv.product_name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
inv.product_code.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
(inv.product_barcode && inv.product_barcode.toLowerCase().includes(searchQuery.toLowerCase()))
|
||||
);
|
||||
}
|
||||
|
||||
return filtered.map((inv) => {
|
||||
const key = `${inv.product_id}-${inv.batch_number}`;
|
||||
const isSelected = selectedInventory.includes(key);
|
||||
return (
|
||||
<TableRow
|
||||
key={key}
|
||||
className={`hover:bg-primary-lightest/20 cursor-pointer transition-colors ${isSelected ? 'bg-primary-lightest/40' : ''}`}
|
||||
onClick={() => toggleSelect(key)}
|
||||
>
|
||||
<TableCell className="text-center" onClick={(e) => e.stopPropagation()}>
|
||||
<Checkbox
|
||||
checked={isSelected}
|
||||
onCheckedChange={() => toggleSelect(key)}
|
||||
/>
|
||||
</TableCell>
|
||||
if (filtered.length === 0) {
|
||||
return (
|
||||
<TableRow>
|
||||
<TableCell colSpan={5} className="text-center py-12 text-grey-3 italic font-medium">
|
||||
{searchQuery ? `找不到與 "${searchQuery}" 相關的商品` : '尚無庫存資料'}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
}
|
||||
|
||||
<TableCell className="py-3">
|
||||
<div className="flex flex-col">
|
||||
<span className="font-semibold text-grey-0">{inv.product_name}</span>
|
||||
<span className="text-xs text-grey-2 font-mono">{inv.product_code}</span>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-sm font-mono text-grey-2">{inv.batch_number || '-'}</TableCell>
|
||||
<TableCell className="text-sm font-mono text-grey-2">{inv.expiry_date || '-'}</TableCell>
|
||||
<TableCell className="text-right font-bold text-primary-main pr-6">{inv.quantity} {inv.unit_name}</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
});
|
||||
})()}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-6 flex items-center justify-between border-t pt-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="px-3 py-1 bg-primary-lightest/50 border border-primary-light/20 rounded-full text-sm font-medium text-primary-main animate-in zoom-in duration-200">
|
||||
已選取 {selectedInventory.length} 項商品
|
||||
</div>
|
||||
{selectedInventory.length > 0 && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="text-grey-3 hover:text-red-500 hover:bg-red-50 text-xs px-2 h-7"
|
||||
onClick={() => setSelectedInventory([])}
|
||||
>
|
||||
清除全部
|
||||
</Button>
|
||||
return filtered.map((inv) => {
|
||||
const key = `${inv.product_id}-${inv.batch_number}`;
|
||||
const isSelected = selectedInventory.includes(key);
|
||||
return (
|
||||
<TableRow
|
||||
key={key}
|
||||
className={`hover:bg-primary-lightest/20 cursor-pointer transition-colors ${isSelected ? 'bg-primary-lightest/40' : ''}`}
|
||||
onClick={() => toggleSelect(key)}
|
||||
>
|
||||
<TableCell className="text-center" onClick={(e) => e.stopPropagation()}>
|
||||
<Checkbox
|
||||
checked={isSelected}
|
||||
onCheckedChange={() => toggleSelect(key)}
|
||||
/>
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="py-3">
|
||||
<div className="flex flex-col">
|
||||
<span className="font-semibold text-grey-0">{inv.product_name}</span>
|
||||
<span className="text-xs text-grey-2 font-mono">{inv.product_code}</span>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-sm font-mono text-grey-2">{inv.batch_number || '-'}</TableCell>
|
||||
<TableCell className="text-sm font-mono text-grey-2">{inv.expiry_date || '-'}</TableCell>
|
||||
<TableCell className="text-right font-bold text-primary-main pr-6">{inv.quantity} {inv.unit_name}</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
});
|
||||
})()}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
className="button-outlined-primary w-24"
|
||||
onClick={() => setIsProductDialogOpen(false)}
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
<Button
|
||||
className="button-filled-primary min-w-32"
|
||||
disabled={selectedInventory.length === 0}
|
||||
onClick={handleAddSelected}
|
||||
>
|
||||
確認加入選取項
|
||||
</Button>
|
||||
<div className="mt-6 flex items-center justify-between border-t pt-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="px-3 py-1 bg-primary-lightest/50 border border-primary-light/20 rounded-full text-sm font-medium text-primary-main animate-in zoom-in duration-200">
|
||||
已選取 {selectedInventory.length} 項商品
|
||||
</div>
|
||||
{selectedInventory.length > 0 && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="text-grey-3 hover:text-red-500 hover:bg-red-50 text-xs px-2 h-7"
|
||||
onClick={() => setSelectedInventory([])}
|
||||
>
|
||||
清除全部
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
className="button-outlined-primary w-24"
|
||||
onClick={() => setIsProductDialogOpen(false)}
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
<Button
|
||||
className="button-filled-primary min-w-32"
|
||||
disabled={selectedInventory.length === 0}
|
||||
onClick={handleAddSelected}
|
||||
>
|
||||
確認加入選取項
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -483,6 +501,7 @@ export default function Show({ order }: any) {
|
||||
</TableHead>
|
||||
<TableHead className="text-right w-40 font-medium text-grey-600">調撥數量</TableHead>
|
||||
<TableHead className="font-medium text-grey-600">單位</TableHead>
|
||||
{isVending && <TableHead className="font-medium text-grey-600">貨道</TableHead>}
|
||||
<TableHead className="font-medium text-grey-600">備註</TableHead>
|
||||
{!isReadOnly && <TableHead className="w-[50px]"></TableHead>}
|
||||
</TableRow>
|
||||
@@ -490,7 +509,7 @@ export default function Show({ order }: any) {
|
||||
<TableBody>
|
||||
{items.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={8} className="text-center h-24 text-gray-500">
|
||||
<TableCell colSpan={isVending ? 9 : 8} className="text-center h-24 text-gray-500">
|
||||
尚未加入商品
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
@@ -524,7 +543,7 @@ export default function Show({ order }: any) {
|
||||
type="number"
|
||||
min="0.01"
|
||||
step="any"
|
||||
value={item.quantity}
|
||||
value={item.quantity ?? ""}
|
||||
onChange={(e) => handleUpdateItem(index, 'quantity', e.target.value)}
|
||||
className="h-9 w-32 font-medium focus:ring-primary-main text-right"
|
||||
/>
|
||||
@@ -532,12 +551,26 @@ export default function Show({ order }: any) {
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell className="text-sm text-gray-500">{item.unit || item.unit_name}</TableCell>
|
||||
{isVending && (
|
||||
<TableCell className="px-1">
|
||||
{isReadOnly ? (
|
||||
<span className="text-sm font-medium">{item.position}</span>
|
||||
) : (
|
||||
<Input
|
||||
value={item.position || ""}
|
||||
onChange={(e) => handleUpdateItem(index, 'position', e.target.value)}
|
||||
placeholder="貨道..."
|
||||
className="h-9 w-24 text-sm font-medium"
|
||||
/>
|
||||
)}
|
||||
</TableCell>
|
||||
)}
|
||||
<TableCell className="px-1">
|
||||
{isReadOnly ? (
|
||||
<span className="text-sm text-gray-600">{item.notes}</span>
|
||||
) : (
|
||||
<Input
|
||||
value={item.notes}
|
||||
value={item.notes || ""}
|
||||
onChange={(e) => handleUpdateItem(index, 'notes', e.target.value)}
|
||||
placeholder="備註..."
|
||||
className="h-9 text-sm"
|
||||
|
||||
Reference in New Issue
Block a user