|
|
@@ -11,6 +11,12 @@ import { GridRowId, GridRowSelectionModel } from "@mui/x-data-grid"; |
|
|
import { GET } from "../auth/[...nextauth]/route"; |
|
|
import { GET } from "../auth/[...nextauth]/route"; |
|
|
import { stringify } from "querystring"; |
|
|
import { stringify } from "querystring"; |
|
|
import { convertObjToURLSearchParams } from "@/app/utils/commonUtil"; |
|
|
import { convertObjToURLSearchParams } from "@/app/utils/commonUtil"; |
|
|
|
|
|
import type { |
|
|
|
|
|
DoReplenishmentRecord, |
|
|
|
|
|
SubmitDoReplenishmentLineRequest, |
|
|
|
|
|
} from "./replenishmentTypes"; |
|
|
|
|
|
|
|
|
|
|
|
export type { DoReplenishmentRecord, SubmitDoReplenishmentLineRequest }; |
|
|
export interface CreateConsoDoInput { |
|
|
export interface CreateConsoDoInput { |
|
|
ids: GridRowSelectionModel; |
|
|
ids: GridRowSelectionModel; |
|
|
} |
|
|
} |
|
|
@@ -27,6 +33,10 @@ export interface DoDetail { |
|
|
status: string; |
|
|
status: string; |
|
|
/** 加單 DO */ |
|
|
/** 加單 DO */ |
|
|
isExtra?: boolean; |
|
|
isExtra?: boolean; |
|
|
|
|
|
/** 揀貨員名稱(delivery_order_pick_order.handlerName) */ |
|
|
|
|
|
handlerName?: string | null; |
|
|
|
|
|
/** 來源 DO 車線 */ |
|
|
|
|
|
truckLaneCode?: string | null; |
|
|
deliveryOrderLines: DoDetailLine[]; |
|
|
deliveryOrderLines: DoDetailLine[]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -34,6 +44,8 @@ export interface DoDetailLine { |
|
|
id: number; |
|
|
id: number; |
|
|
itemNo: string; |
|
|
itemNo: string; |
|
|
qty: number; |
|
|
qty: number; |
|
|
|
|
|
/** Sum of stock_out_line qty for linked pick order line; falls back to qty. */ |
|
|
|
|
|
actualShippedQty?: number; |
|
|
price: number; |
|
|
price: number; |
|
|
status: string; |
|
|
status: string; |
|
|
itemName?: string; |
|
|
itemName?: string; |
|
|
@@ -56,6 +68,7 @@ export interface DoSearchAll { |
|
|
shopName: string; |
|
|
shopName: string; |
|
|
shopAddress?: string; |
|
|
shopAddress?: string; |
|
|
isExtra?: boolean; |
|
|
isExtra?: boolean; |
|
|
|
|
|
truckLanceCode?: string | null; |
|
|
} |
|
|
} |
|
|
export interface DoSearchLiteResponse { |
|
|
export interface DoSearchLiteResponse { |
|
|
records: DoSearchAll[]; |
|
|
records: DoSearchAll[]; |
|
|
@@ -672,3 +685,47 @@ export async function fetchAllDoSearch( |
|
|
|
|
|
|
|
|
return data.records; |
|
|
return data.records; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function submitDoReplenishment( |
|
|
|
|
|
lines: SubmitDoReplenishmentLineRequest[], |
|
|
|
|
|
): Promise<DoReplenishmentRecord[]> { |
|
|
|
|
|
return serverFetchJson<DoReplenishmentRecord[]>(`${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<DoReplenishmentRecord[]> { |
|
|
|
|
|
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<DoReplenishmentRecord[]>(url, { |
|
|
|
|
|
method: "GET", |
|
|
|
|
|
headers: { "Content-Type": "application/json" }, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function fetchDoReplenishmentForBatchRelease(params: { |
|
|
|
|
|
truckLaneCode?: string; |
|
|
|
|
|
shopName?: string; |
|
|
|
|
|
}): Promise<DoReplenishmentRecord[]> { |
|
|
|
|
|
const query = convertObjToURLSearchParams({ |
|
|
|
|
|
truckLaneCode: params.truckLaneCode?.trim() || undefined, |
|
|
|
|
|
shopName: params.shopName?.trim() || undefined, |
|
|
|
|
|
}); |
|
|
|
|
|
return serverFetchJson<DoReplenishmentRecord[]>( |
|
|
|
|
|
`${BASE_API_URL}/do/replenishment/for-batch-release?${query}`, |
|
|
|
|
|
{ |
|
|
|
|
|
method: "GET", |
|
|
|
|
|
headers: { "Content-Type": "application/json" }, |
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
} |