From 16be668c6f864fa9efc8989115d0979d6311515f Mon Sep 17 00:00:00 2001 From: "kelvin.yau" Date: Sat, 18 Oct 2025 16:09:24 +0800 Subject: [PATCH] update --- .../FGPickOrderTicketReleaseTable.tsx | 91 ++++++ .../FinishedGoodSearch/FinishedGoodSearch.tsx | 292 +----------------- .../GoodPickExecutionRecord.tsx | 237 +++++++++++++- src/i18n/zh/pickOrder.json | 10 +- 4 files changed, 335 insertions(+), 295 deletions(-) create mode 100644 src/components/FinishedGoodSearch/FGPickOrderTicketReleaseTable.tsx diff --git a/src/components/FinishedGoodSearch/FGPickOrderTicketReleaseTable.tsx b/src/components/FinishedGoodSearch/FGPickOrderTicketReleaseTable.tsx new file mode 100644 index 0000000..b63c939 --- /dev/null +++ b/src/components/FinishedGoodSearch/FGPickOrderTicketReleaseTable.tsx @@ -0,0 +1,91 @@ +"use client"; + +import React, { useState } from 'react'; +import { + Box, + Typography, + FormControl, + InputLabel, + Select, + MenuItem, + Card, + CardContent, + Stack, +} from '@mui/material'; +import { useTranslation } from 'react-i18next'; +import dayjs from 'dayjs'; + +const FGPickOrderTicketReleaseTable: React.FC = () => { + const { t } = useTranslation("pickOrder"); + const [selectedDate, setSelectedDate] = useState("today"); + const [selectedFloor, setSelectedFloor] = useState(""); + + const getDateLabel = (offset: number) => { + return dayjs().add(offset, 'day').format('YYYY-MM-DD'); + }; + + return ( + + + {/* Title */} + + Ticket Release Table + + + {/* Dropdown Menus */} + + {/* Date Selection Dropdown */} + + {t("Select Date")} + + + + {/* Floor Selection Dropdown */} + + {t("Floor")} + + + + + {/* Table content will go here */} + + + {/* Add your table component here */} + Table content goes here... + + + + + ); +}; + +export default FGPickOrderTicketReleaseTable; \ No newline at end of file diff --git a/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx b/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx index 1186aa3..e6b43df 100644 --- a/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx +++ b/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx @@ -38,6 +38,7 @@ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import { DatePicker } from '@mui/x-date-pickers/DatePicker'; import dayjs, { Dayjs } from 'dayjs'; +import FGPickOrderTicketReleaseTable from "./FGPickOrderTicketReleaseTable"; interface Props { pickOrders: PickOrderResult[]; @@ -217,228 +218,7 @@ const PickOrderSearch: React.FC = ({ pickOrders }) => { },[t]); - const handleDN = useCallback(async () =>{ - const askNumofCarton = await Swal.fire({ - title: t("Enter the number of cartons: "), - icon: "info", - input: "number", - inputPlaceholder: t("Number of cartons"), - inputAttributes:{ - min: "1", - step: "1" - }, - inputValidator: (value) => { - if(!value){ - return t("You need to enter a number") - } - if(parseInt(value) < 1){ - return t("Number must be at least 1"); - } - return null - }, - showCancelButton: true, - confirmButtonText: t("Confirm"), - cancelButtonText: t("Cancel"), - confirmButtonColor: "#8dba00", - cancelButtonColor: "#F04438", - showLoaderOnConfirm: true, - allowOutsideClick: () => !Swal.isLoading() - }); - - if (askNumofCarton.isConfirmed) { - const numOfCartons = askNumofCarton.value; - try{ - if (fgPickOrdersData.length === 0) { - console.error("No FG Pick order data available"); - return; - } - - const currentFgOrder = fgPickOrdersData[0]; - - const printRequest = { - printerId: 1, - printQty: 1, - isDraft: false, - numOfCarton: numOfCartons, - deliveryOrderId: currentFgOrder.deliveryOrderId, - pickOrderId: currentFgOrder.pickOrderId - }; - - console.log("Printing Delivery Note with request: ", printRequest); - - const response = await printDN(printRequest); - - console.log("Print Delivery Note response: ", response); - - if(response.success){ - Swal.fire({ - position: "bottom-end", - icon: "success", - text: t("Printed Successfully."), - showConfirmButton: false, - timer: 1500 - }); - } else { - console.error("Print failed: ", response.message); - } - } catch(error){ - console.error("error: ", error) - } - } - },[t, fgPickOrdersData]); - - const handleDNandLabel = useCallback(async () =>{ - const askNumofCarton = await Swal.fire({ - title: t("Enter the number of cartons: "), - icon: "info", - input: "number", - inputPlaceholder: t("Number of cartons"), - inputAttributes:{ - min: "1", - step: "1" - }, - inputValidator: (value) => { - if(!value){ - return t("You need to enter a number") - } - if(parseInt(value) < 1){ - return t("Number must be at least 1"); - } - return null - }, - showCancelButton: true, - confirmButtonText: t("Confirm"), - cancelButtonText: t("Cancel"), - confirmButtonColor: "#8dba00", - cancelButtonColor: "#F04438", - showLoaderOnConfirm: true, - allowOutsideClick: () => !Swal.isLoading() - }); - - if (askNumofCarton.isConfirmed) { - const numOfCartons = askNumofCarton.value; - try{ - if (fgPickOrdersData.length === 0) { - console.error("No FG Pick order data available"); - return; - } - - const currentFgOrder = fgPickOrdersData[0]; - - const printDNRequest = { - printerId: 1, - printQty: 1, - isDraft: false, - numOfCarton: numOfCartons, - deliveryOrderId: currentFgOrder.deliveryOrderId, - pickOrderId: currentFgOrder.pickOrderId - }; - - const printDNLabelsRequest = { - printerId: 1, - printQty: 1, - numOfCarton: numOfCartons, - deliveryOrderId: currentFgOrder.deliveryOrderId - }; - - console.log("Printing Labels with request: ", printDNLabelsRequest); - console.log("Printing DN with request: ", printDNRequest); - - const LabelsResponse = await printDNLabels(printDNLabelsRequest); - const DNResponse = await printDN(printDNRequest); - - console.log("Print Labels response: ", LabelsResponse); - console.log("Print DN response: ", DNResponse); - - if(LabelsResponse.success && DNResponse.success){ - Swal.fire({ - position: "bottom-end", - icon: "success", - text: t("Printed Successfully."), - showConfirmButton: false, - timer: 1500 - }); - } else { - if(!LabelsResponse.success){ - console.error("Print failed: ", LabelsResponse.message); - } - else{ - console.error("Print failed: ", DNResponse.message); - } - } - } catch(error){ - console.error("error: ", error) - } - } - },[t, fgPickOrdersData]); - - const handleLabel = useCallback(async () =>{ - const askNumofCarton = await Swal.fire({ - title: t("Enter the number of cartons: "), - icon: "info", - input: "number", - inputPlaceholder: t("Number of cartons"), - inputAttributes:{ - min: "1", - step: "1" - }, - inputValidator: (value) => { - if(!value){ - return t("You need to enter a number") - } - if(parseInt(value) < 1){ - return t("Number must be at least 1"); - } - return null - }, - showCancelButton: true, - confirmButtonText: t("Confirm"), - cancelButtonText: t("Cancel"), - confirmButtonColor: "#8dba00", - cancelButtonColor: "#F04438", - showLoaderOnConfirm: true, - allowOutsideClick: () => !Swal.isLoading() - }); - - if (askNumofCarton.isConfirmed) { - const numOfCartons = askNumofCarton.value; - try{ - if (fgPickOrdersData.length === 0) { - console.error("No FG Pick order data available"); - return; - } - - const currentFgOrder = fgPickOrdersData[0]; - - const printRequest = { - printerId: 1, - printQty: 1, - numOfCarton: numOfCartons, - deliveryOrderId: currentFgOrder.deliveryOrderId, - }; - console.log("Printing Labels with request: ", printRequest); - - const response = await printDNLabels(printRequest); - - console.log("Print Labels response: ", response); - - if(response.success){ - Swal.fire({ - position: "bottom-end", - icon: "success", - text: t("Printed Successfully."), - showConfirmButton: false, - timer: 1500 - }); - } else { - console.error("Print failed: ", response.message); - } - } catch(error){ - console.error("error: ", error) - } - } - },[t, fgPickOrdersData]); useEffect(() => { fetchReleasedOrderCount(); @@ -776,7 +556,6 @@ const handleAssignByLane = useCallback(async ( > - - - @@ -895,6 +607,7 @@ const handleAssignByLane = useCallback(async ( + @@ -906,6 +619,7 @@ const handleAssignByLane = useCallback(async ( {tabIndex === 0 && } {tabIndex === 1 && } {tabIndex === 2 && } + {tabIndex === 3 && } ); diff --git a/src/components/FinishedGoodSearch/GoodPickExecutionRecord.tsx b/src/components/FinishedGoodSearch/GoodPickExecutionRecord.tsx index 5b02999..8ea96b2 100644 --- a/src/components/FinishedGoodSearch/GoodPickExecutionRecord.tsx +++ b/src/components/FinishedGoodSearch/GoodPickExecutionRecord.tsx @@ -41,10 +41,10 @@ import { checkPickOrderCompletion, PickOrderCompletionResponse, checkAndCompletePickOrderByConsoCode, - fetchCompletedDoPickOrders, // ✅ 新增:使用新的 API + fetchCompletedDoPickOrders, CompletedDoPickOrderResponse, CompletedDoPickOrderSearchParams, - fetchLotDetailsByPickOrderId // ✅ 修复:导入类型 + fetchLotDetailsByPickOrderId } from "@/app/api/pickOrder/actions"; import { fetchNameList, NameList } from "@/app/api/user/actions"; import { @@ -63,6 +63,9 @@ import GoodPickExecutionForm from "./GoodPickExecutionForm"; import FGPickOrderCard from "./FGPickOrderCard"; import dayjs from "dayjs"; import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; +import { printDN, printDNLabels } from "@/app/api/do/actions"; +import Swal from "sweetalert2"; + interface Props { filterArgs: Record; @@ -108,6 +111,205 @@ const GoodPickExecutionRecord: React.FC = ({ filterArgs }) => { const formProps = useForm(); const errors = formProps.formState.errors; + // ✅ Print handler functions + const handleDN = useCallback(async (deliveryOrderId: number, pickOrderId: number) => { + const askNumofCarton = await Swal.fire({ + title: t("Enter the number of cartons: "), + icon: "info", + input: "number", + inputPlaceholder: t("Number of cartons"), + inputAttributes:{ + min: "1", + step: "1" + }, + inputValidator: (value) => { + if(!value){ + return t("You need to enter a number") + } + if(parseInt(value) < 1){ + return t("Number must be at least 1"); + } + return null + }, + showCancelButton: true, + confirmButtonText: t("Confirm"), + cancelButtonText: t("Cancel"), + confirmButtonColor: "#8dba00", + cancelButtonColor: "#F04438", + showLoaderOnConfirm: true, + allowOutsideClick: () => !Swal.isLoading() + }); + + if (askNumofCarton.isConfirmed) { + const numOfCartons = askNumofCarton.value; + try{ + const printRequest = { + printerId: 1, + printQty: 1, + isDraft: false, + numOfCarton: numOfCartons, + deliveryOrderId: deliveryOrderId, + pickOrderId: pickOrderId + }; + + console.log("Printing Delivery Note with request: ", printRequest); + const response = await printDN(printRequest); + console.log("Print Delivery Note response: ", response); + + if(response.success){ + Swal.fire({ + position: "bottom-end", + icon: "success", + text: t("Printed Successfully."), + showConfirmButton: false, + timer: 1500 + }); + } else { + console.error("Print failed: ", response.message); + } + } catch(error){ + console.error("error: ", error) + } + } + }, [t]); + + const handleDNandLabel = useCallback(async (deliveryOrderId: number, pickOrderId: number) => { + const askNumofCarton = await Swal.fire({ + title: t("Enter the number of cartons: "), + icon: "info", + input: "number", + inputPlaceholder: t("Number of cartons"), + inputAttributes:{ + min: "1", + step: "1" + }, + inputValidator: (value) => { + if(!value){ + return t("You need to enter a number") + } + if(parseInt(value) < 1){ + return t("Number must be at least 1"); + } + return null + }, + showCancelButton: true, + confirmButtonText: t("Confirm"), + cancelButtonText: t("Cancel"), + confirmButtonColor: "#8dba00", + cancelButtonColor: "#F04438", + showLoaderOnConfirm: true, + allowOutsideClick: () => !Swal.isLoading() + }); + + if (askNumofCarton.isConfirmed) { + const numOfCartons = askNumofCarton.value; + try{ + const printDNRequest = { + printerId: 1, + printQty: 1, + isDraft: false, + numOfCarton: numOfCartons, + deliveryOrderId: deliveryOrderId, + pickOrderId: pickOrderId + }; + + const printDNLabelsRequest = { + printerId: 1, + printQty: 1, + numOfCarton: numOfCartons, + deliveryOrderId: deliveryOrderId + }; + + console.log("Printing Labels with request: ", printDNLabelsRequest); + console.log("Printing DN with request: ", printDNRequest); + + const LabelsResponse = await printDNLabels(printDNLabelsRequest); + const DNResponse = await printDN(printDNRequest); + + console.log("Print Labels response: ", LabelsResponse); + console.log("Print DN response: ", DNResponse); + + if(LabelsResponse.success && DNResponse.success){ + Swal.fire({ + position: "bottom-end", + icon: "success", + text: t("Printed Successfully."), + showConfirmButton: false, + timer: 1500 + }); + } else { + if(!LabelsResponse.success){ + console.error("Print failed: ", LabelsResponse.message); + } + else{ + console.error("Print failed: ", DNResponse.message); + } + } + } catch(error){ + console.error("error: ", error) + } + } + }, [t]); + + const handleLabel = useCallback(async (deliveryOrderId: number) => { + const askNumofCarton = await Swal.fire({ + title: t("Enter the number of cartons: "), + icon: "info", + input: "number", + inputPlaceholder: t("Number of cartons"), + inputAttributes:{ + min: "1", + step: "1" + }, + inputValidator: (value) => { + if(!value){ + return t("You need to enter a number") + } + if(parseInt(value) < 1){ + return t("Number must be at least 1"); + } + return null + }, + showCancelButton: true, + confirmButtonText: t("Confirm"), + cancelButtonText: t("Cancel"), + confirmButtonColor: "#8dba00", + cancelButtonColor: "#F04438", + showLoaderOnConfirm: true, + allowOutsideClick: () => !Swal.isLoading() + }); + + if (askNumofCarton.isConfirmed) { + const numOfCartons = askNumofCarton.value; + try{ + const printRequest = { + printerId: 1, + printQty: 1, + numOfCarton: numOfCartons, + deliveryOrderId: deliveryOrderId, + }; + + console.log("Printing Labels with request: ", printRequest); + const response = await printDNLabels(printRequest); + console.log("Print Labels response: ", response); + + if(response.success){ + Swal.fire({ + position: "bottom-end", + icon: "success", + text: t("Printed Successfully."), + showConfirmButton: false, + timer: 1500 + }); + } else { + console.error("Print failed: ", response.message); + } + } catch(error){ + console.error("error: ", error) + } + } + }, [t]); + // ✅ 修改:使用新的 API 获取已完成的 DO Pick Orders const fetchCompletedDoPickOrdersData = useCallback(async (searchParams?: CompletedDoPickOrderSearchParams) => { if (!currentUserId) return; @@ -406,6 +608,37 @@ const GoodPickExecutionRecord: React.FC = ({ filterArgs }) => { > {t("View Details")} + + {doPickOrder.fgPickOrders && doPickOrder.fgPickOrders.length > 0 && ( + <> + + + + + )} ))} diff --git a/src/i18n/zh/pickOrder.json b/src/i18n/zh/pickOrder.json index 00df638..31f6e3e 100644 --- a/src/i18n/zh/pickOrder.json +++ b/src/i18n/zh/pickOrder.json @@ -275,9 +275,9 @@ "Confirm":"確認", "Update your suggested lot to the this scanned lot":"更新您的建議批次為此掃描的批次", "Print Draft":"列印草稿", - "Print Pick Order and DN Label":"列印提料單和送貨單標貼", + "Print Pick Order and DN Label":"列印提料單和送貨單標籤", "Print Pick Order":"列印提料單", - "Print DN Label":"列印送貨單標貼", + "Print DN Label":"列印送貨單標籤", "Print All Draft" : "列印全部草稿", "If you confirm, the system will:":"如果您確認,系統將:", "QR code verified.":"QR 碼驗證成功。", @@ -289,7 +289,6 @@ "Completed DO pick orders: ":"已完成送貨單提料單:", "No completed DO pick orders found":"沒有已完成送貨單提料單", - "Print DN Label":"列印送貨單標貼", "Enter the number of cartons: ": "請輸入總箱數", "Number of cartons": "箱數", "Select an action for the assigned pick orders.": "選擇分配提料單的動作。", @@ -387,5 +386,8 @@ "Today": "是日", "Tomorrow": "翌日", "Day After Tomorrow": "後日", - "Select Date": "請選擇日期" + "Select Date": "請選擇日期", + "Print DN & Label": "列印提料單和送貨單標籤", + "Print Label": "列印送貨單標籤", + "Ticket Release Table": "查看提貨情況" } \ No newline at end of file