|
|
|
@@ -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<string>("All"); |
|
|
|
const [filterStockTakeSession, setFilterStockTakeSession] = useState<string>(""); |
|
|
|
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<PickerSearchKey>[] = [ |
|
|
|
{ |
|
|
|
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<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 statusLower = status.toLowerCase(); |
|
|
|
if (statusLower === "completed") return "success"; |
|
|
|
|