feat(P21PWA1-1,P21PWA1-2,P21PWA1-3): 资产搜索扩展/扫码适配器/IndexedDB离线队列与去重重放
这个提交包含在:
@@ -48,6 +48,10 @@ function resolveAssetExportEndpoint(config) {
|
||||
);
|
||||
}
|
||||
|
||||
function resolveTravelExportEndpoint(config) {
|
||||
return String(config.erpSyncEndpoint ?? '').trim();
|
||||
}
|
||||
|
||||
async function parseResponseBody(response) {
|
||||
const contentType = response.headers.get('content-type') || '';
|
||||
if (contentType.includes('application/json')) {
|
||||
@@ -345,6 +349,57 @@ async function exportProcurementToErp(config, payload) {
|
||||
};
|
||||
}
|
||||
|
||||
async function exportTravelToErp(config, payload) {
|
||||
if (!config.erpSyncEnabled) {
|
||||
return {
|
||||
ok: false,
|
||||
code: 'erp_sync_disabled',
|
||||
message: 'ERP sync disabled',
|
||||
retryable: false,
|
||||
};
|
||||
}
|
||||
|
||||
const provider = normalizeProvider(config);
|
||||
if (provider === 'mock') {
|
||||
const identity = payload?.batchNo ?? payload?.entityId ?? 'UNKNOWN';
|
||||
return {
|
||||
ok: true,
|
||||
code: 'mock_synced',
|
||||
message: 'mock ERP travel synced',
|
||||
response: {
|
||||
externalSummaryId: `ERP-TRAVEL-SUM-${identity}`,
|
||||
externalSummaryNo: `ERP-TRAVEL-SUM-${identity}`,
|
||||
externalBatchId: `ERP-TRAVEL-BATCH-${identity}`,
|
||||
externalBatchNo: `ERP-TRAVEL-BATCH-${identity}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (provider === 'http') {
|
||||
return postJsonToErp(config, {
|
||||
endpoint: resolveTravelExportEndpoint(config),
|
||||
timeoutMs: coerceTimeout(config.erpSyncTimeoutMs, config.erpSyncTimeoutMs),
|
||||
payload,
|
||||
successCode: 'http_synced',
|
||||
successMessage: 'ERP travel synced',
|
||||
missingEndpointCode: 'erp_travel_endpoint_missing',
|
||||
missingEndpointMessage: 'ERP travel endpoint missing',
|
||||
http4xxCode: 'erp_travel_http_4xx',
|
||||
http5xxCode: 'erp_travel_http_5xx',
|
||||
timeoutCode: 'erp_travel_timeout',
|
||||
networkCode: 'erp_travel_network_error',
|
||||
messagePrefix: 'ERP travel sync',
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
ok: false,
|
||||
code: 'erp_sync_provider_invalid',
|
||||
message: `Unsupported ERP sync provider: ${provider}`,
|
||||
retryable: false,
|
||||
};
|
||||
}
|
||||
|
||||
function buildErpPayload(input) {
|
||||
return buildReimbursementJournalPayload(input);
|
||||
}
|
||||
@@ -358,6 +413,7 @@ module.exports = {
|
||||
exportAssetToErp,
|
||||
exportJournalToErp,
|
||||
exportProcurementToErp,
|
||||
exportTravelToErp,
|
||||
normalizeProvider,
|
||||
pullMasterDataFromErp,
|
||||
pushPaidReimbursementToErp,
|
||||
|
||||
在新工单中引用
屏蔽一个用户