feat(inventory): 開放倉庫編號編輯、優化調撥單條碼搜尋與庫存匯入範本雙分頁說明

This commit is contained in:
2026-02-06 16:36:14 +08:00
parent 200d1989bd
commit e018b75783
11 changed files with 555 additions and 20 deletions

View File

@@ -84,7 +84,8 @@ export default function Show({ order }: any) {
const toggleSelectAll = () => {
const filtered = availableInventory.filter(inv =>
inv.product_name.toLowerCase().includes(searchQuery.toLowerCase()) ||
inv.product_code.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}`);
@@ -338,10 +339,10 @@ export default function Show({ order }: any) {
<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-64">
<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="搜尋品名代號..."
placeholder="搜尋品名代號或條碼..."
className="pl-9 h-9 border-2 border-grey-3 focus:ring-primary-main"
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
@@ -364,7 +365,8 @@ export default function Show({ order }: any) {
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_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));
@@ -383,7 +385,8 @@ export default function Show({ order }: any) {
{(() => {
const filtered = availableInventory.filter(inv =>
inv.product_name.toLowerCase().includes(searchQuery.toLowerCase()) ||
inv.product_code.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) {

View File

@@ -1,5 +1,5 @@
import { useState, useMemo } from "react";
import { ArrowLeft, PackagePlus, AlertTriangle, Shield, Boxes } from "lucide-react";
import { ArrowLeft, PackagePlus, AlertTriangle, Shield, Boxes, FileUp } from "lucide-react";
import { Button } from "@/Components/ui/button";
import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout";
import { Head, Link, router } from "@inertiajs/react";
@@ -20,6 +20,7 @@ import {
AlertDialogTitle,
} from "@/Components/ui/alert-dialog";
import { Can } from "@/Components/Permission/Can";
import InventoryImportDialog from "@/Components/Warehouse/Inventory/InventoryImportDialog";
// 庫存頁面 Props
interface Props {
@@ -38,6 +39,7 @@ export default function WarehouseInventoryPage({
const [searchTerm, setSearchTerm] = useState("");
const [typeFilter, setTypeFilter] = useState<string>("all");
const [deleteId, setDeleteId] = useState<string | null>(null);
const [importDialogOpen, setImportDialogOpen] = useState(false);
// 篩選庫存列表
const filteredInventories = useMemo(() => {
@@ -157,6 +159,18 @@ export default function WarehouseInventoryPage({
{lowStockItems}
</Button>
{/* 匯入入庫按鈕 */}
<Can permission="inventory.adjust">
<Button
variant="outline"
className="button-outlined-primary"
onClick={() => setImportDialogOpen(true)}
>
<FileUp className="mr-2 h-4 w-4" />
</Button>
</Can>
{/* 新增庫存按鈕 */}
<Can permission="inventory.adjust">
<Link href={route('warehouses.inventory.create', warehouse.id)}>
@@ -210,6 +224,13 @@ export default function WarehouseInventoryPage({
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
{/* 匯入對話框 */}
<InventoryImportDialog
open={importDialogOpen}
onOpenChange={setImportDialogOpen}
warehouseId={warehouse.id}
/>
</div>
</AuthenticatedLayout>
);