From 97a0589caf65d5a0571f121aa440d42b6792a0d7 Mon Sep 17 00:00:00 2001 From: "kelvin.yau" Date: Fri, 26 Sep 2025 18:43:54 +0800 Subject: [PATCH 1/2] update --- src/app/api/do/actions.tsx | 29 +++++ .../FinishedGoodSearch/FinishedGoodSearch.tsx | 112 +++++++++++++++++- .../FinishedGoodSearch/GoodPickExecution.tsx | 2 +- src/i18n/zh/pickOrder.json | 4 +- 4 files changed, 140 insertions(+), 7 deletions(-) diff --git a/src/app/api/do/actions.tsx b/src/app/api/do/actions.tsx index 818dca4..34627af 100644 --- a/src/app/api/do/actions.tsx +++ b/src/app/api/do/actions.tsx @@ -8,6 +8,8 @@ import { QcItemResult } from "../settings/qcItem"; import { RecordsRes } from "../utils"; import { DoResult } from "."; import { GridRowId, GridRowSelectionModel } from "@mui/x-data-grid"; +import { GET } from "../auth/[...nextauth]/route"; +import { stringify } from "querystring"; export interface CreateConsoDoInput { ids: GridRowSelectionModel; @@ -70,6 +72,21 @@ export interface AssignByStoreResponse { errorPosition: string; entity: any; } + +export interface PrintDeliveryNoteRequest{ + deliveryOrderId: number; + printerId: number; + printQty: number; + numOfCarton: number; + isDraft: boolean; + pickOrderId: number; +} + +export interface PrintDeliveryNoteResponse{ + success: boolean; + message?: string +} + export const assignPickOrderByStore = cache(async (data: AssignByStoreRequest) => { return await serverFetchJson(`${BASE_API_URL}/doPickOrder/assign-by-store`, { @@ -128,3 +145,15 @@ export const fetchDoSearch = cache(async (code: string, shopName: string, status }); +export async function printDN(request: PrintDeliveryNoteRequest){ + const response = await serverFetchJson(`${BASE_API_URL}/do/print-DN`,{ + method: "GET", + body: JSON.stringify(request), + headers: { + 'Content-type': 'application/json', + }, + }); + return response; +} + + diff --git a/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx b/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx index 0d9087e..b376c15 100644 --- a/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx +++ b/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx @@ -24,11 +24,15 @@ import NewCreateItem from "./newcreatitem"; import AssignAndRelease from "./AssignAndRelease"; import AssignTo from "./assignTo"; import { fetchAllItemsInClient, ItemCombo } from "@/app/api/settings/item/actions"; -import { fetchPickOrderClient, autoAssignAndReleasePickOrder, autoAssignAndReleasePickOrderByStore } from "@/app/api/pickOrder/actions"; +import { fetchPickOrderClient, autoAssignAndReleasePickOrder, autoAssignAndReleasePickOrderByStore, FGPickOrderResponse, fetchFGPickOrders } from "@/app/api/pickOrder/actions"; import Jobcreatitem from "./Jobcreatitem"; import { useSession } from "next-auth/react"; import { SessionWithTokens } from "@/config/authConfig"; import PickExecutionDetail from "./GoodPickExecutiondetail"; +import Swal from "sweetalert2"; +import { PrintDeliveryNoteRequest, printDN } from "@/app/api/do/actions"; + + interface Props { pickOrders: PickOrderResult[]; } @@ -52,6 +56,9 @@ const PickOrderSearch: React.FC = ({ pickOrders }) => { const [tabIndex, setTabIndex] = useState(0); const [totalCount, setTotalCount] = useState(); const [isAssigning, setIsAssigning] = useState(false); + + const [fgPickOrdersData, setFgPickOrdersData] = useState([]); + const handleAssignByStore = async (storeId: "2/F" | "4/F") => { if (!currentUserId) { console.error("Missing user id in session"); @@ -109,6 +116,101 @@ const PickOrderSearch: React.FC = ({ pickOrders }) => { setIsOpenCreateModal(false) }, []) + const handleDN = useCallback(async () =>{ + const askNumofCarton = await Swal.fire({ + title: t("Enter the number of cartons: "), + 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"), + showLoaderOnConfirm: true, + allowOutsideClick: () => !Swal.isLoading() + }); + + if (askNumofCarton.isConfirmed) { + const numOfCartons = askNumofCarton.value; + console.log(numOfCartons) + } + },[t]); + + const handleDNandLabel = useCallback(async () =>{ + const askNumofCarton = await Swal.fire({ + title: t("Enter the number of cartons: "), + 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"), + showLoaderOnConfirm: true, + allowOutsideClick: () => !Swal.isLoading() + }); + + if (askNumofCarton.isConfirmed) { + const numOfCartons = askNumofCarton.value; + } + },[t]); + + const handleLabel = useCallback(async () =>{ + const askNumofCarton = await Swal.fire({ + title: t("Enter the number of cartons: "), + 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"), + showLoaderOnConfirm: true, + allowOutsideClick: () => !Swal.isLoading() + }); + + if (askNumofCarton.isConfirmed) { + const numOfCartons = askNumofCarton.value; + } + },[t]); + + const handleDraft = useCallback(async () =>{ + + },[t]); + useEffect(() => { @@ -294,10 +396,10 @@ const PickOrderSearch: React.FC = ({ pickOrders }) => { {/* First 4 buttons aligned left */} - - - - + + + + diff --git a/src/components/FinishedGoodSearch/GoodPickExecution.tsx b/src/components/FinishedGoodSearch/GoodPickExecution.tsx index 3db47c5..585704c 100644 --- a/src/components/FinishedGoodSearch/GoodPickExecution.tsx +++ b/src/components/FinishedGoodSearch/GoodPickExecution.tsx @@ -427,7 +427,7 @@ const PickExecution: React.FC = ({ filterArgs }) => { } finally { setCombinedDataLoading(false); } - }, [currentUserId]); + }, [currentUserId, combinedLotData]); // ✅ Only fetch existing data when session is ready, no auto-assignment useEffect(() => { diff --git a/src/i18n/zh/pickOrder.json b/src/i18n/zh/pickOrder.json index a814f08..7ab9838 100644 --- a/src/i18n/zh/pickOrder.json +++ b/src/i18n/zh/pickOrder.json @@ -273,7 +273,9 @@ "Print Draft":"列印草稿", "Print Pick Order and DN Label":"列印提料單和送貨單標貼", "Print Pick Order":"列印提料單", - "Print DN Label":"列印送貨單標貼" + "Print DN Label":"列印送貨單標貼", + "Enter the number of cartons: ": "請輸入總箱數", + "Number of cartons": "箱數" From 36fee57da240422c4511bf6706fd5b5fdf85cdaf Mon Sep 17 00:00:00 2001 From: "kelvin.yau" Date: Fri, 26 Sep 2025 18:54:07 +0800 Subject: [PATCH 2/2] fix --- .../FinishedGoodSearch/FinishedGoodSearch.tsx | 116 +----------------- 1 file changed, 1 insertion(+), 115 deletions(-) diff --git a/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx b/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx index 5cd6198..7a01600 100644 --- a/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx +++ b/src/components/FinishedGoodSearch/FinishedGoodSearch.tsx @@ -24,16 +24,12 @@ import NewCreateItem from "./newcreatitem"; import AssignAndRelease from "./AssignAndRelease"; import AssignTo from "./assignTo"; import { fetchAllItemsInClient, ItemCombo } from "@/app/api/settings/item/actions"; -import { fetchPickOrderClient, autoAssignAndReleasePickOrder, autoAssignAndReleasePickOrderByStore, FGPickOrderResponse, fetchFGPickOrders } from "@/app/api/pickOrder/actions"; +import { fetchPickOrderClient, autoAssignAndReleasePickOrder, autoAssignAndReleasePickOrderByStore } from "@/app/api/pickOrder/actions"; import Jobcreatitem from "./Jobcreatitem"; import { useSession } from "next-auth/react"; import { SessionWithTokens } from "@/config/authConfig"; import PickExecutionDetail from "./GoodPickExecutiondetail"; import GoodPickExecutionRecord from "./GoodPickExecutionRecord"; -import Swal from "sweetalert2"; -import { PrintDeliveryNoteRequest, printDN } from "@/app/api/do/actions"; - - interface Props { pickOrders: PickOrderResult[]; } @@ -69,9 +65,6 @@ const PickOrderSearch: React.FC = ({ pickOrders }) => { window.addEventListener('pickOrderAssigned', onAssigned); return () => window.removeEventListener('pickOrderAssigned', onAssigned); }, []); - - const [fgPickOrdersData, setFgPickOrdersData] = useState([]); - const handleAssignByStore = async (storeId: "2/F" | "4/F") => { if (!currentUserId) { console.error("Missing user id in session"); @@ -129,101 +122,6 @@ const PickOrderSearch: React.FC = ({ pickOrders }) => { setIsOpenCreateModal(false) }, []) - const handleDN = useCallback(async () =>{ - const askNumofCarton = await Swal.fire({ - title: t("Enter the number of cartons: "), - 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"), - showLoaderOnConfirm: true, - allowOutsideClick: () => !Swal.isLoading() - }); - - if (askNumofCarton.isConfirmed) { - const numOfCartons = askNumofCarton.value; - console.log(numOfCartons) - } - },[t]); - - const handleDNandLabel = useCallback(async () =>{ - const askNumofCarton = await Swal.fire({ - title: t("Enter the number of cartons: "), - 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"), - showLoaderOnConfirm: true, - allowOutsideClick: () => !Swal.isLoading() - }); - - if (askNumofCarton.isConfirmed) { - const numOfCartons = askNumofCarton.value; - } - },[t]); - - const handleLabel = useCallback(async () =>{ - const askNumofCarton = await Swal.fire({ - title: t("Enter the number of cartons: "), - 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"), - showLoaderOnConfirm: true, - allowOutsideClick: () => !Swal.isLoading() - }); - - if (askNumofCarton.isConfirmed) { - const numOfCartons = askNumofCarton.value; - } - },[t]); - - const handleDraft = useCallback(async () =>{ - - },[t]); - useEffect(() => { @@ -417,18 +315,6 @@ const PickOrderSearch: React.FC = ({ pickOrders }) => { - - - - {/* First 4 buttons aligned left */} - - - - - - - - {/* Last 2 buttons aligned right */}