瀏覽代碼

update miss do

production
CANCERYS\kw093 1 天之前
父節點
當前提交
2064f7b380
共有 1 個檔案被更改,包括 25 行新增37 行删除
  1. +25
    -37
      src/app/api/do/actions.tsx

+ 25
- 37
src/app/api/do/actions.tsx 查看文件

@@ -364,12 +364,6 @@ export const fetchDoDetail = cache(async (id: number) => {
});
});

/** 車線搜尋為「車線-X」時改走後端專用 API(只含推算車線為 null/空白之送貨單) */
function isTruckLaneXSearch(truckLanceCode?: string): boolean {
const t = truckLanceCode?.trim().toLowerCase() ?? "";
return t === "車線-x";
}

export async function fetchDoSearch(
code: string,
shopName: string,
@@ -380,7 +374,9 @@ export async function fetchDoSearch(
estArrEndDate: string,
pageNum?: number,
pageSize?: number,
truckLanceCode?: string
truckLanceCode?: string,
/** 後端:All/null 為全部;2F/4F 依供應商白名單篩選 */
floor?: string | null,
): Promise<DoSearchLiteResponse> {
// 构建请求体
const requestBody: any = {
@@ -391,6 +387,7 @@ export async function fetchDoSearch(
truckLanceCode: truckLanceCode || null,
pageNum: pageNum || 1,
pageSize: pageSize || 10,
floor: floor && floor !== "All" ? floor : null,
};

// 如果日期不为空,转换为 LocalDateTime 格式
@@ -400,20 +397,15 @@ export async function fetchDoSearch(
requestBody.estimatedArrivalDate = null;
}

const useUnassignedTruck = isTruckLaneXSearch(truckLanceCode);
if (useUnassignedTruck) {
delete requestBody.truckLanceCode;
}

const url = useUnassignedTruck
? `${BASE_API_URL}/do/search-do-lite-unassigned-truck`
: `${BASE_API_URL}/do/search-do-lite`;

const data = await serverFetchJson<DoSearchLiteResponse>(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(requestBody),
});
/** v2:車線正規化、未指派合併、分批掃描(後端 /do/search-do-lite-v2) */
const data = await serverFetchJson<DoSearchLiteResponse>(
`${BASE_API_URL}/do/search-do-lite-v2`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(requestBody),
},
);

return data;
}
@@ -633,7 +625,8 @@ export async function fetchAllDoSearch(
shopName: string,
status: string,
estArrStartDate: string,
truckLanceCode?: string // 添加这个参数
truckLanceCode?: string,
floor?: string | null,
): Promise<DoSearchAll[]> {
// 使用一个很大的 pageSize 来获取所有匹配的记录
const requestBody: any = {
@@ -641,9 +634,10 @@ export async function fetchAllDoSearch(
shopName: shopName || null,
status: status || null,
estimatedArrivalDate: estArrStartDate || null,
truckLanceCode: truckLanceCode || null, // 添加这个字段
truckLanceCode: truckLanceCode || null,
pageNum: 1,
pageSize: 10000, // 使用一个很大的值来获取所有记录
floor: floor && floor !== "All" ? floor : null,
};

if (estArrStartDate) {
@@ -652,20 +646,14 @@ export async function fetchAllDoSearch(
requestBody.estimatedArrivalDate = null;
}

const useUnassignedTruck = isTruckLaneXSearch(truckLanceCode);
if (useUnassignedTruck) {
delete requestBody.truckLanceCode;
}

const url = useUnassignedTruck
? `${BASE_API_URL}/do/search-do-lite-unassigned-truck`
: `${BASE_API_URL}/do/search-do-lite`;

const data = await serverFetchJson<DoSearchLiteResponse>(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(requestBody),
});
const data = await serverFetchJson<DoSearchLiteResponse>(
`${BASE_API_URL}/do/search-do-lite-v2`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(requestBody),
},
);

return data.records;
}

Loading…
取消
儲存