feat(shipping-notice): 增强订单文档 Profile 管理功能,新增复核与草稿管理
- 添加订单复核相关模型及 API,支持复核案例的创建、更新和确认 - 实现复核草稿的管理功能,允许用户对复核内容进行编辑和保存 - 引入复核事件审计,确保复核过程的可追溯性 - 更新数据库模型以支持复核和草稿的关系管理 - 完善相关服务逻辑,确保复核与草稿的状态管理和数据一致性 - 增强文档模板的管理能力,支持更复杂的业务场景
This commit is contained in:
1 parent
61ac6403c4
commit
b7307fc573
147 files changed
+15108
-1522
No files matched your search
@@ -0,0 +1,73 @@
|
||||
<!--
|
||||
用途:渲染受控 PDF Blob,并仅为服务端验证的 bbox 绘制证据高亮。
|
||||
依赖:pdfjs-dist、Review Evidence DTO。
|
||||
逻辑:预览失败独立显示,不影响同页草稿编辑;缺少可靠 bbox 时只保留页码定位。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import * as pdfjs from 'pdfjs-dist';
|
||||
import workerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url';
|
||||
import type { ShippingOrderReviewEvidence } from '../../types/shipping.api.types';
|
||||
|
||||
pdfjs.GlobalWorkerOptions.workerSrc = workerUrl;
|
||||
|
||||
const props = defineProps<{
|
||||
src: string;
|
||||
evidence?: ShippingOrderReviewEvidence | null;
|
||||
title: string;
|
||||
loadingText: string;
|
||||
unavailableText: string;
|
||||
}>();
|
||||
const canvas = ref<HTMLCanvasElement | null>(null);
|
||||
const loading = ref(false);
|
||||
const failed = ref(false);
|
||||
|
||||
/** 将当前页渲染到 canvas;高亮以 PDF viewport 为基准,绝不猜测不可靠坐标。 */
|
||||
const render = async () => {
|
||||
if (!props.src) return;
|
||||
loading.value = true;
|
||||
failed.value = false;
|
||||
try {
|
||||
const document = await pdfjs.getDocument(props.src).promise;
|
||||
const pageNo = Math.min(Math.max(props.evidence?.page_no || 1, 1), document.numPages);
|
||||
const page = await document.getPage(pageNo);
|
||||
const viewport = page.getViewport({ scale: 1.4 });
|
||||
await nextTick();
|
||||
if (!canvas.value) return;
|
||||
canvas.value.width = Math.ceil(viewport.width);
|
||||
canvas.value.height = Math.ceil(viewport.height);
|
||||
const context = canvas.value.getContext('2d');
|
||||
if (!context) return;
|
||||
await page.render({ canvas: canvas.value, canvasContext: context, viewport }).promise;
|
||||
const bbox = props.evidence?.bbox;
|
||||
if (bbox) {
|
||||
context.save();
|
||||
context.fillStyle = 'rgba(250, 204, 21, 0.35)';
|
||||
context.strokeStyle = 'rgba(202, 138, 4, 0.95)';
|
||||
context.lineWidth = 2;
|
||||
const x = bbox.x0 * viewport.width;
|
||||
const y = bbox.y0 * viewport.height;
|
||||
const width = (bbox.x1 - bbox.x0) * viewport.width;
|
||||
const height = (bbox.y1 - bbox.y0) * viewport.height;
|
||||
context.fillRect(x, y, width, height);
|
||||
context.strokeRect(x, y, width, height);
|
||||
context.restore();
|
||||
}
|
||||
} catch {
|
||||
failed.value = true;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
watch(() => [props.src, props.evidence?.evidence_id], () => { void render(); }, { immediate: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative flex min-h-[360px] items-center justify-center overflow-auto bg-slate-100 p-3 dark:bg-slate-950">
|
||||
<!-- Keep the canvas mounted while PDF.js is loading; otherwise nextTick cannot obtain a render target. -->
|
||||
<canvas ref="canvas" :aria-label="title" class="max-w-full bg-white shadow" :class="{ invisible: loading || failed }" />
|
||||
<span v-if="loading" class="absolute text-sm text-slate-500">{{ loadingText }}</span>
|
||||
<span v-else-if="failed" class="absolute text-sm text-rose-600">{{ unavailableText }}</span>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user