feat(client): expose customs receipt and final files
This commit is contained in:
@@ -32,9 +32,10 @@ export interface MerchantCustomsDocument {
|
|||||||
inboundIds: string[]
|
inboundIds: string[]
|
||||||
inboundCodes: string[]
|
inboundCodes: string[]
|
||||||
frozen: boolean
|
frozen: boolean
|
||||||
completion: MerchantCustomsFile | null
|
receipt: MerchantCustomsFile | null
|
||||||
receiptStatus: 'PENDING' | 'CONFIRMED' | 'REJECTED' | null
|
receiptStatus: 'PENDING' | 'CONFIRMED' | 'REJECTED' | null
|
||||||
receiptRejectReason: string | null
|
receiptRejectReason: string | null
|
||||||
|
finalDocument: MerchantCustomsFile | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MerchantCustomsContainer {
|
export interface MerchantCustomsContainer {
|
||||||
@@ -186,10 +187,17 @@ export function downloadMerchantCustomsSource(document: MerchantCustomsDocument)
|
|||||||
return download(`/merchant/v1/customs/documents/${encodedId(document.documentId)}/download`, document.source.fileName)
|
return download(`/merchant/v1/customs/documents/${encodedId(document.documentId)}/download`, document.source.fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function downloadMerchantCustomsCompletion(document: MerchantCustomsDocument) {
|
export function downloadMerchantCustomsReceipt(document: MerchantCustomsDocument) {
|
||||||
return download(
|
return download(
|
||||||
`/merchant/v1/customs/documents/${encodedId(document.documentId)}/completion/download`,
|
`/merchant/v1/customs/documents/${encodedId(document.documentId)}/receipt/download`,
|
||||||
document.completion?.fileName || `customs-completion-${document.documentId}`,
|
document.receipt?.fileName || `customs-receipt-${document.documentId}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function downloadMerchantCustomsFinal(document: MerchantCustomsDocument) {
|
||||||
|
return download(
|
||||||
|
`/merchant/v1/customs/documents/${encodedId(document.documentId)}/final/download`,
|
||||||
|
document.finalDocument?.fileName || `customs-final-${document.documentId}`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +206,7 @@ export function confirmMerchantCustomsReceipt(document: MerchantCustomsDocument)
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `/merchant/v1/customs/documents/${encodedId(document.documentId)}/receipt/confirm`,
|
url: `/merchant/v1/customs/documents/${encodedId(document.documentId)}/receipt/confirm`,
|
||||||
headers: { 'Idempotency-Key': createIdempotencyKey(`merchant-customs-receipt-confirm-${document.documentId}`) },
|
headers: { 'Idempotency-Key': createIdempotencyKey(`merchant-customs-receipt-confirm-${document.documentId}`) },
|
||||||
data: { expectedVersion: document.completion?.version ?? 0, confirm: true, remark: null },
|
data: { expectedVersion: document.receipt?.version ?? 0, confirm: true, remark: null },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +215,7 @@ export function rejectMerchantCustomsReceipt(document: MerchantCustomsDocument,
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `/merchant/v1/customs/documents/${encodedId(document.documentId)}/receipt/reject`,
|
url: `/merchant/v1/customs/documents/${encodedId(document.documentId)}/receipt/reject`,
|
||||||
headers: { 'Idempotency-Key': createIdempotencyKey(`merchant-customs-receipt-reject-${document.documentId}`) },
|
headers: { 'Idempotency-Key': createIdempotencyKey(`merchant-customs-receipt-reject-${document.documentId}`) },
|
||||||
data: { expectedVersion: document.completion?.version ?? 0, confirm: false, remark: reason },
|
data: { expectedVersion: document.receipt?.version ?? 0, confirm: false, remark: reason },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import {
|
|||||||
MERCHANT_CUSTOMS_STATUS_LABELS,
|
MERCHANT_CUSTOMS_STATUS_LABELS,
|
||||||
deleteMerchantCustomsDocument,
|
deleteMerchantCustomsDocument,
|
||||||
confirmMerchantCustomsReceipt,
|
confirmMerchantCustomsReceipt,
|
||||||
downloadMerchantCustomsCompletion,
|
downloadMerchantCustomsReceipt,
|
||||||
|
downloadMerchantCustomsFinal,
|
||||||
downloadMerchantCustomsSource,
|
downloadMerchantCustomsSource,
|
||||||
getMerchantCustomsForOrder,
|
getMerchantCustomsForOrder,
|
||||||
merchantCustomsErrorMessage,
|
merchantCustomsErrorMessage,
|
||||||
@@ -194,13 +195,13 @@ function saveDownload(blob: Blob, fileName: string) {
|
|||||||
URL.revokeObjectURL(url)
|
URL.revokeObjectURL(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadFile(document: MerchantCustomsDocument, kind: 'source' | 'completion') {
|
async function downloadFile(document: MerchantCustomsDocument, kind: 'source' | 'receipt' | 'final') {
|
||||||
const key = `${document.documentId}:${kind}`
|
const key = `${document.documentId}:${kind}`
|
||||||
downloadingKey.value = key
|
downloadingKey.value = key
|
||||||
try {
|
try {
|
||||||
const result = kind === 'source'
|
const result = kind === 'source'
|
||||||
? await downloadMerchantCustomsSource(document)
|
? await downloadMerchantCustomsSource(document)
|
||||||
: await downloadMerchantCustomsCompletion(document)
|
: kind === 'receipt' ? await downloadMerchantCustomsReceipt(document) : await downloadMerchantCustomsFinal(document)
|
||||||
saveDownload(result.blob, result.fileName)
|
saveDownload(result.blob, result.fileName)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(merchantCustomsErrorMessage(error, '文件下载失败'))
|
ElMessage.error(merchantCustomsErrorMessage(error, '文件下载失败'))
|
||||||
@@ -211,7 +212,7 @@ async function downloadFile(document: MerchantCustomsDocument, kind: 'source' |
|
|||||||
|
|
||||||
async function confirmReceipt(document: MerchantCustomsDocument) {
|
async function confirmReceipt(document: MerchantCustomsDocument) {
|
||||||
try {
|
try {
|
||||||
await ElMessageBox.confirm('确认已核对整份报关行回执吗?确认后将进入整柜报关完成汇总。', '确认报关行回执', { type: 'warning' })
|
await ElMessageBox.confirm('确认已核对整份报关行回执吗?确认后平台会把确认结果发送给报关行执行。', '确认报关行回执', { type: 'warning' })
|
||||||
mutating.value = true
|
mutating.value = true
|
||||||
await confirmMerchantCustomsReceipt(document)
|
await confirmMerchantCustomsReceipt(document)
|
||||||
ElMessage.success('回执确认成功')
|
ElMessage.success('回执确认成功')
|
||||||
@@ -318,12 +319,13 @@ function formatSize(bytes: number) {
|
|||||||
</div>
|
</div>
|
||||||
<div class="customs-document-actions">
|
<div class="customs-document-actions">
|
||||||
<el-button link type="primary" :loading="downloadingKey === `${item.documentId}:source`" @click="downloadFile(item, 'source')"><Download :size="15" />源文件</el-button>
|
<el-button link type="primary" :loading="downloadingKey === `${item.documentId}:source`" @click="downloadFile(item, 'source')"><Download :size="15" />源文件</el-button>
|
||||||
<el-button v-if="item.completion" link type="success" :loading="downloadingKey === `${item.documentId}:completion`" @click="downloadFile(item, 'completion')"><Download :size="15" />报关行回执</el-button>
|
<el-button v-if="item.receipt" link type="success" :loading="downloadingKey === `${item.documentId}:receipt`" @click="downloadFile(item, 'receipt')"><Download :size="15" />报关行回执</el-button>
|
||||||
<template v-if="item.completion && item.receiptStatus !== 'CONFIRMED' && detail.status === 'DECLARING'">
|
<el-button v-if="item.finalDocument" link type="success" :loading="downloadingKey === `${item.documentId}:final`" @click="downloadFile(item, 'final')"><Download :size="15" />报关完税文件</el-button>
|
||||||
|
<template v-if="item.receipt && item.receiptStatus !== 'CONFIRMED' && detail.status === 'DECLARING'">
|
||||||
<el-button link type="success" :disabled="mutating" @click="confirmReceipt(item)">确认整份回执</el-button>
|
<el-button link type="success" :disabled="mutating" @click="confirmReceipt(item)">确认整份回执</el-button>
|
||||||
<el-button link type="danger" :disabled="mutating" @click="rejectReceipt(item)">打回回执</el-button>
|
<el-button link type="danger" :disabled="mutating" @click="rejectReceipt(item)">打回回执</el-button>
|
||||||
</template>
|
</template>
|
||||||
<el-tag v-if="item.completion" size="small" :type="item.receiptStatus === 'CONFIRMED' ? 'success' : item.receiptStatus === 'REJECTED' ? 'danger' : 'warning'">{{ item.receiptStatus === 'CONFIRMED' ? '已确认' : item.receiptStatus === 'REJECTED' ? `已打回:${item.receiptRejectReason || '待补充'}` : '待确认' }}</el-tag>
|
<el-tag v-if="item.receipt" size="small" :type="item.receiptStatus === 'CONFIRMED' ? 'success' : item.receiptStatus === 'REJECTED' ? 'danger' : 'warning'">{{ item.receiptStatus === 'CONFIRMED' ? '已确认' : item.receiptStatus === 'REJECTED' ? `已打回:${item.receiptRejectReason || '待补充'}` : '待确认' }}</el-tag>
|
||||||
<template v-if="canEdit && !locked && !item.frozen">
|
<template v-if="canEdit && !locked && !item.frozen">
|
||||||
<el-button link type="primary" :disabled="mutating" @click="beginEditInbounds(item)"><Pencil :size="15" />改关联</el-button>
|
<el-button link type="primary" :disabled="mutating" @click="beginEditInbounds(item)"><Pencil :size="15" />改关联</el-button>
|
||||||
<el-button link type="primary" :disabled="mutating" @click="chooseReplacement(item)"><Upload :size="15" />覆盖</el-button>
|
<el-button link type="primary" :disabled="mutating" @click="chooseReplacement(item)"><Upload :size="15" />覆盖</el-button>
|
||||||
|
|||||||
@@ -700,13 +700,13 @@ test('supports the frozen customs document workflow and customer-safe downloads'
|
|||||||
'/merchant/v1/customs/loading-plans/',
|
'/merchant/v1/customs/loading-plans/',
|
||||||
'/merchant/v1/customs/documents/',
|
'/merchant/v1/customs/documents/',
|
||||||
'/inbounds',
|
'/inbounds',
|
||||||
'/completion/download',
|
'/receipt/download',
|
||||||
]) assert.match(customsApiSource, new RegExp(path.replaceAll('/', '\\/')))
|
]) assert.match(customsApiSource, new RegExp(path.replaceAll('/', '\\/')))
|
||||||
assert.match(customsApiSource, /MAX_CUSTOMS_FILE_SIZE = 50 \* 1024 \* 1024/)
|
assert.match(customsApiSource, /MAX_CUSTOMS_FILE_SIZE = 50 \* 1024 \* 1024/)
|
||||||
assert.match(customsApiSource, /data: \{ inboundIds, expectedVersion: document\.source\.version \}/)
|
assert.match(customsApiSource, /data: \{ inboundIds, expectedVersion: document\.source\.version \}/)
|
||||||
assert.match(customsApiSource, /requestId: error\.requestId/)
|
assert.match(customsApiSource, /requestId: error\.requestId/)
|
||||||
assert.match(customsDialogSource, /报关开始后仅可查看和下载,不提供退回或解锁/)
|
assert.match(customsDialogSource, /报关开始后仅可查看和下载,不提供退回或解锁/)
|
||||||
assert.match(customsDialogSource, /detail\.status === 'COMPLETED' && item\.completion/)
|
assert.match(customsDialogSource, /item\.finalDocument/)
|
||||||
assert.match(customsDialogSource, /资料版本历史/)
|
assert.match(customsDialogSource, /资料版本历史/)
|
||||||
assert.match(customsDialogSource, /尚未上传退税报关资料/)
|
assert.match(customsDialogSource, /尚未上传退税报关资料/)
|
||||||
assert.match(customsDialogSource, /退税报关资料加载失败/)
|
assert.match(customsDialogSource, /退税报关资料加载失败/)
|
||||||
|
|||||||
Reference in New Issue
Block a user