|
|
@@ -55,6 +55,7 @@ import { |
|
|
getBusyStockTakeSections, |
|
|
getBusyStockTakeSections, |
|
|
getAvailableLotsForStockTakeCreate, |
|
|
getAvailableLotsForStockTakeCreate, |
|
|
getSectionCreateItemOverlaps, |
|
|
getSectionCreateItemOverlaps, |
|
|
|
|
|
getSectionsWithNoAvailableLots, |
|
|
searchItemsForStockTakeCreate, |
|
|
searchItemsForStockTakeCreate, |
|
|
type SectionCreateItemOverlap, |
|
|
type SectionCreateItemOverlap, |
|
|
type StockTakeCreateLotOption, |
|
|
type StockTakeCreateLotOption, |
|
|
@@ -362,6 +363,7 @@ const PickerCardList: React.FC<PickerCardListProps> = ({ |
|
|
const [createDialogLotsLoading, setCreateDialogLotsLoading] = useState(false); |
|
|
const [createDialogLotsLoading, setCreateDialogLotsLoading] = useState(false); |
|
|
const [createDialogItemSearching, setCreateDialogItemSearching] = useState(false); |
|
|
const [createDialogItemSearching, setCreateDialogItemSearching] = useState(false); |
|
|
const [sectionItemOverlaps, setSectionItemOverlaps] = useState<SectionCreateItemOverlap[]>([]); |
|
|
const [sectionItemOverlaps, setSectionItemOverlaps] = useState<SectionCreateItemOverlap[]>([]); |
|
|
|
|
|
const [sectionEmptySections, setSectionEmptySections] = useState<string[]>([]); |
|
|
const [sectionOverlapsLoading, setSectionOverlapsLoading] = useState(false); |
|
|
const [sectionOverlapsLoading, setSectionOverlapsLoading] = useState(false); |
|
|
const [sectionsLoading, setSectionsLoading] = useState(false); |
|
|
const [sectionsLoading, setSectionsLoading] = useState(false); |
|
|
const [stockTakeSectionRows, setStockTakeSectionRows] = useState<StockTakeSectionInfo[]>([]); |
|
|
const [stockTakeSectionRows, setStockTakeSectionRows] = useState<StockTakeSectionInfo[]>([]); |
|
|
@@ -1206,25 +1208,32 @@ const PickerCardList: React.FC<PickerCardListProps> = ({ |
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
if (!openConfirmDialog || createMode !== "section") { |
|
|
if (!openConfirmDialog || createMode !== "section") { |
|
|
setSectionItemOverlaps([]); |
|
|
setSectionItemOverlaps([]); |
|
|
|
|
|
setSectionEmptySections([]); |
|
|
setSectionOverlapsLoading(false); |
|
|
setSectionOverlapsLoading(false); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
const sections = createDialogSelectedSections.map((s) => s.trim()).filter((s) => s.length > 0); |
|
|
const sections = createDialogSelectedSections.map((s) => s.trim()).filter((s) => s.length > 0); |
|
|
if (sections.length === 0) { |
|
|
if (sections.length === 0) { |
|
|
setSectionItemOverlaps([]); |
|
|
setSectionItemOverlaps([]); |
|
|
|
|
|
setSectionEmptySections([]); |
|
|
setSectionOverlapsLoading(false); |
|
|
setSectionOverlapsLoading(false); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
let cancelled = false; |
|
|
let cancelled = false; |
|
|
const timer = window.setTimeout(() => { |
|
|
const timer = window.setTimeout(() => { |
|
|
setSectionOverlapsLoading(true); |
|
|
setSectionOverlapsLoading(true); |
|
|
getSectionCreateItemOverlaps(sections) |
|
|
|
|
|
.then((rows) => { |
|
|
|
|
|
if (!cancelled) setSectionItemOverlaps(Array.isArray(rows) ? rows : []); |
|
|
|
|
|
|
|
|
Promise.all([getSectionCreateItemOverlaps(sections), getSectionsWithNoAvailableLots(sections)]) |
|
|
|
|
|
.then(([rows, emptySections]) => { |
|
|
|
|
|
if (cancelled) return; |
|
|
|
|
|
setSectionItemOverlaps(Array.isArray(rows) ? rows : []); |
|
|
|
|
|
setSectionEmptySections(Array.isArray(emptySections) ? emptySections : []); |
|
|
}) |
|
|
}) |
|
|
.catch((e) => { |
|
|
.catch((e) => { |
|
|
console.error("Failed to load section create item overlaps:", e); |
|
|
|
|
|
if (!cancelled) setSectionItemOverlaps([]); |
|
|
|
|
|
|
|
|
console.error("Failed to load section create previews:", e); |
|
|
|
|
|
if (!cancelled) { |
|
|
|
|
|
setSectionItemOverlaps([]); |
|
|
|
|
|
setSectionEmptySections([]); |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
.finally(() => { |
|
|
.finally(() => { |
|
|
if (!cancelled) setSectionOverlapsLoading(false); |
|
|
if (!cancelled) setSectionOverlapsLoading(false); |
|
|
@@ -1339,6 +1348,7 @@ const PickerCardList: React.FC<PickerCardListProps> = ({ |
|
|
setCreateDialogLotOptions([]); |
|
|
setCreateDialogLotOptions([]); |
|
|
setCreateDialogSelectedLotLineIds([]); |
|
|
setCreateDialogSelectedLotLineIds([]); |
|
|
setSectionItemOverlaps([]); |
|
|
setSectionItemOverlaps([]); |
|
|
|
|
|
setSectionEmptySections([]); |
|
|
setSectionOverlapsLoading(false); |
|
|
setSectionOverlapsLoading(false); |
|
|
onCreateDialogClose?.(); |
|
|
onCreateDialogClose?.(); |
|
|
}; |
|
|
}; |
|
|
@@ -2053,6 +2063,28 @@ const PickerCardList: React.FC<PickerCardListProps> = ({ |
|
|
… |
|
|
… |
|
|
</Typography> |
|
|
</Typography> |
|
|
) : null} |
|
|
) : null} |
|
|
|
|
|
{createMode === "section" && sectionEmptySections.length > 0 ? ( |
|
|
|
|
|
<Alert severity="warning" sx={{ py: 0.5, alignItems: "flex-start" }}> |
|
|
|
|
|
<Typography variant="caption" fontWeight={700} display="block" sx={{ mb: 0.5 }}> |
|
|
|
|
|
{t("Section create empty lots title")} |
|
|
|
|
|
</Typography> |
|
|
|
|
|
<Typography variant="caption" display="block" sx={{ mb: 0.5 }}> |
|
|
|
|
|
{t("Section create empty lots hint")} |
|
|
|
|
|
</Typography> |
|
|
|
|
|
<Box component="ul" sx={{ m: 0, pl: 2, maxHeight: 100, overflowY: "auto" }}> |
|
|
|
|
|
{sectionEmptySections.map((section) => ( |
|
|
|
|
|
<Typography |
|
|
|
|
|
component="li" |
|
|
|
|
|
variant="caption" |
|
|
|
|
|
key={`empty-${section}`} |
|
|
|
|
|
sx={{ display: "list-item" }} |
|
|
|
|
|
> |
|
|
|
|
|
{section} |
|
|
|
|
|
</Typography> |
|
|
|
|
|
))} |
|
|
|
|
|
</Box> |
|
|
|
|
|
</Alert> |
|
|
|
|
|
) : null} |
|
|
{createMode === "section" && sectionItemOverlaps.length > 0 ? ( |
|
|
{createMode === "section" && sectionItemOverlaps.length > 0 ? ( |
|
|
<Alert severity="warning" sx={{ py: 0.5, alignItems: "flex-start" }}> |
|
|
<Alert severity="warning" sx={{ py: 0.5, alignItems: "flex-start" }}> |
|
|
<Typography variant="caption" fontWeight={700} display="block" sx={{ mb: 0.5 }}> |
|
|
<Typography variant="caption" fontWeight={700} display="block" sx={{ mb: 0.5 }}> |
|
|
@@ -2547,6 +2579,28 @@ const PickerCardList: React.FC<PickerCardListProps> = ({ |
|
|
</Typography>{" "} |
|
|
</Typography>{" "} |
|
|
{createMode === "item" ? t("lots unit") : t("sections unit")} |
|
|
{createMode === "item" ? t("lots unit") : t("sections unit")} |
|
|
</Typography> |
|
|
</Typography> |
|
|
|
|
|
{createMode === "section" && sectionEmptySections.length > 0 ? ( |
|
|
|
|
|
<Alert severity="warning" sx={{ py: 0.75 }}> |
|
|
|
|
|
<Typography variant="body2" fontWeight={700} sx={{ mb: 0.5 }}> |
|
|
|
|
|
{t("Section create empty lots title")} |
|
|
|
|
|
</Typography> |
|
|
|
|
|
<Typography variant="body2" sx={{ mb: 0.5 }}> |
|
|
|
|
|
{t("Section create empty lots hint")} |
|
|
|
|
|
</Typography> |
|
|
|
|
|
<Box component="ul" sx={{ m: 0, pl: 2, maxHeight: 120, overflowY: "auto" }}> |
|
|
|
|
|
{sectionEmptySections.map((section) => ( |
|
|
|
|
|
<Typography |
|
|
|
|
|
component="li" |
|
|
|
|
|
variant="body2" |
|
|
|
|
|
key={`confirm-empty-${section}`} |
|
|
|
|
|
sx={{ display: "list-item", mb: 0.5 }} |
|
|
|
|
|
> |
|
|
|
|
|
{section} |
|
|
|
|
|
</Typography> |
|
|
|
|
|
))} |
|
|
|
|
|
</Box> |
|
|
|
|
|
</Alert> |
|
|
|
|
|
) : null} |
|
|
{createMode === "section" && sectionItemOverlaps.length > 0 ? ( |
|
|
{createMode === "section" && sectionItemOverlaps.length > 0 ? ( |
|
|
<Alert severity="warning" sx={{ py: 0.75 }}> |
|
|
<Alert severity="warning" sx={{ py: 0.75 }}> |
|
|
<Typography variant="body2" fontWeight={700} sx={{ mb: 0.5 }}> |
|
|
<Typography variant="body2" fontWeight={700} sx={{ mb: 0.5 }}> |
|
|
|