Pārlūkot izejas kodu

stock take input fix

reset-do-picking-order
CANCERYS\kw093 pirms 2 nedēļām
vecāks
revīzija
131893efa0
2 mainītis faili ar 67 papildinājumiem un 17 dzēšanām
  1. +65
    -17
      src/components/StockTakeManagement/PickerStockTake.tsx
  2. +2
    -0
      src/i18n/zh/inventory.json

+ 65
- 17
src/components/StockTakeManagement/PickerStockTake.tsx Parādīt failu

@@ -137,24 +137,30 @@ const PickerStockTake: React.FC<PickerStockTakeProps> = ({
setLoadingDetails(false);
}
}, [selectedSession, total]);
useEffect(() => {
const inputs: Record<number, { firstQty: string; secondQty: string; firstBadQty: string; secondBadQty: string; remark: string }> = {};
inventoryLotDetails.forEach((detail) => {
const firstTotal = detail.firstStockTakeQty != null
? (detail.firstStockTakeQty + (detail.firstBadQty ?? 0)).toString()
: "";
const secondTotal = detail.secondStockTakeQty != null
? (detail.secondStockTakeQty + (detail.secondBadQty ?? 0)).toString()
: "";
inputs[detail.id] = {
firstQty: firstTotal,
secondQty: secondTotal,
firstBadQty: detail.firstBadQty?.toString() || "",
secondBadQty: detail.secondBadQty?.toString() || "",
remark: detail.remarks || "",
};
setRecordInputs((prev) => {
const next: Record<number, { firstQty: string; secondQty: string; firstBadQty: string; secondBadQty: string; remark: string }> = {};
inventoryLotDetails.forEach((detail) => {
const hasServerFirst = detail.firstStockTakeQty != null;
const hasServerSecond = detail.secondStockTakeQty != null;
const firstTotal = hasServerFirst
? (detail.firstStockTakeQty! + (detail.firstBadQty ?? 0)).toString()
: "";
const secondTotal = hasServerSecond
? (detail.secondStockTakeQty! + (detail.secondBadQty ?? 0)).toString()
: "";
const existing = prev[detail.id];
next[detail.id] = {
firstQty: hasServerFirst ? firstTotal : (existing?.firstQty ?? firstTotal),
secondQty: hasServerSecond ? secondTotal : (existing?.secondQty ?? secondTotal),
firstBadQty: hasServerFirst ? (detail.firstBadQty?.toString() || "") : (existing?.firstBadQty ?? ""),
secondBadQty: hasServerSecond ? (detail.secondBadQty?.toString() || "") : (existing?.secondBadQty ?? ""),
remark: hasServerSecond ? (detail.remarks || "") : (existing?.remark ?? detail.remarks ?? ""),
};
});
return next;
});
setRecordInputs(inputs);
}, [inventoryLotDetails]);
useEffect(() => {
loadDetails(page, pageSize);
@@ -399,7 +405,40 @@ const PickerStockTake: React.FC<PickerStockTakeProps> = ({
}
return false;
}, [selectedSession?.status]);

const handleSubmitAllInputted = useCallback(async () => {
if (!selectedSession || !currentUserId) return;
const toSave = inventoryLotDetails.filter((detail) => {
const submitDisabled = isSubmitDisabled(detail);
if (submitDisabled) return false;
const isFirstSubmit = !detail.stockTakeRecordId || !detail.firstStockTakeQty;
const isSecondSubmit = detail.stockTakeRecordId && detail.firstStockTakeQty && !detail.secondStockTakeQty;
const totalQtyStr = isFirstSubmit ? recordInputs[detail.id]?.firstQty : recordInputs[detail.id]?.secondQty;
return !!totalQtyStr && totalQtyStr.trim() !== "";
});
if (toSave.length === 0) {
onSnackbar(t("No valid input to submit"), "warning");
return;
}
setBatchSaving(true);
let successCount = 0;
let errorCount = 0;
for (const detail of toSave) {
try {
await handleSaveStockTake(detail);
successCount++;
} catch {
errorCount++;
}
}
setBatchSaving(false);
onSnackbar(
t("Submit completed: {{success}} success, {{errors}} errors", { success: successCount, errors: errorCount }),
errorCount > 0 ? "warning" : "success"
);
}, [inventoryLotDetails, recordInputs, isSubmitDisabled, handleSaveStockTake, selectedSession, currentUserId, onSnackbar, t]);
const uniqueWarehouses = Array.from(
new Set(
inventoryLotDetails
@@ -422,6 +461,15 @@ const PickerStockTake: React.FC<PickerStockTakeProps> = ({
<> {t("Warehouse")}: {uniqueWarehouses}</>
)}
</Typography>
{/*
<Button
variant="contained"
onClick={handleSubmitAllInputted}
disabled={batchSaving || saving}
>
{t("Submit All Inputted")}
</Button>
*/}
{/* 如果需要显示快捷键输入,可以把这块注释打开 */}
{/*
{shortcutInput && (


+ 2
- 0
src/i18n/zh/inventory.json Parādīt failu

@@ -16,6 +16,8 @@
"available": "可用",
"Issue Qty": "問題數量",
"tke": "盤點",
"Submit completed: {{success}} success, {{errors}} errors": "提交完成:{{success}} 成功,{{errors}} 錯誤",
"Submit All Inputted": "提交所有輸入",
"Submit Bad Item": "提交不良品",
"Remain available Quantity": "剩餘可用數量",
"Submitting...": "提交中...",


Notiek ielāde…
Atcelt
Saglabāt