|
|
@@ -35,7 +35,7 @@ import { |
|
|
fetchCompletedDoPickOrdersWorkbench, |
|
|
fetchCompletedDoPickOrdersWorkbench, |
|
|
fetchCompletedDoPickOrdersWorkbenchAll, |
|
|
fetchCompletedDoPickOrdersWorkbenchAll, |
|
|
} from "@/app/api/pickOrder/actions"; |
|
|
} from "@/app/api/pickOrder/actions"; |
|
|
import { printDNWorkbench, printDNLabelsWorkbench } from "@/app/api/do/actions"; |
|
|
|
|
|
|
|
|
import { printDNWorkbench, printDNLabelsWorkbench, printDNLabelsReprintWorkbench } from "@/app/api/do/actions"; |
|
|
import { fetchWorkbenchCompletedLotDetails } from "@/app/api/doworkbench/actions"; |
|
|
import { fetchWorkbenchCompletedLotDetails } from "@/app/api/doworkbench/actions"; |
|
|
import SearchBox, { Criterion } from "../SearchBox"; |
|
|
import SearchBox, { Criterion } from "../SearchBox"; |
|
|
|
|
|
|
|
|
@@ -281,6 +281,102 @@ const GoodPickExecutionWorkbenchRecord: React.FC<Props> = ({ |
|
|
}, |
|
|
}, |
|
|
[a4Printer, askNumOfCarton, labelPrinter, loadData, t], |
|
|
[a4Printer, askNumOfCarton, labelPrinter, loadData, t], |
|
|
); |
|
|
); |
|
|
|
|
|
const handleLabelReprint = useCallback(async (doPickOrder: CompletedDoPickOrderResponse) => { |
|
|
|
|
|
if (!labelPrinter) { |
|
|
|
|
|
Swal.fire({ |
|
|
|
|
|
position: "bottom-end", |
|
|
|
|
|
icon: "warning", |
|
|
|
|
|
text: t("Please select a label printer first"), |
|
|
|
|
|
showConfirmButton: false, |
|
|
|
|
|
timer: 1500 |
|
|
|
|
|
}); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const defaultTotalCartons = Math.max(1, doPickOrder.numberOfCartons || 1); |
|
|
|
|
|
const result = await Swal.fire({ |
|
|
|
|
|
title: t("Reprint DN Label"), |
|
|
|
|
|
html: ` |
|
|
|
|
|
<div style="display:flex;flex-direction:column;gap:10px;text-align:left;"> |
|
|
|
|
|
<div style="display:flex;align-items:center;gap:12px;"> |
|
|
|
|
|
<label for="swal-from-carton" style="min-width:120px;">${t("From carton")}</label> |
|
|
|
|
|
<input id="swal-from-carton" class="swal2-input" type="number" min="1" step="1" value="1" style="margin:0;flex:1;outline:none;box-shadow:none;border:1px solid #d9d9d9;" onfocus="this.style.outline='none';this.style.boxShadow='none';this.style.borderColor='#d9d9d9';" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div style="display:flex;align-items:center;gap:12px;"> |
|
|
|
|
|
<label for="swal-to-carton" style="min-width:120px;">${t("To carton")}</label> |
|
|
|
|
|
<input id="swal-to-carton" class="swal2-input" type="number" min="1" step="1" value="1" style="margin:0;flex:1;outline:none;box-shadow:none;border:1px solid #d9d9d9;" onfocus="this.style.outline='none';this.style.boxShadow='none';this.style.borderColor='#d9d9d9';" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div style="display:flex;align-items:center;gap:12px;"> |
|
|
|
|
|
<label for="swal-total-carton" style="min-width:120px;">${t("Total cartons on shipment")}</label> |
|
|
|
|
|
<input id="swal-total-carton" class="swal2-input" type="number" min="1" step="1" value="${defaultTotalCartons}" style="margin:0;flex:1;outline:none;box-shadow:none;border:1px solid #d9d9d9;" onfocus="this.style.outline='none';this.style.boxShadow='none';this.style.borderColor='#d9d9d9';" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
`, |
|
|
|
|
|
showCancelButton: true, |
|
|
|
|
|
confirmButtonText: t("Confirm"), |
|
|
|
|
|
cancelButtonText: t("Cancel"), |
|
|
|
|
|
confirmButtonColor: "#8dba00", |
|
|
|
|
|
cancelButtonColor: "#F04438", |
|
|
|
|
|
focusConfirm: false, |
|
|
|
|
|
preConfirm: () => { |
|
|
|
|
|
const fromCarton = Number((document.getElementById("swal-from-carton") as HTMLInputElement | null)?.value || "0"); |
|
|
|
|
|
const toCarton = Number((document.getElementById("swal-to-carton") as HTMLInputElement | null)?.value || "0"); |
|
|
|
|
|
const totalCartonsOnShipment = Number((document.getElementById("swal-total-carton") as HTMLInputElement | null)?.value || "0"); |
|
|
|
|
|
|
|
|
|
|
|
if (!Number.isInteger(fromCarton) || fromCarton < 1) { |
|
|
|
|
|
Swal.showValidationMessage(t("From carton must be at least 1")); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
if (!Number.isInteger(toCarton) || toCarton < fromCarton) { |
|
|
|
|
|
Swal.showValidationMessage(t("To carton must be greater than or equal to from carton")); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
if (!Number.isInteger(totalCartonsOnShipment) || totalCartonsOnShipment < 1) { |
|
|
|
|
|
Swal.showValidationMessage(t("Total cartons on shipment must be at least 1")); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
if (toCarton > totalCartonsOnShipment) { |
|
|
|
|
|
Swal.showValidationMessage(t("To carton cannot be greater than total cartons on shipment")); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
fromCarton, |
|
|
|
|
|
toCarton, |
|
|
|
|
|
totalCartonsOnShipment, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (!result.isConfirmed || !result.value) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const response = await printDNLabelsReprintWorkbench({ |
|
|
|
|
|
deliveryOrderPickOrderId: doPickOrder.doPickOrderRecordId, |
|
|
|
|
|
printerId: labelPrinter.id, |
|
|
|
|
|
printQty: 1, |
|
|
|
|
|
fromCarton: result.value.fromCarton, |
|
|
|
|
|
toCarton: result.value.toCarton, |
|
|
|
|
|
totalCartonsOnShipment: result.value.totalCartonsOnShipment, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (response.success) { |
|
|
|
|
|
Swal.fire({ |
|
|
|
|
|
position: "bottom-end", |
|
|
|
|
|
icon: "success", |
|
|
|
|
|
text: t("Printed Successfully."), |
|
|
|
|
|
showConfirmButton: false, |
|
|
|
|
|
timer: 1500 |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
console.error("Reprint failed:", response.message); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error("reprint error: ", error); |
|
|
|
|
|
} |
|
|
|
|
|
}, [labelPrinter, t]); |
|
|
|
|
|
|
|
|
const handleDetailClick = useCallback( |
|
|
const handleDetailClick = useCallback( |
|
|
async (record: CompletedDoPickOrderResponse) => { |
|
|
async (record: CompletedDoPickOrderResponse) => { |
|
|
@@ -547,6 +643,9 @@ const GoodPickExecutionWorkbenchRecord: React.FC<Props> = ({ |
|
|
<Button variant="contained" onClick={() => void handlePrintLabel(row.doPickOrderRecordId)}> |
|
|
<Button variant="contained" onClick={() => void handlePrintLabel(row.doPickOrderRecordId)}> |
|
|
{t("Print Label")} |
|
|
{t("Print Label")} |
|
|
</Button> |
|
|
</Button> |
|
|
|
|
|
<Button variant="contained" onClick={() => void handleLabelReprint(row)}> |
|
|
|
|
|
{t("Reprint Label(s)")} |
|
|
|
|
|
</Button> |
|
|
</CardActions> |
|
|
</CardActions> |
|
|
</Card> |
|
|
</Card> |
|
|
))} |
|
|
))} |
|
|
|