fix(admin): 管理控制台全面替换为element plus
This commit is contained in:
1 parent
b69c725992
commit
627da80e65
72 files changed
+12370
-8437
No files matched your search
+122
-118
@@ -1,18 +1,19 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-audit/ShippingAuditEventDetailDrawer.vue
|
||||
用途:审计事件详情抽屉——业务化元数据、敏感脱敏提示、白名单 Diff、XFA 快照引用、哈希摘要。
|
||||
依赖:shipping-audit.api 类型、shippingAuditDisplay、Vue I18n、useMessage。
|
||||
逻辑:由 ShippingAuditCenterPage 传入 detail;事件/动作/结果与列表同源业务标签;
|
||||
展示 before/after checksum 与 XFA snapshot_ref;技术编号以复制芯片展示;
|
||||
若快照/metadata 含视觉绑定前后摘要则单独渲染;关闭时 emit close;不自行拉接口。
|
||||
-->
|
||||
/**
|
||||
* features/admin/modules/shipping-audit/ShippingAuditEventDetailDrawer.vue
|
||||
* 用途:审计事件详情抽屉。业务化元数据、敏感脱敏提示、白名单 Diff、XFA 快照引用和哈希摘要。
|
||||
* 依赖:element-plus 抽屉、shipping-audit.api 类型、shippingAuditDisplay、Vue I18n、useMessage。
|
||||
* 逻辑:由 ShippingAuditCenterPage 传入 detail。关闭时 emit close。不自行拉接口。样式跟列表页已引入的 Element 皮肤走。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElAlert, ElButton, ElDrawer, ElLoading, ElTag } from 'element-plus';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { ShippingAuditEventDetail } from '@/features/admin/api/shipping-audit.api';
|
||||
import { shippingAuditBusinessLabel } from './shippingAuditDisplay';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const props = defineProps<{
|
||||
detail: ShippingAuditEventDetail | null;
|
||||
loading?: boolean;
|
||||
@@ -29,6 +30,9 @@ const open = computed(() => Boolean(props.detail || props.loading));
|
||||
|
||||
/**
|
||||
* 与列表页一致的业务化标签。
|
||||
* @param kind - 标签类别
|
||||
* @param code - 原始码
|
||||
* @returns 业务文案
|
||||
*/
|
||||
function label(kind: 'eventTypes' | 'actions' | 'reasonCodes' | 'actorTypes' | 'results', code?: string | null): string {
|
||||
return shippingAuditBusinessLabel({ t, te }, kind, code);
|
||||
@@ -36,8 +40,9 @@ function label(kind: 'eventTypes' | 'actions' | 'reasonCodes' | 'actorTypes' | '
|
||||
|
||||
/**
|
||||
* 复制技术编号。
|
||||
* @param value - 要复制的编号
|
||||
*/
|
||||
async function copyTechId(value?: string | null) {
|
||||
async function copyTechId(value?: string | null): Promise<void> {
|
||||
const text = String(value || '').trim();
|
||||
if (!text || !navigator?.clipboard?.writeText) return;
|
||||
try {
|
||||
@@ -97,172 +102,171 @@ const visualBindingDiff = computed(() => {
|
||||
|
||||
/**
|
||||
* 关闭抽屉。
|
||||
* @param next - 抽屉是否仍打开
|
||||
*/
|
||||
function onClose() {
|
||||
emit('close');
|
||||
function onVisibleChange(next: boolean): void {
|
||||
if (!next) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex justify-end bg-overlay"
|
||||
data-testid="shipping-audit-detail-drawer"
|
||||
@click.self="onClose"
|
||||
<ElDrawer
|
||||
:model-value="open"
|
||||
:title="t('admin.shippingAudit.detailTitle')"
|
||||
direction="rtl"
|
||||
size="680px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<aside class="h-full w-full max-w-xl overflow-y-auto bg-surface p-6 shadow-2xl">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-lg font-bold">{{ t('admin.shippingAudit.detailTitle') }}</h2>
|
||||
<button type="button" class="text-secondary" @click="onClose">{{ t('admin.close') }}</button>
|
||||
</div>
|
||||
<p v-if="loading" class="mt-6 text-muted">{{ t('admin.shippingAudit.loading') }}</p>
|
||||
<template v-else-if="detail">
|
||||
<p
|
||||
<div v-loading="loading" data-testid="shipping-audit-detail-drawer">
|
||||
<template v-if="detail">
|
||||
<ElAlert
|
||||
v-if="detail.sensitive_redacted"
|
||||
class="mt-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800"
|
||||
:title="t('admin.shippingAudit.sensitiveRedacted')"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
data-testid="shipping-audit-sensitive-redacted"
|
||||
>
|
||||
{{ t('admin.shippingAudit.sensitiveRedacted') }}
|
||||
</p>
|
||||
<dl class="mt-5 grid grid-cols-1 gap-3 text-sm sm:grid-cols-2">
|
||||
/>
|
||||
<dl class="audit-detail-meta">
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingAudit.columns.event') }}</dt>
|
||||
<dd class="mt-0.5 font-medium" data-testid="shipping-audit-detail-event">
|
||||
<dt>{{ t('admin.shippingAudit.columns.event') }}</dt>
|
||||
<dd data-testid="shipping-audit-detail-event">
|
||||
{{ label('eventTypes', detail.event_type) }}
|
||||
</dd>
|
||||
<dd class="text-xs text-muted">{{ label('actions', detail.action) }}</dd>
|
||||
<dd>{{ label('actions', detail.action) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingAudit.columns.actor') }}</dt>
|
||||
<dd class="mt-0.5" data-testid="shipping-audit-detail-actor">
|
||||
<dt>{{ t('admin.shippingAudit.columns.actor') }}</dt>
|
||||
<dd data-testid="shipping-audit-detail-actor">
|
||||
{{ label('actorTypes', detail.actor_type) }}
|
||||
<span v-if="detail.actor_id" class="text-muted"> · {{ t('admin.shippingAudit.copyId') }}</span>
|
||||
<span v-if="detail.actor_id"> · {{ t('admin.shippingAudit.copyId') }}</span>
|
||||
</dd>
|
||||
<button
|
||||
<ElButton
|
||||
v-if="detail.actor_id"
|
||||
type="button"
|
||||
class="mt-1 rounded border border-default px-2 py-0.5 font-mono text-[11px] text-muted"
|
||||
link
|
||||
type="primary"
|
||||
:title="String(detail.actor_id)"
|
||||
@click="copyTechId(detail.actor_id)"
|
||||
>
|
||||
{{ detail.actor_id }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingAudit.columns.reasonCode') }}</dt>
|
||||
<dd class="mt-0.5">{{ label('reasonCodes', detail.reason_code) }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.columns.reasonCode') }}</dt>
|
||||
<dd>{{ label('reasonCodes', detail.reason_code) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingAudit.columns.result') }}</dt>
|
||||
<dd class="mt-0.5" data-testid="shipping-audit-detail-result">
|
||||
{{ label('results', detail.result) }}
|
||||
<dt>{{ t('admin.shippingAudit.columns.result') }}</dt>
|
||||
<dd data-testid="shipping-audit-detail-result">
|
||||
<ElTag effect="light">{{ label('results', detail.result) }}</ElTag>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<section class="mt-5" data-testid="shipping-audit-detail-tech-refs">
|
||||
<h3 class="text-sm font-semibold">{{ t('admin.shippingAudit.columns.refs') }}</h3>
|
||||
<p class="mt-1 text-[11px] text-muted">{{ t('admin.shippingAudit.techRefsHint') }}</p>
|
||||
<div v-if="techRefs.length" class="mt-2 flex flex-wrap gap-2">
|
||||
<button
|
||||
<section data-testid="shipping-audit-detail-tech-refs">
|
||||
<h3>{{ t('admin.shippingAudit.columns.refs') }}</h3>
|
||||
<p>{{ t('admin.shippingAudit.techRefsHint') }}</p>
|
||||
<div v-if="techRefs.length" class="audit-detail-refs">
|
||||
<ElButton
|
||||
v-for="item in techRefs"
|
||||
:key="`${item.label}-${item.value}`"
|
||||
type="button"
|
||||
class="rounded border border-default px-2 py-1 text-[11px] text-secondary"
|
||||
link
|
||||
type="primary"
|
||||
:title="item.value"
|
||||
@click="copyTechId(item.value)"
|
||||
>
|
||||
<span class="text-muted">{{ item.label }}</span>
|
||||
· {{ t('admin.shippingAudit.copyId') }}
|
||||
</button>
|
||||
{{ item.label }} · {{ t('admin.shippingAudit.copyId') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
<p v-else class="mt-2 text-xs text-muted">—</p>
|
||||
<p v-else>—</p>
|
||||
</section>
|
||||
|
||||
<details class="mt-5 rounded-lg border border-default p-3 text-xs">
|
||||
<summary class="cursor-pointer font-medium text-secondary">
|
||||
{{ t('admin.shippingAudit.hashSection') }}
|
||||
</summary>
|
||||
<dl class="mt-3 space-y-2">
|
||||
<details class="audit-detail-block">
|
||||
<summary>{{ t('admin.shippingAudit.hashSection') }}</summary>
|
||||
<dl>
|
||||
<div>
|
||||
<dt class="text-muted">{{ t('admin.shippingAudit.eventHash') }}</dt>
|
||||
<dd class="break-all font-mono text-[10px]">{{ detail.event_hash || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.eventHash') }}</dt>
|
||||
<dd>{{ detail.event_hash || '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-muted">{{ t('admin.shippingAudit.previousEventHash') }}</dt>
|
||||
<dd class="break-all font-mono text-[10px]">{{ detail.previous_event_hash || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.previousEventHash') }}</dt>
|
||||
<dd>{{ detail.previous_event_hash || '—' }}</dd>
|
||||
</div>
|
||||
<div v-if="detail.before_hash">
|
||||
<dt class="text-muted">{{ t('admin.shippingAudit.beforeHash') }}</dt>
|
||||
<dd class="break-all font-mono text-[10px]" data-testid="shipping-audit-before-hash">{{ detail.before_hash }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.beforeHash') }}</dt>
|
||||
<dd data-testid="shipping-audit-before-hash">{{ detail.before_hash }}</dd>
|
||||
</div>
|
||||
<div v-if="detail.after_hash">
|
||||
<dt class="text-muted">{{ t('admin.shippingAudit.afterHash') }}</dt>
|
||||
<dd class="break-all font-mono text-[10px]" data-testid="shipping-audit-after-hash">{{ detail.after_hash }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.afterHash') }}</dt>
|
||||
<dd data-testid="shipping-audit-after-hash">{{ detail.after_hash }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</details>
|
||||
|
||||
<section
|
||||
v-if="visualBindingDiff"
|
||||
class="mt-5"
|
||||
data-testid="shipping-audit-visual-binding-diff"
|
||||
>
|
||||
<h3 class="text-sm font-semibold">{{ t('admin.shippingAudit.visualBindingDiff') }}</h3>
|
||||
<p class="mt-1 text-[11px] text-muted">{{ t('admin.shippingAudit.visualBindingDiffHint') }}</p>
|
||||
<div class="mt-2 space-y-2 rounded-lg border border-default p-3 text-xs">
|
||||
<div>
|
||||
<div class="font-medium text-muted">{{ t('admin.shippingAudit.before') }}</div>
|
||||
<pre class="mt-1 whitespace-pre-wrap break-all">{{ visualBindingDiff.before == null ? '—' : JSON.stringify(visualBindingDiff.before, null, 2) }}</pre>
|
||||
</div>
|
||||
<div>
|
||||
<div class="font-medium text-muted">{{ t('admin.shippingAudit.after') }}</div>
|
||||
<pre class="mt-1 whitespace-pre-wrap break-all">{{ visualBindingDiff.after == null ? '—' : JSON.stringify(visualBindingDiff.after, null, 2) }}</pre>
|
||||
</div>
|
||||
<section v-if="visualBindingDiff" data-testid="shipping-audit-visual-binding-diff">
|
||||
<h3>{{ t('admin.shippingAudit.visualBindingDiff') }}</h3>
|
||||
<p>{{ t('admin.shippingAudit.visualBindingDiffHint') }}</p>
|
||||
<div>
|
||||
<div>{{ t('admin.shippingAudit.before') }}</div>
|
||||
<pre>{{ visualBindingDiff.before == null ? '—' : JSON.stringify(visualBindingDiff.before, null, 2) }}</pre>
|
||||
<div>{{ t('admin.shippingAudit.after') }}</div>
|
||||
<pre>{{ visualBindingDiff.after == null ? '—' : JSON.stringify(visualBindingDiff.after, null, 2) }}</pre>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="detail.xfa_snapshot_refs?.length"
|
||||
class="mt-5"
|
||||
data-testid="shipping-audit-xfa-snapshots"
|
||||
>
|
||||
<h3 class="text-sm font-semibold">{{ t('admin.shippingAudit.xfaSnapshots') }}</h3>
|
||||
<p class="mt-1 text-[11px] text-muted">{{ t('admin.shippingAudit.xfaSnapshotsHint') }}</p>
|
||||
<ul class="mt-2 space-y-2">
|
||||
<li
|
||||
v-for="ref in detail.xfa_snapshot_refs"
|
||||
:key="ref.snapshot_ref"
|
||||
class="rounded-lg border border-default px-3 py-2 text-xs"
|
||||
>
|
||||
<div class="font-medium">{{ ref.purpose }}</div>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-1 rounded border border-default px-2 py-0.5 font-mono text-[11px] text-muted"
|
||||
:title="ref.snapshot_ref"
|
||||
<section v-if="detail.xfa_snapshot_refs?.length" data-testid="shipping-audit-xfa-snapshots">
|
||||
<h3>{{ t('admin.shippingAudit.xfaSnapshots') }}</h3>
|
||||
<p>{{ t('admin.shippingAudit.xfaSnapshotsHint') }}</p>
|
||||
<ul>
|
||||
<li v-for="item in detail.xfa_snapshot_refs" :key="item.snapshot_ref">
|
||||
<div>{{ item.purpose }}</div>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
:title="item.snapshot_ref"
|
||||
data-testid="shipping-audit-xfa-snapshot-ref"
|
||||
@click="copyTechId(ref.snapshot_ref)"
|
||||
@click="copyTechId(item.snapshot_ref)"
|
||||
>
|
||||
{{ t('admin.shippingAudit.copyId') }} · {{ ref.snapshot_ref.slice(0, 12) }}…
|
||||
</button>
|
||||
{{ t('admin.shippingAudit.copyId') }} · {{ item.snapshot_ref.slice(0, 12) }}…
|
||||
</ElButton>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<h3 class="mt-6 font-semibold">{{ t('admin.shippingAudit.diff') }}</h3>
|
||||
<div v-if="detail.diff?.length" class="mt-2 space-y-2" data-testid="shipping-audit-diff-rows">
|
||||
<div
|
||||
v-for="row in detail.diff"
|
||||
:key="row.key"
|
||||
class="rounded-lg border border-default p-3 text-xs"
|
||||
>
|
||||
<div class="font-medium">{{ row.key }} · {{ row.change }}</div>
|
||||
<div class="mt-1 text-muted">{{ t('admin.shippingAudit.before') }}: {{ row.before == null ? '—' : JSON.stringify(row.before) }}</div>
|
||||
<div class="text-muted">{{ t('admin.shippingAudit.after') }}: {{ row.after == null ? '—' : JSON.stringify(row.after) }}</div>
|
||||
<h3>{{ t('admin.shippingAudit.diff') }}</h3>
|
||||
<div v-if="detail.diff?.length" data-testid="shipping-audit-diff-rows">
|
||||
<div v-for="row in detail.diff" :key="row.key" class="audit-detail-block">
|
||||
<div>{{ row.key }} · {{ row.change }}</div>
|
||||
<div>{{ t('admin.shippingAudit.before') }}: {{ row.before == null ? '—' : JSON.stringify(row.before) }}</div>
|
||||
<div>{{ t('admin.shippingAudit.after') }}: {{ row.after == null ? '—' : JSON.stringify(row.after) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="mt-2 text-sm text-muted">{{ t('admin.shippingAudit.noDiff') }}</p>
|
||||
<p v-else>{{ t('admin.shippingAudit.noDiff') }}</p>
|
||||
</template>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</ElDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.audit-detail-meta,
|
||||
.audit-detail-refs {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.audit-detail-meta {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
.audit-detail-block {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.audit-detail-block pre,
|
||||
.audit-detail-block dd {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user