feat: 實作銷售單匯入管理、貨道扣庫優化及 UI 細節調整
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 1m8s

This commit is contained in:
2026-02-09 14:36:47 +08:00
parent 590580e20a
commit b6fe9ad9f3
22 changed files with 1274 additions and 33 deletions

View File

@@ -1,4 +1,4 @@
import { useState, useMemo } from "react";
import { useState, useMemo, useEffect } from "react";
import { ArrowLeft, PackagePlus, AlertTriangle, Shield, Boxes, FileUp } from "lucide-react";
import { Button } from "@/Components/ui/button";
import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout";
@@ -36,11 +36,31 @@ export default function WarehouseInventoryPage({
safetyStockSettings,
availableProducts,
}: Props) {
const [searchTerm, setSearchTerm] = useState("");
const [typeFilter, setTypeFilter] = useState<string>("all");
// 從 URL 讀取初始狀態
const queryParams = new URLSearchParams(window.location.search);
const [searchTerm, setSearchTerm] = useState(queryParams.get("search") || "");
const [typeFilter, setTypeFilter] = useState<string>(queryParams.get("type") || "all");
const [deleteId, setDeleteId] = useState<string | null>(null);
const [importDialogOpen, setImportDialogOpen] = useState(false);
// 當搜尋或篩選變更時,同步到 URL (使用 replace: true 避免產生過多歷史紀錄)
useEffect(() => {
const params: any = {};
if (searchTerm) params.search = searchTerm;
if (typeFilter !== "all") params.type = typeFilter;
router.get(
route("warehouses.inventory.index", warehouse.id),
params,
{
preserveState: true,
preserveScroll: true,
replace: true,
only: ["inventories"], // 僅重新拉取數據,避免全頁重新渲染 (如有後端過濾)
}
);
}, [searchTerm, typeFilter]);
// 篩選庫存列表
const filteredInventories = useMemo(() => {
return inventories.filter((group) => {