feat(equipment-maintenance): 增加上下文设备解析

This commit is contained in:
sophie committed 2026-07-06 15:20:24 +08:00
1 parent 76d5778c3b
commit 2566ce53e4
21 files changed
+512 -62

No files matched your search

@@ -40,6 +40,7 @@ const { t } = useI18n();
<option value="">{{ t('admin.batchEdit.fields.keepUnchanged') }}</option>
<option value="user">{{ t('admin.role.user') }}</option>
<option value="hr">{{ t('admin.role.hr') }}</option>
<option value="maintenance_manager">{{ t('admin.role.maintenanceManager') }}</option>
<option value="admin">{{ t('admin.role.admin') }}</option>
</select>
</div>
@@ -88,6 +88,7 @@ const { t } = useI18n();
<select v-model="form.role" class="w-full border-default rounded-xl px-4 py-3 text-sm">
<option value="user">{{ t('admin.role.user') }}</option>
<option value="hr">{{ t('admin.role.hr') }}</option>
<option value="maintenance_manager">{{ t('admin.role.maintenanceManager') }}</option>
<option value="admin">{{ t('admin.role.admin') }}</option>
</select>
</div>
@@ -40,6 +40,7 @@ const props = defineProps<{
canSendMessage: boolean;
isShippingNoticeAgent: boolean;
isMaintenanceAgent?: boolean;
canManageMaintenance?: boolean;
shippingSuggestedPrompt: string;
shippingFocusTaskNo?: string;
shippingFocusReason?: string;
@@ -200,7 +201,7 @@ watch(
ref="textareaRef"
v-model="inputValue"
rows="1"
:placeholder="isVoiceTranscribing ? $t('chat.voiceTranscribing') : isVoiceRecording ? $t('chat.voiceListening') : shippingFocusTaskNo ? $t('chat.shippingNoticeUi.focusInputPlaceholder', { taskId: shippingFocusTaskNo }) : $t('chat.askAnything')"
:placeholder="isVoiceTranscribing ? $t('chat.voiceTranscribing') : isVoiceRecording ? $t('chat.voiceListening') : shippingFocusTaskNo ? $t('chat.shippingNoticeUi.focusInputPlaceholder', { taskId: shippingFocusTaskNo }) : isMaintenanceAgent ? $t('maintenance.chat.inputPlaceholder') : $t('chat.askAnything')"
class="w-full resize-none border-none bg-transparent px-2.5 py-1.5 text-[15px] leading-relaxed text-primary placeholder-slate-400 focus:border-transparent focus:outline-none focus:ring-0"
style="min-height: 40px; max-height: 220px;"
:disabled="isVoiceTranscribing"
@@ -257,7 +258,7 @@ watch(
</div>
<div
v-if="isMaintenanceAgent"
v-if="isMaintenanceAgent && canManageMaintenance"
class="flex flex-wrap items-center gap-2 px-3 pb-1 text-xs text-muted"
>
<button
@@ -27,6 +27,7 @@ const isMaintenanceAgentPage = computed(() => {
const name = String(page.currentAgent?.name || '').trim();
return name === '设备维保助手' || (name.includes('设备维保') && name.includes('助手'));
});
const canManageMaintenance = computed(() => ['admin', 'maintenance_manager'].includes(String(page.currentUser?.role || '')));
const hideWelcomePanel = computed(() => isTrainingAgentPage.value);
const isTrainingWorkspaceExpanded = ref(false);
const maintenancePanel = ref<'ledger' | 'record' | null>(null);
@@ -220,6 +221,7 @@ watch(() => page.currentAgentId, () => {
:can-send-message="page.canSendMessage"
:is-shipping-notice-agent="page.isShippingNoticeAgent"
:is-maintenance-agent="isMaintenanceAgentPage"
:can-manage-maintenance="canManageMaintenance"
:shipping-suggested-prompt="page.shippingSuggestedPrompt"
:shipping-focus-task-no="page.focusedShippingTaskNo"
:shipping-focus-reason="page.shippingFocusReason"
@@ -240,7 +242,7 @@ watch(() => page.currentAgentId, () => {
</div>
<aside
v-if="isMaintenanceAgentPage && maintenancePanel"
v-if="isMaintenanceAgentPage && canManageMaintenance && maintenancePanel"
class="relative flex flex-col border-l border-default bg-surface shadow-[-8px_0_24px_rgba(15,23,42,0.06)]"
:class="[
isMaintenancePanelFullscreen ? 'absolute inset-y-0 right-0 z-30' : '',
@@ -15,6 +15,9 @@ interface MaintenanceDeviceResultPayload {
matched?: boolean;
device?: MaintenanceDevice;
records?: MaintenanceRecord[];
summary?: {
ledgerMatched?: boolean;
};
actions?: Array<{ id: string; label: string }>;
}
@@ -32,6 +35,8 @@ const payload = computed<MaintenanceDeviceResultPayload | null>(() => {
const device = computed(() => payload.value?.device || null);
const records = computed(() => payload.value?.records || []);
const hasResult = computed(() => Boolean(device.value || records.value.length));
const ledgerMatched = computed(() => payload.value?.summary?.ledgerMatched !== false);
const statusLabel = computed(() => {
const status = device.value?.deviceStatus;
@@ -67,15 +72,20 @@ const rows = computed(() => {
</script>
<template>
<section v-if="device" class="mt-3 rounded-xl border border-slate-300 bg-white p-3 text-sm text-slate-800 shadow-sm">
<section v-if="hasResult" class="mt-3 rounded-xl border border-slate-300 bg-white p-3 text-sm text-slate-800 shadow-sm">
<div class="flex items-center justify-between gap-3 rounded-t-lg border border-slate-200 bg-slate-50 px-3 py-2">
<h3 class="font-semibold">{{ t('maintenance.chat.deviceLedgerInfo') }}</h3>
<span class="rounded-full bg-emerald-50 px-2.5 py-0.5 text-xs font-semibold text-emerald-700">
{{ t('maintenance.chat.matched') }}
<h3 class="font-semibold">
{{ device ? t('maintenance.chat.deviceLedgerInfo') : t('maintenance.chat.recordInfo') }}
</h3>
<span
class="rounded-full px-2.5 py-0.5 text-xs font-semibold"
:class="ledgerMatched ? 'bg-emerald-50 text-emerald-700' : 'bg-amber-50 text-amber-700'"
>
{{ ledgerMatched ? t('maintenance.chat.matched') : t('maintenance.chat.recordMatched') }}
</span>
</div>
<div class="overflow-hidden border-x border-b border-slate-200">
<div v-if="device" class="overflow-hidden border-x border-b border-slate-200">
<table class="w-full table-fixed text-sm">
<tbody>
<tr v-for="(row, rowIndex) in rows" :key="rowIndex" class="border-t border-slate-200 first:border-t-0">
@@ -439,34 +439,30 @@ onMounted(loadRecords);
</div>
<div class="min-h-0 overflow-auto rounded-xl border border-default bg-surface">
<table class="min-w-full text-left text-sm">
<table class="w-full table-fixed text-left text-sm">
<thead class="bg-muted/50 text-secondary">
<tr>
<th class="px-3 py-2">{{ t('maintenance.record.table.deviceCode') }}</th>
<th class="px-3 py-2">{{ t('maintenance.record.table.deviceName') }}</th>
<th class="px-3 py-2">{{ t('maintenance.record.table.modelSpec') }}</th>
<th class="w-[24%] px-3 py-2">{{ t('maintenance.record.table.deviceCode') }}</th>
<th class="w-[22%] px-3 py-2">{{ t('maintenance.record.table.deviceName') }}</th>
<th class="px-3 py-2">{{ t('maintenance.record.table.faultDescription') }}</th>
<th class="px-3 py-2">{{ t('maintenance.record.table.status') }}</th>
<th class="px-3 py-2">{{ t('maintenance.record.table.repairer') }}</th>
<th class="px-3 py-2">{{ t('maintenance.record.table.operation') }}</th>
<th class="w-[14%] px-3 py-2">{{ t('maintenance.record.table.status') }}</th>
<th class="w-[18%] px-3 py-2 text-right">{{ t('maintenance.record.table.operation') }}</th>
</tr>
</thead>
<tbody>
<tr v-if="loading">
<td colspan="7" class="px-3 py-8 text-center text-secondary">{{ t('maintenance.record.table.loading') }}</td>
<td colspan="5" class="px-3 py-8 text-center text-secondary">{{ t('maintenance.record.table.loading') }}</td>
</tr>
<tr v-else-if="!records.length">
<td colspan="7" class="px-3 py-8 text-center text-secondary">{{ t('maintenance.record.table.empty') }}</td>
<td colspan="5" class="px-3 py-8 text-center text-secondary">{{ t('maintenance.record.table.empty') }}</td>
</tr>
<tr v-for="record in records" v-else :key="record.id" class="border-t border-default">
<td class="px-3 py-2 font-semibold">{{ record.deviceCode }}</td>
<td class="px-3 py-2">{{ record.deviceName || '-' }}</td>
<td class="px-3 py-2">{{ record.modelSpec || '-' }}</td>
<td class="max-w-[260px] truncate px-3 py-2">{{ record.faultDescription }}</td>
<td class="truncate px-3 py-2 font-semibold" :title="record.deviceCode">{{ record.deviceCode }}</td>
<td class="truncate px-3 py-2" :title="record.deviceName || '-'">{{ record.deviceName || '-' }}</td>
<td class="truncate px-3 py-2" :title="record.faultDescription">{{ record.faultDescription }}</td>
<td class="px-3 py-2">{{ formatStatus(record.repairStatus) }}</td>
<td class="px-3 py-2">{{ record.repairer || '-' }}</td>
<td class="px-3 py-2">
<div class="flex gap-2">
<div class="flex justify-end gap-2">
<button type="button" class="admin-report-page-btn" @click="startEdit(record)">{{ t('maintenance.record.actions.edit') }}</button>
<button
type="button"
+1
View File
@@ -1086,6 +1086,7 @@
"role": {
"user": "User",
"hr": "HR",
"maintenanceManager": "Maintenance Admin",
"admin": "Admin",
"guest": "Guest"
},
+5 -2
View File
@@ -80,7 +80,7 @@
"panel": {
"recordTitle": "Maintenance Records",
"ledgerTitle": "Ledger Config",
"adminOnly": "Admin actions: asset admins / maintenance supervisors only",
"adminOnly": "Admin actions: admins / maintenance admins only",
"resizeTitle": "Drag to resize",
"ledgerSubtitle": "Equipment List / Equipment Config",
"recordSubtitle": "Record List / Record Config",
@@ -189,9 +189,12 @@
},
"chat": {
"deviceLedgerInfo": "Equipment Ledger Info",
"recordInfo": "Equipment Maintenance Records",
"matched": "Matched",
"recordMatched": "Maintenance records matched",
"recentRecords": "Recent maintenance records ({count})",
"viewRepairHistory": "View Repair History",
"addRepairRecord": "Add Repair Record"
"addRepairRecord": "Add Repair Record",
"inputPlaceholder": "Ask me about equipment maintenance, e.g. query ledger info for A022700978"
}
}
+1
View File
@@ -945,6 +945,7 @@
"role": {
"user": "ผู้ใช้ทั่วไป",
"hr": "HR",
"maintenanceManager": "ผู้ดูแลซ่อมบำรุง",
"admin": "ผู้ดูแลระบบ",
"guest": "ผู้เยี่ยมชม"
},
+5 -2
View File
@@ -80,7 +80,7 @@
"panel": {
"recordTitle": "บันทึกซ่อมบำรุง",
"ledgerTitle": "ตั้งค่าทะเบียน",
"adminOnly": "งานผู้ดูแล: ใช้ได้เฉพาะผู้ดูแลทรัพย์สิน / หัวหน้าซ่อมบำรุง",
"adminOnly": "งานผู้ดูแล: เฉพาะผู้ดูแลระบบ / ผู้ดูแลซ่อมบำรุง",
"resizeTitle": "ลากเพื่อปรับความกว้าง",
"ledgerSubtitle": "รายการอุปกรณ์ / ตั้งค่าอุปกรณ์",
"recordSubtitle": "รายการบันทึก / ตั้งค่าบันทึก",
@@ -189,9 +189,12 @@
},
"chat": {
"deviceLedgerInfo": "ข้อมูลทะเบียนอุปกรณ์",
"recordInfo": "บันทึกซ่อมบำรุงอุปกรณ์",
"matched": "พบข้อมูล",
"recordMatched": "พบบันทึกซ่อมบำรุง",
"recentRecords": "บันทึกซ่อมบำรุงล่าสุด ({count})",
"viewRepairHistory": "ดูประวัติซ่อม",
"addRepairRecord": "เพิ่มบันทึกซ่อม"
"addRepairRecord": "เพิ่มบันทึกซ่อม",
"inputPlaceholder": "ถามข้อมูลซ่อมบำรุงอุปกรณ์ เช่น ค้นหาทะเบียนของ A022700978"
}
}
+1
View File
@@ -1066,6 +1066,7 @@
"role": {
"user": "普通用户",
"hr": "HR",
"maintenanceManager": "维保管理员",
"admin": "管理员",
"guest": "访客"
},
+5 -2
View File
@@ -80,7 +80,7 @@
"panel": {
"recordTitle": "维修记录",
"ledgerTitle": "台账配置",
"adminOnly": "管理操作:仅资产管理员 / 维修主管可用",
"adminOnly": "管理操作:仅管理员 / 维保管理员可用",
"resizeTitle": "拖拽调整宽度",
"ledgerSubtitle": "设备列表 / 设备配置",
"recordSubtitle": "记录列表 / 记录配置",
@@ -189,9 +189,12 @@
},
"chat": {
"deviceLedgerInfo": "设备台账信息",
"recordInfo": "设备维修记录",
"matched": "已匹配",
"recordMatched": "已匹配维修记录",
"recentRecords": "最近维修记录({count} 条)",
"viewRepairHistory": "查维修历史",
"addRepairRecord": "新增维修记录"
"addRepairRecord": "新增维修记录",
"inputPlaceholder": "问我设备维保相关信息,例如:查询 A022700978 的设备台账信息"
}
}
+1
View File
@@ -946,6 +946,7 @@
"role": {
"user": "普通用戶",
"hr": "HR",
"maintenanceManager": "維保管理員",
"admin": "管理員",
"guest": "訪客"
},
+5 -2
View File
@@ -80,7 +80,7 @@
"panel": {
"recordTitle": "維修記錄",
"ledgerTitle": "台帳配置",
"adminOnly": "管理操作:僅資產管理員 / 維修主管可用",
"adminOnly": "管理操作:僅管理員 / 維保管理員可用",
"resizeTitle": "拖曳調整寬度",
"ledgerSubtitle": "設備列表 / 設備配置",
"recordSubtitle": "記錄列表 / 記錄配置",
@@ -189,9 +189,12 @@
},
"chat": {
"deviceLedgerInfo": "設備台帳資訊",
"recordInfo": "設備維修記錄",
"matched": "已匹配",
"recordMatched": "已匹配維修記錄",
"recentRecords": "最近維修記錄({count} 筆)",
"viewRepairHistory": "查維修歷史",
"addRepairRecord": "新增維修記錄"
"addRepairRecord": "新增維修記錄",
"inputPlaceholder": "問我設備維保相關資訊,例如:查詢 A022700978 的設備台帳資訊"
}
}