From 7564ee01ebc2139aead5227cc87f17add4c825df Mon Sep 17 00:00:00 2001 From: "CANCERYS\\kw093" Date: Sun, 15 Mar 2026 09:40:13 +0800 Subject: [PATCH] update stock take drop down --- .../StockTakeManagement/PickerCardList.tsx | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/components/StockTakeManagement/PickerCardList.tsx b/src/components/StockTakeManagement/PickerCardList.tsx index b42009a..f1a766d 100644 --- a/src/components/StockTakeManagement/PickerCardList.tsx +++ b/src/components/StockTakeManagement/PickerCardList.tsx @@ -28,7 +28,9 @@ import { AllPickedStockTakeListReponse, createStockTakeForSections, getStockTakeRecordsPaged, + } from "@/app/api/stockTake/actions"; +import { fetchStockTakeSections } from "@/app/api/warehouse/actions"; import dayjs from "dayjs"; import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; @@ -53,6 +55,7 @@ const [total, setTotal] = useState(0); const [openConfirmDialog, setOpenConfirmDialog] = useState(false); const [filterSectionDescription, setFilterSectionDescription] = useState("All"); const [filterStockTakeSession, setFilterStockTakeSession] = useState(""); +const [sectionDescriptionAutocompleteOptions, setSectionDescriptionAutocompleteOptions] = useState<{ value: string; label: string }[]>([]); type PickerSearchKey = "sectionDescription" | "stockTakeSession"; const sectionDescriptionOptions = Array.from( new Set( @@ -86,10 +89,11 @@ const filteredSessions = stockTakeSessions.filter((s) => { // SearchBox 的条件配置 const criteria: Criterion[] = [ { - type: "select", + type: "autocomplete", label: t("Stock Take Section Description"), paramName: "sectionDescription", - options: sectionDescriptionOptions, + options: sectionDescriptionAutocompleteOptions, + needAll: true, }, { type: "text", @@ -164,7 +168,22 @@ const handleResetSearch = () => { setCreating(false); } }, [fetchStockTakeSessions, t]); - + useEffect(() => { + fetchStockTakeSections() + .then((sections) => { + const descSet = new Set(); + sections.forEach((s) => { + const desc = s.stockTakeSectionDescription?.trim(); + if (desc) descSet.add(desc); + }); + setSectionDescriptionAutocompleteOptions( + Array.from(descSet).map((desc) => ({ value: desc, label: desc })) + ); + }) + .catch((e) => { + console.error("Failed to load section descriptions for filter:", e); + }); + }, []); const getStatusColor = (status: string) => { const statusLower = status.toLowerCase(); if (statusLower === "completed") return "success";