Selaa lähdekoodia

stocktaked/appovered logic update

stockTakeUpdate
CANCERYS\kw093 1 viikko sitten
vanhempi
commit
5935ab1631
4 muutettua tiedostoa jossa 75 lisäystä ja 5 poistoa
  1. +12
    -0
      src/app/api/stockTake/actions.ts
  2. +59
    -5
      src/components/StockTakeManagement/PickerCardList.tsx
  3. +2
    -0
      src/i18n/en/stockTake.json
  4. +2
    -0
      src/i18n/zh/stockTake.json

+ 12
- 0
src/app/api/stockTake/actions.ts Näytä tiedosto

@@ -449,6 +449,18 @@ export const getSectionCreateItemOverlaps = async (sections: string[]) => {
);
};

/** Sections that currently have no creatable lots (would become empty headers). */
export const getSectionsWithNoAvailableLots = async (sections: string[]) => {
const list = sections.map((s) => s.trim()).filter((s) => s.length > 0);
if (list.length === 0) return [] as string[];
const params = new URLSearchParams();
list.forEach((s) => params.append("sections", s));
return serverFetchJson<string[]>(
`${BASE_API_URL}/stockTakeRecord/sectionsWithNoAvailableLots?${params.toString()}`,
{ method: "GET" },
);
};

export const getAvailableLotsForStockTakeCreate = async (
itemIds: number[],
lotOrigin?: string | null,


+ 59
- 5
src/components/StockTakeManagement/PickerCardList.tsx Näytä tiedosto

@@ -55,6 +55,7 @@ import {
getBusyStockTakeSections,
getAvailableLotsForStockTakeCreate,
getSectionCreateItemOverlaps,
getSectionsWithNoAvailableLots,
searchItemsForStockTakeCreate,
type SectionCreateItemOverlap,
type StockTakeCreateLotOption,
@@ -362,6 +363,7 @@ const PickerCardList: React.FC<PickerCardListProps> = ({
const [createDialogLotsLoading, setCreateDialogLotsLoading] = useState(false);
const [createDialogItemSearching, setCreateDialogItemSearching] = useState(false);
const [sectionItemOverlaps, setSectionItemOverlaps] = useState<SectionCreateItemOverlap[]>([]);
const [sectionEmptySections, setSectionEmptySections] = useState<string[]>([]);
const [sectionOverlapsLoading, setSectionOverlapsLoading] = useState(false);
const [sectionsLoading, setSectionsLoading] = useState(false);
const [stockTakeSectionRows, setStockTakeSectionRows] = useState<StockTakeSectionInfo[]>([]);
@@ -1206,25 +1208,32 @@ const PickerCardList: React.FC<PickerCardListProps> = ({
useEffect(() => {
if (!openConfirmDialog || createMode !== "section") {
setSectionItemOverlaps([]);
setSectionEmptySections([]);
setSectionOverlapsLoading(false);
return;
}
const sections = createDialogSelectedSections.map((s) => s.trim()).filter((s) => s.length > 0);
if (sections.length === 0) {
setSectionItemOverlaps([]);
setSectionEmptySections([]);
setSectionOverlapsLoading(false);
return;
}
let cancelled = false;
const timer = window.setTimeout(() => {
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) => {
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(() => {
if (!cancelled) setSectionOverlapsLoading(false);
@@ -1339,6 +1348,7 @@ const PickerCardList: React.FC<PickerCardListProps> = ({
setCreateDialogLotOptions([]);
setCreateDialogSelectedLotLineIds([]);
setSectionItemOverlaps([]);
setSectionEmptySections([]);
setSectionOverlapsLoading(false);
onCreateDialogClose?.();
};
@@ -2053,6 +2063,28 @@ const PickerCardList: React.FC<PickerCardListProps> = ({
…
</Typography>
) : 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 ? (
<Alert severity="warning" sx={{ py: 0.5, alignItems: "flex-start" }}>
<Typography variant="caption" fontWeight={700} display="block" sx={{ mb: 0.5 }}>
@@ -2547,6 +2579,28 @@ const PickerCardList: React.FC<PickerCardListProps> = ({
</Typography>{" "}
{createMode === "item" ? t("lots unit") : t("sections unit")}
</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 ? (
<Alert severity="warning" sx={{ py: 0.75 }}>
<Typography variant="body2" fontWeight={700} sx={{ mb: 0.5 }}>


+ 2
- 0
src/i18n/en/stockTake.json Näytä tiedosto

@@ -64,6 +64,8 @@
"Confirm create stock take": "Confirm create stock take",
"Section create item overlap title": "These items are already in an open item stock-take round; this round will skip them",
"Section create item overlap line": "Item {{item}} is in round #{{round}}{{roundName}}; this round will not include it (section {{section}})",
"Section create empty lots title": "These sections have no lots available to stock-take",
"Section create empty lots hint": "Creating them will add empty section headers (excluded from round progress). Uncheck them, or continue anyway.",
"Control Time": "Time spent",
"Create by item": "Item stock-take",
"Create by section": "Location stock-take",


+ 2
- 0
src/i18n/zh/stockTake.json Näytä tiedosto

@@ -185,6 +185,8 @@
"Confirm create stock take": "確認建立盤點",
"Section create item overlap title": "以下貨品已在進行中的貨品盤點輪,本輪會略過(不會盤到)",
"Section create item overlap line": "貨品 {{item}} 正由輪次 #{{round}}{{roundName}} 盤點中,本輪不會包含此貨品(區域 {{section}})",
"Section create empty lots title": "以下區域目前沒有可盤批號",
"Section create empty lots hint": "建立後會變成沒有明細的空區(不計入輪次進度)。可取消勾選後再建立,或仍繼續建立。",
"Not filled": "(未填寫)",
"Warehouse missing stock take section drawer hint": "以下倉庫位置尚未設定盤點區域(ST-xxx),無法納入盤點區域選擇。請點各筆「前往此倉庫設定」補上。",
"Warehouse missing stock take section showing": "顯示前 {{shown}} 筆,共 {{count}} 筆",


Ladataan…
Peruuta
Tallenna