|
|
|
@@ -294,17 +294,6 @@ const PoSearch: React.FC<Props> = ({ |
|
|
|
if (typeof v === "string" && (v as string).trim() === "") return; |
|
|
|
cleanedQuery[k] = String(v); |
|
|
|
}); |
|
|
|
const searchedCodeRaw = (filterArgs as any)?.code; |
|
|
|
const searchedCode = |
|
|
|
typeof searchedCodeRaw === "string" ? searchedCodeRaw.trim() : ""; |
|
|
|
const isM18PoCode = |
|
|
|
searchedCode.length > 14 && |
|
|
|
(searchedCode.startsWith("PP") || searchedCode.startsWith("PF")); |
|
|
|
if (isM18PoCode) { |
|
|
|
cleanedQuery.refreshFromM18 = "true"; |
|
|
|
setIsM18LookupLoading(true); |
|
|
|
setAutoSyncStatus("載入中..."); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
const baseListResp = await clientAuthFetch( |
|
|
|
@@ -320,17 +309,8 @@ const PoSearch: React.FC<Props> = ({ |
|
|
|
const records: PoResult[] = res.records ?? []; |
|
|
|
setFilteredPo(records); |
|
|
|
setTotalCount(res.total ?? 0); |
|
|
|
if (isM18PoCode) { |
|
|
|
const refreshAction = baseListResp.headers.get("X-M18-Po-Refresh"); |
|
|
|
if (refreshAction === "synced") { |
|
|
|
setAutoSyncStatus(records.length > 0 ? "已從M18同步PO" : "找不到PO"); |
|
|
|
} else { |
|
|
|
setAutoSyncStatus(null); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
console.error("PO list fetch error:", e); |
|
|
|
if (isM18PoCode) setAutoSyncStatus("找不到PO"); |
|
|
|
} finally { |
|
|
|
setIsM18LookupLoading(false); |
|
|
|
autoSyncInProgressRef.current = false; |
|
|
|
|