diff --git a/api/pda-loading.js b/api/pda-loading.js index ccbe673..0facd21 100644 --- a/api/pda-loading.js +++ b/api/pda-loading.js @@ -1,6 +1,9 @@ import { session } from '@/stores/session.js' import { requireOnline } from '@/utils/network.js' import { apiDownload, apiRequest, apiUpload } from '@/api/http.js' +import { resolveEvidencePreviewUrl } from '@/utils/api-url.js' + +export { resolveEvidencePreviewUrl } from '@/utils/api-url.js' const EVIDENCE_TYPES = Object.freeze([ 'PHOTO_STEP_1', 'PHOTO_STEP_2', 'PHOTO_STEP_3', 'PHOTO_STEP_4', 'SEAL' @@ -221,12 +224,7 @@ export function getEvidencePreviewUrl(inboundId, evidenceId, tenantId) { export function downloadEvidencePreview(previewUrl) { requireOnline('当前网络不可用,无法查看装柜照片') if (!previewUrl) throw new Error('装柜照片地址尚未同步') - const baseUrl = session.apiBase || '/api/platform/v1' - let url = String(previewUrl) - if (!/^https?:\/\//i.test(url) && /^https?:\/\//i.test(baseUrl)) { - const origin = baseUrl.match(/^(https?:\/\/[^/]+)/i)?.[1] || '' - url = `${origin}${url.startsWith('/') ? '' : '/'}${url}` - } + const url = resolveEvidencePreviewUrl(previewUrl, session.apiBase || '/api/platform/v1') debugLog('evidence.preview.start', { previewPath: String(previewUrl), resolvedUrl: url }) return apiDownload({ url }).then((response) => { const responseHeaders = response.header || {} diff --git a/pages/picking/picking.vue b/pages/picking/picking.vue index 808a293..9a35d85 100644 --- a/pages/picking/picking.vue +++ b/pages/picking/picking.vue @@ -114,7 +114,7 @@ - + @@ -124,15 +124,18 @@ - 装柜证据空仓、半仓、满仓、锁仓及带锁码照 + 装柜证据每类至少 1 张,拍照后自动上传,可继续追加 {{ remoteSyncState.label }} - + - - {{ slot.label }} - {{ evidenceEntries(slot.type).length ? evidenceEntries(slot.type).length + ' 张' : '待拍摄' }} + + {{ evidenceEntries(slot.type).length ? '✓' : slotIndex + 1 }} + + {{ slot.label }} + {{ evidenceEntries(slot.type).length ? `已拍 ${evidenceEntries(slot.type).length} 张` : '待拍摄' }} + @@ -144,7 +147,6 @@ - 现场拍摄后自动上传,可继续追加 {{ evidenceUploadState(slot.type) }} @@ -308,6 +310,10 @@ ✓ 集装箱号 {{ currentBox.currentContainerNo }} · 柜次号 {{ currentBox.cabinetNo }} · 订单 {{ currentBox.orderNo }} + + 装柜照片已拍 {{ evidenceCapturedTypeCount }}/{{ evidenceSlots.length }} 类 + {{ sealNo ? '封签号已填写' : '封签号未填写' }} + {{ completionSummary.picked }} @@ -328,20 +334,11 @@ - + - - - - ✓ - 本班次 {{ boxes.length }} 个柜次任务已全部处理 - - - - {{ toast.message }} @@ -488,8 +485,13 @@ if (this.summary.pending > 0) return '提交时需选择原因' return `已处理 ${this.summary.processed}/${this.summary.total}` }, - nextBoxButtonText() { - return this.completedCount === this.boxes.length ? '查看全部完成' : '下一箱' + evidenceCapturedTypeCount() { + return this.evidenceSlots.filter((slot) => this.evidenceEntries(slot.type).length > 0).length + }, + evidenceNextButtonText() { + return this.evidenceCapturedTypeCount === this.evidenceSlots.length && Boolean(String(this.sealNo || '').trim()) + ? '查看装柜取证' + : '去拍照' }, visibleBoxList() { return this.boxes @@ -513,17 +515,17 @@ }, onLoad(options = {}) { if (!requireSession()) return + this.currentUser = session.currentUser if (options.taskId) { // A local completion marker belongs to the previously opened task. The // canonical server detail decides whether this task is complete. this.completedBoxes = {} this.boxes = [{ - boxNo: String(options.currentContainerNo || options.cabinetNo || '同步中'), cabinetNo: options.cabinetNo ? String(options.cabinetNo) : null, currentContainerNo: options.currentContainerNo ? String(options.currentContainerNo) : null, orderNo: String(options.orderNo || options.inboundCode || ''), + boxNo: '同步中', cabinetNo: null, currentContainerNo: null, orderNo: '', taskId: String(options.taskId), loadingPlanId: null, containerBookingId: null, - inboundId: options.inboundId ? String(options.inboundId) : null, - inboundVersion: options.inboundVersion == null ? null : Number(options.inboundVersion), + inboundId: null, inboundVersion: null, warehouseId: options.warehouseId ? String(options.warehouseId) : null, - tenantId: options.tenantId ? String(options.tenantId) : null, items: [] + tenantId: null, items: [] }] this.currentBoxIndex = 0 this.remoteTaskId = options.taskId ? String(options.taskId) : null @@ -531,6 +533,7 @@ }, async onShow() { if (!requireSession()) return + this.currentUser = session.currentUser this.startHardwareScanner() if (this.cameraPicking) { this.debugEvidence('choose.resume', { evidenceIdentity: this.evidenceIdentity }) @@ -1645,15 +1648,10 @@ } this.openOverlay('complete') }, - nextBox() { + continueToEvidence() { this.closeOverlay(false) - const nextIndex = this.boxes.findIndex((box, index) => !this.completedBoxes[index]) - if (nextIndex < 0) { - this.openOverlay('allComplete') - return - } - this.selectBox(nextIndex) - this.showToast('切换至下一箱', 'success') + this.activeStage = 'evidence' + this.scrollToTop() }, resetOverlayState() { this.activeOverlay = '' diff --git a/pages/tasks/tasks.vue b/pages/tasks/tasks.vue index 690bb7c..2b41f9f 100644 --- a/pages/tasks/tasks.vue +++ b/pages/tasks/tasks.vue @@ -74,7 +74,7 @@ }, enterTask(task) { if (!this.isTaskReady(task)) { this.showToast('任务尚未满足后端进入条件', 'error'); return } - uni.navigateTo({ url: `/pages/picking/picking?cabinetNo=${encodeURIComponent(task.cabinetNo)}¤tContainerNo=${encodeURIComponent(task.currentContainerNo)}&warehouseId=${encodeURIComponent(task.warehouseId)}&taskId=${encodeURIComponent(task.taskId)}&orderNo=${encodeURIComponent(task.displayNo || '')}` }) + uni.navigateTo({ url: `/pages/picking/picking?taskId=${encodeURIComponent(task.taskId)}&warehouseId=${encodeURIComponent(task.warehouseId)}` }) }, showToast(message, type) { clearTimeout(this._toastTimer); this.toast = { visible: true, message, type }; this._toastTimer = setTimeout(() => { this.toast.visible = false }, 2200) } } diff --git a/styles/pda.scss b/styles/pda.scss index 32158dc..badb5cd 100644 --- a/styles/pda.scss +++ b/styles/pda.scss @@ -592,9 +592,10 @@ .pick-item-actions { display: grid; - grid-template-columns: 1.15fr 1fr 0.78fr; + grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; - margin-top: 12px; + width: 100%; + margin-top: 14px; } .processed-actions { @@ -602,18 +603,30 @@ } .pick-btn { + display: flex; + box-sizing: border-box; + width: 100%; height: 48px; - padding: 0 6px; - border-radius: 7px; + min-width: 0; + margin: 0; + padding: 0 8px; + align-items: center; + justify-content: center; + border: 1px solid transparent; + border-radius: 10px; font-size: 13px; - font-weight: 600; - line-height: 48px; + font-weight: 700; + line-height: 18px; + white-space: nowrap; + transition: transform 120ms ease-out, box-shadow 120ms ease-out, background-color 120ms ease-out; } - .pick-btn-confirm { color: #ffffff; background: $success; } - .pick-btn-partial { border: 1px solid #75a5ef; color: #4a7dff; background: #eef5ff; } - .pick-btn-skip { color: $skip; background: #eef0f3; } - .pick-btn-undo { border: 1px solid #d8dde4; color: $text-secondary; background: #ffffff; } + .pick-btn::after { border: 0; } + .pick-btn:active { transform: translateY(1px); box-shadow: none; } + .pick-btn-confirm { border-color: #0d8f84; color: #ffffff; background: $success; box-shadow: 0 3px 8px rgba(13, 148, 136, 0.22); } + .pick-btn-partial { border-color: #75a5ef; color: #2467d4; background: #eef5ff; box-shadow: 0 2px 6px rgba(74, 125, 255, 0.12); } + .pick-btn-skip { border-color: #d8dee7; color: #536174; background: #f5f7fa; } + .pick-btn-undo { border-color: #efb7b7; color: #b42323; background: #fff5f5; box-shadow: 0 2px 6px rgba(180, 35, 35, 0.08); } .empty-state { display: flex; @@ -1096,8 +1109,6 @@ .incomplete-reason { box-sizing: border-box; min-height: 48px; padding: 10px 12px; border: 1px solid $border; border-radius: 8px; color: $text; font-size: 13px; line-height: 20px; text-align: left; background: #ffffff; } .incomplete-reason.selected { border-color: $danger; color: #a51d1d; background: $danger-light; } .danger-confirm { background: $danger; } - .all-complete-btn { width: 100%; height: 48px; margin-top: 20px; border-radius: 9px; color: #ffffff; font-size: 14px; font-weight: 700; line-height: 48px; background: $primary; } - .complete-modal { box-sizing: border-box; width: calc(100vw - 32px); @@ -1130,6 +1141,7 @@ .complete-title { font-size: 20px; font-weight: 700; } .complete-desc { margin-top: 6px; color: $text-secondary; font-size: 12px; } + .complete-evidence-status { display: flex; margin-top: 14px; padding: 10px 12px; align-items: center; justify-content: space-between; gap: 8px; border-radius: 9px; color: #285d9e; font-size: 12px; font-weight: 600; background: #edf4ff; } .complete-stats { display: flex; @@ -1157,8 +1169,8 @@ .red { color: $danger; } .loading-evidence-section { - margin: 8px 12px 92px; - padding: 14px; + margin: 8px 12px 32px; + padding: 12px; border: 1px solid #d8e4f4; border-radius: 10px; background: $card; @@ -1171,28 +1183,30 @@ .sync-state.ready { color: $success; background: #e8f8ef; } .sync-state.error { color: $danger; background: #fff0f0; } .sync-state.loading { color: #8a5a00; background: #fff7df; } - .evidence-grid { display: flex; flex-direction: column; margin-top: 12px; } - .evidence-card { margin-bottom: 12px; padding: 10px; border: 1px solid #d7e1ed; border-radius: 9px; background: #f8fafc; } + .evidence-grid { display: flex; flex-direction: column; margin-top: 10px; } + .evidence-card { margin-bottom: 8px; padding: 7px 9px; border: 1px solid #d7e1ed; border-radius: 9px; background: #f8fafc; } .evidence-card:last-child { margin-bottom: 0; } .evidence-card.filled { border-color: #a7d6ba; background: #f4fbf6; } - .evidence-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; } - .evidence-card-title { display: flex; min-width: 0; align-items: center; gap: 7px; } + .evidence-card-header { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 10px; } + .evidence-card-main { display: flex; min-width: 0; align-items: center; gap: 9px; } + .evidence-step { display: flex; width: 28px; height: 28px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 50%; color: #47617f; font-size: 11px; font-weight: 700; background: #e8eef6; } + .evidence-step.complete { color: #ffffff; background: $success; } + .evidence-card-title { display: flex; min-width: 0; flex-direction: column; gap: 1px; } .evidence-label { display: block; color: $text; font-size: 12px; font-weight: 700; } - .evidence-count { padding: 2px 6px; border-radius: 99px; color: $text-secondary; font-size: 10px; line-height: 16px; background: #e9eef5; } - .evidence-count.complete { color: #087443; background: #dff4e7; } + .evidence-count { color: $text-secondary; font-size: 10px; line-height: 15px; } + .evidence-count.complete { color: #087443; } .evidence-photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 9px; } .evidence-photo-item { position: relative; min-width: 0; padding: 4px; border: 1px solid #dbe5ef; border-radius: 8px; background: #ffffff; } .evidence-thumbnail { display: flex; width: 100%; height: 68px; align-items: center; justify-content: center; border-radius: 6px; color: $text-secondary; font-size: 9px; line-height: 13px; text-align: center; background: #e7edf5; } .evidence-thumbnail-placeholder { box-sizing: border-box; padding: 6px; } .evidence-file { display: block; overflow: hidden; margin-top: 4px; padding: 0 2px; color: $text-secondary; font-size: 9px; line-height: 14px; text-overflow: ellipsis; white-space: nowrap; } .evidence-void-btn { position: absolute; top: 8px; right: 8px; min-width: 40px; height: 40px; padding: 0 7px; border: 0; border-radius: 20px; color: #ffffff; font-size: 10px; line-height: 40px; background: rgba(185, 28, 28, 0.9); } - .evidence-empty-hint { display: block; margin-top: 7px; color: $text-secondary; font-size: 10px; line-height: 15px; } .evidence-upload-state { display: block; margin-top: 5px; color: $text-secondary; font-size: 10px; line-height: 15px; } .evidence-upload-state.uploading, .evidence-upload-state.pending { color: #174d91; } .evidence-upload-state.failed { color: $danger; } .evidence-upload-state.succeeded { color: $success; } .evidence-btn { min-height: 40px; margin-top: 8px; padding: 0 9px; border: 1px solid #9db7d9; border-radius: 7px; color: #174d91; font-size: 12px; line-height: 40px; background: #ffffff; } - .evidence-add-btn { flex-shrink: 0; min-width: 78px; min-height: 40px; margin-top: 0; line-height: 40px; } + .evidence-add-btn { flex-shrink: 0; min-width: 76px; min-height: 42px; margin-top: 0; line-height: 42px; } .evidence-retry-btn { min-height: 40px; margin-top: 6px; padding: 0 9px; border: 1px solid $danger; border-radius: 7px; color: $danger; font-size: 12px; line-height: 40px; background: #fff5f4; } .seal-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; } .seal-input { flex: 1; height: 42px; box-sizing: border-box; padding: 0 10px; border: 1px solid $border; border-radius: 7px; font-size: 12px; background: #f8fafc; } @@ -1238,8 +1252,6 @@ .header-title { font-size: 18px; } .box-select-btn { padding: 0 10px; font-size: 12px; } .pick-item { padding-right: 10px; padding-left: 10px; } - .pick-item-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } - .pick-btn-confirm { grid-column: 1 / -1; } .processed-actions { grid-template-columns: 1fr; } .evidence-photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .submit-section { gap: 8px; width: calc(100% - 12px); padding-right: 8px; padding-left: 8px; } diff --git a/tests/api-url.test.mjs b/tests/api-url.test.mjs new file mode 100644 index 0000000..e54ae9b --- /dev/null +++ b/tests/api-url.test.mjs @@ -0,0 +1,24 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import { resolveEvidencePreviewUrl } from '../utils/api-url.js' + +const previewPath = '/api/platform/v1/inbounds/100/loading/evidence/200/content/pda?tenantId=300' + +test('evidence preview uses the H5 gateway proxy prefix after reopening a task', () => { + assert.equal( + resolveEvidencePreviewUrl(previewPath, '/gateway-api/platform/v1'), + '/gateway-api/platform/v1/inbounds/100/loading/evidence/200/content/pda?tenantId=300' + ) +}) + +test('evidence preview uses the configured absolute gateway origin on a PDA', () => { + assert.equal( + resolveEvidencePreviewUrl(previewPath, 'https://test.example.com/api/platform/v1'), + 'https://test.example.com/api/platform/v1/inbounds/100/loading/evidence/200/content/pda?tenantId=300' + ) +}) + +test('absolute evidence preview URLs remain unchanged', () => { + const absoluteUrl = 'https://files.example.com/evidence/200.png' + assert.equal(resolveEvidencePreviewUrl(absoluteUrl, '/gateway-api/platform/v1'), absoluteUrl) +}) diff --git a/tests/evidence-layout.test.mjs b/tests/evidence-layout.test.mjs new file mode 100644 index 0000000..65e8ba8 --- /dev/null +++ b/tests/evidence-layout.test.mjs @@ -0,0 +1,21 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import { readFile } from 'node:fs/promises' + +const read = (path) => readFile(new URL(path, import.meta.url), 'utf8') + +test('empty evidence slots stay compact and completed slots expand with photos', async () => { + const [page, styles] = await Promise.all([ + read('../pages/picking/picking.vue'), + read('../styles/pda.scss') + ]) + + assert.match(page, /每类至少 1 张,拍照后自动上传,可继续追加/) + assert.match(page, /v-for="\(slot, slotIndex\) in evidenceSlots"/) + assert.match(page, /class="evidence-step"[\s\S]*?slotIndex \+ 1/) + assert.match(page, /evidenceEntries\(slot\.type\)\.length \? '✓'/) + assert.doesNotMatch(page, /class="evidence-empty-hint"/) + assert.match(styles, /\.evidence-card-header \{[^}]*min-height: 44px/) + assert.match(styles, /\.evidence-add-btn \{[^}]*min-height: 42px/) + assert.match(styles, /\.evidence-photo-grid \{[^}]*grid-template-columns/) +}) diff --git a/tests/page-contract.test.mjs b/tests/page-contract.test.mjs index 9cde457..84226ac 100644 --- a/tests/page-contract.test.mjs +++ b/tests/page-contract.test.mjs @@ -125,7 +125,7 @@ test('non-picking operations remain complete static task pages', async () => { test('picking page keeps scan, draft and risky transition contracts', async () => { const [page, scanner] = await Promise.all([read('../pages/picking/picking.vue'), read('../utils/scan-broadcast.js')]) - for (const text of ['确认拣出', '部分拣货', '跳拣', '提交拣货完成', '下一箱', '最近扫码']) assert.match(page, new RegExp(text)) + for (const text of ['确认拣出', '部分拣货', '跳拣', '提交拣货完成', '去拍照', '最近扫码']) assert.match(page, new RegExp(text)) assert.match(page, /saveCurrentBoxDraft\(\)[\s\S]*?this\.boxDrafts =/) assert.match(page, /loadBoxState\(index\)[\s\S]*?const draft = this\.boxDrafts\[index\]/) assert.match(page, /requestBoxSwitch\(index\)[\s\S]*?this\.openOverlay\('switchBoxConfirm'\)/) @@ -213,10 +213,10 @@ test('business dialogs use uni-ui popup components consistently', async () => { assert.match(profile, /]*:is-mask-click="true"[^>]*@change="handleOverlayChange\\('${name}', \\$event\\)"`)) } - assert.equal((picking.match(/ { assert.match(app, /@import '@\/styles\/pda\.scss'/) assert.doesNotMatch(styles, /<\/?style\b/) for (const className of ['pick-btn', 'partial-quick-btn']) assert.match(styles, new RegExp(`\\.${className}\\s*\\{[\\s\\S]*?height:\\s*48px;`)) + assert.match(styles, /\.pick-item-actions\s*\{[^}]*grid-template-columns:\s*repeat\(3, minmax\(0, 1fr\)\);[^}]*width:\s*100%;/) + assert.match(styles, /\.pick-btn\s*\{[^}]*width:\s*100%;[^}]*margin:\s*0;[^}]*align-items:\s*center;[^}]*justify-content:\s*center;/) + assert.match(styles, /\.pick-btn::after\s*\{[^}]*border:\s*0;/) + assert.match(styles, /\.processed-actions\s*\{[^}]*grid-template-columns:\s*1fr;/) + assert.match(styles, /\.pick-btn-undo\s*\{[^}]*border-color:\s*#efb7b7;[^}]*color:\s*#b42323;[^}]*background:\s*#fff5f5;/) assert.doesNotMatch(styles, /\.scan-btn\s*\{/) assert.match(styles, /\.modal-cancel-btn,[\s\S]*?height:\s*48px;/) assert.match(styles, /\.modal-sheet\s*\{[\s\S]*?padding:\s*20px 18px 18px;/) assert.doesNotMatch(styles, /\.modal-sheet\s*\{[\s\S]*?padding:[^;]*env\(/) assert.match(styles, /\.submit-decision-modal\s*\{[^}]*padding:\s*18px 16px 16px;/) - assert.match(styles, /\.evidence-card\s*\{[^}]*margin-bottom:\s*12px;/) + assert.match(styles, /\.evidence-card\s*\{[^}]*margin-bottom:\s*8px;/) assert.match(styles, /\.evidence-card:last-child\s*\{[^}]*margin-bottom:\s*0;/) assert.match(tasks, /\.task-card\s*\{[^}]*margin:\s*0 0 12px;/) assert.match(tasks, /\.task-card:last-child\s*\{[^}]*margin-bottom:\s*0;/) diff --git a/tests/pda-loading-api.test.mjs b/tests/pda-loading-api.test.mjs index 8ac2072..cd53937 100644 --- a/tests/pda-loading-api.test.mjs +++ b/tests/pda-loading-api.test.mjs @@ -89,6 +89,8 @@ test('PDA downloads authenticated evidence previews returned by the backend', () assert.match(source, /response\.tempFilePath/) assert.match(source, /evidence\.preview\.response/) assert.match(source, /\^image\\\//) + assert.match(source, /resolveEvidencePreviewUrl/) + assert.match(source, /const url = resolveEvidencePreviewUrl\(previewUrl, session\.apiBase/) }) test('PDA cabinet picking adapter claims online and submits one atomic batch', () => { diff --git a/tests/picking-evidence-stage.test.mjs b/tests/picking-evidence-stage.test.mjs index e0cc40d..e865d1c 100644 --- a/tests/picking-evidence-stage.test.mjs +++ b/tests/picking-evidence-stage.test.mjs @@ -21,6 +21,15 @@ test('a server task never inherits a completed marker from the previously opened assert.match(page, /submitStatusHint\(\)[\s\S]*?if \(this\.pickingCompleted\) return '拣货已完成,请继续装柜取证'/) const submit = page.match(/async submitPicking\(\) \{[\s\S]*?\n\t\t\t\},/)?.[0] || '' assert.doesNotMatch(submit, /completedBoxes/) + assert.match(page, /v-else-if="pickingOperationReady" class="pick-item-actions processed-actions"/) + assert.doesNotMatch(page, /v-else-if="!(?:pickingCompleted|completedBoxes\[currentBoxIndex\])"/) +}) + +test('picking completion leads to current cabinet evidence instead of an all-complete summary', () => { + assert.match(page, /装柜照片已拍 \{\{ evidenceCapturedTypeCount \}\}\/\{\{ evidenceSlots\.length \}\} 类/) + assert.match(page, /evidenceNextButtonText\(\)[\s\S]*?'查看装柜取证'[\s\S]*?'去拍照'/) + assert.match(page, /continueToEvidence\(\)[\s\S]*?this\.activeStage = 'evidence'[\s\S]*?this\.scrollToTop\(\)/) + assert.doesNotMatch(page, /查看全部完成|allCompletePopup|nextBox\(\)/) }) test('loading evidence is not requested before picking completion', () => { diff --git a/tests/picking-refresh-route.test.mjs b/tests/picking-refresh-route.test.mjs new file mode 100644 index 0000000..48d1bcf --- /dev/null +++ b/tests/picking-refresh-route.test.mjs @@ -0,0 +1,28 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import { readFile } from 'node:fs/promises' + +const read = (path) => readFile(new URL(path, import.meta.url), 'utf8') + +test('direct H5 refresh restores the page user before rendering picking content', async () => { + const page = await read('../pages/picking/picking.vue') + + assert.match(page, //) + assert.match(page, /onLoad\(options = \{\}\) \{[\s\S]*?if \(!requireSession\(\)\) return[\s\S]*?this\.currentUser = session\.currentUser/) + assert.match(page, /async onShow\(\) \{[\s\S]*?if \(!requireSession\(\)\) return[\s\S]*?this\.currentUser = session\.currentUser/) +}) + +test('picking route carries only stable task and warehouse identity', async () => { + const [tasks, page] = await Promise.all([ + read('../pages/tasks/tasks.vue'), + read('../pages/picking/picking.vue') + ]) + const navigation = tasks.match(/uni\.navigateTo\(\{ url: `\/pages\/picking\/picking\?[^`]+` \}\)/)?.[0] || '' + const onLoad = page.match(/onLoad\(options = \{\}\) \{[\s\S]*?\n\t\t\},\n\t\t\tasync onShow/)?.[0] || '' + + assert.match(navigation, /\?taskId=\$\{encodeURIComponent\(task\.taskId\)\}&warehouseId=\$\{encodeURIComponent\(task\.warehouseId\)\}/) + assert.doesNotMatch(navigation, /cabinetNo|currentContainerNo|orderNo|inboundId|tenantId/) + assert.match(onLoad, /taskId: String\(options\.taskId\)/) + assert.match(onLoad, /warehouseId: options\.warehouseId \? String\(options\.warehouseId\) : null/) + assert.doesNotMatch(onLoad, /options\.(cabinetNo|currentContainerNo|orderNo|inboundId|inboundVersion|tenantId)/) +}) diff --git a/utils/api-url.js b/utils/api-url.js new file mode 100644 index 0000000..38bbdbb --- /dev/null +++ b/utils/api-url.js @@ -0,0 +1,15 @@ +export function resolveEvidencePreviewUrl(previewUrl, baseUrl) { + const rawUrl = String(previewUrl || '') + const normalizedBase = String(baseUrl || '').replace(/\/$/, '') + if (!rawUrl || /^https?:\/\//i.test(rawUrl)) return rawUrl + if (/^https?:\/\//i.test(normalizedBase)) { + const origin = normalizedBase.match(/^(https?:\/\/[^/]+)/i)?.[1] || '' + return `${origin}${rawUrl.startsWith('/') ? '' : '/'}${rawUrl}` + } + const platformPrefix = '/api/platform/v1' + if (rawUrl === platformPrefix || rawUrl.startsWith(`${platformPrefix}/`)) { + return `${normalizedBase}${rawUrl.slice(platformPrefix.length)}` + } + if (rawUrl.startsWith('/')) return rawUrl + return `${normalizedBase}/${rawUrl}` +}