按 UI 评审闭环 UI-02~UI-07(查询降权、对象/处理人可读化、筛选分层、数据源名映射、焦点外环);概览与登录壳按约定暂缓。 Co-authored-by: Cursor <cursoragent@cursor.com>
752 lines
28 KiB
Vue
752 lines
28 KiB
Vue
<script setup lang="ts">
|
|
/**
|
|
* Alarm detail: summary, observations, evidence, and handling history.
|
|
* Boundary: footer commands follow the role rules. A closed alarm keeps only
|
|
* 返回. Server error text is not rendered. Closed basis is not a recovery.
|
|
* Depends on the alarm read APIs and the three command routes.
|
|
*/
|
|
import { computed, nextTick, onMounted, reactive, ref, watch } from "vue";
|
|
import { useI18n } from "vue-i18n";
|
|
import { useRoute, useRouter } from "vue-router";
|
|
import {
|
|
ElAlert,
|
|
ElButton,
|
|
ElDialog,
|
|
ElForm,
|
|
ElFormItem,
|
|
ElInput,
|
|
ElMessage,
|
|
ElOption,
|
|
ElSelect,
|
|
ElTable,
|
|
ElTableColumn,
|
|
ElTag,
|
|
type FormInstance,
|
|
type FormRules,
|
|
} from "element-plus";
|
|
import FormPageShell from "../shared/components/FormPageShell.vue";
|
|
import { useAuthStore } from "../stores/auth";
|
|
import {
|
|
ALARM_PERMISSION,
|
|
alarmCommandVisibility,
|
|
clearIdempotencyKey,
|
|
holdIdempotencyKey,
|
|
type IdempotencyHold,
|
|
} from "./actions";
|
|
import { appendProgress, claimAlarm, closeAlarm, getAlarm, listEvidence, listHistory, listOccurrences } from "./client";
|
|
import { describeAlarmError, isAlarmConflict, isAlarmForbidden, isAlarmNotFound } from "./errors";
|
|
import { formatDateTime, formatHandlerLabel, formatIdentityLabel } from "./format";
|
|
import type { AlarmRecord, ClosedBasis, EvidenceBundle, HistoryEvent, OccurrenceList } from "./types";
|
|
|
|
const { t, te } = useI18n();
|
|
const route = useRoute();
|
|
const router = useRouter();
|
|
const auth = useAuthStore();
|
|
|
|
const alarm = ref<AlarmRecord | null>(null);
|
|
const occurrences = ref<OccurrenceList["items"]>([]);
|
|
const evidence = ref<EvidenceBundle | null>(null);
|
|
const history = ref<HistoryEvent[]>([]);
|
|
const phase = ref<"loading" | "ready" | "error" | "forbidden" | "missing">("loading");
|
|
const loadError = ref("");
|
|
const sectionError = ref("");
|
|
const commandError = ref("");
|
|
const commandConflict = ref(false);
|
|
const commandBusy = ref(false);
|
|
|
|
const progressOpen = ref(false);
|
|
const closeOpen = ref(false);
|
|
const progressModel = reactive({ note: "", evidence: "" });
|
|
const closeModel = reactive({ result: "", note: "", evidence: "" });
|
|
const progressForm = ref<FormInstance>();
|
|
const closeForm = ref<FormInstance>();
|
|
|
|
const claimHold = ref<IdempotencyHold>(clearIdempotencyKey());
|
|
const progressHold = ref<IdempotencyHold>(clearIdempotencyKey());
|
|
const closeHold = ref<IdempotencyHold>(clearIdempotencyKey());
|
|
|
|
let loadSeq = 0;
|
|
|
|
const commands = computed(() =>
|
|
alarmCommandVisibility({
|
|
roles: auth.user?.roles ?? [],
|
|
subject: auth.user?.subject,
|
|
status: alarm.value?.status ?? "",
|
|
currentHandler: alarm.value?.current_handler ?? null,
|
|
}),
|
|
);
|
|
|
|
const progressRules = computed<FormRules>(() => ({
|
|
note: [{ required: true, whitespace: true, message: t("alarm.progressDialog.required"), trigger: "blur" }],
|
|
}));
|
|
const closeRules = computed<FormRules>(() => ({
|
|
result: [{ required: true, message: t("alarm.closeDialog.resultRequired"), trigger: "change" }],
|
|
note: [{ required: true, whitespace: true, message: t("alarm.closeDialog.noteRequired"), trigger: "blur" }],
|
|
}));
|
|
|
|
function newKey(): string {
|
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
return crypto.randomUUID();
|
|
}
|
|
return `alarm-${Date.now()}`;
|
|
}
|
|
|
|
function textOrNone(value: string | null | undefined): string {
|
|
if (value === null || value === undefined || value.trim() === "") {
|
|
return t("alarm.detail.fields.none");
|
|
}
|
|
return value;
|
|
}
|
|
|
|
function objectLabel(identityKey: string): string {
|
|
return formatIdentityLabel(identityKey) || t("alarm.detail.fields.none");
|
|
}
|
|
|
|
function handlerDisplay(subject: string | null | undefined): { label: string; title?: string } {
|
|
const short = formatHandlerLabel(subject);
|
|
if (!short) {
|
|
return { label: t("alarm.detail.fields.none") };
|
|
}
|
|
const full = subject?.trim() ?? short;
|
|
return { label: short, title: full !== short ? full : undefined };
|
|
}
|
|
|
|
function statusText(status: string): string {
|
|
const key = `alarm.status.${status}`;
|
|
return te(key) ? t(key) : status;
|
|
}
|
|
|
|
function statusTag(status: string): "warning" | "primary" | "info" {
|
|
if (status === "pending") {
|
|
return "warning";
|
|
}
|
|
if (status === "processing") {
|
|
return "primary";
|
|
}
|
|
return "info";
|
|
}
|
|
|
|
function named(group: string, value: string | null | undefined): string {
|
|
if (!value) {
|
|
return t("alarm.detail.fields.none");
|
|
}
|
|
const key = `alarm.${group}.${value}`;
|
|
return te(key) ? t(key) : value;
|
|
}
|
|
|
|
function roleText(role: string): string {
|
|
const key = `alarm.role.${role}`;
|
|
return te(key) ? t(key) : role;
|
|
}
|
|
|
|
function backToList(): void {
|
|
void router.push({ name: "alarm-list" });
|
|
}
|
|
|
|
function openPrevious(): void {
|
|
const id = alarm.value?.previous_alarm_id;
|
|
if (!id) {
|
|
return;
|
|
}
|
|
void router.push({ name: "alarm-detail", params: { id } });
|
|
}
|
|
|
|
async function load(): Promise<void> {
|
|
const id = String(route.params.id ?? "");
|
|
const seq = ++loadSeq;
|
|
phase.value = "loading";
|
|
loadError.value = "";
|
|
sectionError.value = "";
|
|
alarm.value = null;
|
|
occurrences.value = [];
|
|
evidence.value = null;
|
|
history.value = [];
|
|
if (!id) {
|
|
phase.value = "missing";
|
|
return;
|
|
}
|
|
const [alarmResult, occurrenceResult, evidenceResult, historyResult] = await Promise.allSettled([
|
|
getAlarm(id),
|
|
listOccurrences(id),
|
|
listEvidence(id),
|
|
listHistory(id),
|
|
]);
|
|
if (seq !== loadSeq) {
|
|
return;
|
|
}
|
|
if (alarmResult.status === "rejected") {
|
|
if (isAlarmNotFound(alarmResult.reason)) {
|
|
phase.value = "missing";
|
|
return;
|
|
}
|
|
phase.value = isAlarmForbidden(alarmResult.reason) ? "forbidden" : "error";
|
|
loadError.value = describeAlarmError(
|
|
alarmResult.reason,
|
|
t,
|
|
te,
|
|
"alarm.detail.loadFailed",
|
|
ALARM_PERMISSION.read,
|
|
);
|
|
return;
|
|
}
|
|
alarm.value = alarmResult.value;
|
|
if (occurrenceResult.status === "fulfilled") {
|
|
occurrences.value = occurrenceResult.value.items;
|
|
}
|
|
if (evidenceResult.status === "fulfilled") {
|
|
evidence.value = evidenceResult.value;
|
|
}
|
|
if (historyResult.status === "fulfilled") {
|
|
history.value = historyResult.value.items;
|
|
}
|
|
if (
|
|
occurrenceResult.status === "rejected" ||
|
|
evidenceResult.status === "rejected" ||
|
|
historyResult.status === "rejected"
|
|
) {
|
|
const reason =
|
|
(occurrenceResult.status === "rejected" && occurrenceResult.reason) ||
|
|
(evidenceResult.status === "rejected" && evidenceResult.reason) ||
|
|
(historyResult.status === "rejected" && historyResult.reason);
|
|
sectionError.value = describeAlarmError(reason, t, te, "alarm.detail.sectionFailed", ALARM_PERMISSION.read);
|
|
}
|
|
phase.value = "ready";
|
|
}
|
|
|
|
function permissionFor(command: "claim" | "progress" | "close"): string {
|
|
if (command === "claim") {
|
|
return ALARM_PERMISSION.take;
|
|
}
|
|
if (command === "progress") {
|
|
return ALARM_PERMISSION.progress;
|
|
}
|
|
return ALARM_PERMISSION.close;
|
|
}
|
|
|
|
async function runCommand(
|
|
command: "claim" | "progress" | "close",
|
|
send: () => Promise<unknown>,
|
|
): Promise<boolean> {
|
|
if (commandBusy.value) {
|
|
return false;
|
|
}
|
|
commandBusy.value = true;
|
|
commandError.value = "";
|
|
commandConflict.value = false;
|
|
try {
|
|
await send();
|
|
return true;
|
|
} catch (error) {
|
|
commandConflict.value = isAlarmConflict(error);
|
|
commandError.value = describeAlarmError(
|
|
error,
|
|
t,
|
|
te,
|
|
"alarm.command.failed",
|
|
permissionFor(command),
|
|
);
|
|
return false;
|
|
} finally {
|
|
commandBusy.value = false;
|
|
}
|
|
}
|
|
|
|
async function finishCommand(ok: boolean, successKey: string, closeDialog: () => void): Promise<void> {
|
|
if (ok) {
|
|
closeDialog();
|
|
ElMessage.success(t(successKey));
|
|
} else if (commandConflict.value) {
|
|
closeDialog();
|
|
}
|
|
await load();
|
|
}
|
|
|
|
async function onClaim(): Promise<void> {
|
|
const id = alarm.value?.id;
|
|
if (!id || !commands.value.claim) {
|
|
return;
|
|
}
|
|
claimHold.value = holdIdempotencyKey(claimHold.value, "claim", newKey);
|
|
const key = claimHold.value.key;
|
|
const ok = await runCommand("claim", () => claimAlarm(id, key));
|
|
if (ok) {
|
|
claimHold.value = clearIdempotencyKey();
|
|
}
|
|
await finishCommand(ok, "alarm.command.claimed", () => undefined);
|
|
}
|
|
|
|
async function openProgress(): Promise<void> {
|
|
progressModel.note = "";
|
|
progressModel.evidence = "";
|
|
commandError.value = "";
|
|
commandConflict.value = false;
|
|
progressOpen.value = true;
|
|
await nextTick();
|
|
progressForm.value?.clearValidate();
|
|
}
|
|
|
|
async function submitProgress(): Promise<void> {
|
|
const id = alarm.value?.id;
|
|
if (!id || !commands.value.progress || commandBusy.value) {
|
|
return;
|
|
}
|
|
const valid = await progressForm.value?.validate().catch(() => false);
|
|
if (!valid) {
|
|
return;
|
|
}
|
|
const note = progressModel.note.trim();
|
|
const evidenceRef = progressModel.evidence.trim();
|
|
const payload = JSON.stringify({ note, evidence_ref: evidenceRef });
|
|
progressHold.value = holdIdempotencyKey(progressHold.value, payload, newKey);
|
|
const body = evidenceRef ? { note, evidence_ref: evidenceRef } : { note };
|
|
const ok = await runCommand("progress", () => appendProgress(id, progressHold.value.key, body));
|
|
if (ok) {
|
|
progressHold.value = clearIdempotencyKey();
|
|
}
|
|
await finishCommand(ok, "alarm.command.progressSaved", () => {
|
|
progressOpen.value = false;
|
|
});
|
|
}
|
|
|
|
async function openClose(): Promise<void> {
|
|
closeModel.result = "";
|
|
closeModel.note = "";
|
|
closeModel.evidence = "";
|
|
commandError.value = "";
|
|
commandConflict.value = false;
|
|
closeOpen.value = true;
|
|
await nextTick();
|
|
closeForm.value?.clearValidate();
|
|
}
|
|
|
|
async function submitClose(): Promise<void> {
|
|
const id = alarm.value?.id;
|
|
if (!id || !commands.value.close || commandBusy.value) {
|
|
return;
|
|
}
|
|
const valid = await closeForm.value?.validate().catch(() => false);
|
|
if (!valid) {
|
|
return;
|
|
}
|
|
const note = closeModel.note.trim();
|
|
const evidenceRef = closeModel.evidence.trim();
|
|
const payload = JSON.stringify({ result: closeModel.result, note, evidence_ref: evidenceRef });
|
|
closeHold.value = holdIdempotencyKey(closeHold.value, payload, newKey);
|
|
const body = evidenceRef
|
|
? { result: closeModel.result, note, evidence_ref: evidenceRef }
|
|
: { result: closeModel.result, note };
|
|
const ok = await runCommand("close", () => closeAlarm(id, closeHold.value.key, body));
|
|
if (ok) {
|
|
closeHold.value = clearIdempotencyKey();
|
|
}
|
|
await finishCommand(ok, "alarm.command.closed", () => {
|
|
closeOpen.value = false;
|
|
});
|
|
}
|
|
|
|
function keepDialog(done: () => void): void {
|
|
if (commandBusy.value) {
|
|
return;
|
|
}
|
|
done();
|
|
}
|
|
|
|
watch(
|
|
() => route.params.id,
|
|
() => {
|
|
void load();
|
|
},
|
|
);
|
|
|
|
onMounted(() => {
|
|
void load();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<FormPageShell test-id="alarm-detail" body-test-id="alarm-scroll" footer-test-id="alarm-footer">
|
|
<p v-if="phase === 'loading'" data-testid="alarm-detail-loading">{{ t("alarm.detail.loading") }}</p>
|
|
<ElAlert
|
|
v-else-if="phase === 'missing'"
|
|
type="warning"
|
|
data-testid="alarm-missing"
|
|
:title="t('alarm.detail.notFound')"
|
|
show-icon
|
|
:closable="false"
|
|
/>
|
|
<ElAlert
|
|
v-else-if="phase === 'forbidden' || phase === 'error'"
|
|
type="error"
|
|
data-testid="alarm-detail-error"
|
|
:title="loadError || t('alarm.detail.loadFailed')"
|
|
show-icon
|
|
:closable="false"
|
|
/>
|
|
<template v-else-if="alarm">
|
|
<ElAlert
|
|
v-if="commandError"
|
|
class="mb-3.5"
|
|
:type="commandConflict ? 'warning' : 'error'"
|
|
data-testid="alarm-command-error"
|
|
:title="commandError"
|
|
:description="commandConflict ? t('alarm.command.conflictRefreshed') : undefined"
|
|
show-icon
|
|
:closable="false"
|
|
/>
|
|
<ElAlert
|
|
v-if="sectionError"
|
|
class="mb-3.5"
|
|
type="error"
|
|
data-testid="alarm-section-error"
|
|
:title="sectionError"
|
|
show-icon
|
|
:closable="false"
|
|
/>
|
|
|
|
<section class="wm-form-section" data-testid="alarm-summary">
|
|
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("alarm.detail.summary") }}</h3>
|
|
<dl class="grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2">
|
|
<div class="sm:col-span-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--bg-surface-soft)] p-3">
|
|
<div class="grid grid-cols-1 gap-3 sm:grid-cols-3">
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.status") }}</dt>
|
|
<dd class="mt-1 font-semibold text-[var(--text-primary)]">
|
|
<ElTag :type="statusTag(alarm.status)" effect="light" data-testid="alarm-detail-status">
|
|
{{ statusText(alarm.status) }}
|
|
</ElTag>
|
|
<span v-if="alarm.close_result" class="ml-1 text-[13px] font-medium">
|
|
{{ t("alarm.list.resultSep") }}{{ named("closeResult", alarm.close_result) }}
|
|
</span>
|
|
</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.scenario") }}</dt>
|
|
<dd class="mt-1 text-[15px] font-semibold text-[var(--text-primary)]">{{ alarm.scenario_name }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.object") }}</dt>
|
|
<dd
|
|
class="mt-1 text-[15px] font-semibold text-[var(--text-primary)]"
|
|
data-testid="alarm-identity"
|
|
:title="alarm.identity_key"
|
|
>
|
|
{{ objectLabel(alarm.identity_key) }}
|
|
</dd>
|
|
<p
|
|
v-if="objectLabel(alarm.identity_key) !== alarm.identity_key"
|
|
class="mt-0.5 truncate text-[12px] text-[var(--text-muted)]"
|
|
data-testid="alarm-identity-raw"
|
|
:title="alarm.identity_key"
|
|
>
|
|
{{ alarm.identity_key }}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.module") }}</dt>
|
|
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">{{ alarm.module_key }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.count") }}</dt>
|
|
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">{{ alarm.occurrence_count }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.firstOccurred") }}</dt>
|
|
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
|
{{ formatDateTime(alarm.first_occurred_at) || t("alarm.detail.fields.none") }}
|
|
</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.lastOccurred") }}</dt>
|
|
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
|
{{ formatDateTime(alarm.last_occurred_at) || t("alarm.detail.fields.none") }}
|
|
</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.handler") }}</dt>
|
|
<dd
|
|
class="mt-0.5 font-medium text-[var(--text-primary)]"
|
|
data-testid="alarm-handler"
|
|
:title="handlerDisplay(alarm.current_handler).title"
|
|
>
|
|
{{ handlerDisplay(alarm.current_handler).label }}
|
|
</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.claimedAt") }}</dt>
|
|
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
|
{{ formatDateTime(alarm.claimed_at) || t("alarm.detail.fields.none") }}
|
|
</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.closedAt") }}</dt>
|
|
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
|
{{ formatDateTime(alarm.closed_at) || t("alarm.detail.fields.none") }}
|
|
</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.openedAt") }}</dt>
|
|
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
|
{{ formatDateTime(alarm.opened_at) || t("alarm.detail.fields.none") }}
|
|
</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.updatedAt") }}</dt>
|
|
<dd class="mt-0.5 font-medium text-[var(--text-primary)]">
|
|
{{ formatDateTime(alarm.updated_at) || t("alarm.detail.fields.none") }}
|
|
</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.scenarioKey") }}</dt>
|
|
<dd class="mt-0.5 text-[var(--text-secondary)]">{{ alarm.scenario_key }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.cycle") }}</dt>
|
|
<dd class="mt-0.5 text-[var(--text-secondary)]">{{ textOrNone(alarm.cycle_key) }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.event") }}</dt>
|
|
<dd class="mt-0.5 text-[var(--text-secondary)]">{{ textOrNone(alarm.event_key) }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-[12px] text-[var(--text-muted)]">{{ t("alarm.detail.fields.previous") }}</dt>
|
|
<dd class="mt-0.5">
|
|
<ElButton
|
|
v-if="alarm.previous_alarm_id"
|
|
link
|
|
type="primary"
|
|
data-testid="alarm-previous"
|
|
@click="openPrevious"
|
|
>
|
|
{{ alarm.previous_alarm_id }}
|
|
</ElButton>
|
|
<span v-else class="text-[var(--text-secondary)]">{{ t("alarm.detail.fields.none") }}</span>
|
|
</dd>
|
|
</div>
|
|
</dl>
|
|
</section>
|
|
|
|
<section class="wm-form-section" data-testid="alarm-occurrences">
|
|
<h3 class="mb-1 text-[14.5px] font-semibold">{{ t("alarm.detail.occurrences") }}</h3>
|
|
<p class="mb-2.5 text-[var(--text-muted)]">{{ t("alarm.detail.occurrencesHint") }}</p>
|
|
<ElTable :data="occurrences" row-key="id" :empty-text="t('alarm.detail.occurrencesEmpty')">
|
|
<ElTableColumn :label="t('alarm.occurrence.observedAt')" min-width="160">
|
|
<template #default="{ row }">{{ formatDateTime(row.observed_at) }}</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn :label="t('alarm.occurrence.receivedAt')" min-width="160">
|
|
<template #default="{ row }">{{ formatDateTime(row.received_at) }}</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn prop="cycle_key" :label="t('alarm.occurrence.cycle')" min-width="120" />
|
|
<ElTableColumn prop="event_key" :label="t('alarm.occurrence.event')" min-width="120" />
|
|
</ElTable>
|
|
</section>
|
|
|
|
<section class="wm-form-section" data-testid="alarm-evidence">
|
|
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("alarm.detail.evidence") }}</h3>
|
|
<h4 class="mb-2 font-semibold">{{ t("alarm.detail.revisionEvidence") }}</h4>
|
|
<ElTable
|
|
:data="evidence?.revision_evidence ?? []"
|
|
row-key="id"
|
|
:empty-text="t('alarm.detail.revisionEmpty')"
|
|
>
|
|
<ElTableColumn :label="t('alarm.evidenceCols.receivedAt')" min-width="160">
|
|
<template #default="{ row }">{{ formatDateTime(row.received_at) }}</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn :label="t('alarm.evidenceCols.recordedAt')" min-width="160">
|
|
<template #default="{ row }">{{ formatDateTime(row.recorded_at) }}</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn prop="snapshot_version_no" :label="t('alarm.evidenceCols.snapshotVersion')" min-width="110" />
|
|
</ElTable>
|
|
<h4 class="mb-1 mt-4 font-semibold">{{ t("alarm.detail.closedBasis") }}</h4>
|
|
<p class="mb-2.5 text-[var(--text-muted)]" data-testid="alarm-closed-basis-hint">
|
|
{{ t("alarm.detail.closedBasisHint") }}
|
|
</p>
|
|
<ElTable :data="evidence?.closed_basis ?? []" row-key="id" :empty-text="t('alarm.detail.closedBasisEmpty')">
|
|
<ElTableColumn :label="t('alarm.evidenceCols.observedAt')" min-width="160">
|
|
<template #default="{ row }">{{ formatDateTime((row as ClosedBasis).observed_at) }}</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn :label="t('alarm.evidenceCols.receivedAt')" min-width="160">
|
|
<template #default="{ row }">{{ formatDateTime(row.received_at) }}</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn prop="cycle_key" :label="t('alarm.evidenceCols.cycle')" min-width="120" />
|
|
<ElTableColumn prop="event_key" :label="t('alarm.evidenceCols.event')" min-width="120" />
|
|
</ElTable>
|
|
</section>
|
|
|
|
<section class="wm-form-section" data-testid="alarm-history">
|
|
<h3 class="mb-3 text-[14.5px] font-semibold">{{ t("alarm.detail.history") }}</h3>
|
|
<ElTable :data="history" row-key="id" :empty-text="t('alarm.detail.historyEmpty')">
|
|
<ElTableColumn prop="seq" :label="t('alarm.historyCols.seq')" width="72" />
|
|
<ElTableColumn :label="t('alarm.historyCols.command')" min-width="100">
|
|
<template #default="{ row }">{{ named("commandName", (row as HistoryEvent).command) }}</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn :label="t('alarm.historyCols.actor')" min-width="140">
|
|
<template #default="{ row }">
|
|
{{ (row as HistoryEvent).actor_subject }}
|
|
{{ roleText((row as HistoryEvent).actor_role) }}
|
|
</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn prop="handler_subject" :label="t('alarm.historyCols.handler')" min-width="120" />
|
|
<ElTableColumn :label="t('alarm.historyCols.note')" min-width="180">
|
|
<template #default="{ row }">{{ textOrNone((row as HistoryEvent).note) }}</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn :label="t('alarm.historyCols.result')" min-width="100">
|
|
<template #default="{ row }">{{ named("closeResult", (row as HistoryEvent).close_result) }}</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn :label="t('alarm.historyCols.evidence')" min-width="140">
|
|
<template #default="{ row }">{{ textOrNone((row as HistoryEvent).evidence_ref) }}</template>
|
|
</ElTableColumn>
|
|
<ElTableColumn :label="t('alarm.historyCols.at')" min-width="160">
|
|
<template #default="{ row }">{{ formatDateTime((row as HistoryEvent).recorded_at) }}</template>
|
|
</ElTableColumn>
|
|
</ElTable>
|
|
</section>
|
|
</template>
|
|
|
|
<template #footer>
|
|
<ElButton data-testid="footer-back" :disabled="commandBusy" @click="backToList">
|
|
{{ t("alarm.actions.back") }}
|
|
</ElButton>
|
|
<template v-if="phase === 'ready' && alarm && alarm.status !== 'closed'">
|
|
<ElButton
|
|
v-if="commands.claim"
|
|
type="primary"
|
|
data-testid="footer-claim"
|
|
:loading="commandBusy"
|
|
@click="onClaim"
|
|
>
|
|
{{ t("alarm.actions.claim") }}
|
|
</ElButton>
|
|
<ElButton
|
|
v-if="commands.progress"
|
|
data-testid="footer-progress"
|
|
:disabled="commandBusy"
|
|
@click="openProgress"
|
|
>
|
|
{{ t("alarm.actions.progress") }}
|
|
</ElButton>
|
|
<ElButton
|
|
v-if="commands.close"
|
|
type="primary"
|
|
data-testid="footer-close"
|
|
:disabled="commandBusy"
|
|
@click="openClose"
|
|
>
|
|
{{ t("alarm.actions.close") }}
|
|
</ElButton>
|
|
</template>
|
|
</template>
|
|
</FormPageShell>
|
|
|
|
<ElDialog
|
|
v-model="progressOpen"
|
|
align-center
|
|
append-to-body
|
|
:close-on-click-modal="false"
|
|
:before-close="keepDialog"
|
|
:title="t('alarm.progressDialog.title')"
|
|
width="480px"
|
|
data-testid="alarm-progress-dialog"
|
|
>
|
|
<ElAlert
|
|
v-if="commandError && progressOpen"
|
|
class="mb-3"
|
|
type="error"
|
|
:title="commandError"
|
|
show-icon
|
|
:closable="false"
|
|
/>
|
|
<ElForm
|
|
ref="progressForm"
|
|
:model="progressModel"
|
|
:rules="progressRules"
|
|
label-position="top"
|
|
@submit.prevent
|
|
>
|
|
<ElFormItem :label="t('alarm.progressDialog.note')" prop="note" data-testid="progress-note">
|
|
<ElInput
|
|
v-model="progressModel.note"
|
|
type="textarea"
|
|
:rows="4"
|
|
maxlength="2000"
|
|
:placeholder="t('alarm.progressDialog.notePlaceholder')"
|
|
/>
|
|
</ElFormItem>
|
|
<ElFormItem :label="t('alarm.progressDialog.evidence')" data-testid="progress-evidence">
|
|
<ElInput
|
|
v-model="progressModel.evidence"
|
|
maxlength="512"
|
|
:placeholder="t('alarm.progressDialog.evidencePlaceholder')"
|
|
/>
|
|
</ElFormItem>
|
|
</ElForm>
|
|
<template #footer>
|
|
<ElButton :disabled="commandBusy" @click="progressOpen = false">
|
|
{{ t("alarm.progressDialog.cancel") }}
|
|
</ElButton>
|
|
<ElButton type="primary" data-testid="progress-submit" :loading="commandBusy" @click="submitProgress">
|
|
{{ commandBusy ? t("alarm.actions.submitting") : t("alarm.progressDialog.submit") }}
|
|
</ElButton>
|
|
</template>
|
|
</ElDialog>
|
|
|
|
<ElDialog
|
|
v-model="closeOpen"
|
|
align-center
|
|
append-to-body
|
|
:close-on-click-modal="false"
|
|
:before-close="keepDialog"
|
|
:title="t('alarm.closeDialog.title')"
|
|
width="480px"
|
|
data-testid="alarm-close-dialog"
|
|
>
|
|
<ElAlert
|
|
v-if="commandError && closeOpen"
|
|
class="mb-3"
|
|
type="error"
|
|
:title="commandError"
|
|
show-icon
|
|
:closable="false"
|
|
/>
|
|
<ElForm
|
|
ref="closeForm"
|
|
:model="closeModel"
|
|
:rules="closeRules"
|
|
label-position="top"
|
|
@submit.prevent
|
|
>
|
|
<ElFormItem :label="t('alarm.closeDialog.result')" prop="result" data-testid="close-result">
|
|
<ElSelect v-model="closeModel.result" class="w-full" :placeholder="t('alarm.closeDialog.resultPlaceholder')">
|
|
<ElOption :label="t('alarm.closeResult.resolved')" value="resolved" />
|
|
<ElOption :label="t('alarm.closeResult.false_positive')" value="false_positive" />
|
|
</ElSelect>
|
|
</ElFormItem>
|
|
<ElFormItem :label="t('alarm.closeDialog.note')" prop="note" data-testid="close-note">
|
|
<ElInput
|
|
v-model="closeModel.note"
|
|
type="textarea"
|
|
:rows="4"
|
|
maxlength="2000"
|
|
:placeholder="t('alarm.closeDialog.notePlaceholder')"
|
|
/>
|
|
</ElFormItem>
|
|
<ElFormItem :label="t('alarm.closeDialog.evidence')" data-testid="close-evidence">
|
|
<ElInput
|
|
v-model="closeModel.evidence"
|
|
maxlength="512"
|
|
:placeholder="t('alarm.closeDialog.evidencePlaceholder')"
|
|
/>
|
|
</ElFormItem>
|
|
</ElForm>
|
|
<template #footer>
|
|
<ElButton :disabled="commandBusy" @click="closeOpen = false">
|
|
{{ t("alarm.closeDialog.cancel") }}
|
|
</ElButton>
|
|
<ElButton type="primary" data-testid="close-submit" :loading="commandBusy" @click="submitClose">
|
|
{{ commandBusy ? t("alarm.actions.submitting") : t("alarm.closeDialog.submit") }}
|
|
</ElButton>
|
|
</template>
|
|
</ElDialog>
|
|
</template>
|