| @@ -28,7 +28,9 @@ import { | |||||
| AllPickedStockTakeListReponse, | AllPickedStockTakeListReponse, | ||||
| createStockTakeForSections, | createStockTakeForSections, | ||||
| getStockTakeRecordsPaged, | getStockTakeRecordsPaged, | ||||
| } from "@/app/api/stockTake/actions"; | } from "@/app/api/stockTake/actions"; | ||||
| import { fetchStockTakeSections } from "@/app/api/warehouse/actions"; | |||||
| import dayjs from "dayjs"; | import dayjs from "dayjs"; | ||||
| import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; | import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; | ||||
| @@ -53,6 +55,7 @@ const [total, setTotal] = useState(0); | |||||
| const [openConfirmDialog, setOpenConfirmDialog] = useState(false); | const [openConfirmDialog, setOpenConfirmDialog] = useState(false); | ||||
| const [filterSectionDescription, setFilterSectionDescription] = useState<string>("All"); | const [filterSectionDescription, setFilterSectionDescription] = useState<string>("All"); | ||||
| const [filterStockTakeSession, setFilterStockTakeSession] = useState<string>(""); | const [filterStockTakeSession, setFilterStockTakeSession] = useState<string>(""); | ||||
| const [sectionDescriptionAutocompleteOptions, setSectionDescriptionAutocompleteOptions] = useState<{ value: string; label: string }[]>([]); | |||||
| type PickerSearchKey = "sectionDescription" | "stockTakeSession"; | type PickerSearchKey = "sectionDescription" | "stockTakeSession"; | ||||
| const sectionDescriptionOptions = Array.from( | const sectionDescriptionOptions = Array.from( | ||||
| new Set( | new Set( | ||||
| @@ -86,10 +89,11 @@ const filteredSessions = stockTakeSessions.filter((s) => { | |||||
| // SearchBox 的条件配置 | // SearchBox 的条件配置 | ||||
| const criteria: Criterion<PickerSearchKey>[] = [ | const criteria: Criterion<PickerSearchKey>[] = [ | ||||
| { | { | ||||
| type: "select", | |||||
| type: "autocomplete", | |||||
| label: t("Stock Take Section Description"), | label: t("Stock Take Section Description"), | ||||
| paramName: "sectionDescription", | paramName: "sectionDescription", | ||||
| options: sectionDescriptionOptions, | |||||
| options: sectionDescriptionAutocompleteOptions, | |||||
| needAll: true, | |||||
| }, | }, | ||||
| { | { | ||||
| type: "text", | type: "text", | ||||
| @@ -164,7 +168,22 @@ const handleResetSearch = () => { | |||||
| setCreating(false); | setCreating(false); | ||||
| } | } | ||||
| }, [fetchStockTakeSessions, t]); | }, [fetchStockTakeSessions, t]); | ||||
| useEffect(() => { | |||||
| fetchStockTakeSections() | |||||
| .then((sections) => { | |||||
| const descSet = new Set<string>(); | |||||
| 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 getStatusColor = (status: string) => { | ||||
| const statusLower = status.toLowerCase(); | const statusLower = status.toLowerCase(); | ||||
| if (statusLower === "completed") return "success"; | if (statusLower === "completed") return "success"; | ||||