From 93472687bd2c448905b0ef46f42a2c0693f55995 Mon Sep 17 00:00:00 2001 From: "vluk@2fi-solutions.com.hk" Date: Tue, 16 Jun 2026 00:42:27 +0800 Subject: [PATCH] no message --- src/app/api/do/actions.tsx | 57 +++++++++++++++++++ src/app/api/do/replenishmentTypes.ts | 34 +++++++++++ .../DoSearch/batchReleaseReplenishmentHtml.ts | 3 +- 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/app/api/do/replenishmentTypes.ts diff --git a/src/app/api/do/actions.tsx b/src/app/api/do/actions.tsx index e336cd1..0a60d3c 100644 --- a/src/app/api/do/actions.tsx +++ b/src/app/api/do/actions.tsx @@ -11,6 +11,12 @@ import { GridRowId, GridRowSelectionModel } from "@mui/x-data-grid"; import { GET } from "../auth/[...nextauth]/route"; import { stringify } from "querystring"; import { convertObjToURLSearchParams } from "@/app/utils/commonUtil"; +import type { + DoReplenishmentRecord, + SubmitDoReplenishmentLineRequest, +} from "./replenishmentTypes"; + +export type { DoReplenishmentRecord, SubmitDoReplenishmentLineRequest }; export interface CreateConsoDoInput { ids: GridRowSelectionModel; } @@ -27,6 +33,10 @@ export interface DoDetail { status: string; /** 加單 DO */ isExtra?: boolean; + /** 揀貨員名稱(delivery_order_pick_order.handlerName) */ + handlerName?: string | null; + /** 來源 DO 車線 */ + truckLaneCode?: string | null; deliveryOrderLines: DoDetailLine[]; } @@ -34,6 +44,8 @@ export interface DoDetailLine { id: number; itemNo: string; qty: number; + /** Sum of stock_out_line qty for linked pick order line; falls back to qty. */ + actualShippedQty?: number; price: number; status: string; itemName?: string; @@ -56,6 +68,7 @@ export interface DoSearchAll { shopName: string; shopAddress?: string; isExtra?: boolean; + truckLanceCode?: string | null; } export interface DoSearchLiteResponse { records: DoSearchAll[]; @@ -672,3 +685,47 @@ export async function fetchAllDoSearch( return data.records; } + +export async function submitDoReplenishment( + lines: SubmitDoReplenishmentLineRequest[], +): Promise { + return serverFetchJson(`${BASE_API_URL}/do/replenishment`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ lines }), + }); +} + +export async function fetchDoReplenishmentList(params: { + deliveryDate?: string; + status?: string; +}): Promise { + const query = convertObjToURLSearchParams({ + deliveryDate: params.deliveryDate || undefined, + status: params.status && params.status !== "all" ? params.status : undefined, + }); + const url = query + ? `${BASE_API_URL}/do/replenishment?${query}` + : `${BASE_API_URL}/do/replenishment`; + return serverFetchJson(url, { + method: "GET", + headers: { "Content-Type": "application/json" }, + }); +} + +export async function fetchDoReplenishmentForBatchRelease(params: { + truckLaneCode?: string; + shopName?: string; +}): Promise { + const query = convertObjToURLSearchParams({ + truckLaneCode: params.truckLaneCode?.trim() || undefined, + shopName: params.shopName?.trim() || undefined, + }); + return serverFetchJson( + `${BASE_API_URL}/do/replenishment/for-batch-release?${query}`, + { + method: "GET", + headers: { "Content-Type": "application/json" }, + }, + ); +} diff --git a/src/app/api/do/replenishmentTypes.ts b/src/app/api/do/replenishmentTypes.ts new file mode 100644 index 0000000..e4e7108 --- /dev/null +++ b/src/app/api/do/replenishmentTypes.ts @@ -0,0 +1,34 @@ +export interface SubmitDoReplenishmentLineRequest { + deliveryDate: string; + sourceDoId: number; + sourceDoLineId: number; + replenishQty: number; + truckLaneCode?: string; + reason?: string; +} + +export interface DoReplenishmentRecord { + id: number; + code: string; + deliveryDate: string; + sourceDoId: number; + sourceDoCode?: string; + sourceDoLineId: number; + itemId: number; + itemNo?: string; + itemName?: string; + originalQty?: number; + replenishQty: number; + shortUom?: string; + shopCode?: string; + shopName?: string; + truckLaneCode?: string; + targetDoId?: number; + targetDoCode?: string; + targetDoEstimatedArrivalDate?: string; + pickOrderLineId?: number; + deliveryOrderPickOrderId?: number; + status: string; + reason?: string; + created?: string; +} diff --git a/src/components/DoSearch/batchReleaseReplenishmentHtml.ts b/src/components/DoSearch/batchReleaseReplenishmentHtml.ts index 303e4bd..86666ce 100644 --- a/src/components/DoSearch/batchReleaseReplenishmentHtml.ts +++ b/src/components/DoSearch/batchReleaseReplenishmentHtml.ts @@ -1,4 +1,5 @@ -import { DoReplenishmentRecord, DoSearchAll } from "@/app/api/do/actions"; +import type { DoSearchAll } from "@/app/api/do/actions"; +import type { DoReplenishmentRecord } from "@/app/api/do/replenishmentTypes"; import { NAVIGATION_CONTENT_WIDTH } from "@/config/uiConfig"; import { TFunction } from "i18next";