feat(shipping-notice): 增强订单抽取与审计功能,支持取消与保留策略
- 在环境配置中新增进度细化、订单提取取消与审计导出相关的开关 - 实现订单抽取运行的取消功能,允许管理员在运行中进行操作 - 引入审计事件的保留策略,支持三年保留期的自动清理 - 更新相关模型与服务,确保新功能的完整性与可追溯性 - 增强文档与代码注释,反映新的业务逻辑与审计要求
This commit is contained in:
1 parent
c85997884b
commit
95cdfe66b0
158 files changed
+19005
-1201
No files matched your search
+107
-7
@@ -5,7 +5,7 @@
|
||||
逻辑:验证页进入本页;管理员选择未参与建模的样本、复核候选后写入真值,再执行并批准,最后回到发布检查。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
@@ -15,11 +15,15 @@ import {
|
||||
confirmOrderProfileBlindTestReviews,
|
||||
createOrderProfileTestSuite,
|
||||
executeOrderProfileTestSuite,
|
||||
createOrderProfileSample,
|
||||
getOrderProfileSampleStatus,
|
||||
listOrderProfileBlindTestAvailableSamples,
|
||||
listOrderProfileBoundSamples,
|
||||
listOrderProfileSamples,
|
||||
previewOrderProfileBlindTestCandidate,
|
||||
removeOrderProfileTestSample,
|
||||
} from '@/features/admin/api/shipping-order-document-profile.api';
|
||||
import { uploadFileAsset } from '@/shared/api/file-assets.api';
|
||||
import type {
|
||||
OrderProfileBlindTestAvailableSample,
|
||||
OrderProfileBlindTestCandidate,
|
||||
@@ -43,9 +47,22 @@ const working = ref(false);
|
||||
const hasTrainingSample = ref(false);
|
||||
const availableSamplesLoaded = ref(false);
|
||||
const availableSamplesLoading = ref(false);
|
||||
const uploadingSample = ref(false);
|
||||
const pendingUpload = ref<{ intakeNo: string; filename: string; state: 'parsing' | 'failed' } | null>(null);
|
||||
let uploadPollingTimer: number | null = null;
|
||||
let availableSamplesController: AbortController | null = null;
|
||||
let availableSamplesTimeout: number | null = null;
|
||||
|
||||
/** 当前选择仅以 API 列表中的 document/table 组合为准,避免浏览器提交伪造样本。 */
|
||||
const selectedSample = computed(() => availableSamples.value.find((item) => `${item.document_id}:${item.table_id}` === selectedSampleKey.value) || null);
|
||||
/** 用安全表格摘要区分同页多表;内部 table_id 仅作为请求身份,绝不展示给管理员。 */
|
||||
function sampleLabel(sample: OrderProfileBlindTestAvailableSample): string {
|
||||
const header = sample.header_preview.join(' / ');
|
||||
return t('admin.shippingOrderProfiles.blindTest.sampleOption', {
|
||||
filename: sample.filename, page: sample.page_no, table: sample.table_index,
|
||||
rows: sample.row_count, columns: sample.column_count, header,
|
||||
});
|
||||
}
|
||||
/** 盲测执行成功且尚未批准时才允许批准;批准后证据在服务端保持不可变。 */
|
||||
const canApprove = computed(() => hasTrainingSample.value && suite.value?.status === 'draft' && suite.value.latest_run?.status === 'passed');
|
||||
/** 将服务端安全失败码转为管理员可定位的摘要;不回显订单正文或人工真值。 */
|
||||
@@ -100,17 +117,93 @@ async function loadSuite(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/** 仅在管理员需要挑选盲测样本时加载候选摘要,避免页面首屏等待历史样本逐份证据校验。 */
|
||||
async function loadAvailableSamples(): Promise<void> {
|
||||
if (!suite.value || suite.value.status !== 'draft' || availableSamplesLoaded.value || availableSamplesLoading.value) return;
|
||||
/** 按需读取独立样本摘要;上传解析完成时可强制刷新并定位刚上传的文档。 */
|
||||
async function loadAvailableSamples(force = false): Promise<void> {
|
||||
if (!suite.value || suite.value.status !== 'draft' || (!force && availableSamplesLoaded.value) || availableSamplesLoading.value) return;
|
||||
availableSamplesController?.abort();
|
||||
if (availableSamplesTimeout) window.clearTimeout(availableSamplesTimeout);
|
||||
const controller = new AbortController();
|
||||
availableSamplesController = controller;
|
||||
availableSamplesLoading.value = true;
|
||||
let timedOut = false;
|
||||
availableSamplesTimeout = window.setTimeout(() => {
|
||||
timedOut = true;
|
||||
controller.abort();
|
||||
}, 15_000);
|
||||
try {
|
||||
availableSamples.value = (await listOrderProfileBlindTestAvailableSamples(suite.value.id)).samples;
|
||||
availableSamples.value = (await listOrderProfileBlindTestAvailableSamples(suite.value.id, controller.signal)).samples;
|
||||
availableSamplesLoaded.value = true;
|
||||
} catch (error) {
|
||||
if (timedOut) {
|
||||
message.error(t('admin.shippingOrderProfiles.blindTest.loadIndependentSamplesTimedOut'));
|
||||
} else if (!controller.signal.aborted) {
|
||||
report(error);
|
||||
}
|
||||
} finally {
|
||||
if (availableSamplesController === controller) {
|
||||
availableSamplesController = null;
|
||||
availableSamplesLoading.value = false;
|
||||
}
|
||||
if (availableSamplesTimeout) window.clearTimeout(availableSamplesTimeout);
|
||||
availableSamplesTimeout = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** 停止上传样本的后台轮询,避免离开盲测页后继续向已卸载页面写入状态。 */
|
||||
function stopUploadPolling(): void {
|
||||
if (uploadPollingTimer) window.clearTimeout(uploadPollingTimer);
|
||||
uploadPollingTimer = null;
|
||||
}
|
||||
|
||||
/** 上传完成后精确选中同一 Intake 的首个可盲测表格,仍必须经过管理员预览和复核。 */
|
||||
async function pollUploadedSample(intakeNo: string): Promise<void> {
|
||||
try {
|
||||
const result = await getOrderProfileSampleStatus(intakeNo);
|
||||
if (result.parse_status === 'parsed' && result.document_count > 0) {
|
||||
const uploaded = (await listOrderProfileSamples()).find((item) => item.intake_no === intakeNo);
|
||||
await loadAvailableSamples(true);
|
||||
const selected = uploaded && availableSamples.value.find((item) => item.document_id === uploaded.document_id);
|
||||
if (selected) {
|
||||
selectedSampleKey.value = `${selected.document_id}:${selected.table_id}`;
|
||||
pendingUpload.value = null;
|
||||
message.success(t('admin.shippingOrderProfiles.wizard.sampleReady'));
|
||||
} else {
|
||||
pendingUpload.value = { intakeNo, filename: pendingUpload.value?.filename || '', state: 'failed' };
|
||||
message.error(t('admin.shippingOrderProfiles.blindTest.noIndependentSamples'));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (['failed', 'error'].includes(result.parse_status)) {
|
||||
pendingUpload.value = { intakeNo, filename: pendingUpload.value?.filename || '', state: 'failed' };
|
||||
return;
|
||||
}
|
||||
uploadPollingTimer = window.setTimeout(() => void pollUploadedSample(intakeNo), 1500);
|
||||
} catch {
|
||||
uploadPollingTimer = window.setTimeout(() => void pollUploadedSample(intakeNo), 2000);
|
||||
}
|
||||
}
|
||||
|
||||
/** 上传 PDF/EML 到隔离模板样本池;上传后不会自动写入盲测真值。 */
|
||||
async function uploadIndependentSample(event: Event): Promise<void> {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
input.value = '';
|
||||
if (!file || uploadingSample.value) return;
|
||||
if (!/\.(pdf|eml)$/i.test(file.name)) {
|
||||
message.error(t('admin.shippingOrderProfiles.sampleFileTypeInvalid'));
|
||||
return;
|
||||
}
|
||||
stopUploadPolling();
|
||||
uploadingSample.value = true;
|
||||
try {
|
||||
const asset = await uploadFileAsset(file);
|
||||
const intake = await createOrderProfileSample(asset.asset_no);
|
||||
pendingUpload.value = { intakeNo: intake.intake_no, filename: file.name, state: 'parsing' };
|
||||
void pollUploadedSample(intake.intake_no);
|
||||
} catch (error) {
|
||||
report(error);
|
||||
} finally {
|
||||
availableSamplesLoading.value = false;
|
||||
uploadingSample.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +332,11 @@ function goToPublishCheck(): void {
|
||||
}
|
||||
|
||||
onMounted(loadSuite);
|
||||
onBeforeUnmount(() => {
|
||||
stopUploadPolling();
|
||||
availableSamplesController?.abort();
|
||||
if (availableSamplesTimeout) window.clearTimeout(availableSamplesTimeout);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -261,7 +359,8 @@ onMounted(loadSuite);
|
||||
<h2>{{ t('admin.shippingOrderProfiles.blindTest.selectIndependentSample') }}</h2>
|
||||
<p v-if="!availableSamplesLoaded">{{ t('admin.shippingOrderProfiles.blindTest.loadIndependentSamplesHint') }}</p>
|
||||
<p v-else-if="!availableSamples.length">{{ t('admin.shippingOrderProfiles.blindTest.noIndependentSamples') }}</p>
|
||||
<div class="sample-picker"><button v-if="!availableSamplesLoaded" type="button" class="btn-secondary" :disabled="availableSamplesLoading" @click="loadAvailableSamples">{{ availableSamplesLoading ? t('admin.shippingOrderProfiles.blindTest.loadingIndependentSamples') : t('admin.shippingOrderProfiles.blindTest.loadIndependentSamples') }}</button><template v-else-if="availableSamples.length"><select v-model="selectedSampleKey" class="select-field"><option value="">{{ t('admin.shippingOrderProfiles.blindTest.selectSamplePlaceholder') }}</option><option v-for="sample in availableSamples" :key="`${sample.document_id}:${sample.table_id}`" :value="`${sample.document_id}:${sample.table_id}`">{{ sample.filename }} · P{{ sample.page_no }}</option></select><button type="button" class="btn-primary" :disabled="!selectedSample || working" @click="previewSample">{{ t('admin.shippingOrderProfiles.blindTest.addCurrentSample') }}</button></template></div>
|
||||
<div class="sample-picker"><label class="btn-secondary upload-sample"><input type="file" accept=".pdf,.eml,application/pdf,message/rfc822" :disabled="uploadingSample" @change="uploadIndependentSample"><span>{{ uploadingSample ? t('admin.shippingOrderProfiles.wizard.uploading') : t('admin.shippingOrderProfiles.wizard.uploadNewSample') }}</span></label><button v-if="!availableSamplesLoaded" type="button" class="btn-secondary" :disabled="availableSamplesLoading" @click="() => void loadAvailableSamples()">{{ availableSamplesLoading ? t('admin.shippingOrderProfiles.blindTest.loadingIndependentSamples') : t('admin.shippingOrderProfiles.blindTest.loadIndependentSamples') }}</button><template v-else-if="availableSamples.length"><select v-model="selectedSampleKey" class="select-field"><option value="">{{ t('admin.shippingOrderProfiles.blindTest.selectSamplePlaceholder') }}</option><option v-for="sample in availableSamples" :key="`${sample.document_id}:${sample.table_id}`" :value="`${sample.document_id}:${sample.table_id}`">{{ sampleLabel(sample) }}</option></select><button type="button" class="btn-primary" :disabled="!selectedSample || working" @click="previewSample">{{ t('admin.shippingOrderProfiles.blindTest.addCurrentSample') }}</button></template></div>
|
||||
<p v-if="pendingUpload" class="upload-status" :class="{ failed: pendingUpload.state === 'failed' }">{{ pendingUpload.filename }} · {{ pendingUpload.state === 'parsing' ? t('admin.shippingOrderProfiles.wizard.sampleParsing') : t('admin.shippingOrderProfiles.wizard.sampleParseFailed') }}</p>
|
||||
</section>
|
||||
|
||||
<section v-if="candidate" class="card candidate-card">
|
||||
@@ -296,6 +395,7 @@ header { align-items: flex-start; margin-bottom: 24px; } h1, h2, h3, p { margin:
|
||||
.card { display: grid; gap: 14px; margin-top: 14px; border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-surface); padding: 18px; }
|
||||
.status { color: var(--status-warning-fg); font-weight: 700; } .status.approved { color: var(--status-success-fg); } .status.superseded { color: var(--status-error-fg); }
|
||||
.sample-picker .select-field { min-width: 260px; } .candidate-card .input-field { padding: 8px; border-radius: 6px; } textarea.input-field { min-height: 72px; font-family: ui-monospace, monospace; }
|
||||
.upload-sample { position: relative; cursor: pointer; }.upload-sample input { position: absolute; width: 1px; height: 1px; opacity: 0; }.upload-status { margin: 10px 0 0; color: var(--status-info-fg); font-size: .85rem; }.upload-status.failed { color: var(--status-error-fg); }
|
||||
.candidate-card { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); } .candidate-card > h2, .candidate-card > p, .candidate-card > button { grid-column: 1 / -1; }
|
||||
.review-item { display: grid; gap: 8px; border: 1px solid var(--border-default); border-radius: 8px; padding: 12px; } code { overflow-wrap: anywhere; white-space: pre-wrap; color: var(--text-primary); font-size: 12px; } label { display: flex; gap: 6px; align-items: center; }
|
||||
ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; } li { border-top: 1px solid var(--border-default); padding-top: 8px; }
|
||||
|
||||
+205
-12
@@ -32,6 +32,7 @@ import {
|
||||
previewOrderProfileOrderFieldValues,
|
||||
releaseOrderDocumentProfileEditLease,
|
||||
renewOrderDocumentProfileEditLease,
|
||||
readOrderProfilePreviewPageRegionText,
|
||||
suggestOrderProfileHeader,
|
||||
suggestOrderProfileOrderFields,
|
||||
saveOrderDocumentProfileDraft,
|
||||
@@ -41,6 +42,7 @@ import type {
|
||||
CoordinateReconstructionPreview,
|
||||
OrderFieldValuePreview,
|
||||
OrderProfileCanvasRegion,
|
||||
OrderProfileDocumentMatchAnchor,
|
||||
OrderProfileFieldRegion,
|
||||
OrderProfileRelativeRegion,
|
||||
OrderProfileBoundSample,
|
||||
@@ -120,6 +122,9 @@ let resolveRouteLeave: ((allowed: boolean) => void) | null = null;
|
||||
const suggestingRegions = ref(false);
|
||||
const suggestionProgress = ref("");
|
||||
const creationKind = ref<OrderProfileCanvasRegion["kind"] | null>(null);
|
||||
const pendingDocumentAnchorLabel = ref<OrderProfileCanvasRegion | null>(null);
|
||||
const pendingOrderFieldAnchor = ref<OrderProfileCanvasRegion | null>(null);
|
||||
const documentAnchorNotice = ref('');
|
||||
const history = ref<OrderProfileCanvasRegion[][]>([]);
|
||||
const future = ref<OrderProfileCanvasRegion[][]>([]);
|
||||
const editLeaseToken = ref<string | null>(null);
|
||||
@@ -146,6 +151,14 @@ const form = reactive({
|
||||
changeNote: "",
|
||||
});
|
||||
const regions = ref<OrderProfileCanvasRegion[]>([]);
|
||||
/** 文档匹配锚点独立于字段坐标;必须以固定标签和固定值关系区分模板。 */
|
||||
const documentMatch = reactive({
|
||||
requiredAnchors: [] as OrderProfileDocumentMatchAnchor[],
|
||||
optionalAnchors: [] as OrderProfileDocumentMatchAnchor[],
|
||||
minimumScore: 0.9,
|
||||
minimumMargin: 0.15,
|
||||
});
|
||||
const documentMatchDirty = ref(false);
|
||||
const lineFields = computed<ShippingOrderFieldConfig[]>(
|
||||
() =>
|
||||
schemas.value
|
||||
@@ -180,7 +193,9 @@ const selectedRegion = computed(
|
||||
/** 当前样本值只能来自本次按画布坐标回读的结果,禁止回退到旧的自动建议缓存。 */
|
||||
const selectedRegionSampleValue = computed(() => {
|
||||
const region = selectedRegion.value;
|
||||
if (region?.kind !== 'order_field' || !region.fieldCode) return null;
|
||||
if (!region || !['order_field', 'header_field'].includes(region.kind)) return null;
|
||||
if (region.suggestedValue) return region.suggestedValue;
|
||||
if (!region.fieldCode) return null;
|
||||
return orderFieldValuePreviews.value.find((item) => item.field_code === region.fieldCode)?.value || null;
|
||||
});
|
||||
/** 右侧选区值与画布标签共享同一个读取状态,禁止以旧建议值回退。 */
|
||||
@@ -199,6 +214,7 @@ const selectedRegionKindLabel = computed(() => {
|
||||
const translationKeys: Record<NonNullable<OrderProfileCanvasRegion['kind']>, string> = {
|
||||
order_anchor: 'orderAnchor', order_field: 'orderField', header_field: 'header',
|
||||
header: 'header', line: 'line', field: 'field', exclusion: 'exclusion',
|
||||
document_anchor_label: 'documentMatchAnchorLabel', document_anchor_value: 'documentMatchAnchorValue',
|
||||
};
|
||||
const translationKey = translationKeys[kind];
|
||||
return t(`admin.shippingOrderProfiles.workbench.${translationKey}`);
|
||||
@@ -260,7 +276,7 @@ const selectedFieldHeaderSuggestion = computed(() => {
|
||||
)
|
||||
: null;
|
||||
});
|
||||
const dirty = computed(() => history.value.length > 0);
|
||||
const dirty = computed(() => history.value.length > 0 || documentMatchDirty.value);
|
||||
/** 当前标注样本可同时作为训练证据;盲测样本仍由独立工作台维护。 */
|
||||
const currentSampleIsTraining = computed(() => boundSamples.value.some(
|
||||
(item) => item.sample_role === 'training' && item.document_id === form.documentId && item.table_id === form.tableId,
|
||||
@@ -362,6 +378,7 @@ const redo = () => {
|
||||
const addRegion = (
|
||||
kind: OrderProfileCanvasRegion["kind"],
|
||||
drawnRegion?: OrderProfileRelativeRegion,
|
||||
selectedText?: string | null,
|
||||
) => {
|
||||
checkpoint();
|
||||
const effectiveKind = kind === "header" ? "header_field" : kind;
|
||||
@@ -432,7 +449,7 @@ const addRegion = (
|
||||
const item: OrderProfileCanvasRegion = {
|
||||
id: `${effectiveKind}_${pageNo.value}_${sequence}`,
|
||||
kind: effectiveKind,
|
||||
label: t(`admin.shippingOrderProfiles.workbench.regionLabels.${effectiveKind}`, {
|
||||
label: selectedText || t(`admin.shippingOrderProfiles.workbench.regionLabels.${effectiveKind}`, {
|
||||
count: sequence,
|
||||
}),
|
||||
region,
|
||||
@@ -444,6 +461,7 @@ const addRegion = (
|
||||
? `order_field_${pageNo.value}_${sequence}`
|
||||
: null,
|
||||
fieldCode: null,
|
||||
suggestedValue: selectedText || null,
|
||||
pageNo: pageNo.value,
|
||||
};
|
||||
if (effectiveKind === "order_field" && selectedOrderAnchor) {
|
||||
@@ -456,14 +474,124 @@ const addRegion = (
|
||||
};
|
||||
/** 进入画布绘制模式;下一次拖拽创建对应区域,避免先生成默认框再反复移动。 */
|
||||
const startDrawing = (kind: OrderProfileCanvasRegion["kind"]) => {
|
||||
if (kind === 'document_anchor_label') pendingDocumentAnchorLabel.value = null;
|
||||
if (kind === 'order_anchor') pendingOrderFieldAnchor.value = null;
|
||||
creationKind.value = creationKind.value === kind ? null : kind;
|
||||
};
|
||||
/** 应用画布拖出的区域并退出绘制模式;字段自动归属当前或首个物理行。 */
|
||||
const createDrawnRegion = (region: OrderProfileRelativeRegion) => {
|
||||
/** 读取画布框内的冻结文字;空框只保留在本地,绝不触发一个必填项不完整的自动保存。 */
|
||||
const readDocumentAnchorText = async (region: OrderProfileRelativeRegion): Promise<string | null> => {
|
||||
if (!active.value || !form.documentId) return null;
|
||||
try {
|
||||
const result = await readOrderProfilePreviewPageRegionText(active.value.id, form.documentId, pageNo.value, region);
|
||||
return result.text.trim() || null;
|
||||
} catch (error) {
|
||||
fail(error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
/** 应用画布拖出的区域并退出绘制模式;匹配锚点从框内坐标文本建立,字段自动归属当前或首个物理行。 */
|
||||
const createDrawnRegion = async (region: OrderProfileRelativeRegion) => {
|
||||
const kind = creationKind.value;
|
||||
creationKind.value = null;
|
||||
if (kind === 'document_anchor_label') {
|
||||
const label = await readDocumentAnchorText(region);
|
||||
if (!label) {
|
||||
documentAnchorNotice.value = t('admin.shippingOrderProfiles.workbench.documentMatchAnchorTextMissing');
|
||||
creationKind.value = 'document_anchor_label';
|
||||
return;
|
||||
}
|
||||
// The first box is only a pending local gesture. Do not autosave a half-built
|
||||
// anchor because the v2 contract correctly requires both label and fixed value.
|
||||
history.value.push(snapshot());
|
||||
future.value = [];
|
||||
const id = `document_anchor_${pageNo.value}_${documentMatch.requiredAnchors.length + 1}`;
|
||||
const labelRegion: OrderProfileCanvasRegion = {
|
||||
id: `${id}_label`, kind, label, region, parentId: id, pageNo: pageNo.value,
|
||||
};
|
||||
regions.value.push(labelRegion);
|
||||
documentAnchorNotice.value = '';
|
||||
pendingDocumentAnchorLabel.value = labelRegion;
|
||||
selectedId.value = labelRegion.id;
|
||||
creationKind.value = 'document_anchor_value';
|
||||
return;
|
||||
}
|
||||
if (kind === 'document_anchor_value' && pendingDocumentAnchorLabel.value) {
|
||||
const value = await readDocumentAnchorText(region);
|
||||
if (!value) {
|
||||
documentAnchorNotice.value = t('admin.shippingOrderProfiles.workbench.documentMatchAnchorTextMissing');
|
||||
creationKind.value = 'document_anchor_value';
|
||||
return;
|
||||
}
|
||||
const labelRegion = pendingDocumentAnchorLabel.value;
|
||||
const anchorId = labelRegion.parentId!;
|
||||
const valueRegion: OrderProfileCanvasRegion = {
|
||||
id: `${anchorId}_value`, kind, label: value, region, parentId: anchorId, pageNo: pageNo.value,
|
||||
};
|
||||
regions.value.push(valueRegion);
|
||||
documentAnchorNotice.value = '';
|
||||
documentMatch.requiredAnchors.push({
|
||||
anchor_id: anchorId,
|
||||
label: labelRegion.label, value, value_position: region.y0 >= labelRegion.region.y1 ? 'below' : 'right',
|
||||
page_no: pageNo.value,
|
||||
label_region: labelRegion.region,
|
||||
value_region: valueRegion.region,
|
||||
minimum_evidence_level: 'coordinate',
|
||||
});
|
||||
pendingDocumentAnchorLabel.value = null;
|
||||
documentMatchDirty.value = true;
|
||||
selectedId.value = valueRegion.id;
|
||||
markLocalChange();
|
||||
schedulePreview();
|
||||
scheduleAutosave();
|
||||
return;
|
||||
}
|
||||
if (kind === 'order_anchor') {
|
||||
const label = await readDocumentAnchorText(region);
|
||||
if (!label) {
|
||||
documentAnchorNotice.value = t('admin.shippingOrderProfiles.workbench.documentMatchAnchorTextMissing');
|
||||
creationKind.value = 'order_anchor';
|
||||
return;
|
||||
}
|
||||
history.value.push(snapshot());
|
||||
future.value = [];
|
||||
const sequence = pageRegions.value.filter((item) => item.kind === 'order_anchor').length + 1;
|
||||
const orderFieldId = `order_field_${pageNo.value}_${sequence}`;
|
||||
const anchor: OrderProfileCanvasRegion = {
|
||||
id: `${orderFieldId}_anchor`, kind, label, region, orderFieldId, pageNo: pageNo.value,
|
||||
};
|
||||
regions.value.push(anchor);
|
||||
pendingOrderFieldAnchor.value = anchor;
|
||||
selectedId.value = anchor.id;
|
||||
documentAnchorNotice.value = t('admin.shippingOrderProfiles.workbench.orderFieldAnchorNext');
|
||||
creationKind.value = 'order_field';
|
||||
return;
|
||||
}
|
||||
if (kind === 'order_field' && pendingOrderFieldAnchor.value) {
|
||||
const value = await readDocumentAnchorText(region);
|
||||
if (!value) {
|
||||
documentAnchorNotice.value = t('admin.shippingOrderProfiles.workbench.documentMatchAnchorTextMissing');
|
||||
creationKind.value = 'order_field';
|
||||
return;
|
||||
}
|
||||
const anchor = pendingOrderFieldAnchor.value;
|
||||
const valueRegion: OrderProfileCanvasRegion = {
|
||||
id: anchor.orderFieldId!, kind, label: value, region, parentId: anchor.id,
|
||||
orderFieldId: anchor.orderFieldId, valueMode: 'single_line', suggestedValue: value, pageNo: pageNo.value,
|
||||
};
|
||||
regions.value.push(valueRegion);
|
||||
pendingOrderFieldAnchor.value = null;
|
||||
documentAnchorNotice.value = '';
|
||||
selectedId.value = valueRegion.id;
|
||||
markLocalChange();
|
||||
schedulePreview();
|
||||
scheduleAutosave();
|
||||
return;
|
||||
}
|
||||
if (kind) {
|
||||
addRegion(kind, region);
|
||||
const selectedText = kind === 'header_field'
|
||||
? await readDocumentAnchorText(region)
|
||||
: null;
|
||||
addRegion(kind, region, selectedText);
|
||||
schedulePreview();
|
||||
}
|
||||
};
|
||||
@@ -501,12 +629,20 @@ const removeSelected = () => {
|
||||
checkpoint();
|
||||
const removedId = selectedRegion.value.id;
|
||||
const removesSharedAnchor = selectedRegion.value.kind === "order_anchor";
|
||||
const documentAnchorId = ['document_anchor_label', 'document_anchor_value'].includes(selectedRegion.value.kind)
|
||||
? selectedRegion.value.parentId
|
||||
: null;
|
||||
// Removing a shared label removes dependent value boxes; removing one value box
|
||||
// preserves the label and any sibling customer/address field.
|
||||
regions.value = regions.value.filter(
|
||||
(item) => item.id !== removedId && item.parentId !== removedId &&
|
||||
(!removesSharedAnchor || item.parentId !== removedId),
|
||||
(!removesSharedAnchor || item.parentId !== removedId) && item.parentId !== documentAnchorId,
|
||||
);
|
||||
if (documentAnchorId) {
|
||||
documentMatch.requiredAnchors = documentMatch.requiredAnchors.filter((item) => item.anchor_id !== documentAnchorId);
|
||||
documentMatch.optionalAnchors = documentMatch.optionalAnchors.filter((item) => item.anchor_id !== documentAnchorId);
|
||||
documentMatchDirty.value = true;
|
||||
}
|
||||
selectedId.value = null;
|
||||
schedulePreview();
|
||||
};
|
||||
@@ -535,6 +671,15 @@ const updateRegion = (id: string, region: OrderProfileRelativeRegion) => {
|
||||
const normalized = normalizedCanvasRegion(region);
|
||||
if (!normalized) return;
|
||||
item.region = normalized;
|
||||
if (item.parentId && ['document_anchor_label', 'document_anchor_value'].includes(item.kind)) {
|
||||
const anchor = documentMatch.requiredAnchors.find((entry) => entry.anchor_id === item.parentId)
|
||||
|| documentMatch.optionalAnchors.find((entry) => entry.anchor_id === item.parentId);
|
||||
if (anchor) {
|
||||
if (item.kind === 'document_anchor_label') anchor.label_region = normalized;
|
||||
else anchor.value_region = normalized;
|
||||
documentMatchDirty.value = true;
|
||||
}
|
||||
}
|
||||
schedulePreview();
|
||||
scheduleOrderFieldSuggestionValues();
|
||||
};
|
||||
@@ -670,10 +815,10 @@ const definition = () => {
|
||||
document_match: {
|
||||
document_type: "purchase_order" as const,
|
||||
page_pattern: "one_or_more" as const,
|
||||
required_anchors: [],
|
||||
optional_anchors: [],
|
||||
minimum_score: 0.9,
|
||||
minimum_margin: 0.15,
|
||||
required_anchors: documentMatch.requiredAnchors.map((item) => ({ ...item })),
|
||||
optional_anchors: documentMatch.optionalAnchors.map((item) => ({ ...item })),
|
||||
minimum_score: documentMatch.minimumScore,
|
||||
minimum_margin: documentMatch.minimumMargin,
|
||||
},
|
||||
table_regions: tableRegions,
|
||||
order_field_layouts: regions.value
|
||||
@@ -807,6 +952,7 @@ const save = async (automatic = false) => {
|
||||
if (localChangeVersion === savingChangeVersion) {
|
||||
history.value = [];
|
||||
future.value = [];
|
||||
documentMatchDirty.value = false;
|
||||
}
|
||||
saveState.value = 'saved';
|
||||
autosaveFailures = 0;
|
||||
@@ -1248,6 +1394,16 @@ const mergeEquivalentOrderAnchors = (items: OrderProfileCanvasRegion[]) => {
|
||||
/** 从 v2 定义恢复区域,供草稿重开后继续在画布上编辑。 */
|
||||
const restoreRegions = (profile: ShippingOrderDocumentProfile) => {
|
||||
const restored: OrderProfileCanvasRegion[] = [
|
||||
...(profile.definition.document_match.required_anchors || []).flatMap<OrderProfileCanvasRegion>((anchor) => {
|
||||
if (!anchor.label_region || !anchor.value_region || !anchor.page_no) return [];
|
||||
return [{
|
||||
id: `${anchor.anchor_id}_label`, kind: 'document_anchor_label', label: anchor.label,
|
||||
region: anchor.label_region, parentId: anchor.anchor_id, pageNo: anchor.page_no,
|
||||
}, {
|
||||
id: `${anchor.anchor_id}_value`, kind: 'document_anchor_value', label: anchor.value,
|
||||
region: anchor.value_region, parentId: anchor.anchor_id, pageNo: anchor.page_no,
|
||||
}];
|
||||
}),
|
||||
...(profile.definition.draft_unbound_order_field_layouts || []).flatMap<OrderProfileCanvasRegion>((item) => {
|
||||
const pageNo = item.page_scope === "exact_page" ? item.page_no || 1 : 1;
|
||||
if (!item.anchor?.region || (!item.value_region && !item.absolute_value_region)) {
|
||||
@@ -1436,6 +1592,11 @@ const edit = async (profile: ShippingOrderDocumentProfile) => {
|
||||
form.displayName = profile.display_name;
|
||||
form.schemaId = profile.schema_version_id;
|
||||
form.changeNote = profile.change_note || "";
|
||||
documentMatch.requiredAnchors = (profile.definition.document_match.required_anchors || []).map((item) => ({ ...item }));
|
||||
documentMatch.optionalAnchors = (profile.definition.document_match.optional_anchors || []).map((item) => ({ ...item }));
|
||||
documentMatch.minimumScore = profile.definition.document_match.minimum_score;
|
||||
documentMatch.minimumMargin = profile.definition.document_match.minimum_margin;
|
||||
documentMatchDirty.value = false;
|
||||
regions.value = restoreRegions(profile);
|
||||
history.value = [];
|
||||
future.value = [];
|
||||
@@ -1604,7 +1765,13 @@ const handleShortcut = (event: KeyboardEvent) => {
|
||||
documentCanvas.value?.resetZoom();
|
||||
return;
|
||||
}
|
||||
if (event.key.toLowerCase() === "g") {
|
||||
event.preventDefault();
|
||||
void suggestRegions();
|
||||
return;
|
||||
}
|
||||
const kindByKey: Record<string, OrderProfileCanvasRegion["kind"]> = {
|
||||
m: "document_anchor_label",
|
||||
h: "header_field",
|
||||
l: "line",
|
||||
f: "field",
|
||||
@@ -1768,13 +1935,27 @@ onBeforeUnmount(() => {
|
||||
<header>
|
||||
<span>{{ t("admin.shippingOrderProfiles.workbench.currentConfiguration") }}</span>
|
||||
</header>
|
||||
<section class="document-match-editor">
|
||||
<div class="document-match-editor__heading">
|
||||
<div>
|
||||
<strong>{{ t('admin.shippingOrderProfiles.workbench.documentMatchAnchorTool') }}</strong>
|
||||
<p>{{ t('admin.shippingOrderProfiles.workbench.documentMatchAnchorHint') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="!documentMatch.requiredAnchors.length" class="document-match-editor__warning">{{ t('admin.shippingOrderProfiles.workbench.documentMatchAnchorEmpty') }}</p>
|
||||
<p v-if="documentAnchorNotice" class="document-match-editor__warning">{{ documentAnchorNotice }}</p>
|
||||
<article v-for="(anchor, index) in documentMatch.requiredAnchors" :key="`required-${index}`" class="document-match-editor__row">
|
||||
<b>{{ t('common.required') }}</b>
|
||||
<span>{{ anchor.label }}</span><span>{{ anchor.value }}</span>
|
||||
</article>
|
||||
</section>
|
||||
<section v-if="selectedRegion" class="editor">
|
||||
<div class="selected-region-meta">
|
||||
<span>{{ t('admin.shippingOrderProfiles.workbench.selectedRegion') }}</span>
|
||||
<strong>{{ selectedRegionKindLabel }}</strong>
|
||||
<small>{{ selectedRegionGeometry }}</small>
|
||||
</div>
|
||||
<section v-if="selectedRegion.kind === 'order_field'" class="sample-value-card">
|
||||
<section v-if="['order_field', 'header_field'].includes(selectedRegion.kind)" class="sample-value-card">
|
||||
<span>{{ t('admin.shippingOrderProfiles.workbench.currentSampleValue') }}</span>
|
||||
<strong :class="{ empty: !selectedRegionSampleValue }">
|
||||
{{ selectedRegionSampleDisplay }}
|
||||
@@ -2187,6 +2368,18 @@ onBeforeUnmount(() => {
|
||||
margin: 0 0.8rem;
|
||||
padding: 0.8rem 0;
|
||||
}
|
||||
.document-match-editor {
|
||||
border-bottom: 1px solid #cbd5e1;
|
||||
padding: 0.85rem;
|
||||
background: #f8fafc;
|
||||
}
|
||||
.document-match-editor__heading { display: flex; gap: 0.5rem; align-items: start; }
|
||||
.document-match-editor__heading strong { font-size: 0.84rem; }
|
||||
.document-match-editor__heading p { margin: 0.3rem 0 0; font-size: 0.72rem; color: #64748b; }
|
||||
.document-match-editor__warning { margin: 0.6rem 0; color: #b45309; font-size: 0.75rem; }
|
||||
.document-match-editor__row { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.4fr); gap: 0.35rem; align-items: center; margin-top: 0.45rem; }
|
||||
.document-match-editor__row b { font-size: 0.7rem; color: #0f766e; }
|
||||
.document-match-editor__row span { overflow: hidden; color: #475569; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.selected-region-meta { display: grid; gap: .2rem; margin-bottom: .8rem; border-bottom: 1px solid #dbe4ef; padding-bottom: .75rem; }
|
||||
.selected-region-meta span { color: #64748b; font-size: .7rem; font-weight: 700; }
|
||||
.selected-region-meta strong { color: #0f172a; font-size: .82rem; }
|
||||
|
||||
+36
-2
@@ -2,7 +2,7 @@
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileLibraryPage.vue
|
||||
用途:按 profile_code 聚合展示订单文档模板族,是创建和继续编辑的唯一首页。
|
||||
依赖:Profile family API、Vue Router、Vue I18n。
|
||||
逻辑:列表只选择下一步路由;草稿进入编辑页,已发布版本创建新草稿,历史版本进入只读版本中心。
|
||||
逻辑:列表只选择下一步路由;草稿可继续编辑或删除,已发布版本创建新草稿,历史版本进入只读版本中心。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
@@ -10,7 +10,8 @@ import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { cloneOrderDocumentProfile, listOrderDocumentProfileFamilies } from '@/features/admin/api/shipping-order-document-profile.api';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { cloneOrderDocumentProfile, deleteOrderDocumentProfile, listOrderDocumentProfileFamilies } from '@/features/admin/api/shipping-order-document-profile.api';
|
||||
import type { OrderProfileVersionFamilySummary } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -19,6 +20,13 @@ const message = useMessage();
|
||||
const loading = ref(false);
|
||||
const query = ref('');
|
||||
const families = ref<OrderProfileVersionFamilySummary[]>([]);
|
||||
const deletingDraft = ref<OrderProfileVersionFamilySummary | null>(null);
|
||||
const deleteConfirmOpen = computed({
|
||||
get: () => deletingDraft.value !== null,
|
||||
set: (visible: boolean) => {
|
||||
if (!visible) deletingDraft.value = null;
|
||||
},
|
||||
});
|
||||
|
||||
const filteredFamilies = computed(() => {
|
||||
const keyword = query.value.trim().toLowerCase();
|
||||
@@ -55,6 +63,26 @@ async function createNewVersion(item: OrderProfileVersionFamilySummary): Promise
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开系统内确认框,避免浏览器原生弹窗中断管理员的模板管理流程。 */
|
||||
function requestDeleteDraft(item: OrderProfileVersionFamilySummary): void {
|
||||
if (item.draft_profile_id) deletingDraft.value = item;
|
||||
}
|
||||
|
||||
/** 删除已确认的草稿;服务端仍拒绝删除已发布或退役的历史版本。 */
|
||||
async function confirmDeleteDraft(): Promise<void> {
|
||||
const item = deletingDraft.value;
|
||||
if (!item?.draft_profile_id) return;
|
||||
try {
|
||||
await deleteOrderDocumentProfile(item.draft_profile_id);
|
||||
message.success(t('admin.shippingOrderProfiles.deleted'));
|
||||
await loadFamilies();
|
||||
} catch (error) {
|
||||
message.error(error instanceof BusinessError ? error.message : t('admin.shippingOrderProfiles.library.loadFailed'));
|
||||
} finally {
|
||||
deletingDraft.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** 进入不可变历史详情,不允许在此页面把版本伪装成新草稿。 */
|
||||
function viewVersion(item: OrderProfileVersionFamilySummary): void {
|
||||
router.push({ name: 'AdminShippingOrderDocumentProfileVersionDetail', params: { profileCode: item.profile_code, version: item.default_version } });
|
||||
@@ -103,6 +131,7 @@ onMounted(loadFamilies);
|
||||
</td>
|
||||
<td class="profile-library__actions">
|
||||
<button v-if="item.draft_profile_id" class="btn-ghost btn-sm" type="button" @click="continueEditing(item)">{{ t('admin.shippingOrderProfiles.versionCenter.continueEditing') }}</button>
|
||||
<button v-if="item.draft_profile_id" class="btn-danger btn-sm" type="button" @click="requestDeleteDraft(item)">{{ t('admin.delete') }}</button>
|
||||
<button v-else-if="item.published_profile_id" class="btn-secondary btn-sm" type="button" @click="createNewVersion(item)">{{ t('admin.shippingOrderProfiles.newVersion') }}</button>
|
||||
<button class="btn-ghost btn-sm" type="button" @click="viewVersion(item)">{{ t('admin.shippingOrderProfiles.versionCenter.viewVersion') }}</button>
|
||||
</td>
|
||||
@@ -111,6 +140,11 @@ onMounted(loadFamilies);
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
<DeleteConfirmDialog
|
||||
v-model="deleteConfirmOpen"
|
||||
:message="t('admin.shippingOrderProfiles.deleteConfirm')"
|
||||
@confirm="confirmDeleteDraft"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
|
||||
+18
-21
@@ -7,7 +7,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowLeft, ArrowRight, BoxSelect, Copy, Eraser, Minus, Plus, Redo2, RotateCcw, Save, ScanLine, Sparkles, TableProperties, Trash2 } from 'lucide-vue-next';
|
||||
import { Anchor, ArrowLeft, ArrowRight, Columns3, Copy, Eraser, Minus, Plus, Redo2, RotateCcw, Rows3, Save, TableProperties, Tag, TextCursorInput, Trash2, WandSparkles } from 'lucide-vue-next';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type { OrderProfileCanvasRegion, OrderProfilePreviewPageGrant } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
|
||||
@@ -59,7 +59,6 @@ const loading = ref(false);
|
||||
const canvas = ref<HTMLElement | null>(null);
|
||||
const viewport = ref<HTMLElement | null>(null);
|
||||
const zoom = ref(1);
|
||||
const toolsOpen = ref(true);
|
||||
const zoomPercent = computed(() => Math.round(zoom.value * 100));
|
||||
const pageInput = ref(props.pageNo);
|
||||
type ResizeHandle = 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw';
|
||||
@@ -238,18 +237,16 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
<div v-if="loading" class="canvas-state">{{ t('admin.shippingOrderProfiles.workbench.loadingPage') }}</div>
|
||||
<div v-else-if="!imageUrl" class="canvas-state">{{ t('admin.shippingOrderProfiles.workbench.selectBoundPdf') }}</div>
|
||||
<div v-else class="canvas-work-area" :class="{ readonly: readonlyMode }">
|
||||
<aside v-if="!readonlyMode" class="annotation-tools" :class="{ collapsed: !toolsOpen }">
|
||||
<button type="button" class="tools-toggle" :aria-expanded="toolsOpen" :aria-label="toolsOpen ? t('admin.shippingOrderProfiles.workbench.hideAnnotationTools') : t('admin.shippingOrderProfiles.workbench.showAnnotationTools')" @click="toolsOpen = !toolsOpen"><BoxSelect /><span v-if="toolsOpen">{{ t('admin.shippingOrderProfiles.workbench.annotationTools') }}</span></button>
|
||||
<template v-if="toolsOpen">
|
||||
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawOrderAnchor')" :class="{ active: creationKind === 'order_anchor' }" @click="emit('draw', 'order_anchor')"><BoxSelect /><span>{{ t('admin.shippingOrderProfiles.workbench.orderAnchorTool') }}</span></button>
|
||||
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawOrderField')" :class="{ active: creationKind === 'order_field' }" @click="emit('draw', 'order_field')"><BoxSelect /><span>{{ t('admin.shippingOrderProfiles.workbench.orderField') }}</span></button>
|
||||
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawHeader')" :class="{ active: creationKind === 'header_field' }" @click="emit('draw', 'header_field')"><TableProperties /><span>{{ t('admin.shippingOrderProfiles.workbench.headerTool') }}</span></button>
|
||||
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawLine')" :class="{ active: creationKind === 'line' }" @click="emit('draw', 'line')"><ScanLine /><span>{{ t('admin.shippingOrderProfiles.workbench.lineTool') }}</span></button>
|
||||
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawField')" :class="{ active: creationKind === 'field' }" @click="emit('draw', 'field')"><BoxSelect /><span>{{ t('admin.shippingOrderProfiles.workbench.fieldTool') }}</span></button>
|
||||
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawExclusion')" :class="{ active: creationKind === 'exclusion' }" @click="emit('draw', 'exclusion')"><Eraser /><span>{{ t('admin.shippingOrderProfiles.workbench.exclusionTool') }}</span></button>
|
||||
<button type="button" class="suggest" :disabled="autoSuggestDisabled || suggesting" @click="emit('suggest')"><Sparkles /><span>{{ suggesting ? t('admin.shippingOrderProfiles.workbench.autoSuggestRunning') : t('admin.shippingOrderProfiles.workbench.autoSuggest') }}</span></button>
|
||||
<p v-if="suggestionProgress" class="suggestion-progress" :class="{ failed: !suggesting }">{{ suggestionProgress }}</p>
|
||||
</template>
|
||||
<aside v-if="!readonlyMode" class="annotation-tools">
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawDocumentMatchAnchorShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawDocumentMatchAnchorShortcut')" :class="{ active: creationKind === 'document_anchor_label' || creationKind === 'document_anchor_value' }" @click="emit('draw', 'document_anchor_label')"><Anchor /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawOrderAnchorShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawOrderAnchorShortcut')" :class="{ active: creationKind === 'order_anchor' }" @click="emit('draw', 'order_anchor')"><Tag /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawOrderFieldShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawOrderFieldShortcut')" :class="{ active: creationKind === 'order_field' }" @click="emit('draw', 'order_field')"><TextCursorInput /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawHeaderShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawHeaderShortcut')" :class="{ active: creationKind === 'header_field' }" @click="emit('draw', 'header_field')"><TableProperties /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawLineShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawLineShortcut')" :class="{ active: creationKind === 'line' }" @click="emit('draw', 'line')"><Rows3 /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawFieldShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawFieldShortcut')" :class="{ active: creationKind === 'field' }" @click="emit('draw', 'field')"><Columns3 /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawExclusionShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawExclusionShortcut')" :class="{ active: creationKind === 'exclusion' }" @click="emit('draw', 'exclusion')"><Eraser /></button>
|
||||
<button type="button" class="suggest" :aria-label="t('admin.shippingOrderProfiles.workbench.autoSuggestShortcut')" :title="t('admin.shippingOrderProfiles.workbench.autoSuggestShortcut')" :disabled="autoSuggestDisabled || suggesting" @click="emit('suggest')"><WandSparkles /></button>
|
||||
<p v-if="suggestionProgress" class="suggestion-progress" :class="{ failed: !suggesting }">{{ suggestionProgress }}</p>
|
||||
</aside>
|
||||
<div ref="viewport" class="canvas-viewport" :class="{ panning: !creationKind || readonlyMode }" @wheel.prevent="handleWheel">
|
||||
<div ref="canvas" class="canvas-stage" :class="{ drawing: creationKind && !readonlyMode }" :style="{ '--canvas-zoom': zoom }" @pointerdown="beginCreation">
|
||||
@@ -312,13 +309,10 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
.canvas-stage img { display: block; width: 100%; user-select: none; }
|
||||
.canvas-stage.drawing { cursor: crosshair; }
|
||||
.creation-region { position: absolute; z-index: 5; box-sizing: border-box; border: 2px dashed #34d399; background: rgb(16 185 129 / .18); pointer-events: none; }
|
||||
.annotation-tools { display: grid; align-content: start; gap: .3rem; flex: 0 0 7rem; padding: .35rem; border: 1px solid rgb(71 85 105 / .9); border-radius: .5rem; background: rgb(15 23 42 / .94); box-shadow: 0 8px 24px rgb(15 23 42 / .3); }
|
||||
.annotation-tools.collapsed { flex-basis: 2.45rem; padding: .3rem; }
|
||||
.annotation-tools button { display: flex; min-height: 2rem; align-items: center; gap: .4rem; border: 1px solid transparent; border-radius: .35rem; background: #1e293b; padding: .35rem .45rem; color: #e2e8f0; font-size: .7rem; text-align: left; white-space: nowrap; }
|
||||
.annotation-tools { display: grid; align-content: start; gap: .3rem; flex: 0 0 2.65rem; padding: .3rem; border: 1px solid rgb(71 85 105 / .9); border-radius: .5rem; background: rgb(15 23 42 / .94); box-shadow: 0 8px 24px rgb(15 23 42 / .3); }
|
||||
.annotation-tools button { display: grid; min-height: 2rem; place-items: center; border: 1px solid transparent; border-radius: .35rem; background: #1e293b; padding: .35rem; color: #e2e8f0; }
|
||||
.annotation-tools button:hover, .annotation-tools button.active { border-color: #38bdf8; background: #0c4a6e; color: #f0f9ff; }
|
||||
.annotation-tools .tools-toggle { justify-content: center; }
|
||||
.annotation-tools.collapsed .tools-toggle { padding-inline: 0; }
|
||||
.annotation-tools .suggest { border-color: #0ea5e9; background: #0284c7; font-weight: 700; }
|
||||
.annotation-tools .suggest { border-color: #0ea5e9; background: #0284c7; }
|
||||
.annotation-tools button:disabled { cursor: not-allowed; opacity: .45; }
|
||||
.suggestion-progress { margin: .1rem; color: #bae6fd; font-size: .66rem; line-height: 1.35; }
|
||||
.suggestion-progress.failed { color: #fca5a5; }
|
||||
@@ -340,6 +334,10 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
.region-order_field .region-label, .region-order_field .resize-handle { background: #15803d; }
|
||||
.region-order_anchor { z-index: 2; border: 1.5px solid #a855f7; background: rgb(168 85 247 / .08); }
|
||||
.region-order_anchor .region-label, .region-order_anchor .resize-handle { background: #7e22ce; }
|
||||
.region-document_anchor_label { z-index: 2; border: 1.5px solid #0ea5e9; background: rgb(14 165 233 / .1); }
|
||||
.region-document_anchor_label .region-label, .region-document_anchor_label .resize-handle { background: #0369a1; }
|
||||
.region-document_anchor_value { z-index: 2; border: 1.5px solid #f97316; background: rgb(249 115 22 / .1); }
|
||||
.region-document_anchor_value .region-label, .region-document_anchor_value .resize-handle { background: #c2410c; }
|
||||
.region-line { z-index: 0; border-color: #a78bfa; background: rgb(167 139 250 / .1); pointer-events: none; }
|
||||
.region-line .region-label, .region-line .line-hit-edge, .region-line.selected .resize-handle { pointer-events: auto; }
|
||||
.region-line .region-label, .region-line .resize-handle { background: #6d28d9; }
|
||||
@@ -370,5 +368,4 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
.annotation-tools { flex-basis: 2.45rem; }
|
||||
.annotation-tools button span, .suggestion-progress { display: none; }
|
||||
}
|
||||
.tools-toggle span { display: none; }
|
||||
</style>
|
||||
Reference in new issue
Block a user