feat(i18n): 将前端用户可见中文硬编码改为四语言
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
dce915ea30
commit
ac7b53a523
105 files changed
+2928
-647
No files matched your search
@@ -15,8 +15,7 @@ import type { ScheduleTask } from '@/shared/types/schedule.types';
|
||||
import type { AgentTypeCatalogEntry, IntentRouteOption } from '../composables/useAgentsAdminRegistry';
|
||||
import type { AdminContentProfileOption } from '@/features/admin/api/admin.api';
|
||||
import {
|
||||
DEFAULT_TRAINING_EMPLOYEE_CHAT_QUESTIONS,
|
||||
DEFAULT_TRAINING_HR_CHAT_QUESTIONS,
|
||||
getDefaultTrainingChatQuestions,
|
||||
} from '@/features/chat/training/trainingChatQuestions';
|
||||
import {
|
||||
applyCatalogDefaultsToForm,
|
||||
@@ -188,10 +187,10 @@ const handleTrainingWorkspaceToggle = () => {
|
||||
if (props.form.training_workspace_enabled) {
|
||||
props.form.content_profile = 'training';
|
||||
if (!props.form.training_employee_chat_questions_text.trim()) {
|
||||
props.form.training_employee_chat_questions_text = DEFAULT_TRAINING_EMPLOYEE_CHAT_QUESTIONS.join('\n');
|
||||
props.form.training_employee_chat_questions_text = getDefaultTrainingChatQuestions('employee').join('\n');
|
||||
}
|
||||
if (!props.form.training_hr_chat_questions_text.trim()) {
|
||||
props.form.training_hr_chat_questions_text = DEFAULT_TRAINING_HR_CHAT_QUESTIONS.join('\n');
|
||||
props.form.training_hr_chat_questions_text = getDefaultTrainingChatQuestions('hr').join('\n');
|
||||
}
|
||||
} else if (props.form.content_profile === 'training') {
|
||||
props.form.content_profile = '';
|
||||
@@ -305,10 +304,10 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
||||
|
||||
<template v-if="showDifyFields">
|
||||
<div class="space-y-2">
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">Dify应用类型</label>
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.difyAppType') }}</label>
|
||||
<select v-model="form.dify_app_type" class="w-full input-field text-sm">
|
||||
<option value="chatflow">Chatflow</option>
|
||||
<option value="workflow">Workflow</option>
|
||||
<option value="chatflow">{{ t('admin.agent.fields.difyAppTypes.chatflow') }}</option>
|
||||
<option value="workflow">{{ t('admin.agent.fields.difyAppTypes.workflow') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
@@ -565,30 +564,30 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
||||
|
||||
<div class="col-span-1 md:col-span-2 space-y-3">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">常见问题</label>
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.suggestedQuestions.title') }}</label>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-default px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
@click="emit('addSuggestedQuestion')"
|
||||
>
|
||||
<Plus class="h-4 w-4" />
|
||||
添加问题
|
||||
{{ t('admin.agent.suggestedQuestions.add') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm">
|
||||
<label class="inline-flex items-center gap-2 text-secondary">
|
||||
<input v-model="form.suggested_questions_style" type="radio" value="plain" class="accent-brand-600" />
|
||||
<span>无样式</span>
|
||||
<span>{{ t('admin.agent.suggestedQuestions.stylePlain') }}</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center gap-2 text-secondary">
|
||||
<input v-model="form.suggested_questions_style" type="radio" value="styled" class="accent-brand-600" />
|
||||
<span>有样式</span>
|
||||
<span>{{ t('admin.agent.suggestedQuestions.styleStyled') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-if="form.suggested_questions.length === 0" class="rounded-xl border border-dashed border-default px-4 py-5 text-sm text-muted">
|
||||
暂未配置常见问题,点击“添加问题”后会同步到对应 Agent 的 Chat 欢迎页。
|
||||
{{ t('admin.agent.suggestedQuestions.empty') }}
|
||||
</div>
|
||||
|
||||
<div v-else class="space-y-3">
|
||||
@@ -602,14 +601,16 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
|
||||
v-model="item.question"
|
||||
type="text"
|
||||
class="w-full input-field text-sm"
|
||||
placeholder="请输入常见问题,例如:查询我有多少假期?"
|
||||
:placeholder="t('admin.agent.suggestedQuestions.questionPlaceholder')"
|
||||
/>
|
||||
<input
|
||||
v-model="item.group"
|
||||
type="text"
|
||||
class="w-full input-field text-sm"
|
||||
:disabled="form.suggested_questions_style !== 'styled'"
|
||||
:placeholder="form.suggested_questions_style === 'styled' ? '可选:分组标题,例如:考勤与休假' : '无样式下无需分组'"
|
||||
:placeholder="form.suggested_questions_style === 'styled'
|
||||
? t('admin.agent.suggestedQuestions.groupPlaceholderStyled')
|
||||
: t('admin.agent.suggestedQuestions.groupPlaceholderPlain')"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -500,13 +500,13 @@ export function useAgentsAdmin() {
|
||||
payload.dify_api_key = form.value.dify_api_key;
|
||||
}
|
||||
await updateAdminAgent(form.value.id, payload);
|
||||
msg.success('应用更新成功');
|
||||
msg.success(t('admin.agent.updateSuccess'));
|
||||
} else {
|
||||
await createAdminAgent({
|
||||
...registryPayload,
|
||||
dify_api_key: form.value.dify_api_key,
|
||||
});
|
||||
msg.success('应用创建成功');
|
||||
msg.success(t('admin.agent.createSuccess'));
|
||||
}
|
||||
|
||||
await loadAgents();
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/**
|
||||
* features/admin/modules/platform-apps/PlatformAppsPage.vue
|
||||
* 用途:平台应用说明(新手指南)管理——按 Agent 维护指南资料上传、启停与排序。
|
||||
* 依赖:admin.api 指南 CRUD/上传、vue-i18n、lucide 图标。
|
||||
* 逻辑:Admin 路由挂载;选择应用后拉取指南列表,弹窗内上传并保存元数据。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -29,6 +35,9 @@ const form = ref({
|
||||
const isUploading = ref(false);
|
||||
const uploadError = ref('');
|
||||
|
||||
/**
|
||||
* 拉取 Agent 列表并默认选中第一项,再加载其指南。
|
||||
*/
|
||||
const fetchAgents = async () => {
|
||||
try {
|
||||
agents.value = await listAdminAgents();
|
||||
@@ -41,6 +50,9 @@ const fetchAgents = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 按当前选中 Agent 拉取指南列表。
|
||||
*/
|
||||
const fetchGuides = async () => {
|
||||
if (!selectedAgentId.value) return;
|
||||
isLoading.value = true;
|
||||
@@ -62,6 +74,9 @@ onMounted(() => {
|
||||
fetchAgents();
|
||||
});
|
||||
|
||||
/**
|
||||
* 打开新建指南弹窗并重置表单。
|
||||
*/
|
||||
const openCreateModal = () => {
|
||||
isEditing.value = false;
|
||||
editingId.value = null;
|
||||
@@ -79,6 +94,10 @@ const openCreateModal = () => {
|
||||
isModalOpen.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开编辑指南弹窗并回填行数据。
|
||||
* @param guide - 列表行指南对象
|
||||
*/
|
||||
const openEditModal = (guide: any) => {
|
||||
isEditing.value = true;
|
||||
editingId.value = guide.id;
|
||||
@@ -96,6 +115,10 @@ const openEditModal = (guide: any) => {
|
||||
isModalOpen.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 上传指南文件并回填 path/type/size;必要时校正 guide_usage 与文件类型一致性。
|
||||
* @param event - input file change 事件
|
||||
*/
|
||||
const handleFileUpload = async (event: Event) => {
|
||||
const file = (event.target as HTMLInputElement).files?.[0];
|
||||
if (!file) return;
|
||||
@@ -118,12 +141,15 @@ const handleFileUpload = async (event: Event) => {
|
||||
form.value.file_name = res.file_name;
|
||||
}
|
||||
} catch (err: any) {
|
||||
uploadError.value = err.message || '上传失败';
|
||||
uploadError.value = err.message || t('admin.platformApps.uploadFailed');
|
||||
} finally {
|
||||
isUploading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 提交新建或更新指南元数据。
|
||||
*/
|
||||
const submitForm = async () => {
|
||||
if (!selectedAgentId.value || !form.value.file_path || !form.value.file_name) return;
|
||||
|
||||
@@ -143,8 +169,12 @@ const submitForm = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 确认后删除指南。
|
||||
* @param id - 指南主键
|
||||
*/
|
||||
const deleteGuide = async (id: number) => {
|
||||
if (!confirm('确定要删除该指南吗?删除后不可恢复。')) return;
|
||||
if (!confirm(t('admin.platformApps.confirmDelete'))) return;
|
||||
try {
|
||||
await deleteAdminAgentGuide(id);
|
||||
await fetchGuides();
|
||||
@@ -153,6 +183,10 @@ const deleteGuide = async (id: number) => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换指南启停状态。
|
||||
* @param guide - 列表行指南对象
|
||||
*/
|
||||
const toggleStatus = async (guide: any) => {
|
||||
try {
|
||||
await updateAdminAgentGuide(guide.id, { status: guide.status === 1 ? 0 : 1 });
|
||||
@@ -162,6 +196,11 @@ const toggleStatus = async (guide: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 将字节数格式化为可读文件大小。
|
||||
* @param bytes - 文件字节数
|
||||
* @returns 如 `1.2 MB`
|
||||
*/
|
||||
const formatSize = (bytes: number) => {
|
||||
if (!bytes) return '0 B';
|
||||
const k = 1024;
|
||||
@@ -170,6 +209,10 @@ const formatSize = (bytes: number) => {
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
};
|
||||
|
||||
/**
|
||||
* 按文件类型返回列表图标组件。
|
||||
* @param type - 文件类型(video/pdf/其它)
|
||||
*/
|
||||
const getIcon = (type: string) => {
|
||||
if (type === 'video') return Play;
|
||||
if (type === 'pdf') return FileText;
|
||||
@@ -185,7 +228,7 @@ const getIcon = (type: string) => {
|
||||
{{ t('admin.nav.platformApps') }}
|
||||
</h2>
|
||||
<p class="text-sm text-muted mt-1">
|
||||
管理应用的新手指南资料(支持视频、PDF等)
|
||||
{{ t('admin.platformApps.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -193,7 +236,7 @@ const getIcon = (type: string) => {
|
||||
<div class="surface-panel rounded-2xl p-6 shadow-sm border border-subtle flex-1 flex flex-col gap-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-4">
|
||||
<label class="font-medium text-sm text-default">选择应用:</label>
|
||||
<label class="font-medium text-sm text-default">{{ t('admin.platformApps.selectAgent') }}</label>
|
||||
<select v-model="selectedAgentId" class="input-field w-64" @change="fetchGuides">
|
||||
<option v-for="agent in agents" :key="agent.id" :value="agent.id">
|
||||
{{ agent.name }}
|
||||
@@ -202,7 +245,7 @@ const getIcon = (type: string) => {
|
||||
</div>
|
||||
<button v-if="selectedAgentId" type="button" class="btn-primary" @click="openCreateModal">
|
||||
<Plus class="w-5 h-5 mr-1" />
|
||||
<span>添加指南</span>
|
||||
<span>{{ t('admin.platformApps.addGuide') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -211,25 +254,25 @@ const getIcon = (type: string) => {
|
||||
</div>
|
||||
|
||||
<div v-else-if="!selectedAgentId" class="flex flex-col items-center justify-center py-20 text-muted">
|
||||
请先选择一个应用
|
||||
{{ t('admin.platformApps.selectAgentFirst') }}
|
||||
</div>
|
||||
|
||||
<div v-else-if="guides.length === 0" class="flex flex-col items-center justify-center py-20 text-muted">
|
||||
该应用暂无新手指南资料
|
||||
{{ t('admin.platformApps.emptyGuides') }}
|
||||
</div>
|
||||
|
||||
<div v-else class="overflow-x-auto rounded-xl border border-subtle">
|
||||
<table class="w-full text-left text-sm whitespace-nowrap">
|
||||
<thead class="bg-muted text-muted uppercase text-xs font-semibold tracking-wider border-b border-subtle">
|
||||
<tr>
|
||||
<th class="px-6 py-4">类型</th>
|
||||
<th class="px-6 py-4">资料名称</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colType') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colFileName') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.guideUsage') }}</th>
|
||||
<th class="px-6 py-4">Agent应用</th>
|
||||
<th class="px-6 py-4">文件大小</th>
|
||||
<th class="px-6 py-4">排序</th>
|
||||
<th class="px-6 py-4">状态</th>
|
||||
<th class="px-6 py-4 text-right">操作</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colAgent') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colFileSize') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colSort') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colStatus') }}</th>
|
||||
<th class="px-6 py-4 text-right">{{ t('admin.platformApps.colActions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-subtle">
|
||||
@@ -259,14 +302,14 @@ const getIcon = (type: string) => {
|
||||
:class="guide.status === 1 ? 'bg-green-100 text-green-700 hover:bg-green-200' : 'bg-gray-100 text-gray-700 hover:bg-gray-200'"
|
||||
@click="toggleStatus(guide)"
|
||||
>
|
||||
{{ guide.status === 1 ? '已启用' : '已禁用' }}
|
||||
{{ guide.status === 1 ? t('admin.platformApps.statusEnabled') : t('admin.platformApps.statusDisabled') }}
|
||||
</button>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-right space-x-2">
|
||||
<button type="button" class="btn-icon-ds" @click="openEditModal(guide)" title="编辑">
|
||||
<button type="button" class="btn-icon-ds" @click="openEditModal(guide)" :title="t('common.edit')">
|
||||
<Edit2 class="w-4 h-4" />
|
||||
</button>
|
||||
<button type="button" class="btn-icon-ds text-red-500 hover:bg-red-50" @click="deleteGuide(guide.id)" title="删除">
|
||||
<button type="button" class="btn-icon-ds text-red-500 hover:bg-red-50" @click="deleteGuide(guide.id)" :title="t('common.delete')">
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</td>
|
||||
@@ -280,13 +323,13 @@ const getIcon = (type: string) => {
|
||||
<div v-if="isModalOpen" class="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-2xl shadow-xl w-full max-w-lg overflow-hidden flex flex-col max-h-[90vh]">
|
||||
<div class="px-6 py-4 border-b border-subtle flex justify-between items-center">
|
||||
<h3 class="text-lg font-bold text-default">{{ isEditing ? '编辑指南' : '添加指南' }}</h3>
|
||||
<h3 class="text-lg font-bold text-default">{{ isEditing ? t('admin.platformApps.editGuide') : t('admin.platformApps.addGuide') }}</h3>
|
||||
<button @click="isModalOpen = false" class="text-muted hover:text-default text-xl leading-none">×</button>
|
||||
</div>
|
||||
|
||||
<div class="p-6 overflow-y-auto space-y-4">
|
||||
<div v-if="!isEditing" class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">上传文件</label>
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.uploadFile') }}</label>
|
||||
<input
|
||||
type="file"
|
||||
accept="video/mp4,video/webm,application/pdf,image/png,image/jpeg"
|
||||
@@ -294,20 +337,20 @@ const getIcon = (type: string) => {
|
||||
@change="handleFileUpload"
|
||||
/>
|
||||
<div v-if="isUploading" class="text-sm text-blue-600 mt-2 flex items-center gap-2">
|
||||
<div class="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div> 上传中...
|
||||
<div class="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div> {{ t('admin.platformApps.uploading') }}
|
||||
</div>
|
||||
<div v-if="uploadError" class="text-sm text-red-500 mt-2">{{ uploadError }}</div>
|
||||
<div v-if="form.file_path && !isUploading" class="text-sm text-green-600 mt-2">已上传文件就绪</div>
|
||||
<div v-if="form.file_path && !isUploading" class="text-sm text-green-600 mt-2">{{ t('admin.platformApps.uploadReady') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">资料名称</label>
|
||||
<input v-model="form.file_name" type="text" class="input-field w-full" placeholder="如:人事助手使用手册" />
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.fileName') }}</label>
|
||||
<input v-model="form.file_name" type="text" class="input-field w-full" :placeholder="t('admin.platformApps.fileNamePlaceholder')" />
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">备注说明</label>
|
||||
<textarea v-model="form.remark" class="input-field w-full h-20" placeholder="简要说明..."></textarea>
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.remark') }}</label>
|
||||
<textarea v-model="form.remark" class="input-field w-full h-20" :placeholder="t('admin.platformApps.remarkPlaceholder')"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
@@ -321,29 +364,29 @@ const getIcon = (type: string) => {
|
||||
<p class="text-xs text-muted">{{ t('admin.platformApps.guideUsageHint') }}</p>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">排序权重</label>
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.sortOrder') }}</label>
|
||||
<input v-model.number="form.sort_order" type="number" class="input-field w-full" />
|
||||
<p class="text-xs text-muted">数值越小越靠前</p>
|
||||
<p class="text-xs text-muted">{{ t('admin.platformApps.sortOrderHint') }}</p>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">状态</label>
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.status') }}</label>
|
||||
<select v-model="form.status" class="input-field w-full">
|
||||
<option :value="1">启用</option>
|
||||
<option :value="0">禁用</option>
|
||||
<option :value="1">{{ t('admin.platformApps.enable') }}</option>
|
||||
<option :value="0">{{ t('admin.platformApps.disable') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 border-t border-subtle bg-muted flex justify-end gap-3">
|
||||
<button type="button" class="btn-secondary" @click="isModalOpen = false">取消</button>
|
||||
<button type="button" class="btn-secondary" @click="isModalOpen = false">{{ t('admin.cancel') }}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
@click="submitForm"
|
||||
:disabled="isUploading || !form.file_path || !form.file_name"
|
||||
>
|
||||
保存
|
||||
{{ t('admin.platformApps.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+4
-11
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* features/admin/modules/procurement-contract/ProcurementContractPage.vue
|
||||
* 用途:采购合同审查管理——模板库 / 风险规则 / 审查历史(Tab),含鉴权下载。
|
||||
* 依赖:procurement-contract.api、ContractRiskRulesPanel、DeleteConfirmDialog、useMessage、vue-i18n。
|
||||
* 依赖:procurement-contract.api、contract-ocr-match-tokens、ContractRiskRulesPanel、DeleteConfirmDialog、useMessage、vue-i18n。
|
||||
* 逻辑:Admin 路由挂载;会话 Agent 读模板列表走 /api/procurement-contract。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
type ContractReviewRow,
|
||||
type ContractTemplateRow,
|
||||
} from '@/features/admin/api/procurement-contract.api';
|
||||
import { V4_REGION_CONFIG } from './contract-ocr-match-tokens';
|
||||
import ContractRiskRulesPanel from './components/ContractRiskRulesPanel.vue';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
@@ -44,7 +45,7 @@ const reviewTotal = ref(0);
|
||||
const showUpload = ref(false);
|
||||
const uploading = ref(false);
|
||||
const editingTemplate = ref<ContractTemplateRow | null>(null);
|
||||
const uploadName = ref('标准采购合同');
|
||||
const uploadName = ref(t('admin.procurementContract.defaultTemplateName'));
|
||||
const uploadVersion = ref('V1.0');
|
||||
const uploadStatus = ref<'enabled' | 'disabled'>('enabled');
|
||||
const uploadDefault = ref(false);
|
||||
@@ -89,14 +90,6 @@ const regionSignatureTerms = ref('');
|
||||
const regionAttachmentStart = ref('');
|
||||
let reviewFilterTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
|
||||
const V4_REGION_CONFIG: ContractComparisonRegionConfig = {
|
||||
metadata_fields: ['contract_no', 'buyer', 'seller', 'version'],
|
||||
body_start_anchors: ['兹因甲方向乙方购买设备'],
|
||||
body_end_anchors: ['本合同一式两份', '以下无正文', '本页以下无正文'],
|
||||
signature_terms: ['甲方', '乙方', '盖章', '签署日期', '合同专用章'],
|
||||
attachment_start_anchors: ['附件', '性能需求表', '技术协议', '设备配置清单'],
|
||||
attachment_policy: 'page_count_only',
|
||||
};
|
||||
const metadataFieldOptions: ContractMetadataField[] = ['contract_no', 'buyer', 'seller', 'version'];
|
||||
|
||||
/**
|
||||
@@ -172,7 +165,7 @@ async function switchTab(next: 'templates' | 'rules' | 'reviews'): Promise<void>
|
||||
*/
|
||||
function resetUploadForm(): void {
|
||||
editingTemplate.value = null;
|
||||
uploadName.value = '标准采购合同';
|
||||
uploadName.value = t('admin.procurementContract.defaultTemplateName');
|
||||
uploadVersion.value = 'V1.0';
|
||||
uploadStatus.value = 'enabled';
|
||||
uploadDefault.value = false;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* features/admin/modules/procurement-contract/contract-ocr-match-tokens.ts
|
||||
* 用途:采购合同比对区域的 V4 默认 OCR/正文匹配锚点与签章关键词(检测用 token,非 UI 文案)。
|
||||
* 依赖:procurement-contract.api 的 ContractComparisonRegionConfig 类型。
|
||||
* 逻辑:ProcurementContractPage「恢复 V4 默认配置」与新建区域配置时引用;勿当作 i18n 展示文案。
|
||||
*
|
||||
* NOTE: Strings below are OCR match tokens for Chinese contract PDFs. Keep them in Chinese
|
||||
* regardless of UI locale so region recognition against Chinese source documents still works.
|
||||
*/
|
||||
import type { ContractComparisonRegionConfig } from '@/features/admin/api/procurement-contract.api';
|
||||
|
||||
/** V4 默认比对区域配置(锚点/关键词为中文 OCR 匹配 token)。 */
|
||||
export const V4_REGION_CONFIG: ContractComparisonRegionConfig = {
|
||||
metadata_fields: ['contract_no', 'buyer', 'seller', 'version'],
|
||||
body_start_anchors: ['兹因甲方向乙方购买设备'],
|
||||
body_end_anchors: ['本合同一式两份', '以下无正文', '本页以下无正文'],
|
||||
signature_terms: ['甲方', '乙方', '盖章', '签署日期', '合同专用章'],
|
||||
attachment_start_anchors: ['附件', '性能需求表', '技术协议', '设备配置清单'],
|
||||
attachment_policy: 'page_count_only',
|
||||
};
|
||||
@@ -2,10 +2,11 @@
|
||||
/**
|
||||
* features/chat/components/ChatAssetHistoryDialog.vue
|
||||
* 用途:展示固定资产履历候选文件列表,并复用既有文件预览弹窗打开具体履历。
|
||||
* 依赖:聊天页 useChatPage 提供的查询状态与打开预览回调。
|
||||
* 依赖:vue-i18n、聊天页 useChatPage 提供的查询状态与打开预览回调。
|
||||
* 逻辑:用户点击资产编号后打开;先显示检索状态,再列出共享盘匹配文件,点击单条文件进入预览。
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ExternalLink, FileText, Loader2, X } from 'lucide-vue-next';
|
||||
import type { AssetHistoryFileItem } from '../types/chat.types';
|
||||
|
||||
@@ -24,7 +25,8 @@ const emit = defineEmits<{
|
||||
openPreview: [item: AssetHistoryFileItem];
|
||||
}>();
|
||||
|
||||
const titleText = computed(() => props.assetId || props.assetName || '资产履历');
|
||||
const { t } = useI18n();
|
||||
const titleText = computed(() => props.assetId || props.assetName || t('chat.assetHistory.title'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -36,17 +38,17 @@ const titleText = computed(() => props.assetId || props.assetName || '资产履
|
||||
<div class="dialog-panel flex max-h-[88vh] w-[min(96vw,900px)] max-w-[900px] flex-col">
|
||||
<div class="dialog-header">
|
||||
<div>
|
||||
<h3 class="section-title">资产履历</h3>
|
||||
<p class="section-desc mt-1">当前资产:{{ titleText }}</p>
|
||||
<h3 class="section-title">{{ $t('chat.assetHistory.title') }}</h3>
|
||||
<p class="section-desc mt-1">{{ $t('chat.assetHistory.currentAsset', { name: titleText }) }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-icon-ds" aria-label="关闭" @click="emit('close')">
|
||||
<button type="button" class="btn-icon-ds" :aria-label="$t('common.close')" @click="emit('close')">
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="dialog-body flex min-h-0 flex-1 flex-col gap-4 border-t-0 pt-4">
|
||||
<div v-if="loading" class="flex h-56 items-center justify-center text-sm text-muted">
|
||||
<Loader2 class="mr-2 h-5 w-5 animate-spin text-brand-500" />
|
||||
正在检索共享盘履历文件...
|
||||
{{ $t('chat.assetHistory.searching') }}
|
||||
</div>
|
||||
<div v-else-if="error" class="rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700">
|
||||
{{ error }}
|
||||
@@ -55,7 +57,7 @@ const titleText = computed(() => props.assetId || props.assetName || '资产履
|
||||
v-else-if="items.length === 0"
|
||||
class="flex h-56 items-center justify-center rounded-2xl border border-dashed border-default bg-surface-soft text-sm text-muted"
|
||||
>
|
||||
未找到匹配的履历文件
|
||||
{{ $t('chat.assetHistory.empty') }}
|
||||
</div>
|
||||
<div v-else class="min-h-0 flex-1 overflow-auto rounded-2xl border border-default bg-surface">
|
||||
<div
|
||||
@@ -70,9 +72,9 @@ const titleText = computed(() => props.assetId || props.assetName || '资产履
|
||||
</div>
|
||||
<div class="mt-1 break-all text-xs text-secondary">{{ item.relative_path }}</div>
|
||||
<div class="mt-2 flex flex-wrap gap-3 text-xs text-muted">
|
||||
<span v-if="item.modified_at">修改时间:{{ item.modified_at }}</span>
|
||||
<span v-if="item.size_bytes">大小:{{ Math.max(1, Math.round(item.size_bytes / 1024)) }} KB</span>
|
||||
<span v-if="item.match_reason">匹配方式:{{ item.match_reason }}</span>
|
||||
<span v-if="item.modified_at">{{ $t('chat.assetHistory.modifiedAt', { time: item.modified_at }) }}</span>
|
||||
<span v-if="item.size_bytes">{{ $t('chat.assetHistory.sizeKb', { size: Math.max(1, Math.round(item.size_bytes / 1024)) }) }}</span>
|
||||
<span v-if="item.match_reason">{{ $t('chat.assetHistory.matchReason', { reason: item.match_reason }) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
@@ -81,7 +83,7 @@ const titleText = computed(() => props.assetId || props.assetName || '资产履
|
||||
@click="emit('openPreview', item)"
|
||||
>
|
||||
<ExternalLink class="h-4 w-4" />
|
||||
查看履历
|
||||
{{ $t('chat.assetHistory.viewFile') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/chat/components/ChatGuideModal.vue
|
||||
* Agent 学习之窗:指南目录与视频 / PDF / 图片预览。
|
||||
* 用途:Agent 学习之窗弹窗,展示指南目录与视频 / PDF / 图片预览。
|
||||
* 依赖:lucide-vue-next、useChatGuides.AgentGuide、vue-i18n($t)。
|
||||
* 逻辑:由 Chat 页打开;目录折叠/展开与空态文案走 chat.guide.* / chat.learningWindow。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { BookOpen, FileText, Image as ImageIcon, PanelLeftClose, PanelLeftOpen, Play, X } from 'lucide-vue-next';
|
||||
@@ -27,7 +29,7 @@ defineProps<{
|
||||
<div class="flex shrink-0 items-center justify-between border-b border-default bg-surface px-6 py-4">
|
||||
<h3 class="flex items-center gap-2 text-lg font-bold text-primary">
|
||||
<BookOpen class="h-5 w-5 text-brand-600" />
|
||||
{{ agentName }} - 学习之窗
|
||||
{{ agentName }} - {{ $t('chat.learningWindow') }}
|
||||
</h3>
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
@@ -36,7 +38,7 @@ defineProps<{
|
||||
@click="showSidebar = !showSidebar"
|
||||
>
|
||||
<component :is="showSidebar ? PanelLeftClose : PanelLeftOpen" class="h-4 w-4" />
|
||||
{{ showSidebar ? '收起目录' : '展开目录' }}
|
||||
{{ showSidebar ? $t('chat.guide.collapseToc') : $t('chat.guide.expandToc') }}
|
||||
</button>
|
||||
<div class="h-5 w-px bg-default" />
|
||||
<button
|
||||
@@ -104,7 +106,7 @@ defineProps<{
|
||||
</template>
|
||||
<div v-else class="flex flex-col items-center gap-3 text-muted">
|
||||
<BookOpen class="h-12 w-12 opacity-20" />
|
||||
<p class="text-sm">请选择左侧指南进行查阅</p>
|
||||
<p class="text-sm">{{ $t('chat.guide.selectHint') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -520,7 +520,7 @@ watch(
|
||||
class="rounded-full border border-default bg-surface-soft px-3 py-1 font-medium text-secondary transition-colors hover:bg-surface-soft/70"
|
||||
@click="emit('use-shipping-suggested-prompt')"
|
||||
>
|
||||
{{ shippingSuggestedPrompt || '推荐问题' }}
|
||||
{{ shippingSuggestedPrompt || $t('chat.recommendedQuestion') }}
|
||||
</button>
|
||||
<span>{{ t('chat.shippingNoticeConfirmBatchHint') }}</span>
|
||||
</div>
|
||||
@@ -557,7 +557,7 @@ watch(
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isThinking || isUploadingAttachments"
|
||||
title="附件"
|
||||
:title="$t('chat.attachmentsUi.title')"
|
||||
class="flex h-9 w-9 items-center justify-center rounded-lg text-muted transition-colors hover:text-brand-600 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
@click="toggleAttachmentMenu"
|
||||
>
|
||||
@@ -574,7 +574,7 @@ watch(
|
||||
@click="selectAttachmentLocal"
|
||||
>
|
||||
<Paperclip class="h-4 w-4 text-brand-500" />
|
||||
上传本地文件
|
||||
{{ $t('chat.attachmentsUi.uploadLocal') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="attachmentPolicy.canRemote"
|
||||
@@ -583,7 +583,7 @@ watch(
|
||||
@click="selectAttachmentUrl"
|
||||
>
|
||||
<Link2 class="h-4 w-4 text-brand-500" />
|
||||
粘贴 URL
|
||||
{{ $t('chat.attachmentsUi.pasteUrl') }}
|
||||
</button>
|
||||
<div v-if="showAttachmentUrlPanel" class="px-3 py-2">
|
||||
<div class="flex items-center gap-2">
|
||||
@@ -591,7 +591,7 @@ watch(
|
||||
ref="attachmentUrlInputRef"
|
||||
v-model="attachmentUrlInput"
|
||||
:disabled="isThinking || isUploadingAttachments"
|
||||
placeholder="粘贴附件 URL(http/https)"
|
||||
:placeholder="$t('chat.attachmentsUi.urlPlaceholder')"
|
||||
class="flex-1 rounded-lg border border-default bg-surface-soft px-3 py-2 text-xs text-secondary placeholder-slate-400 focus:outline-none focus:ring-0"
|
||||
@keydown.enter.prevent="submitRemoteUrl"
|
||||
/>
|
||||
@@ -599,7 +599,7 @@ watch(
|
||||
type="button"
|
||||
:disabled="isThinking || isUploadingAttachments"
|
||||
class="flex h-9 w-9 items-center justify-center rounded-lg border border-default text-muted transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
|
||||
title="添加"
|
||||
:title="$t('chat.attachmentsUi.add')"
|
||||
@click="submitRemoteUrl"
|
||||
>
|
||||
<Check class="h-4 w-4" />
|
||||
@@ -608,7 +608,7 @@ watch(
|
||||
type="button"
|
||||
:disabled="isThinking || isUploadingAttachments"
|
||||
class="flex h-9 w-9 items-center justify-center rounded-lg border border-default text-muted transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
|
||||
title="取消"
|
||||
:title="$t('chat.attachmentsUi.cancel')"
|
||||
@click="closeAttachmentMenu"
|
||||
>
|
||||
<X class="h-4 w-4" />
|
||||
|
||||
@@ -75,7 +75,7 @@ onBeforeUnmount(() => {
|
||||
@click="emit('open-guide')"
|
||||
>
|
||||
<BookOpen class="h-4 w-4" />
|
||||
学习之窗
|
||||
{{ $t('chat.learningWindow') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
/**
|
||||
* features/chat/components/ChatQueryPreviewDialog.vue
|
||||
* Text2SQL 查询结果全量预览弹窗 UI。
|
||||
* 依赖:vue-i18n、useChatQueryPreview 状态。
|
||||
* 逻辑:列名匹配仍兼容服务端中文表头与本地化后的展示标签,避免切语言后丢失资产编号/图片交互。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Loader2, X } from 'lucide-vue-next';
|
||||
import type { QueryPreviewState } from '../composables/useChatQueryPreview';
|
||||
|
||||
@@ -22,15 +25,32 @@ const emit = defineEmits<{
|
||||
'open-asset-image': [payload: { assetId: string; assetName: string }];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/** 判断列是否命中资产编号(服务端中文表头或本地化标签)。 */
|
||||
function matchesAssetIdColumn(column: string): boolean {
|
||||
return column === '资产编号' || column === t('chat.assetColumns.assetId');
|
||||
}
|
||||
|
||||
/** 判断列是否命中资产名称。 */
|
||||
function matchesAssetNameColumn(column: string): boolean {
|
||||
return column === '资产名称' || column === t('chat.assetColumns.assetName');
|
||||
}
|
||||
|
||||
/** 判断列是否命中图片。 */
|
||||
function matchesImageColumn(column: string): boolean {
|
||||
return column === '图片' || column === t('chat.assetColumns.image');
|
||||
}
|
||||
|
||||
const totalPages = computed(() =>
|
||||
Math.max(1, Math.ceil((props.state.total || 0) / (props.state.pageSize || 100))),
|
||||
);
|
||||
const assetIdColumnIndex = computed(() => props.state.columns.findIndex((column) => column === '资产编号'));
|
||||
const assetNameColumnIndex = computed(() => props.state.columns.findIndex((column) => column === '资产名称'));
|
||||
const imageColumnIndex = computed(() => props.state.columns.findIndex((column) => column === '图片'));
|
||||
const assetIdColumnIndex = computed(() => props.state.columns.findIndex((column) => matchesAssetIdColumn(column)));
|
||||
const assetNameColumnIndex = computed(() => props.state.columns.findIndex((column) => matchesAssetNameColumn(column)));
|
||||
const imageColumnIndex = computed(() => props.state.columns.findIndex((column) => matchesImageColumn(column)));
|
||||
|
||||
function isHighlightColumn(column: string): boolean {
|
||||
return column === '资产编号' || column === '图片';
|
||||
return matchesAssetIdColumn(column) || matchesImageColumn(column);
|
||||
}
|
||||
|
||||
function normalizeCellText(cell: unknown): string {
|
||||
@@ -68,16 +88,16 @@ function emitAssetAction(row: unknown[], cellIndex: number): void {
|
||||
<div class="dialog-panel flex max-h-[88vh] w-[min(96vw,1280px)] max-w-[1280px] flex-col">
|
||||
<div class="dialog-header">
|
||||
<div>
|
||||
<h3 class="section-title">查询结果全量预览</h3>
|
||||
<h3 class="section-title">{{ $t('chat.queryPreview.title') }}</h3>
|
||||
<p class="section-desc mt-1">{{ state.query || state.title }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-icon-ds" aria-label="关闭" @click="emit('close')">
|
||||
<button type="button" class="btn-icon-ds" :aria-label="$t('common.close')" @click="emit('close')">
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="dialog-body flex min-h-0 flex-1 flex-col gap-4 border-t-0 pt-4">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3 rounded-xl border border-default bg-surface-soft px-4 py-3 text-sm text-secondary">
|
||||
<div>共 {{ state.total || 0 }} 条,当前第 {{ state.page }} / {{ totalPages }} 页</div>
|
||||
<div>{{ $t('chat.queryPreview.summary', { total: state.total || 0, page: state.page, pages: totalPages }) }}</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
@@ -85,7 +105,7 @@ function emitAssetAction(row: unknown[], cellIndex: number): void {
|
||||
:disabled="loading || state.page <= 1"
|
||||
@click="emit('change-page', -1)"
|
||||
>
|
||||
上一页
|
||||
{{ $t('chat.queryPreview.prev') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@@ -93,7 +113,7 @@ function emitAssetAction(row: unknown[], cellIndex: number): void {
|
||||
:disabled="loading || state.page >= totalPages"
|
||||
@click="emit('change-page', 1)"
|
||||
>
|
||||
下一页
|
||||
{{ $t('chat.queryPreview.next') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -105,7 +125,7 @@ function emitAssetAction(row: unknown[], cellIndex: number): void {
|
||||
<Loader2 class="h-6 w-6 animate-spin text-brand-500" />
|
||||
</div>
|
||||
<div v-else-if="!state.columns.length" class="flex h-56 items-center justify-center text-sm text-muted">
|
||||
暂无可预览数据
|
||||
{{ $t('chat.queryPreview.empty') }}
|
||||
</div>
|
||||
<table v-else class="min-w-full border-collapse text-sm">
|
||||
<thead class="sticky top-0 z-10 bg-slate-50">
|
||||
|
||||
@@ -167,7 +167,7 @@ const userInitial = (fallback: string) => {
|
||||
@click="emit('open-guide')"
|
||||
>
|
||||
<BookOpen class="h-4 w-4" />
|
||||
学习之窗
|
||||
{{ $t('chat.learningWindow') }}
|
||||
</button>
|
||||
</div>
|
||||
<span v-if="agentDescription" class="mt-1 block cursor-help truncate text-[11px] text-muted">
|
||||
@@ -278,7 +278,7 @@ const userInitial = (fallback: string) => {
|
||||
class="flex h-10 min-w-[2.5rem] items-center justify-center rounded-full bg-brand-600 px-3 text-sm font-bold text-white shadow-sm shadow-brand-500/20 transition-colors hover:bg-brand-700"
|
||||
@click="showUserDropdown = !showUserDropdown"
|
||||
>
|
||||
退出
|
||||
{{ $t('chat.exitShort') }}
|
||||
</button>
|
||||
|
||||
<div
|
||||
|
||||
@@ -72,7 +72,7 @@ async function handleQueryPreviewAssetImage(assetId: string, assetName: string)
|
||||
>
|
||||
<div class="flex items-center gap-2 rounded-full border border-brand-200 bg-white/95 px-4 py-2 text-sm text-brand-700 shadow-lg backdrop-blur">
|
||||
<Loader2 class="h-4 w-4 animate-spin text-brand-500" />
|
||||
<span>正在搜索该资产的履历资料,请耐心等待...</span>
|
||||
<span>{{ page.t('chat.assetHistory.searchingToast') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@@ -81,7 +81,7 @@ async function handleQueryPreviewAssetImage(assetId: string, assetName: string)
|
||||
>
|
||||
<div class="flex items-center gap-2 rounded-full border border-brand-200 bg-white/95 px-4 py-2 text-sm text-brand-700 shadow-lg backdrop-blur">
|
||||
<Loader2 class="h-4 w-4 animate-spin text-brand-500" />
|
||||
<span>正在搜索该资产的图片资料,请耐心等待...</span>
|
||||
<span>{{ page.t('chat.assetImage.searchingToast') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<ChatLeaveAgentDialog
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/chat/components/ToolRunProgressCard.vue
|
||||
* 用途:展示文件检核等 Agent 异步 tool_run 的实时进度、知识库同步态与 Excel 下载。
|
||||
* 依赖:vue-i18n、lucide 图标、getAuthHeaders、toolRunProgress.api。
|
||||
* 逻辑:由聊天消息列表在绑定 run_id 后挂载;轮询结果经 props.run 传入,本组件只负责展示与下载。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { AlertCircle, CheckCircle2, Clock3, Download, Loader2 } from 'lucide-vue-next';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type { ToolRunProgress } from '../api/toolRunProgress.api';
|
||||
@@ -12,19 +19,26 @@ const props = defineProps<{
|
||||
fallbackTitle?: string;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const downloadingExcel = ref(false);
|
||||
const downloadError = ref('');
|
||||
|
||||
/**
|
||||
* 将后端 run.status 映射为本地化状态文案。
|
||||
* 核心逻辑:命中已知状态码用 i18n;未知状态回退原始值,再回退“等待中”。
|
||||
* @param status - 任务状态码
|
||||
* @returns 面向用户的状态标签
|
||||
*/
|
||||
const statusLabel = (status?: string) => {
|
||||
const map: Record<string, string> = {
|
||||
running: '执行中',
|
||||
success: '已完成',
|
||||
partial_failed: '部分失败',
|
||||
failed: '失败',
|
||||
cancelled: '已取消',
|
||||
canceled: '已取消',
|
||||
running: t('chat.toolRun.statusRunning'),
|
||||
success: t('chat.toolRun.statusSuccess'),
|
||||
partial_failed: t('chat.toolRun.statusPartialFailed'),
|
||||
failed: t('chat.toolRun.statusFailed'),
|
||||
cancelled: t('chat.toolRun.statusCancelled'),
|
||||
canceled: t('chat.toolRun.statusCancelled'),
|
||||
};
|
||||
return map[String(status || '')] || status || '等待中';
|
||||
return map[String(status || '')] || status || t('chat.toolRun.statusWaiting');
|
||||
};
|
||||
|
||||
const formatTime = (value?: string | null) => {
|
||||
@@ -52,21 +66,30 @@ const percent = () => {
|
||||
return Math.max(0, Math.min(value, 100));
|
||||
};
|
||||
|
||||
/**
|
||||
* 组装知识库同步徽标文案与样式。
|
||||
* 核心逻辑:按 sync_status 分桶映射 tone/icon;未知状态带上原始 status。
|
||||
* @param status - knowledge_base.sync_status
|
||||
*/
|
||||
const kbSyncMeta = (status?: string | null) => {
|
||||
const value = String(status || '').toLowerCase();
|
||||
if (value === 'success') {
|
||||
return { label: '知识库已同步', tone: 'border-emerald-200 bg-emerald-50 text-emerald-700', icon: 'success' };
|
||||
return { label: t('chat.toolRun.kbSynced'), tone: 'border-emerald-200 bg-emerald-50 text-emerald-700', icon: 'success' };
|
||||
}
|
||||
if (value === 'failed') {
|
||||
return { label: '知识库同步失败', tone: 'border-rose-200 bg-rose-50 text-rose-700', icon: 'failed' };
|
||||
return { label: t('chat.toolRun.kbSyncFailed'), tone: 'border-rose-200 bg-rose-50 text-rose-700', icon: 'failed' };
|
||||
}
|
||||
if (['queued', 'cleaning', 'syncing'].includes(value)) {
|
||||
return { label: '知识库同步中', tone: 'border-sky-200 bg-sky-50 text-sky-700', icon: 'syncing' };
|
||||
return { label: t('chat.toolRun.kbSyncing'), tone: 'border-sky-200 bg-sky-50 text-sky-700', icon: 'syncing' };
|
||||
}
|
||||
if (value === 'skipped') {
|
||||
return { label: '知识库未同步', tone: 'border-slate-200 bg-slate-50 text-slate-600', icon: 'skipped' };
|
||||
return { label: t('chat.toolRun.kbNotSynced'), tone: 'border-slate-200 bg-slate-50 text-slate-600', icon: 'skipped' };
|
||||
}
|
||||
return { label: `知识库:${status || '未知'}`, tone: 'border-slate-200 bg-slate-50 text-slate-600', icon: 'skipped' };
|
||||
return {
|
||||
label: t('chat.toolRun.kbUnknown', { status: status || t('chat.toolRun.kbStatusUnknown') }),
|
||||
tone: 'border-slate-200 bg-slate-50 text-slate-600',
|
||||
icon: 'skipped',
|
||||
};
|
||||
};
|
||||
|
||||
const parseDownloadFilename = (disposition: string | null, fallback: string) => {
|
||||
@@ -99,7 +122,7 @@ const downloadExcel = async () => {
|
||||
const res = await fetch(url, { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({}));
|
||||
throw new Error(stringifyDownloadError(body, `下载失败:${res.status}`));
|
||||
throw new Error(stringifyDownloadError(body, t('chat.toolRun.downloadFailedStatus', { status: res.status })));
|
||||
}
|
||||
const blob = await res.blob();
|
||||
const filename = parseDownloadFilename(
|
||||
@@ -115,7 +138,7 @@ const downloadExcel = async () => {
|
||||
document.body.removeChild(link);
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
} catch (e: any) {
|
||||
downloadError.value = e?.message || '下载 Excel 失败';
|
||||
downloadError.value = e?.message || t('chat.toolRun.downloadFailed');
|
||||
} finally {
|
||||
downloadingExcel.value = false;
|
||||
}
|
||||
@@ -133,20 +156,20 @@ const downloadExcel = async () => {
|
||||
<CheckCircle2 v-else-if="run?.status === 'success'" class="h-4 w-4 text-emerald-600" />
|
||||
<AlertCircle v-else-if="run?.status === 'failed' || run?.status === 'partial_failed'" class="h-4 w-4 text-amber-600" />
|
||||
<Clock3 v-else class="h-4 w-4 text-sky-600" />
|
||||
{{ run?.title || fallbackTitle || '任务进度' }}
|
||||
{{ run?.title || fallbackTitle || $t('chat.toolRun.fallbackTitle') }}
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-slate-500">
|
||||
<template v-if="run">
|
||||
批次:{{ run.run_no }} · 状态:{{ statusLabel(run.status) }}
|
||||
<span v-if="run.error_message" class="ml-2 text-rose-700">错误信息:{{ run.error_message }}</span>
|
||||
{{ $t('chat.toolRun.batch', { runNo: run.run_no }) }} · {{ $t('chat.toolRun.status', { status: statusLabel(run.status) }) }}
|
||||
<span v-if="run.error_message" class="ml-2 text-rose-700">{{ $t('chat.toolRun.errorMessage', { message: run.error_message }) }}</span>
|
||||
</template>
|
||||
<template v-else-if="loading || waiting">正在等待检核任务启动...</template>
|
||||
<template v-else-if="loading || waiting">{{ $t('chat.toolRun.waitingStart') }}</template>
|
||||
<template v-else-if="error">{{ error }}</template>
|
||||
</p>
|
||||
<p v-if="run?.status === 'running' && run.current_step" class="mt-1 text-xs text-sky-700">
|
||||
当前阶段:{{ run.current_step.label || run.current_step.step }}
|
||||
<span v-if="run.current_step.row_id"> · 当前记录:{{ run.current_step.row_id }}</span>
|
||||
<span v-if="run.current_step.started_at"> · 阶段开始:{{ formatTime(run.current_step.started_at) }}</span>
|
||||
{{ $t('chat.toolRun.currentStep', { step: run.current_step.label || run.current_step.step }) }}
|
||||
<span v-if="run.current_step.row_id"> · {{ $t('chat.toolRun.currentRow', { rowId: run.current_step.row_id }) }}</span>
|
||||
<span v-if="run.current_step.started_at"> · {{ $t('chat.toolRun.stepStarted', { time: formatTime(run.current_step.started_at) }) }}</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex shrink-0 flex-wrap items-center justify-end gap-2">
|
||||
@@ -171,7 +194,7 @@ const downloadExcel = async () => {
|
||||
>
|
||||
<Loader2 v-if="downloadingExcel" class="h-3.5 w-3.5 animate-spin" />
|
||||
<Download v-else class="h-3.5 w-3.5" />
|
||||
{{ downloadingExcel ? '下载中...' : '下载 Excel' }}
|
||||
{{ downloadingExcel ? $t('chat.toolRun.downloading') : $t('chat.toolRun.downloadExcel') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -188,47 +211,47 @@ const downloadExcel = async () => {
|
||||
></div>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center justify-between gap-2 text-xs text-slate-500">
|
||||
<span>进度 {{ percent() }}%</span>
|
||||
<span>开始:{{ formatTime(run.started_at) }} · 完成:{{ formatTime(run.finished_at) }}</span>
|
||||
<span>{{ $t('chat.toolRun.progress', { percent: percent() }) }}</span>
|
||||
<span>{{ $t('chat.toolRun.startedAt', { time: formatTime(run.started_at) }) }} · {{ $t('chat.toolRun.finishedAt', { time: formatTime(run.finished_at) }) }}</span>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-1.5 sm:grid-cols-4 lg:grid-cols-8">
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">总数</div>
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">{{ $t('chat.toolRun.total') }}</div>
|
||||
<div class="text-base font-bold text-slate-800">{{ run.total_count }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">已处理</div>
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">{{ $t('chat.toolRun.processed') }}</div>
|
||||
<div class="text-base font-bold text-sky-700">{{ run.processed_count }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">成功</div>
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">{{ $t('chat.toolRun.success') }}</div>
|
||||
<div class="text-base font-bold text-emerald-700">{{ run.success_count }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">失败</div>
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">{{ $t('chat.toolRun.failed') }}</div>
|
||||
<div class="text-base font-bold text-rose-700">{{ run.failed_count }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">跳过</div>
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">{{ $t('chat.toolRun.skipped') }}</div>
|
||||
<div class="text-base font-bold text-amber-700">{{ run.skipped_count }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">合格笔数</div>
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">{{ $t('chat.toolRun.qualified') }}</div>
|
||||
<div class="text-base font-bold text-emerald-700">{{ run.judgement?.qualified_count ?? 0 }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">不合格笔数</div>
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">{{ $t('chat.toolRun.unqualified') }}</div>
|
||||
<div class="text-base font-bold text-rose-700">{{ run.judgement?.unqualified_count ?? 0 }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-white/80 px-2 py-1.5">
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">人工判定笔数</div>
|
||||
<div class="whitespace-nowrap text-xs text-slate-500">{{ $t('chat.toolRun.manual') }}</div>
|
||||
<div class="text-base font-bold text-amber-700">{{ run.judgement?.manual_count ?? 0 }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="run.knowledge_base?.error_message" class="rounded-xl bg-amber-50 px-3 py-2 text-xs text-amber-700">
|
||||
知识库同步错误:{{ run.knowledge_base.error_message }}
|
||||
{{ $t('chat.toolRun.kbSyncError', { message: run.knowledge_base.error_message }) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -236,7 +259,7 @@ const downloadExcel = async () => {
|
||||
<div class="h-2.5 overflow-hidden rounded-full bg-slate-200">
|
||||
<div class="h-full w-1/3 animate-pulse rounded-full bg-gradient-to-r from-sky-400 to-emerald-400" />
|
||||
</div>
|
||||
<p class="text-xs text-slate-500">检核启动后,这里会显示实时进度。</p>
|
||||
<p class="text-xs text-slate-500">{{ $t('chat.toolRun.waitingHint') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Check, Copy, Download, Edit2, Eye, LayoutGrid, MessageSquareText, RotateCw, X } from 'lucide-vue-next';
|
||||
import { useAuthStore } from '@/features/auth/stores/auth.store';
|
||||
import LeaveMessageBlock, { type LeaveMessageHandlers } from './LeaveMessageBlock.vue';
|
||||
@@ -85,6 +86,7 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const { t } = useI18n();
|
||||
const INLINE_DOWNLOAD_ALLOWED_EMPLOYEE_ID = '17070141';
|
||||
const RESTRICTED_INLINE_DOWNLOAD_FILE_NAME = '资产明细全量导出表.csv';
|
||||
|
||||
@@ -149,56 +151,57 @@ interface InlineFileEntry {
|
||||
table: InlinePreviewTable;
|
||||
}
|
||||
|
||||
const FIXED_ASSET_HEADER_LABELS: Record<string, string> = {
|
||||
id: '序号',
|
||||
asset_id: '资产编号',
|
||||
asset_no: '资产编号',
|
||||
asset_name: '资产名称',
|
||||
currency_amount: '本币金额(元)',
|
||||
specification: '规格型号',
|
||||
account_period: '账套',
|
||||
operating_center_code: '账套',
|
||||
custodian_person: '保管人',
|
||||
custodian_name: '保管人',
|
||||
custodian_dept: '保管部门',
|
||||
department_name: '保管部门',
|
||||
image: '图片',
|
||||
picture: '图片',
|
||||
storage_location: '存放位置名称',
|
||||
location_name: '存放位置名称',
|
||||
asset_status: '资产状态',
|
||||
reserved_field: '预留残值',
|
||||
residual_value: '预留残值',
|
||||
supplier: '供应商',
|
||||
vendor_name: '供应商',
|
||||
asset_nature: '资产性质',
|
||||
nature: '资产性质',
|
||||
amount_local: '本币金额(元)',
|
||||
unit_price: '本币金额(元)',
|
||||
quantity: '数量',
|
||||
unit: '计量单位',
|
||||
unit_of_measurement: '计量单位',
|
||||
acquisition_date: '取得时间',
|
||||
acquired_date: '取得时间',
|
||||
accounting_date: '入账日期',
|
||||
recorded_date: '入账日期',
|
||||
created_at: '创建时间',
|
||||
created_time: '创建时间',
|
||||
updated_at: '更新时间',
|
||||
snapshot_time: '快照时间',
|
||||
/** 英文字段名 → chat.assetColumns.* key(展示用;匹配仍用 aliases 中的中英文别名) */
|
||||
const FIXED_ASSET_HEADER_KEYS: Record<string, string> = {
|
||||
id: 'chat.assetColumns.id',
|
||||
asset_id: 'chat.assetColumns.assetId',
|
||||
asset_no: 'chat.assetColumns.assetId',
|
||||
asset_name: 'chat.assetColumns.assetName',
|
||||
currency_amount: 'chat.assetColumns.currencyAmount',
|
||||
specification: 'chat.assetColumns.specification',
|
||||
account_period: 'chat.assetColumns.accountPeriod',
|
||||
operating_center_code: 'chat.assetColumns.accountPeriod',
|
||||
custodian_person: 'chat.assetColumns.custodianPerson',
|
||||
custodian_name: 'chat.assetColumns.custodianPerson',
|
||||
custodian_dept: 'chat.assetColumns.custodianDept',
|
||||
department_name: 'chat.assetColumns.custodianDept',
|
||||
image: 'chat.assetColumns.image',
|
||||
picture: 'chat.assetColumns.image',
|
||||
storage_location: 'chat.assetColumns.storageLocation',
|
||||
location_name: 'chat.assetColumns.storageLocation',
|
||||
asset_status: 'chat.assetColumns.assetStatus',
|
||||
reserved_field: 'chat.assetColumns.residualValue',
|
||||
residual_value: 'chat.assetColumns.residualValue',
|
||||
supplier: 'chat.assetColumns.supplier',
|
||||
vendor_name: 'chat.assetColumns.supplier',
|
||||
asset_nature: 'chat.assetColumns.assetNature',
|
||||
nature: 'chat.assetColumns.assetNature',
|
||||
amount_local: 'chat.assetColumns.currencyAmount',
|
||||
unit_price: 'chat.assetColumns.currencyAmount',
|
||||
quantity: 'chat.assetColumns.quantity',
|
||||
unit: 'chat.assetColumns.unit',
|
||||
unit_of_measurement: 'chat.assetColumns.unit',
|
||||
acquisition_date: 'chat.assetColumns.acquisitionDate',
|
||||
acquired_date: 'chat.assetColumns.acquisitionDate',
|
||||
accounting_date: 'chat.assetColumns.accountingDate',
|
||||
recorded_date: 'chat.assetColumns.accountingDate',
|
||||
created_at: 'chat.assetColumns.createdAt',
|
||||
created_time: 'chat.assetColumns.createdAt',
|
||||
updated_at: 'chat.assetColumns.updatedAt',
|
||||
snapshot_time: 'chat.assetColumns.snapshotTime',
|
||||
};
|
||||
const FIXED_ASSET_CANONICAL_COLUMNS = [
|
||||
{ key: 'id', label: '序号', aliases: ['id', '序号'] },
|
||||
{ key: 'asset_id', label: '资产编号', aliases: ['asset_id', 'asset_no', '资产编号'] },
|
||||
{ key: 'asset_name', label: '资产名称', aliases: ['asset_name', '资产名称'] },
|
||||
{ key: 'custodian_person', label: '保管人', aliases: ['custodian_person', 'custodian_name', '保管人', '保管人姓名'] },
|
||||
{ key: 'custodian_dept', label: '保管部门', aliases: ['custodian_dept', 'department_name', '保管部门', '保管部门名称'] },
|
||||
{ key: 'image', label: '图片', aliases: ['image', 'picture', '图片'] },
|
||||
{ key: 'account_period', label: '账套', aliases: ['account_period', 'operating_center_code', '账套'] },
|
||||
{ key: 'supplier', label: '供应商', aliases: ['supplier', 'vendor_name', '供应商', '供应厂商'] },
|
||||
{ key: 'asset_status', label: '资产状态', aliases: ['asset_status', '资产状态'] },
|
||||
{ key: 'quantity', label: '数量', aliases: ['quantity', '数量'] },
|
||||
{ key: 'acquisition_date', label: '取得时间', aliases: ['acquisition_date', 'acquired_date', '取得时间', '取得日期'] },
|
||||
{ key: 'id', labelKey: 'chat.assetColumns.id', aliases: ['id', '序号'] },
|
||||
{ key: 'asset_id', labelKey: 'chat.assetColumns.assetId', aliases: ['asset_id', 'asset_no', '资产编号'] },
|
||||
{ key: 'asset_name', labelKey: 'chat.assetColumns.assetName', aliases: ['asset_name', '资产名称'] },
|
||||
{ key: 'custodian_person', labelKey: 'chat.assetColumns.custodianPerson', aliases: ['custodian_person', 'custodian_name', '保管人', '保管人姓名'] },
|
||||
{ key: 'custodian_dept', labelKey: 'chat.assetColumns.custodianDept', aliases: ['custodian_dept', 'department_name', '保管部门', '保管部门名称'] },
|
||||
{ key: 'image', labelKey: 'chat.assetColumns.image', aliases: ['image', 'picture', '图片'] },
|
||||
{ key: 'account_period', labelKey: 'chat.assetColumns.accountPeriod', aliases: ['account_period', 'operating_center_code', '账套'] },
|
||||
{ key: 'supplier', labelKey: 'chat.assetColumns.supplier', aliases: ['supplier', 'vendor_name', '供应商', '供应厂商'] },
|
||||
{ key: 'asset_status', labelKey: 'chat.assetColumns.assetStatus', aliases: ['asset_status', '资产状态'] },
|
||||
{ key: 'quantity', labelKey: 'chat.assetColumns.quantity', aliases: ['quantity', '数量'] },
|
||||
{ key: 'acquisition_date', labelKey: 'chat.assetColumns.acquisitionDate', aliases: ['acquisition_date', 'acquired_date', '取得时间', '取得日期'] },
|
||||
] as const;
|
||||
const INLINE_DIALOG_PAGE_SIZE = 15;
|
||||
|
||||
@@ -238,14 +241,15 @@ function parseCsvLine(line: string): string[] {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将固定资产 CSV 的英文列名转换成面向业务展示的中文列名。
|
||||
* 将固定资产 CSV 的英文列名转换成面向业务展示的本地化列名。
|
||||
* 核心逻辑:优先命中已知字段映射;未知字段保留原值,避免误伤其他 Agent 的文件。
|
||||
* @param header - CSV 原始表头。
|
||||
* @returns 中文表头或原始表头。
|
||||
* @returns 本地化表头或原始表头。
|
||||
*/
|
||||
function localizeInlineTableHeader(header: string): string {
|
||||
const normalizedHeader = String(header || '').trim().toLowerCase();
|
||||
return FIXED_ASSET_HEADER_LABELS[normalizedHeader] || header || '-';
|
||||
const key = FIXED_ASSET_HEADER_KEYS[normalizedHeader];
|
||||
return key ? t(key) : (header || '-');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,14 +272,14 @@ function formatInlineDateOnly(value: string): string {
|
||||
|
||||
/**
|
||||
* 统一表格中的空值展示。
|
||||
* 核心逻辑:对空串、短横线、null/none 等占位值统一显示“无”,但保留数字 0 与正常文本。
|
||||
* 核心逻辑:对空串、短横线、null/none 等占位值统一显示本地化“无”,但保留数字 0 与正常文本。
|
||||
* @param value - 原始单元格值。
|
||||
* @returns 归一化后的展示值。
|
||||
*/
|
||||
function normalizeInlineTableCell(value: string): string {
|
||||
const normalized = String(value ?? '').trim();
|
||||
if (!normalized) return '无';
|
||||
if (['-', '--', 'null', 'none', 'n/a', 'na'].includes(normalized.toLowerCase())) return '无';
|
||||
if (!normalized) return t('chat.assetColumns.empty');
|
||||
if (['-', '--', 'null', 'none', 'n/a', 'na'].includes(normalized.toLowerCase())) return t('chat.assetColumns.empty');
|
||||
return normalized;
|
||||
}
|
||||
|
||||
@@ -338,7 +342,7 @@ function serializeCsvRows(rows: string[][]): string {
|
||||
* @returns 规范化后的表头与数据行。
|
||||
*/
|
||||
function buildFixedAssetInlineTable(rawHeaders: string[], dataRows: string[][]): InlinePreviewTable {
|
||||
const headers = FIXED_ASSET_CANONICAL_COLUMNS.map((column) => column.label);
|
||||
const headers = FIXED_ASSET_CANONICAL_COLUMNS.map((column) => t(column.labelKey));
|
||||
const canonicalHeaders = FIXED_ASSET_CANONICAL_COLUMNS.map((column) => column.key);
|
||||
const allRows = dataRows.map((row, rowIndex) => FIXED_ASSET_CANONICAL_COLUMNS.map((column) => {
|
||||
if (column.key === 'id') return String(rowIndex + 1);
|
||||
@@ -352,7 +356,7 @@ function buildFixedAssetInlineTable(rawHeaders: string[], dataRows: string[][]):
|
||||
if (normalizedImageValue) {
|
||||
return normalizeInlineTableCell(normalizedImageValue);
|
||||
}
|
||||
return normalizedAssetId ? '查看' : '无';
|
||||
return normalizedAssetId ? t('chat.assetColumns.view') : t('chat.assetColumns.empty');
|
||||
}
|
||||
const columnIndex = findInlineTableHeaderIndex(rawHeaders, [...column.aliases]);
|
||||
const rawValue = columnIndex >= 0 ? row[columnIndex] ?? '' : '';
|
||||
@@ -573,7 +577,10 @@ function canOpenInlineAssetHistory(cellIndex: number, cellValue: string): boolea
|
||||
}
|
||||
|
||||
function isInlineHighlightHeader(header: string): boolean {
|
||||
return header === '资产编号' || header === '图片';
|
||||
return header === t('chat.assetColumns.assetId')
|
||||
|| header === t('chat.assetColumns.image')
|
||||
|| header === '资产编号'
|
||||
|| header === '图片';
|
||||
}
|
||||
|
||||
async function openInlineAssetHistory(row: string[], cellIndex: number): Promise<void> {
|
||||
@@ -911,7 +918,7 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
<Download class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.inlineFile.download') }}
|
||||
</button>
|
||||
<button type="button" class="btn-icon-ds" aria-label="关闭" @click="closeInlinePreviewDialog">
|
||||
<button type="button" class="btn-icon-ds" :aria-label="$t('common.close')" @click="closeInlinePreviewDialog">
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -79,7 +79,7 @@ const { message, index, handlers } = defineProps<{
|
||||
@change="handlers.syncLeaveDuration(handlers.getLeaveFormPayload(message)!.form)"
|
||||
>
|
||||
<option value="" disabled>{{ $t('chat.selectLeaveType') }}</option>
|
||||
<option v-for="leaveType in LEAVE_TYPES" :key="leaveType.value" :value="leaveType.value">{{ leaveType.label }}</option>
|
||||
<option v-for="leaveType in LEAVE_TYPES" :key="leaveType.value" :value="leaveType.value">{{ $t(leaveType.labelKey) }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
|
||||
@@ -60,20 +60,20 @@ const emit = defineEmits<{
|
||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<div class="text-[11px] font-bold uppercase tracking-[0.15em] text-brand-600/80">
|
||||
第三步:逐题考试
|
||||
{{ $t('chat.training.stepExamTitle') }}
|
||||
</div>
|
||||
<h3 class="mt-1 text-lg font-bold text-slate-800">
|
||||
第 {{ currentQuestionIndex + 1 }} / {{ totalCount }} 题
|
||||
{{ $t('chat.training.exam.questionCounter', { current: currentQuestionIndex + 1, total: totalCount }) }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2 text-[13px]">
|
||||
<div class="rounded-lg bg-slate-50 px-3 py-1.5 font-medium text-slate-600 border border-slate-100 flex items-center gap-2">
|
||||
<span>当前分数:</span>
|
||||
<span class="text-slate-800 font-bold">{{ score }} 分</span>
|
||||
<span>{{ $t('chat.training.currentScoreLabel') }}</span>
|
||||
<span class="text-slate-800 font-bold">{{ $t('chat.training.scoreShort', { score }) }}</span>
|
||||
</div>
|
||||
<div class="rounded-lg bg-slate-50 px-3 py-1.5 font-medium text-slate-600 border border-slate-100 flex items-center gap-2">
|
||||
<span>及格线:</span>
|
||||
<span class="text-slate-800 font-bold">{{ passScore }} 分</span>
|
||||
<span>{{ $t('chat.training.passLineLabel') }}</span>
|
||||
<span class="text-slate-800 font-bold">{{ $t('chat.training.passScoreShort', { passScore }) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -158,16 +158,16 @@ const emit = defineEmits<{
|
||||
<div class="flex items-center gap-2 text-sm font-bold" :class="feedbackCorrect ? 'text-emerald-700' : 'text-red-700'">
|
||||
<CheckCircle2 v-if="feedbackCorrect" class="h-4 w-4" />
|
||||
<XCircle v-else class="h-4 w-4" />
|
||||
{{ feedbackCorrect ? '回答正确,继续下一题' : '回答错误' }}
|
||||
{{ feedbackCorrect ? $t('chat.training.exam.correctFeedback') : $t('chat.training.wrongFeedbackShort') }}
|
||||
</div>
|
||||
|
||||
<div class="mt-3 space-y-2 text-[13px] leading-6 text-slate-600">
|
||||
<div class="flex gap-2">
|
||||
<span class="font-medium text-slate-500 shrink-0">你的答案:</span>
|
||||
<span class="font-medium text-slate-500 shrink-0">{{ $t('chat.training.yourAnswerLabel') }}</span>
|
||||
<span class="font-medium" :class="feedbackCorrect ? 'text-emerald-600' : 'text-red-600'">{{ answerLabel || '--' }}</span>
|
||||
</div>
|
||||
<div v-if="!feedbackCorrect" class="flex gap-2">
|
||||
<span class="font-medium text-slate-500 shrink-0">正确答案:</span>
|
||||
<span class="font-medium text-slate-500 shrink-0">{{ $t('chat.training.correctAnswerLabel') }}</span>
|
||||
<span class="text-emerald-600 font-medium">{{ question.options?.find(o => o.id === question.answer)?.label || '--' }}</span>
|
||||
</div>
|
||||
<div class="mt-2 pl-2 border-l-2 border-slate-200/60 text-slate-500/90">
|
||||
@@ -183,7 +183,7 @@ const emit = defineEmits<{
|
||||
@click="emit('next')"
|
||||
>
|
||||
<ClipboardCheck class="h-4 w-4" />
|
||||
{{ answeredCount >= totalCount - 1 ? '完成考试并查看结果' : '下一题' }}
|
||||
{{ answeredCount >= totalCount - 1 ? $t('chat.training.finishAndViewResult') : $t('chat.training.exam.nextQuestion') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -33,10 +33,10 @@ const emit = defineEmits<{
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-[11px] font-bold uppercase tracking-[0.15em] text-slate-500">
|
||||
第四步:结算结果
|
||||
{{ $t('chat.training.stepResultTitle') }}
|
||||
</div>
|
||||
<h3 class="text-lg font-bold text-slate-800">
|
||||
{{ isPassed ? '恭喜,你已通过考核!' : '很遗憾,考试未通过' }}
|
||||
{{ isPassed ? $t('chat.training.passTitleShort') : $t('chat.training.failTitleShort') }}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
@@ -59,7 +59,7 @@ const emit = defineEmits<{
|
||||
<div class="mt-1 text-2xl font-black text-emerald-600">{{ correctCount }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-red-50/50 p-4 border border-red-100/50 text-center">
|
||||
<div class="text-[11px] font-bold text-red-400 uppercase">答错</div>
|
||||
<div class="text-[11px] font-bold text-red-400 uppercase">{{ $t('chat.training.wrongCountShort') }}</div>
|
||||
<div class="mt-1 text-2xl font-black text-red-500">{{ wrongCount }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -78,12 +78,12 @@ const emit = defineEmits<{
|
||||
@click="emit('restart')"
|
||||
>
|
||||
<RotateCcw class="h-4 w-4" />
|
||||
重新考试
|
||||
{{ $t('chat.training.result.retryExam') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="flex items-center gap-2 text-emerald-600 font-medium text-sm">
|
||||
<CheckCircle2 class="h-4 w-4" />
|
||||
成绩已同步至 HR 管理系统
|
||||
{{ $t('chat.training.syncedToHr') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -30,7 +30,7 @@ const emit = defineEmits<{
|
||||
<div class="h-12 w-12 flex items-center justify-center rounded-full bg-white/20 backdrop-blur-md border border-white/30 group-hover:bg-brand-600 group-hover:border-brand-500 transition-all duration-300">
|
||||
<PlayCircle class="h-6 w-6 text-white fill-white/20" />
|
||||
</div>
|
||||
<span class="text-white text-xs font-medium drop-shadow-md">点击播放视频</span>
|
||||
<span class="text-white text-xs font-medium drop-shadow-md">{{ $t('chat.training.clickPlayVideo') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -377,7 +377,10 @@ export function useChat() {
|
||||
* 说明:
|
||||
* - Dify Chatflow 失败时常以 `workflow_finished + data.status=failed` 返回,HTTP 仍是 200;
|
||||
* - 若这里只按“终态成功”处理,页面会出现“没有任何响应”;
|
||||
* - 因此需要优先从 top-level / nested data / error 对象里抽取失败文案。
|
||||
* - 因此需要优先从 top-level / nested data / error 对象里抽取失败文案;
|
||||
* - 上下文过长与缺省失败文案走 chat.streamError.contextTooLong / workflowFailed。
|
||||
* @param data - SSE 事件 JSON
|
||||
* @returns 用户可读错误;非失败终态返回空串
|
||||
*/
|
||||
const extractWorkflowFailureMessage = (data: Record<string, unknown>) => {
|
||||
if (String(data.event || '') !== 'workflow_finished') return '';
|
||||
@@ -399,11 +402,11 @@ export function useChat() {
|
||||
const normalized = formatStreamError(candidate).trim();
|
||||
if (!normalized || normalized === 'Unknown error') continue;
|
||||
if (/maximum context length|input_tokens/i.test(normalized)) {
|
||||
return '当前会话上下文过长,模型无法继续回答。请新建对话后重新查询该资产编号。';
|
||||
return t('chat.streamError.contextTooLong');
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
return '工作流执行失败,请稍后重试';
|
||||
return t('chat.streamError.workflowFailed');
|
||||
};
|
||||
|
||||
const streamErrorLabels = (): StreamErrorLabels => ({
|
||||
|
||||
@@ -24,9 +24,6 @@ export type AgentSuggestedQuestionItem = {
|
||||
const DEFAULT_KB = '企业知识库';
|
||||
const ERP_KB = 'ERP知识库';
|
||||
|
||||
const TRAINING_AGENT_DESCRIPTION =
|
||||
'我是你的新人培训助手,会在同一个聊天页面内带你完成视频学习、知识点复盘、逐题考试和结果复盘。';
|
||||
|
||||
const normalizeAgentSuggestedQuestions = (value: unknown): AgentSuggestedQuestionItem[] => {
|
||||
if (!Array.isArray(value)) return [];
|
||||
return value
|
||||
@@ -114,7 +111,7 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
const welcome = String(currentAgent.value?.welcome_message || '').trim();
|
||||
if (welcome) return welcome;
|
||||
const text = String(currentAgent.value?.description || '').trim();
|
||||
if (!text && matchesTrainingAgent(currentAgent.value)) return TRAINING_AGENT_DESCRIPTION;
|
||||
if (!text && matchesTrainingAgent(currentAgent.value)) return t('chat.training.agentDescription');
|
||||
return text;
|
||||
});
|
||||
|
||||
@@ -148,7 +145,7 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
const styledSuggestedQuestionSections = computed(() => {
|
||||
const groups = new Map<string, AgentSuggestedQuestionItem[]>();
|
||||
for (const item of agentSuggestedQuestions.value) {
|
||||
const groupName = String(item.group || '').trim() || '常见问题';
|
||||
const groupName = String(item.group || '').trim() || t('chat.faqGroup');
|
||||
if (!groups.has(groupName)) {
|
||||
groups.set(groupName, []);
|
||||
}
|
||||
|
||||
@@ -1,40 +1,42 @@
|
||||
/**
|
||||
* features/chat/composables/useChatAssetHistory.ts
|
||||
* 用途:管理固定资产履历检索、友好提示与文件预览跳转。
|
||||
* 依赖:chat.api、useChatSourceFiles 暴露的 openPreview、聊天提示消息。
|
||||
* 依赖:chat.api、vue-i18n、useChatSourceFiles 暴露的 openPreview、聊天提示消息。
|
||||
* 逻辑:页面层统一持有“打开履历”动作,消息气泡/查询预览弹窗复用该入口;
|
||||
* 点击资产编号后先进入“检索中”状态,命中履历文件则直接打开最佳候选预览,未命中时仅提示用户。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import type { ComputedRef } from 'vue';
|
||||
import type { ComposerTranslation } from 'vue-i18n';
|
||||
import { searchAssetHistoryFiles } from '../api/chat.api';
|
||||
import type { AssetHistoryFileItem, SourceFileLink } from '../types/chat.types';
|
||||
import type { ComputedRef } from 'vue';
|
||||
|
||||
interface UseChatAssetHistoryOptions {
|
||||
agentId: ComputedRef<number>;
|
||||
openPreview: (file: SourceFileLink) => Promise<void>;
|
||||
warn: (message: string) => void;
|
||||
t: ComposerTranslation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把后端返回的技术性错误翻译成用户可理解的提示。
|
||||
* AI 触发时机:当资产履历查询失败,但原始错误包含英文配置名、共享盘术语等技术细节时调用。
|
||||
* 核心逻辑:优先识别已知的履历共享盘配置异常,返回面向业务用户的中文说明;其他错误保持原文,避免吞掉真实上下文。
|
||||
* 核心逻辑:优先识别已知的履历共享盘配置异常,返回面向业务用户的本地化说明;其他错误保持原文。
|
||||
* 参数约束:仅处理展示文案,不改变错误对象本身;返回值必须适合作为 toast/警告弹窗直接展示。
|
||||
*/
|
||||
function normalizeAssetHistoryErrorMessage(message: string): string {
|
||||
function normalizeAssetHistoryErrorMessage(message: string, t: ComposerTranslation): string {
|
||||
const normalizedMessage = String(message || '').trim();
|
||||
const lowerCaseMessage = normalizedMessage.toLowerCase();
|
||||
if (lowerCaseMessage.includes('asset history share is not configured')) {
|
||||
return '当前系统暂未配置资产履历文件目录,暂时无法查看履历,请联系管理员处理。';
|
||||
return String(t('chat.assetHistory.shareNotConfigured'));
|
||||
}
|
||||
if (lowerCaseMessage.includes('asset history share is unreachable')) {
|
||||
return '当前环境暂时无法访问资产履历共享盘,请联系管理员检查测试环境共享盘挂载或访问权限。';
|
||||
return String(t('chat.assetHistory.shareUnreachable'));
|
||||
}
|
||||
if (lowerCaseMessage.includes('asset history share is invalid')) {
|
||||
return '当前环境的资产履历目录配置无效,请联系管理员检查共享盘目录配置。';
|
||||
return String(t('chat.assetHistory.shareInvalid'));
|
||||
}
|
||||
return normalizedMessage || '检索资产履历失败';
|
||||
return normalizedMessage || String(t('chat.assetHistory.searchFailed'));
|
||||
}
|
||||
|
||||
export function useChatAssetHistory(options: UseChatAssetHistoryOptions) {
|
||||
@@ -44,6 +46,7 @@ export function useChatAssetHistory(options: UseChatAssetHistoryOptions) {
|
||||
const assetId = ref('');
|
||||
const assetName = ref('');
|
||||
const items = ref<AssetHistoryFileItem[]>([]);
|
||||
const { t } = options;
|
||||
|
||||
const close = () => {
|
||||
open.value = false;
|
||||
@@ -66,7 +69,7 @@ export function useChatAssetHistory(options: UseChatAssetHistoryOptions) {
|
||||
return;
|
||||
}
|
||||
if (!normalizedAssetId && !normalizedAssetName) {
|
||||
options.warn('当前资产缺少可用于检索履历的编号或名称');
|
||||
options.warn(String(t('chat.assetHistory.missingIdentifier')));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,15 +88,15 @@ export function useChatAssetHistory(options: UseChatAssetHistoryOptions) {
|
||||
const bestMatch = items.value[0];
|
||||
if (!bestMatch) {
|
||||
const displayName = normalizedAssetId || normalizedAssetName;
|
||||
options.warn(`未找到资产 ${displayName} 的履历文件,如确认应有履历,请联系管理员补充。`);
|
||||
options.warn(String(t('chat.assetHistory.notFound', { name: displayName })));
|
||||
return;
|
||||
}
|
||||
await openHistoryFilePreview(bestMatch);
|
||||
} catch (err: unknown) {
|
||||
const rawMessage = err instanceof Error ? err.message : '检索资产履历失败';
|
||||
const message = normalizeAssetHistoryErrorMessage(rawMessage);
|
||||
const rawMessage = err instanceof Error ? err.message : String(t('chat.assetHistory.searchFailed'));
|
||||
const message = normalizeAssetHistoryErrorMessage(rawMessage, t);
|
||||
error.value = message;
|
||||
options.warn(`履历查询失败:${message}`);
|
||||
options.warn(String(t('chat.assetHistory.queryFailed', { message })));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/chat/composables/useChatAssetImage.ts
|
||||
* 用途:管理固定资产图片检索、友好提示与预览跳转。
|
||||
* 依赖:chat.api、useChatSourceFiles 暴露的 openPreview、聊天提示消息。
|
||||
* 依赖:chat.api、vue-i18n、useChatSourceFiles 暴露的 openPreview、聊天提示消息。
|
||||
* 逻辑:用户点击“图片 -> 查看”后,本 composable 统一向后端索要最佳图片,再复用现有文件预览弹窗在站内展示。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import type { ComputedRef } from 'vue';
|
||||
import type { ComposerTranslation } from 'vue-i18n';
|
||||
import { resolveAssetImagePreview } from '../api/chat.api';
|
||||
import type { SourceFileLink } from '../types/chat.types';
|
||||
|
||||
@@ -13,37 +14,39 @@ interface UseChatAssetImageOptions {
|
||||
agentId: ComputedRef<number>;
|
||||
openPreviewGallery: (files: SourceFileLink[], initialIndex?: number) => Promise<void>;
|
||||
warn: (message: string) => void;
|
||||
t: ComposerTranslation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把后端返回的图片检索错误翻译成业务用户能看懂的提示。
|
||||
* AI 触发时机:当用户点击“图片 -> 查看”失败,但原始报错包含接口路径、外部系统术语等技术细节时调用。
|
||||
* 核心逻辑:优先识别已知的配置/检索异常并转成中文说明;未知错误保留原始文本,方便排查。
|
||||
* 核心逻辑:优先识别已知的配置/检索异常并转成本地化说明;未知错误保留原始文本,方便排查。
|
||||
* 参数与输出约束:只负责展示文案,不吞掉真实错误对象;返回值必须适合作为 toast 直接展示。
|
||||
*/
|
||||
function normalizeAssetImageErrorMessage(message: string): string {
|
||||
function normalizeAssetImageErrorMessage(message: string, t: ComposerTranslation): string {
|
||||
const normalizedMessage = String(message || '').trim();
|
||||
const lowerCaseMessage = normalizedMessage.toLowerCase();
|
||||
if (lowerCaseMessage.includes('固定资产图片文档库未配置')) {
|
||||
return '当前系统暂未配置固定资产图片文档库,暂时无法查看图片,请联系管理员处理。';
|
||||
return String(t('chat.assetImage.libraryNotConfigured'));
|
||||
}
|
||||
if (lowerCaseMessage.includes('请求的资源不存在')) {
|
||||
return '设备管理员还未上传照片~';
|
||||
return String(t('chat.assetImage.noPhotoUploaded'));
|
||||
}
|
||||
if (lowerCaseMessage.includes('未找到资产')) {
|
||||
return normalizedMessage;
|
||||
}
|
||||
return normalizedMessage || '检索固定资产图片失败';
|
||||
return normalizedMessage || String(t('chat.assetImage.searchFailed'));
|
||||
}
|
||||
|
||||
|
||||
export function useChatAssetImage(options: UseChatAssetImageOptions) {
|
||||
const loading = ref(false);
|
||||
const { t } = options;
|
||||
|
||||
/**
|
||||
* 检索固定资产图片并直接打开预览。
|
||||
* AI 触发时机:当用户点击聊天表格或 CSV 预览里的“图片 -> 查看”时调用。
|
||||
* 核心逻辑:先向后端请求全部命中的图片文件,再把图片组交给通用 FilePreviewModal 预览。
|
||||
* 核心逻辑:先向后端请求全部命中的图片文件,再把图片组交给通用 FilePreviewModal 预览。
|
||||
* 参数约束:至少要提供资产编号或资产名称之一;后端负责登录外部文档库和挑选最佳图片。
|
||||
*/
|
||||
const openImage = async (nextAssetId: string, nextAssetName = '') => {
|
||||
@@ -51,7 +54,7 @@ export function useChatAssetImage(options: UseChatAssetImageOptions) {
|
||||
const normalizedAssetName = String(nextAssetName || '').trim();
|
||||
if (loading.value) return;
|
||||
if (!normalizedAssetId && !normalizedAssetName) {
|
||||
options.warn('当前资产缺少可用于检索图片的编号或名称');
|
||||
options.warn(String(t('chat.assetImage.missingIdentifier')));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,7 +69,7 @@ export function useChatAssetImage(options: UseChatAssetImageOptions) {
|
||||
: (result?.item ? [result.item] : []);
|
||||
if (!items.length) {
|
||||
const displayName = normalizedAssetId || normalizedAssetName;
|
||||
options.warn(`未找到资产 ${displayName} 的图片文件,请联系管理员补充。`);
|
||||
options.warn(String(t('chat.assetImage.notFound', { name: displayName })));
|
||||
return;
|
||||
}
|
||||
await options.openPreviewGallery(
|
||||
@@ -78,12 +81,12 @@ export function useChatAssetImage(options: UseChatAssetImageOptions) {
|
||||
0,
|
||||
);
|
||||
} catch (err: unknown) {
|
||||
const rawMessage = err instanceof Error ? err.message : '检索固定资产图片失败';
|
||||
const message = normalizeAssetImageErrorMessage(rawMessage);
|
||||
if (message === '设备管理员还未上传照片~') {
|
||||
const rawMessage = err instanceof Error ? err.message : String(t('chat.assetImage.searchFailed'));
|
||||
const message = normalizeAssetImageErrorMessage(rawMessage, t);
|
||||
if (message === String(t('chat.assetImage.noPhotoUploaded'))) {
|
||||
options.warn(message);
|
||||
} else {
|
||||
options.warn(`图片查询失败:${message}`);
|
||||
options.warn(String(t('chat.assetImage.queryFailed', { message })));
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
|
||||
@@ -66,7 +66,7 @@ export interface UseChatAttachmentsOptions {
|
||||
|
||||
export function useChatAttachments(options: UseChatAttachmentsOptions) {
|
||||
const { deps, currentAgentId, currentAgent } = options;
|
||||
const { msg } = deps;
|
||||
const { msg, t } = deps;
|
||||
|
||||
const attachments = ref<PendingAttachment[]>([]);
|
||||
const isUploadingAttachments = ref(false);
|
||||
@@ -267,12 +267,12 @@ export function useChatAttachments(options: UseChatAttachmentsOptions) {
|
||||
const files = Array.from(fileList);
|
||||
for (const f of files) {
|
||||
if (attachmentPolicy.value.totalLimit && attachments.value.length >= attachmentPolicy.value.totalLimit) {
|
||||
msg.warning(`附件数量已达上限(${attachmentPolicy.value.totalLimit})`);
|
||||
msg.warning(t('chat.attachmentsUi.limitReached', { limit: attachmentPolicy.value.totalLimit }));
|
||||
break;
|
||||
}
|
||||
const ext = extractExt(f.name || '');
|
||||
if (attachmentPolicy.value.allowedExts && (!ext || !attachmentPolicy.value.allowedExts.has(ext))) {
|
||||
msg.warning(`不支持的附件类型:${f.name}`);
|
||||
msg.warning(t('chat.attachmentsUi.unsupportedType', { name: f.name }));
|
||||
continue;
|
||||
}
|
||||
let type = inferFileTypeFromFile(f);
|
||||
@@ -280,23 +280,23 @@ export function useChatAttachments(options: UseChatAttachmentsOptions) {
|
||||
if (attachmentPolicy.value.enabled.custom.local && !isKnownDifyExt(ext)) {
|
||||
type = 'custom';
|
||||
} else {
|
||||
msg.warning(`不支持的附件类型:${f.name}`);
|
||||
msg.warning(t('chat.attachmentsUi.unsupportedType', { name: f.name }));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const caps = attachmentPolicy.value.enabled[type];
|
||||
if (!caps?.local) {
|
||||
msg.warning(`当前应用不支持上传此类型附件:${type}`);
|
||||
msg.warning(t('chat.attachmentsUi.typeNotAllowed', { type }));
|
||||
continue;
|
||||
}
|
||||
const limit = attachmentPolicy.value.sizeLimitMb[type];
|
||||
if (limit && f.size > limit * 1024 * 1024) {
|
||||
msg.warning(`附件过大(上限 ${limit}MB):${f.name}`);
|
||||
msg.warning(t('chat.attachmentsUi.tooLarge', { limit, name: f.name }));
|
||||
continue;
|
||||
}
|
||||
const countSameType = attachments.value.filter((a) => a.type === type).length;
|
||||
if (caps.limit && countSameType >= caps.limit) {
|
||||
msg.warning(`该类型附件数量已达上限(${caps.limit})`);
|
||||
msg.warning(t('chat.attachmentsUi.typeLimitReached', { limit: caps.limit }));
|
||||
continue;
|
||||
}
|
||||
attachments.value.push({ id: `${Date.now()}_${Math.random()}`, kind: 'local', file: f, type });
|
||||
@@ -309,20 +309,20 @@ export function useChatAttachments(options: UseChatAttachmentsOptions) {
|
||||
if (!raw) return;
|
||||
const url = raw.startsWith('//') ? `${window.location.protocol}${raw}` : raw;
|
||||
if (!/^https?:\/\//i.test(url)) {
|
||||
msg.warning('仅支持 http/https URL');
|
||||
msg.warning(t('chat.attachmentsUi.httpOnly'));
|
||||
return;
|
||||
}
|
||||
if (!attachmentPolicy.value.canRemote) {
|
||||
msg.warning('当前应用不支持 URL 附件');
|
||||
msg.warning(t('chat.attachmentsUi.urlNotSupported'));
|
||||
return;
|
||||
}
|
||||
if (attachmentPolicy.value.totalLimit && attachments.value.length >= attachmentPolicy.value.totalLimit) {
|
||||
msg.warning(`附件数量已达上限(${attachmentPolicy.value.totalLimit})`);
|
||||
msg.warning(t('chat.attachmentsUi.limitReached', { limit: attachmentPolicy.value.totalLimit }));
|
||||
return;
|
||||
}
|
||||
const ext = extractExt(url);
|
||||
if (attachmentPolicy.value.allowedExts && (!ext || !attachmentPolicy.value.allowedExts.has(ext))) {
|
||||
msg.warning('不支持的 URL 附件类型');
|
||||
msg.warning(t('chat.attachmentsUi.unsupportedUrlType'));
|
||||
return;
|
||||
}
|
||||
let type = inferFileTypeFromUrl(url);
|
||||
@@ -330,18 +330,18 @@ export function useChatAttachments(options: UseChatAttachmentsOptions) {
|
||||
if (attachmentPolicy.value.enabled.custom.remote && !isKnownDifyExt(ext)) {
|
||||
type = 'custom';
|
||||
} else {
|
||||
msg.warning('不支持的 URL 附件类型');
|
||||
msg.warning(t('chat.attachmentsUi.unsupportedUrlType'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
const caps = attachmentPolicy.value.enabled[type];
|
||||
if (!caps?.remote) {
|
||||
msg.warning(`当前应用不支持该类型 URL 附件:${type}`);
|
||||
msg.warning(t('chat.attachmentsUi.urlTypeNotAllowed', { type }));
|
||||
return;
|
||||
}
|
||||
const countSameType = attachments.value.filter((a) => a.type === type).length;
|
||||
if (caps.limit && countSameType >= caps.limit) {
|
||||
msg.warning(`该类型附件数量已达上限(${caps.limit})`);
|
||||
msg.warning(t('chat.attachmentsUi.typeLimitReached', { limit: caps.limit }));
|
||||
return;
|
||||
}
|
||||
attachments.value.push({ id: `${Date.now()}_${Math.random()}`, kind: 'remote', url, type });
|
||||
|
||||
@@ -120,9 +120,9 @@ export function useChatLeave(options: UseChatLeaveOptions) {
|
||||
canUseLeaveFeature,
|
||||
...oaLogin,
|
||||
...agentPicker,
|
||||
getLeaveTypeLabel,
|
||||
getLeaveTypeLabel: (val: string) => getLeaveTypeLabel(val, t),
|
||||
formatDurationLabel: (hours: number, leaveType?: string) => formatDurationLabel(hours, leaveType, t),
|
||||
formatYesNoLabel,
|
||||
formatYesNoLabel: (value: 0 | 1 | null) => formatYesNoLabel(value, t),
|
||||
syncLeaveDuration,
|
||||
getLeaveFormPayload,
|
||||
getLeaveConfirmationPayload,
|
||||
|
||||
@@ -180,11 +180,13 @@ export function useChatPage() {
|
||||
agentId: currentAgentId,
|
||||
openPreview,
|
||||
warn: (text) => msg.warning(text),
|
||||
t,
|
||||
});
|
||||
const assetImage = useChatAssetImage({
|
||||
agentId: currentAgentId,
|
||||
openPreviewGallery,
|
||||
warn: (text) => msg.warning(text),
|
||||
t,
|
||||
});
|
||||
|
||||
watch(currentAgentId, (id) => {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
/**
|
||||
* features/chat/composables/useChatQueryPreview.ts
|
||||
* Text2SQL 查询结果全量预览弹窗:分页加载与消息 payload 解析。
|
||||
* 用途:Text2SQL 查询结果全量预览弹窗:分页加载与消息 payload 解析。
|
||||
* 依赖:vue-i18n、chat.api.getChatQueryPreviewPage、chat.types.ChatMessage。
|
||||
* 逻辑:Chat 消息气泡触发 openDialog;文案走 chat.queryPreview.*。
|
||||
*/
|
||||
import { ref, type ComputedRef } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { getChatQueryPreviewPage } from '../api/chat.api';
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
|
||||
@@ -29,8 +32,15 @@ export interface UseChatQueryPreviewOptions {
|
||||
currentAgentId: ComputedRef<number>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装查询结果全量预览弹窗状态与分页加载逻辑。
|
||||
* 核心逻辑:从消息 payload 判断可预览;调用 getChatQueryPreviewPage 拉取分页数据。
|
||||
* @param options.currentAgentId - 当前 Agent ID(请求预览接口必填)
|
||||
* @returns 弹窗状态、摘要文案与 open/close/changePage 操作
|
||||
*/
|
||||
export function useChatQueryPreview(options: UseChatQueryPreviewOptions) {
|
||||
const { currentAgentId } = options;
|
||||
const { t } = useI18n();
|
||||
|
||||
const show = ref(false);
|
||||
const loading = ref(false);
|
||||
@@ -46,6 +56,11 @@ export function useChatQueryPreview(options: UseChatQueryPreviewOptions) {
|
||||
total: 0,
|
||||
});
|
||||
|
||||
/**
|
||||
* 从消息中提取 text2sql 预览 payload。
|
||||
* @param msg - 聊天消息
|
||||
* @returns 预览 payload;非目标 kind 时返回 null
|
||||
*/
|
||||
const getPayload = (msg: ChatMessage): QueryPreviewPayload | null => {
|
||||
const payload = msg?.payload;
|
||||
if (!payload || typeof payload !== 'object') return null;
|
||||
@@ -53,29 +68,52 @@ export function useChatQueryPreview(options: UseChatQueryPreviewOptions) {
|
||||
return payload as QueryPreviewPayload;
|
||||
};
|
||||
|
||||
/**
|
||||
* 判断消息是否可打开全量预览。
|
||||
* @param msg - 聊天消息
|
||||
* @returns 是否可预览
|
||||
*/
|
||||
const canOpen = (msg: ChatMessage) => {
|
||||
const payload = getPayload(msg);
|
||||
return !!(payload?.previewable && Number(msg?.chat_log_id) > 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* 生成“查看全部预览”摘要文案(含可选总条数)。
|
||||
* @param msg - 聊天消息
|
||||
* @returns 本地化摘要
|
||||
*/
|
||||
const getSummary = (msg: ChatMessage) => {
|
||||
const payload = getPayload(msg);
|
||||
const total = Number(payload?.total_count || 0);
|
||||
if (total > 0) return `查看全部预览(共 ${total} 条)`;
|
||||
return '查看全部预览';
|
||||
if (total > 0) return t('chat.queryPreview.viewAllWithTotal', { total });
|
||||
return t('chat.queryPreview.viewAll');
|
||||
};
|
||||
|
||||
/**
|
||||
* 按当前 pageSize 计算总页数。
|
||||
* @returns 至少为 1 的页数
|
||||
*/
|
||||
const totalPages = () =>
|
||||
Math.max(1, Math.ceil((state.value.total || 0) / (state.value.pageSize || 100)));
|
||||
|
||||
/**
|
||||
* 关闭预览弹窗并清空错误。
|
||||
*/
|
||||
const close = () => {
|
||||
show.value = false;
|
||||
error.value = '';
|
||||
};
|
||||
|
||||
/**
|
||||
* 拉取指定 chat_log 的分页预览数据。
|
||||
* 核心逻辑:Agent 未就绪时写本地化错误;成功后合并 state;失败回落 loadFailed。
|
||||
* @param chatLogId - 聊天日志 ID
|
||||
* @param page - 页码,默认 1
|
||||
*/
|
||||
const loadPage = async (chatLogId: number, page = 1) => {
|
||||
if (!currentAgentId.value) {
|
||||
error.value = '当前 Agent 未就绪,请稍后重试';
|
||||
error.value = t('chat.queryPreview.agentNotReady');
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
@@ -85,10 +123,11 @@ export function useChatQueryPreview(options: UseChatQueryPreviewOptions) {
|
||||
page,
|
||||
page_size: state.value.pageSize,
|
||||
});
|
||||
const fallbackTitle = t('chat.queryPreview.title');
|
||||
state.value = {
|
||||
...state.value,
|
||||
chatLogId,
|
||||
title: String(result.query || state.value.title || '查询结果全量预览').trim() || '查询结果全量预览',
|
||||
title: String(result.query || state.value.title || fallbackTitle).trim() || fallbackTitle,
|
||||
query: String(result.query || '').trim(),
|
||||
columns: Array.isArray(result.columns) ? result.columns : [],
|
||||
rows: Array.isArray(result.rows) ? result.rows : [],
|
||||
@@ -97,20 +136,25 @@ export function useChatQueryPreview(options: UseChatQueryPreviewOptions) {
|
||||
total: Number(result.total || 0),
|
||||
};
|
||||
} catch (err: unknown) {
|
||||
error.value = (err as { message?: string })?.message || '加载全量预览失败';
|
||||
error.value = (err as { message?: string })?.message || t('chat.queryPreview.loadFailed');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开预览弹窗并加载第一页。
|
||||
* @param msg - 触发预览的聊天消息
|
||||
*/
|
||||
const openDialog = async (msg: ChatMessage) => {
|
||||
const chatLogId = Number(msg?.chat_log_id || 0);
|
||||
if (!chatLogId) return;
|
||||
const payload = getPayload(msg);
|
||||
const fallbackTitle = t('chat.queryPreview.title');
|
||||
state.value = {
|
||||
...state.value,
|
||||
chatLogId,
|
||||
title: String(payload?.query || msg?.content || '查询结果全量预览').trim() || '查询结果全量预览',
|
||||
title: String(payload?.query || msg?.content || fallbackTitle).trim() || fallbackTitle,
|
||||
query: String(payload?.query || '').trim(),
|
||||
page: 1,
|
||||
total: Number(payload?.total_count || 0),
|
||||
@@ -119,6 +163,10 @@ export function useChatQueryPreview(options: UseChatQueryPreviewOptions) {
|
||||
await loadPage(chatLogId, 1);
|
||||
};
|
||||
|
||||
/**
|
||||
* 相对当前页翻页并重新加载。
|
||||
* @param delta - 页码增量(通常 ±1)
|
||||
*/
|
||||
const changePage = async (delta: number) => {
|
||||
const nextPage = state.value.page + delta;
|
||||
if (nextPage < 1 || nextPage > totalPages()) return;
|
||||
|
||||
@@ -551,6 +551,7 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
currentAgentId,
|
||||
refreshShippingActions,
|
||||
msg,
|
||||
t,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -659,6 +660,7 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
saveLocalMessageToBackend,
|
||||
refreshShippingActions,
|
||||
msg,
|
||||
t,
|
||||
});
|
||||
|
||||
const shippingIntakes = useShippingNoticeIntakes({
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/chat/composables/useChatSourceFiles.ts
|
||||
* 检索来源 / 源文件链接解析与预览。
|
||||
* 用途:检索来源 / 源文件链接解析与预览。
|
||||
* 依赖:vue-i18n(t)、chat.api.resolveChatSourceFile、useMessage。
|
||||
* 逻辑:消息气泡源文件按钮调用 openPreview;缺链时抛 chat.sourcePreviewLinkMissing。
|
||||
*/
|
||||
import { ref, type ComputedRef, type Ref } from 'vue';
|
||||
import type { ComposerTranslation } from 'vue-i18n';
|
||||
@@ -389,7 +391,7 @@ export function useChatSourceFiles({ agentId, t, msg, isMobile }: UseChatSourceF
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!file.url) throw new Error('当前源文件暂未返回可预览链接');
|
||||
if (!file.url) throw new Error(t('chat.sourcePreviewLinkMissing'));
|
||||
return { name: file.name, url: file.url, actualExt: file.actualExt };
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
/**
|
||||
* features/chat/composables/useToolRunProgress.ts
|
||||
* 用途:轮询 Tool/文件检核任务进度,并在执行中锁定输入。
|
||||
* 依赖:vue-i18n、toolRunProgress.api、toolRunProgressConfig。
|
||||
* 逻辑:Chat 页 progress 卡片消费;lockMessage / queryFailed 走 chat.toolRun.*。
|
||||
*/
|
||||
import { computed, onBeforeUnmount, ref, type Ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { buildFileCheckLogProgressUrl } from '../utils/toolRunProgressConfig';
|
||||
import { getToolRunProgress, type ToolRunProgress } from '../api/toolRunProgress.api';
|
||||
import type { ToolRunProgressMatchSource } from '../types/tool-run-progress.types';
|
||||
@@ -43,11 +50,15 @@ const isTerminalStatus = (status?: string | null) => TERMINAL_STATUSES.has(Strin
|
||||
|
||||
/**
|
||||
* 轮询任务进度:有 run_id 时走 detail;或走 for-log / active。
|
||||
* 核心逻辑:按 config 选择 detail/session/active URL;running 时定时刷新;终态停表。
|
||||
* @param configRef - 进度轮询配置
|
||||
* @param options.allowEmptySessionPolls - 允许 for-session 空结果继续重试
|
||||
*/
|
||||
export function useToolRunProgress(
|
||||
configRef: Ref<ToolRunProgressConfig | null>,
|
||||
options: UseToolRunProgressOptions = {},
|
||||
) {
|
||||
const { t } = useI18n();
|
||||
const run = ref<ToolRunProgress | null>(null);
|
||||
const matchSource = ref<ToolRunProgressMatchSource | null>(null);
|
||||
const loading = ref(false);
|
||||
@@ -68,7 +79,7 @@ export function useToolRunProgress(
|
||||
|
||||
const isRunning = computed(() => run.value?.status === 'running');
|
||||
const shouldLockInput = computed(() => Boolean(configRef.value?.lock_input_when_running) && isRunning.value);
|
||||
const lockMessage = computed(() => configRef.value?.lock_message || '当前任务执行中,请等待完成');
|
||||
const lockMessage = computed(() => configRef.value?.lock_message || t('chat.toolRun.lockWaiting'));
|
||||
|
||||
const clearTimer = () => {
|
||||
if (timer !== undefined) {
|
||||
@@ -100,7 +111,7 @@ export function useToolRunProgress(
|
||||
matchSource.value = payload.match_source ?? null;
|
||||
return payload.run ?? null;
|
||||
} catch (e: unknown) {
|
||||
const message = e instanceof Error ? e.message : '任务进度查询失败';
|
||||
const message = e instanceof Error ? e.message : t('chat.toolRun.queryFailed');
|
||||
error.value = message;
|
||||
matchSource.value = null;
|
||||
clearTimer();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/chat/constants/leave.ts
|
||||
* 请假功能常量:假别编码、OA 跳转地址。
|
||||
* 用途:请假功能常量:假别编码、OA 跳转地址、假别 i18n key 映射。
|
||||
* 依赖:无;展示文案由 chat.leave.types.* 经 t() 解析。
|
||||
* 逻辑:LEAVE_TYPES 仅保留 value + labelKey;LEAVE_TYPE_MAP 仍为 NLU 关键词匹配(不走 i18n)。
|
||||
* 说明:Agent 门控已迁移至 shared/utils/agent-registry.utils(intent_routes)。
|
||||
*/
|
||||
export const OA_BASE_URL = 'http://192.168.100.221:8888';
|
||||
@@ -10,34 +12,48 @@ export const OA_REQUEST_VIEW_PATH = '/workflow/request/ViewRequest.jsp?requestid
|
||||
export const OA_AUTO_LOGIN_TARGET = 'hxops-oa-leave-request';
|
||||
export const OA_PASSWORD_STORAGE_KEY = 'hxops_oa_login_password';
|
||||
|
||||
/** 下拉假别选项(value 为 OA 编码) */
|
||||
export const LEAVE_TYPES = [
|
||||
{ label: '事假(小时)', value: '005' },
|
||||
{ label: '病假(小时)', value: '006' },
|
||||
{ label: '丧假(天)', value: '007' },
|
||||
{ label: '年假(天)', value: '010' },
|
||||
{ label: '因公出差(小时)', value: '021' },
|
||||
{ label: '调休假(小时)', value: '025' },
|
||||
{ label: '产假(天)', value: '401' },
|
||||
{ label: '陪产假(天)', value: '402' },
|
||||
{ label: '婚假(天)', value: '403' },
|
||||
{ label: '住院病假(小时)', value: '405' },
|
||||
{ label: '工伤假(天)', value: '406' },
|
||||
{ label: '返乡假(小时)', value: 'ZZ01' },
|
||||
{ label: '事假(经理专用小时)', value: 'ZZ04' },
|
||||
{ label: '病假(经理专用小时)', value: 'ZZ05' },
|
||||
{ label: '丧假(经理专用天)', value: 'ZZ07' },
|
||||
{ label: '产假(经理专用天)', value: 'ZZ08' },
|
||||
{ label: '陪产假(经理专用天)', value: 'ZZ09' },
|
||||
{ label: '婚假(经理专用天)', value: 'ZZ10' },
|
||||
{ label: '其他假(小时)', value: '035' },
|
||||
{ label: '育儿假(小时)', value: '408' },
|
||||
/** 假别编码 → i18n key(相对 chat.leave.types) */
|
||||
export const LEAVE_TYPE_LABEL_KEYS: Record<string, string> = {
|
||||
'005': 'chat.leave.types.005',
|
||||
'006': 'chat.leave.types.006',
|
||||
'007': 'chat.leave.types.007',
|
||||
'010': 'chat.leave.types.010',
|
||||
'021': 'chat.leave.types.021',
|
||||
'025': 'chat.leave.types.025',
|
||||
'401': 'chat.leave.types.401',
|
||||
'402': 'chat.leave.types.402',
|
||||
'403': 'chat.leave.types.403',
|
||||
'405': 'chat.leave.types.405',
|
||||
'406': 'chat.leave.types.406',
|
||||
ZZ01: 'chat.leave.types.ZZ01',
|
||||
ZZ04: 'chat.leave.types.ZZ04',
|
||||
ZZ05: 'chat.leave.types.ZZ05',
|
||||
ZZ07: 'chat.leave.types.ZZ07',
|
||||
ZZ08: 'chat.leave.types.ZZ08',
|
||||
ZZ09: 'chat.leave.types.ZZ09',
|
||||
ZZ10: 'chat.leave.types.ZZ10',
|
||||
'035': 'chat.leave.types.035',
|
||||
'408': 'chat.leave.types.408',
|
||||
};
|
||||
|
||||
/** 下拉假别展示顺序(与 OA 编码一致) */
|
||||
const LEAVE_TYPE_ORDER = [
|
||||
'005', '006', '007', '010', '021', '025',
|
||||
'401', '402', '403', '405', '406',
|
||||
'ZZ01', 'ZZ04', 'ZZ05', 'ZZ07', 'ZZ08', 'ZZ09', 'ZZ10',
|
||||
'035', '408',
|
||||
] as const;
|
||||
|
||||
/** 下拉假别选项(value 为 OA 编码;labelKey 供 t() 解析) */
|
||||
export const LEAVE_TYPES: Array<{ labelKey: string; value: string }> = LEAVE_TYPE_ORDER.map((value) => ({
|
||||
labelKey: LEAVE_TYPE_LABEL_KEYS[value] ?? `chat.leave.types.${value}`,
|
||||
value,
|
||||
}));
|
||||
|
||||
/** 按「天」计价的假别编码 */
|
||||
export const LEAVE_TYPE_BY_DAY = new Set(['010', '007', '401', '402', '403', '406', 'ZZ07', 'ZZ08', 'ZZ09', 'ZZ10']);
|
||||
|
||||
/** 自然语言关键词 → OA 假别编码 */
|
||||
/** 自然语言关键词 → OA 假别编码(NLU 匹配,故意保留中文关键词) */
|
||||
export const LEAVE_TYPE_MAP: Record<string, string> = {
|
||||
事假: '005',
|
||||
病假: '006',
|
||||
|
||||
@@ -1,26 +1,48 @@
|
||||
/**
|
||||
* features/chat/constants/shipping.ts
|
||||
* 用途:发货通知功能常量 — 任务编号正则、菜单动作规格与决策动作集合。
|
||||
* 依赖:types/shipping.types(ShippingMenuAction)。
|
||||
* 依赖:types/shipping.types(ShippingMenuAction)、vue-i18n(菜单展示文案)。
|
||||
* 逻辑:shipping/* handler 与 useChatShipping 引用本模块,避免动作 id 硬编码分散。
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
import type { ShippingMenuAction } from '../types/shipping.types';
|
||||
|
||||
/** 工作区发货任务编号格式(如 SN-20250610-ABCDEF12) */
|
||||
export const SHIPPING_TASK_ID_RE = /SN-\d{8}-[A-F0-9]{8}/i;
|
||||
|
||||
/** 菜单动作 id / variant(展示文案经 resolveShippingMenuActionSpec 取 i18n) */
|
||||
export const SHIPPING_MENU_ACTION_SPECS: Record<
|
||||
ShippingMenuAction,
|
||||
{ id: string; label: string; message: string; variant: 'primary' | 'secondary' | 'danger' }
|
||||
{ id: string; variant: 'primary' | 'secondary' | 'danger' }
|
||||
> = {
|
||||
upload: { id: 'upload_inventory_file', label: '选择库存文件', message: '我要上传库存 Excel', variant: 'primary' },
|
||||
paste: { id: 'paste_inventory_json', label: '粘贴库存', message: '我粘贴库存小表', variant: 'secondary' },
|
||||
retry_rpa: { id: 'retry_rpa', label: '重新获取库存', message: '重新获取库存', variant: 'secondary' },
|
||||
confirm: { id: 'confirm', label: '确认', message: '确认', variant: 'primary' },
|
||||
reparse: { id: 'reparse', label: '重新解析', message: '重新解析', variant: 'secondary' },
|
||||
reject: { id: 'reject', label: '驳回', message: '驳回', variant: 'danger' },
|
||||
upload: { id: 'upload_inventory_file', variant: 'primary' },
|
||||
paste: { id: 'paste_inventory_json', variant: 'secondary' },
|
||||
retry_rpa: { id: 'retry_rpa', variant: 'secondary' },
|
||||
confirm: { id: 'confirm', variant: 'primary' },
|
||||
reparse: { id: 'reparse', variant: 'secondary' },
|
||||
reject: { id: 'reject', variant: 'danger' },
|
||||
};
|
||||
|
||||
/**
|
||||
* 解析菜单动作的展示 label / message(四语言)。
|
||||
* 核心逻辑:id/variant 来自静态规格;文案走 chat.shippingNoticeMenu.*。
|
||||
* @param action - 菜单动作键
|
||||
* @param t - 可选翻译函数;缺省用全局 i18n
|
||||
* @returns 含 id/label/message/variant 的完整动作规格
|
||||
*/
|
||||
export function resolveShippingMenuActionSpec(
|
||||
action: ShippingMenuAction,
|
||||
t?: (key: string, ...args: unknown[]) => string,
|
||||
) {
|
||||
const base = SHIPPING_MENU_ACTION_SPECS[action];
|
||||
const translate = t || ((key: string, ...args: unknown[]) => String(i18n.global.t(key, ...(args as []))));
|
||||
return {
|
||||
...base,
|
||||
label: translate(`chat.shippingNoticeMenu.${action}.label`),
|
||||
message: translate(`chat.shippingNoticeMenu.${action}.message`),
|
||||
};
|
||||
}
|
||||
|
||||
export const SHIPPING_DECISION_ACTIONS = new Set([
|
||||
'confirm',
|
||||
'confirm_inventory_mapping',
|
||||
|
||||
@@ -1,14 +1,30 @@
|
||||
/**
|
||||
* 请假:假种标签、时长/是否展示、余额数字格式化。
|
||||
* features/chat/leave/leaveDisplay.ts
|
||||
* 用途:请假假种标签、时长/是否展示、余额数字格式化。
|
||||
* 依赖:leave.ts 常量、leaveDateTime、vue-i18n t()。
|
||||
* 逻辑:由 LeaveMessageBlock / useChatLeave 在展示层调用;假别文案经 labelKey + t() 解析。
|
||||
*/
|
||||
import { LEAVE_TYPES } from '../constants/leave';
|
||||
import { LEAVE_TYPES, LEAVE_TYPE_LABEL_KEYS } from '../constants/leave';
|
||||
import { isLeaveTypeByDay } from './leaveDateTime';
|
||||
|
||||
export function getLeaveTypeLabel(val: string): string {
|
||||
const item = LEAVE_TYPES.find((x) => x.value === val);
|
||||
return item ? item.label : val;
|
||||
/**
|
||||
* 按 OA 假别编码解析本地化标签。
|
||||
* 核心逻辑:优先 LEAVE_TYPE_LABEL_KEYS;找不到则回退编码本身。
|
||||
* @param val - OA 假别编码
|
||||
* @param t - i18n t 函数
|
||||
* @returns 本地化假别名
|
||||
*/
|
||||
export function getLeaveTypeLabel(val: string, t: (key: string) => string): string {
|
||||
const key = LEAVE_TYPE_LABEL_KEYS[val] || LEAVE_TYPES.find((x) => x.value === val)?.labelKey;
|
||||
return key ? t(key) : val;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按时长与假别计价单位格式化展示文案。
|
||||
* @param hours - 小时数
|
||||
* @param leaveType - 假别编码
|
||||
* @param t - i18n t 函数
|
||||
*/
|
||||
export function formatDurationLabel(
|
||||
hours: number,
|
||||
leaveType: string | undefined,
|
||||
@@ -22,12 +38,20 @@ export function formatDurationLabel(
|
||||
return `${hours} ${t('chat.hourUnit')}`;
|
||||
}
|
||||
|
||||
export function formatYesNoLabel(value: 0 | 1 | null): string {
|
||||
if (value === 0) return '是';
|
||||
if (value === 1) return '否';
|
||||
return '未选择';
|
||||
/**
|
||||
* 将 0/1 是否字段格式化为是/否/未选择。
|
||||
* @param value - OA 是否字段
|
||||
* @param t - i18n t 函数
|
||||
*/
|
||||
export function formatYesNoLabel(value: 0 | 1 | null, t: (key: string) => string): string {
|
||||
if (value === 0) return t('chat.yes');
|
||||
if (value === 1) return t('chat.no');
|
||||
return t('chat.notSelected');
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化假期余额数字;空值显示「暂无数据」。
|
||||
*/
|
||||
export function formatLeaveBalanceNumber(value: unknown, t: (key: string) => string): string {
|
||||
if (value === null || value === undefined) return t('chat.noData');
|
||||
const num = Number(value);
|
||||
|
||||
@@ -114,7 +114,7 @@ export function createLeaveFormApi(ctx: LeaveFormContext) {
|
||||
const unit = isByDay ? ctx.t('chat.dayUnit') : ctx.t('chat.hourUnit');
|
||||
const requestedDisplay = isByDay ? Math.round(requestedHours / 8) : requestedHours;
|
||||
const remainingDisplay = isByDay ? Math.round(balance.remaining_hours / 8) : balance.remaining_hours;
|
||||
const label = getLeaveTypeLabel(form.leaveType);
|
||||
const label = getLeaveTypeLabel(form.leaveType, ctx.t);
|
||||
ctx.msg.warning(ctx.t('chat.durationExceedsBalance', {
|
||||
label,
|
||||
requested: `${requestedDisplay}${unit}`,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/chat/page/useChatPageMarkdown.ts
|
||||
* 用途:统一处理聊天页 Markdown 渲染、内嵌文件块提取、消息可见性判断与特殊链接点击。
|
||||
* 依赖:Vue computed、marked、ChatMessageBubble handlers、聊天消息类型。
|
||||
* 依赖:Vue computed、marked、vue-i18n、ChatMessageBubble handlers、聊天消息类型。
|
||||
* 逻辑:由 useChatPage 组装上下文后创建页面级 Markdown API,再分发给 ChatMessageBubble 做消息渲染和交互。
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { marked } from 'marked';
|
||||
import i18n from '@/i18n';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { ChatMessageBubbleHandlers } from '../components/messages/ChatMessageBubble.vue';
|
||||
import type { ChatMessage, InlineDownloadFile, SourceFileLink } from '../types/chat.types';
|
||||
@@ -19,6 +20,42 @@ import {
|
||||
|
||||
marked.setOptions({ gfm: true, breaks: true });
|
||||
|
||||
const tt = (key: string, params?: Record<string, unknown>) => String(i18n.global.t(key, params as any));
|
||||
|
||||
/** 内部规范表头键(兼容服务端中文列名);展示时再映射到 chat.assetColumns.* */
|
||||
const FIXED_ASSET_TABLE_TARGET_HEADERS = [
|
||||
'序号',
|
||||
'资产编号',
|
||||
'资产名称',
|
||||
'保管人',
|
||||
'保管部门',
|
||||
'图片',
|
||||
'账套',
|
||||
'供应商',
|
||||
'资产状态',
|
||||
'数量',
|
||||
'取得时间',
|
||||
] as const;
|
||||
|
||||
const FIXED_ASSET_HEADER_I18N_KEYS: Record<(typeof FIXED_ASSET_TABLE_TARGET_HEADERS)[number], string> = {
|
||||
序号: 'chat.assetColumns.id',
|
||||
资产编号: 'chat.assetColumns.assetId',
|
||||
资产名称: 'chat.assetColumns.assetName',
|
||||
保管人: 'chat.assetColumns.custodianPerson',
|
||||
保管部门: 'chat.assetColumns.custodianDept',
|
||||
图片: 'chat.assetColumns.image',
|
||||
账套: 'chat.assetColumns.accountPeriod',
|
||||
供应商: 'chat.assetColumns.supplier',
|
||||
资产状态: 'chat.assetColumns.assetStatus',
|
||||
数量: 'chat.assetColumns.quantity',
|
||||
取得时间: 'chat.assetColumns.acquisitionDate',
|
||||
};
|
||||
|
||||
function displayFixedAssetHeader(header: string): string {
|
||||
const key = FIXED_ASSET_HEADER_I18N_KEYS[header as keyof typeof FIXED_ASSET_HEADER_I18N_KEYS];
|
||||
return key ? tt(key) : header;
|
||||
}
|
||||
|
||||
const INLINE_FILE_BLOCK_REGEX = /\[FILE_START\]([\s\S]*?)\[FILE_END\]/g;
|
||||
const INLINE_ATTACHMENT_HINT_REGEX = /^.*(?:如果您需要查看全部数据,请下载附件。?|请下载附件。?).*$/gim;
|
||||
|
||||
@@ -188,24 +225,11 @@ function downloadInlineFile(file: InlineDownloadFile): void {
|
||||
|
||||
function normalizeAssetHistoryText(value: string): string {
|
||||
const normalized = String(value || '').trim();
|
||||
if (!normalized || normalized === '-' || normalized === '无') return '';
|
||||
const emptyLabel = tt('chat.assetColumns.empty');
|
||||
if (!normalized || normalized === '-' || normalized === '无' || normalized === emptyLabel) return '';
|
||||
return normalized;
|
||||
}
|
||||
|
||||
const FIXED_ASSET_TABLE_TARGET_HEADERS = [
|
||||
'序号',
|
||||
'资产编号',
|
||||
'资产名称',
|
||||
'保管人',
|
||||
'保管部门',
|
||||
'图片',
|
||||
'账套',
|
||||
'供应商',
|
||||
'资产状态',
|
||||
'数量',
|
||||
'取得时间',
|
||||
];
|
||||
|
||||
const FIXED_ASSET_TABLE_HEADER_ALIASES: Record<string, string[]> = {
|
||||
序号: ['序号', 'id'],
|
||||
资产编号: ['资产编号', 'asset_id', 'asset_no'],
|
||||
@@ -265,10 +289,12 @@ function normalizeFixedAssetPreviewTables(container: HTMLElement): void {
|
||||
if (header === '图片') {
|
||||
const assetIdIndex = headerIndexMap.get('资产编号');
|
||||
const assetId = assetIdIndex !== undefined ? normalizeAssetHistoryText(cells[assetIdIndex]?.textContent || '') : '';
|
||||
return assetId ? '查看' : '无';
|
||||
return assetId ? tt('chat.assetColumns.view') : tt('chat.assetColumns.empty');
|
||||
}
|
||||
const cellIndex = headerIndexMap.get(header);
|
||||
return cellIndex !== undefined ? normalizeAssetHistoryText(cells[cellIndex]?.textContent || '') || '无' : '无';
|
||||
return cellIndex !== undefined
|
||||
? normalizeAssetHistoryText(cells[cellIndex]?.textContent || '') || tt('chat.assetColumns.empty')
|
||||
: tt('chat.assetColumns.empty');
|
||||
};
|
||||
return FIXED_ASSET_TABLE_TARGET_HEADERS.map((header) => pickCellText(header));
|
||||
});
|
||||
@@ -278,32 +304,36 @@ function normalizeFixedAssetPreviewTables(container: HTMLElement): void {
|
||||
if (!thead || !tbody) return;
|
||||
|
||||
thead.innerHTML = `<tr>${FIXED_ASSET_TABLE_TARGET_HEADERS.map((header) => (
|
||||
`<th class="${header === '资产编号' || header === '图片' ? 'chat-fixed-asset-highlight-header' : ''}">${header}</th>`
|
||||
`<th class="${header === '资产编号' || header === '图片' ? 'chat-fixed-asset-highlight-header' : ''}">${displayFixedAssetHeader(header)}</th>`
|
||||
)).join('')}</tr>`;
|
||||
tbody.innerHTML = normalizedRows.map((row) => (
|
||||
`<tr>${row.map((cell) => `<td>${cell || '无'}</td>`).join('')}</tr>`
|
||||
`<tr>${row.map((cell) => `<td>${cell || tt('chat.assetColumns.empty')}</td>`).join('')}</tr>`
|
||||
)).join('');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 把聊天结果表格里的“资产编号”和“图片”列增强为可点击入口。
|
||||
* 核心逻辑:只处理包含“资产编号”表头的表格,并从同行“资产名称”列一并带出检索关键词;资产编号走履历检索,图片走图片预览检索。
|
||||
* 核心逻辑:只处理包含资产编号表头的表格(兼容服务端中文与本地化展示标签),并从同行资产名称列一并带出检索关键词。
|
||||
*/
|
||||
function enhanceAssetHistoryTableLinks(html: string): string {
|
||||
if (!html || typeof document === 'undefined' || !html.includes('<table')) return html;
|
||||
const container = document.createElement('div');
|
||||
container.innerHTML = html;
|
||||
normalizeFixedAssetPreviewTables(container);
|
||||
const assetIdLabel = tt('chat.assetColumns.assetId');
|
||||
const assetNameLabel = tt('chat.assetColumns.assetName');
|
||||
const imageLabel = tt('chat.assetColumns.image');
|
||||
const viewLabel = tt('chat.assetColumns.view');
|
||||
const tables = Array.from(container.querySelectorAll('table'));
|
||||
tables.forEach((table) => {
|
||||
const headerCells = Array.from(table.querySelectorAll('thead th'));
|
||||
if (headerCells.length === 0) return;
|
||||
const headerLabels = headerCells.map((cell) => normalizeAssetHistoryText(cell.textContent || ''));
|
||||
const assetIdIndex = headerLabels.findIndex((label) => label === '资产编号');
|
||||
const assetIdIndex = headerLabels.findIndex((label) => label === '资产编号' || label === assetIdLabel);
|
||||
if (assetIdIndex < 0) return;
|
||||
const assetNameIndex = headerLabels.findIndex((label) => label === '资产名称');
|
||||
const imageIndex = headerLabels.findIndex((label) => label === '图片');
|
||||
const assetNameIndex = headerLabels.findIndex((label) => label === '资产名称' || label === assetNameLabel);
|
||||
const imageIndex = headerLabels.findIndex((label) => label === '图片' || label === imageLabel);
|
||||
const rows = Array.from(table.querySelectorAll('tbody tr'));
|
||||
rows.forEach((row) => {
|
||||
const cells = Array.from(row.querySelectorAll('td'));
|
||||
@@ -322,7 +352,7 @@ function enhanceAssetHistoryTableLinks(html: string): string {
|
||||
if (imageIndex >= 0) {
|
||||
const imageCell = cells[imageIndex];
|
||||
if (!imageCell) return;
|
||||
const imageText = normalizeAssetHistoryText(imageCell.textContent || '') || '查看';
|
||||
const imageText = normalizeAssetHistoryText(imageCell.textContent || '') || viewLabel;
|
||||
const imageLink = document.createElement('a');
|
||||
imageLink.href = `#asset-image?asset_id=${encodeURIComponent(assetId)}&asset_name=${encodeURIComponent(assetName)}`;
|
||||
imageLink.className = 'chat-asset-history-link';
|
||||
@@ -411,7 +441,7 @@ export function createChatPageMarkdownApi(ctx: ChatPageMarkdownContext) {
|
||||
if (fileCheckRunId) {
|
||||
event.preventDefault();
|
||||
void downloadFileCheckExcelByRunId(fileCheckRunId).catch((error: unknown) => {
|
||||
const text = error instanceof Error ? error.message : '下载 Excel 失败';
|
||||
const text = error instanceof Error ? error.message : tt('chat.toolRun.downloadFailed');
|
||||
message.error(text);
|
||||
});
|
||||
return;
|
||||
@@ -436,7 +466,7 @@ export function createChatPageMarkdownApi(ctx: ChatPageMarkdownContext) {
|
||||
const html = typeof rendered === 'string' ? rendered : displayText;
|
||||
return enhanceAssetHistoryTableLinks(html)
|
||||
.replace(/<(td|th)\b([^>]*)>(?:\s| |<br\s*\/?>)*<\/\1>/gi, (_match, tagName: string, attrs: string) => (
|
||||
`<${tagName}${attrs}>无</${tagName}>`
|
||||
`<${tagName}${attrs}>${tt('chat.assetColumns.empty')}</${tagName}>`
|
||||
))
|
||||
.replace(/<table\b[\s\S]*?<\/table>/gi, (tableHtml: string) => (
|
||||
`<div class="chat-table-scroll"><div class="chat-table-inner">${tableHtml}</div></div>`
|
||||
|
||||
@@ -72,7 +72,7 @@ export interface ChatPageSendContext {
|
||||
refreshToolRunProgressAfterSend: () => Promise<void>;
|
||||
prepareToolRunProgressBeforeSend: () => Promise<void>;
|
||||
msg: { warning: (text: string) => void; info: (text: string) => void };
|
||||
t: (key: string) => string;
|
||||
t: (key: string, values?: Record<string, unknown>) => string;
|
||||
copiedIndex: Ref<number | null>;
|
||||
getChatContext?: () => { task_id?: string; batch_no?: string; display_query?: string };
|
||||
onAssistantMessageFinished?: (message: ChatMessage, runMessages: ChatMessage[]) => void | Promise<void>;
|
||||
@@ -123,7 +123,7 @@ export function createChatPageSendApi(ctx: ChatPageSendContext) {
|
||||
if (requestId) suffix = `(rid=${requestId})`;
|
||||
}
|
||||
const message = e instanceof Error ? e.message : 'unknown error';
|
||||
ctx.msg.warning(`附件处理失败:${message}${suffix}`);
|
||||
ctx.msg.warning(ctx.t('chat.attachmentsUi.processFailed', { message, suffix }));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import { computed, nextTick, ref, watch, type Ref } from 'vue';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
import {
|
||||
agentHasProgress,
|
||||
@@ -208,7 +209,7 @@ export function useChatPageToolRun(ctx: ChatPageToolRunContext) {
|
||||
|
||||
...runErrors.value,
|
||||
|
||||
[runId]: e instanceof Error ? e.message : '任务进度查询失败',
|
||||
[runId]: e instanceof Error ? e.message : String(i18n.global.t('chat.toolRun.queryFailed')),
|
||||
|
||||
};
|
||||
|
||||
@@ -272,7 +273,7 @@ export function useChatPageToolRun(ctx: ChatPageToolRunContext) {
|
||||
|
||||
...chatLogErrors.value,
|
||||
|
||||
[chatLogId]: '暂未找到关联的检核任务,请稍后刷新或查看排程执行记录',
|
||||
[chatLogId]: String(i18n.global.t('chat.toolRun.runNotFound')),
|
||||
|
||||
};
|
||||
|
||||
@@ -292,7 +293,7 @@ export function useChatPageToolRun(ctx: ChatPageToolRunContext) {
|
||||
|
||||
...chatLogErrors.value,
|
||||
|
||||
[chatLogId]: e instanceof Error ? e.message : '任务进度查询失败',
|
||||
[chatLogId]: e instanceof Error ? e.message : String(i18n.global.t('chat.toolRun.queryFailed')),
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
/**
|
||||
* 对话页:当前登录用户展示名、工号与登出/管理入口。
|
||||
* features/chat/page/useChatPageUser.ts
|
||||
* 用途:对话页当前登录用户展示名、工号与登出/管理入口。
|
||||
* 依赖:vue-i18n、vue-router、shared/utils/auth。
|
||||
* 逻辑:Chat 页顶栏展示名;无真实姓名时回落 chat.currentUser。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { Router } from 'vue-router';
|
||||
import { getStoredAuthUser, logoutAuth } from '@/shared/utils/auth';
|
||||
|
||||
/**
|
||||
* 组装对话页用户展示与登出/管理跳转。
|
||||
* 核心逻辑:优先 real_name → name/wecom_name → 非纯数字 username → chat.currentUser。
|
||||
* @param router - Vue Router,用于登出与管理后台跳转
|
||||
*/
|
||||
export function useChatPageUser(router: Router) {
|
||||
const { t } = useI18n();
|
||||
const currentUser = ref(getStoredAuthUser());
|
||||
|
||||
const currentUserDisplayName = computed(() => {
|
||||
@@ -16,7 +26,7 @@ export function useChatPageUser(router: Router) {
|
||||
if (aliasName) return aliasName;
|
||||
const username = currentUser.value?.username?.trim();
|
||||
if (username && !/^\d+$/.test(username)) return username;
|
||||
return '当前用户';
|
||||
return t('chat.currentUser');
|
||||
});
|
||||
|
||||
const currentUserEmployeeId = computed(() => {
|
||||
@@ -26,16 +36,25 @@ export function useChatPageUser(router: Router) {
|
||||
return username || '-';
|
||||
});
|
||||
|
||||
/**
|
||||
* 清空本地 currentUser(响应全局登出事件)。
|
||||
*/
|
||||
const onAuthLogout = () => {
|
||||
currentUser.value = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 登出并跳转登录页。
|
||||
*/
|
||||
const handleLogout = () => {
|
||||
logoutAuth();
|
||||
onAuthLogout();
|
||||
router.push('/login');
|
||||
};
|
||||
|
||||
/**
|
||||
* 跳转管理后台。
|
||||
*/
|
||||
const goToAdmin = () => {
|
||||
router.push('/admin');
|
||||
};
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingConversation.ts
|
||||
* 用途:发货聊天会话侧栏同步与带任务编号的菜单消息发送。
|
||||
* 依赖:chat.types、shipping.types、Vue Ref/ComputedRef。
|
||||
* 逻辑:useChatShipping 通过 createShippingConversationHelpers 发送菜单类消息并刷新历史。
|
||||
* 依赖:chat.types、shipping.types、vue-i18n、Vue Ref/ComputedRef。
|
||||
* 逻辑:useChatShipping 通过 createShippingConversationHelpers 发送菜单类消息并刷新历史;
|
||||
* 带 taskId 时用 chat.shippingNoticeTurn.withTaskId 拼接正文。
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
import type { ChatSessionItem } from '../types/chat.types';
|
||||
import type { ChatUploadFileSpec } from '../types/shipping.types';
|
||||
import type { ComputedRef, Ref } from 'vue';
|
||||
@@ -36,11 +38,16 @@ export async function ensureShippingHistorySynced(ctx: ShippingConversationConte
|
||||
|
||||
/**
|
||||
* 创建发货会话辅助函数(菜单消息发送 + 历史同步)。
|
||||
* 核心逻辑:有 taskId 时用 i18n withTaskId 模板拼接;display_query 仍为原始菜单文案。
|
||||
* @param ctx - 发货会话上下文
|
||||
* @returns sendShippingMenuMessage / ensureShippingHistorySynced
|
||||
*/
|
||||
export function createShippingConversationHelpers(ctx: ShippingConversationContext) {
|
||||
const sendShippingMenuMessage = async (message: string) => {
|
||||
const taskId = ctx.getActiveShippingTaskId();
|
||||
const text = taskId ? `${message}\n任务编号:${taskId}` : message;
|
||||
const text = taskId
|
||||
? String(i18n.global.t('chat.shippingNoticeTurn.withTaskId', { text: message, taskId }))
|
||||
: message;
|
||||
await ctx.sendMessage(text, ctx.currentAgentId.value, ctx.selectedKb.value, [], {
|
||||
task_id: taskId || undefined,
|
||||
display_query: message,
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingDecisionFormat.ts
|
||||
* 用途:决策 API 响应格式化为助手 Markdown 消息。
|
||||
* 依赖:无;useChatShippingDecision 在 submit_decision 成功后调用。
|
||||
* 依赖:vue-i18n;useChatShippingDecision 在 submit_decision 成功后调用。
|
||||
* 逻辑:按 decision 类型追加映射提示、下一步指引与任务编号尾注。
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
|
||||
const tt = (key: string, params?: Record<string, unknown>) =>
|
||||
String(params ? i18n.global.t(key, params) : i18n.global.t(key));
|
||||
|
||||
/**
|
||||
* 将 submit_decision 结果格式化为本地 assistant 消息 Markdown。
|
||||
*/
|
||||
@@ -19,9 +24,14 @@ export function formatShippingDecisionAssistantMessage(
|
||||
const headers = Array.isArray(preview.headers) ? (preview.headers as unknown[]).filter(Boolean) : [];
|
||||
const suggested = (preview.suggested_mapping || {}) as Record<string, string>;
|
||||
if (preview.header_row_index) {
|
||||
lines.push('', `表头在第 ${preview.header_row_index} 行:${headers.join(' | ')}`);
|
||||
lines.push('', tt('chat.shippingNoticeDecisionFormat.headerAtRow', {
|
||||
row: preview.header_row_index,
|
||||
headers: headers.join(' | '),
|
||||
}));
|
||||
} else if (headers.length) {
|
||||
lines.push('', `当前表头:${headers.join(' | ')}`);
|
||||
lines.push('', tt('chat.shippingNoticeDecisionFormat.currentHeaders', {
|
||||
headers: headers.join(' | '),
|
||||
}));
|
||||
}
|
||||
const mappingLines = [
|
||||
suggested.sku ? `- sku → ${suggested.sku}` : null,
|
||||
@@ -29,20 +39,20 @@ export function formatShippingDecisionAssistantMessage(
|
||||
suggested.available_qty ? `- available_qty → ${suggested.available_qty}` : null,
|
||||
].filter((line): line is string => Boolean(line));
|
||||
if (mappingLines.length) {
|
||||
lines.push('', '建议列映射:', ...mappingLines);
|
||||
lines.push('', tt('chat.shippingNoticeDecisionFormat.suggestedMapping'), ...mappingLines);
|
||||
}
|
||||
lines.push(
|
||||
'',
|
||||
'如需调整,请说明要改的列(例如:available_qty 改用 Qty Available)。',
|
||||
'也可点击「选择库存文件」重新上传。',
|
||||
tt('chat.shippingNoticeDecisionFormat.adjustHint'),
|
||||
tt('chat.shippingNoticeDecisionFormat.reuploadHint'),
|
||||
);
|
||||
} else if (decision === 'confirm_inventory_mapping') {
|
||||
if (String(result.checkpoint || '').trim() === 'map_ok') {
|
||||
lines.push('', '下一步:匹配库存与发货需求。');
|
||||
lines.push('', tt('chat.shippingNoticeDecisionFormat.nextMatch'));
|
||||
}
|
||||
} else if (decision === 'reparse_inventory') {
|
||||
lines.push('', '请重新上传或粘贴库存 Excel。');
|
||||
lines.push('', tt('chat.shippingNoticeDecisionFormat.reuploadOrPaste'));
|
||||
}
|
||||
lines.push('', `任务编号:${taskId}`);
|
||||
lines.push('', tt('chat.shippingNoticeDecisionFormat.taskIdLine', { taskId }));
|
||||
return lines.join('\n');
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
* 用途:发货聊天用户输入意图识别,供 handleSend 前置拦截。
|
||||
* 依赖:shippingMenu.resolveShippingNumericChoice、types/shipping.types。
|
||||
* 逻辑:useChatShippingSendHandler 调用;覆盖手工上传、库存上传、Excel 生成/下载、列映射与切票。
|
||||
*
|
||||
* [NLU] 本文件中文关键词/正则为匹配中文用户输入的意图 token,刻意保留,不作 UI 展示国际化。
|
||||
*/
|
||||
import { resolveShippingNumericChoice } from './shippingMenu';
|
||||
import type { ShippingMenuAction } from '../types/shipping.types';
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingMapping.ts
|
||||
* 用途:库存列映射消息 payload 读取与字段对齐 Markdown 生成。
|
||||
* 依赖:shippingText.normalizeShippingHeaderForDisplay、chat.types、shipping.types。
|
||||
* 依赖:shippingText.normalizeShippingHeaderForDisplay、chat.types、shipping.types、vue-i18n。
|
||||
* 逻辑:ShippingInventoryMappingMessage 与 useChatShippingMappingForm 读取 mapping 消息数据。
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
import { normalizeShippingHeaderForDisplay } from './shippingText';
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
import type { ShippingInventoryMappingFormPayload } from '../types/shipping.types';
|
||||
|
||||
const tt = (key: string, params?: Record<string, unknown>) =>
|
||||
String(params ? i18n.global.t(key, params) : i18n.global.t(key));
|
||||
|
||||
/**
|
||||
* 从 shipping-inventory-mapping 类型消息中提取 taskId、schema_preview 与 form。
|
||||
*/
|
||||
@@ -41,14 +45,16 @@ export function buildShippingFieldAlignmentText(payload: { data?: { field_alignm
|
||||
const invCols = (alignment as { inventory_columns?: { mapping?: Record<string, { source_column?: string }> } }).inventory_columns || {};
|
||||
const mapping = invCols.mapping || {};
|
||||
const rows: Array<[string, string]> = [
|
||||
['sku', normalizeShippingHeaderForDisplay(mapping?.sku?.source_column) || '(未识别)'],
|
||||
['reservation_id', normalizeShippingHeaderForDisplay(mapping?.reservation_id?.source_column) || '(未识别/可选)'],
|
||||
['available_qty', normalizeShippingHeaderForDisplay(mapping?.available_qty?.source_column) || '(未识别)'],
|
||||
['sku', normalizeShippingHeaderForDisplay(mapping?.sku?.source_column) || tt('chat.shippingNoticeFieldAlignment.unrecognized')],
|
||||
['reservation_id', normalizeShippingHeaderForDisplay(mapping?.reservation_id?.source_column) || tt('chat.shippingNoticeFieldAlignment.unrecognizedOptional')],
|
||||
['available_qty', normalizeShippingHeaderForDisplay(mapping?.available_qty?.source_column) || tt('chat.shippingNoticeFieldAlignment.unrecognized')],
|
||||
];
|
||||
const lines: string[] = [];
|
||||
const matchRule = String((alignment as { match_rule?: string }).match_rule || '').trim();
|
||||
if (matchRule) lines.push(`匹配规则:${matchRule}`);
|
||||
lines.push('', '字段对齐表:', '', '|系统字段|库存列|', '|---|---|');
|
||||
if (matchRule) lines.push(tt('chat.shippingNoticeFieldAlignment.matchRule', { rule: matchRule }));
|
||||
const sys = tt('chat.shippingNoticeFieldAlignment.tableHeaderSystem');
|
||||
const inv = tt('chat.shippingNoticeFieldAlignment.tableHeaderInventory');
|
||||
lines.push('', tt('chat.shippingNoticeFieldAlignment.tableTitle'), '', `|${sys}|${inv}|`, '|---|---|');
|
||||
for (const [k, v] of rows) {
|
||||
lines.push(`|${k}|${v}|`);
|
||||
}
|
||||
@@ -56,7 +62,7 @@ export function buildShippingFieldAlignmentText(payload: { data?: { field_alignm
|
||||
? (alignment as { warnings: unknown[] }).warnings.filter(Boolean)
|
||||
: [];
|
||||
if (warnings.length) {
|
||||
lines.push('', '提示:', ...warnings.map((w) => `- ${String(w)}`));
|
||||
lines.push('', tt('chat.shippingNoticeFieldAlignment.hints'), ...warnings.map((w) => `- ${String(w)}`));
|
||||
}
|
||||
return lines.join('\n').trim();
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
* 用途:发货聊天数字菜单解析、动作按钮合并与决策文本识别(纯函数)。
|
||||
* 依赖:types/shipping.types。
|
||||
* 逻辑:useChatShippingSendHandler 在发送前调用;按钮只来自后端状态机 UI State,不从自然语言正文猜测。
|
||||
*
|
||||
* [NLU] classify / resolve* 中的中文正则与决策词表用于匹配用户/Agent 中文输入,刻意保留;展示文案在 UI 层走 i18n。
|
||||
*/
|
||||
import type { ShippingActionButton, ShippingMenuAction } from '../types/shipping.types';
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingText.ts
|
||||
* 用途:发货聊天消息文本净化(纯函数,无 Vue 依赖)。
|
||||
* 依赖:constants/shippingNoticeActions、types/shipping.types。
|
||||
* 用途:发货聊天消息文本净化(展示替换走 i18n;匹配模式保留中文以对齐 Agent 中文输出)。
|
||||
* 依赖:constants/shippingNoticeActions、types/shipping.types、vue-i18n。
|
||||
* 逻辑:ChatView 渲染前 sanitize;动作按钮统一来自后端 shipping_ui_state。
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
import { SHIPPING_INTERNAL_STATUS_TOKENS } from '@/constants/shippingNoticeActions';
|
||||
import type { ShippingActionButton } from '../types/shipping.types';
|
||||
|
||||
const tt = (key: string) => String(i18n.global.t(key));
|
||||
|
||||
/**
|
||||
* 文本归一化用于判断 Agent 正文编号项是否重复描述了结构化按钮。
|
||||
*/
|
||||
@@ -18,6 +21,7 @@ const normalizeActionComparableText = (value: string) =>
|
||||
const isNumberedActionLine = (line: string) =>
|
||||
/^\s*(?:[-*]\s*)?[1-91-9][\.\、\)::]\s*/.test(line);
|
||||
|
||||
// [NLU] 下列中文正则用于匹配 Agent 中文正文/历史菜单泄漏,非 UI 展示文案,刻意保留。
|
||||
const isActionListContextLine = (line: string) =>
|
||||
/(?:请选择操作|选择操作|操作选项|按钮)/.test(line);
|
||||
|
||||
@@ -36,38 +40,38 @@ const isPlainActionMenuLine = (line: string) =>
|
||||
/**
|
||||
* 规范化运行态提示文案,隐藏“第几次重试/尝试”这类面对业务用户价值较低的过程指标。
|
||||
*
|
||||
* 核心逻辑:仅收敛库存获取相关状态短语,保留“已触发 / 已重新触发 / 进行中”这些对下一步决策有帮助的状态,
|
||||
* 不在前台暴露机械性的第 N 次计数。
|
||||
* 核心逻辑:匹配侧保留中文状态短语(对齐后端/Agent 输出);替换侧走 i18n 展示。
|
||||
*/
|
||||
export function sanitizeShippingRuntimeStatusText(text: string): string {
|
||||
// [NLU] 左侧正则匹配中文运行态原文;右侧为 UI 展示文案。
|
||||
return String(text || '')
|
||||
.replace(
|
||||
/已手动重新触发\s*RPA\s*库存导出\s*[((]\s*(?:手动第\s*\d+\s*次(?:尝试)?|第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?)\s*[))]\s*[。.]?/gi,
|
||||
'已重新触发库存获取。',
|
||||
tt('chat.shippingNoticeSanitize.retriggeredInventory'),
|
||||
)
|
||||
.replace(
|
||||
/已重新触发库存获取\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
|
||||
'已重新触发库存获取。',
|
||||
tt('chat.shippingNoticeSanitize.retriggeredInventory'),
|
||||
)
|
||||
.replace(
|
||||
/已触发库存获取\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
|
||||
'已触发库存获取。',
|
||||
tt('chat.shippingNoticeSanitize.triggeredInventory'),
|
||||
)
|
||||
.replace(
|
||||
/已触发\s*RPA\s*库存导出\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
|
||||
'已触发库存获取。',
|
||||
tt('chat.shippingNoticeSanitize.triggeredInventory'),
|
||||
)
|
||||
.replace(
|
||||
/RPA\s*库存导出进行中\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
|
||||
'库存获取进行中。',
|
||||
tt('chat.shippingNoticeSanitize.inventoryInProgress'),
|
||||
)
|
||||
.replace(
|
||||
/库存获取进行中\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
|
||||
'库存获取进行中。',
|
||||
tt('chat.shippingNoticeSanitize.inventoryInProgress'),
|
||||
)
|
||||
.replace(
|
||||
/手动第\s*\d+\s*次尝试/gi,
|
||||
'手动重试',
|
||||
tt('chat.shippingNoticeSanitize.manualRetry'),
|
||||
)
|
||||
.replace(/\s+([。!?,])/g, '$1')
|
||||
.trim();
|
||||
@@ -244,50 +248,53 @@ export function stripShippingActionListByButtons(
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏 Agent 回复中的内部状态 token,并将 task_id 统一为「任务编号」展示。
|
||||
* 隐藏 Agent 回复中的内部状态 token,并将 task_id 统一为本地化「任务编号」展示。
|
||||
* 核心逻辑:匹配侧保留中文/英文工程词;替换侧走 chat.shippingNoticeSanitize。
|
||||
*/
|
||||
export function sanitizeShippingConversationText(text: string, enabled: boolean): string {
|
||||
if (!enabled) return text;
|
||||
// [NLU] 匹配模式对齐中文 Agent 工程泄漏;替换串为 UI 文案。
|
||||
let result = sanitizeShippingRuntimeStatusText(String(text || ''))
|
||||
.replace(
|
||||
/已回到列映射步骤。?请根据\s*schema_preview\s*提供新的\s*map_json\s*[,,]\s*再调用\s*(?:应用库存字段映射|apply_inventory_mapping)[^。.\n]*[。.]?/gi,
|
||||
'已回到库存字段确认步骤。请检查系统识别的库存列名,确认无误后继续;如有问题请修改映射。',
|
||||
tt('chat.shippingNoticeSanitize.backToAlignConfirm'),
|
||||
)
|
||||
.replace(
|
||||
/请根据\s*schema_preview\s*提供新的\s*map_json\s*[,,]\s*再调用\s*(?:应用库存字段映射|apply_inventory_mapping)[^。.\n]*[。.]?/gi,
|
||||
'请检查系统识别的库存列名,确认无误后继续;如有问题请修改映射。',
|
||||
tt('chat.shippingNoticeSanitize.checkColumnsContinue'),
|
||||
)
|
||||
.replace(
|
||||
/根据\s*data\.schema_preview\.headers\s*与\s*sample_rows\s*推断\s*JSON[^。.\n]*再调用\s*(?:应用库存字段映射|apply_inventory_mapping)[^。.\n]*[。.]?/gi,
|
||||
'请根据库存表头和样例行确认字段对应关系。',
|
||||
tt('chat.shippingNoticeSanitize.confirmHeadersFromSample'),
|
||||
)
|
||||
.replace(/通过\s*(?:Hxops|HXOPS|hxops)\s*聊天区上传/gi, '在当前对话中上传')
|
||||
.replace(/在\s*(?:Hxops|HXOPS|hxops)\s*聊天区上传/gi, '在当前对话中上传')
|
||||
.replace(/(?:Hxops|HXOPS|hxops)\s*聊天区/gi, '当前对话')
|
||||
.replace(/(?:Hxops|HXOPS|hxops)\s*Chat/gi, '当前对话')
|
||||
.replace(/到\s*(?:Hxops|HXOPS|hxops)(\s*[??])?/gi, '到当前对话$1')
|
||||
.replace(/\b(?:Hxops|HXOPS|hxops)\b/g, '当前系统')
|
||||
.replace(/\btask_id\s*[::]/gi, '任务编号:')
|
||||
.replace(/\btask_id\b/gi, '任务编号');
|
||||
.replace(/通过\s*(?:Hxops|HXOPS|hxops)\s*聊天区上传/gi, tt('chat.shippingNoticeSanitize.uploadInCurrentChat'))
|
||||
.replace(/在\s*(?:Hxops|HXOPS|hxops)\s*聊天区上传/gi, tt('chat.shippingNoticeSanitize.uploadInCurrentChat'))
|
||||
.replace(/(?:Hxops|HXOPS|hxops)\s*聊天区/gi, tt('chat.shippingNoticeSanitize.currentChat'))
|
||||
.replace(/(?:Hxops|HXOPS|hxops)\s*Chat/gi, tt('chat.shippingNoticeSanitize.currentChat'))
|
||||
.replace(/到\s*(?:Hxops|HXOPS|hxops)(\s*[??])?/gi, (_m, q) => `${tt('chat.shippingNoticeSanitize.toCurrentChatPrefix')}${q || ''}`)
|
||||
.replace(/\b(?:Hxops|HXOPS|hxops)\b/g, tt('chat.shippingNoticeSanitize.currentSystem'))
|
||||
.replace(/\btask_id\s*[::]/gi, tt('chat.shippingNoticeSanitize.taskIdLabel'))
|
||||
.replace(/\btask_id\b/gi, tt('chat.shippingNoticeSanitize.taskIdWord'));
|
||||
result = result
|
||||
.replace(/\bcreate_task\b/gi, '新建任务')
|
||||
.replace(/\bget_task_status\b/gi, '查询任务状态')
|
||||
.replace(/\bparse_notice\b/gi, '解析发货通知')
|
||||
.replace(/\bsubmit_decision\b/gi, '提交处理结果')
|
||||
.replace(/\bmatch_inventory\b/gi, '匹配库存')
|
||||
.replace(/\bgenerate_excel\b/gi, '生成发货 Excel')
|
||||
.replace(/\bgenerate_shipment_excel\b/gi, '生成发货 Excel')
|
||||
.replace(/\bupload_to_freight\b/gi, '上传货代系统')
|
||||
.replace(/\bapply_inventory_mapping\b/gi, '应用库存字段映射')
|
||||
.replace(/\bget_inventory_schema_preview\b/gi, '读取库存表头预览')
|
||||
.replace(/\bschema_preview(?:\.headers)?\b/gi, '库存表头预览')
|
||||
.replace(/\bdata\.库存表头预览\b/gi, '库存表头预览')
|
||||
.replace(/\bmap_json\b/gi, '字段映射')
|
||||
.replace(/\bsample_rows\b/gi, '样例行')
|
||||
.replace(/\bretry_rpa\b/gi, '重新获取库存')
|
||||
.replace(/\bretry_upload\b/gi, '重试上传货代')
|
||||
.replace(/\bstructured\b/gi, '结构化内容')
|
||||
.replace(/\braw_text\b/gi, '通知原文');
|
||||
.replace(/\bcreate_task\b/gi, tt('chat.shippingNoticeSanitize.createTask'))
|
||||
.replace(/\bget_task_status\b/gi, tt('chat.shippingNoticeSanitize.getTaskStatus'))
|
||||
.replace(/\bparse_notice\b/gi, tt('chat.shippingNoticeSanitize.parseNotice'))
|
||||
.replace(/\bsubmit_decision\b/gi, tt('chat.shippingNoticeSanitize.submitDecision'))
|
||||
.replace(/\bmatch_inventory\b/gi, tt('chat.shippingNoticeSanitize.matchInventory'))
|
||||
.replace(/\bgenerate_excel\b/gi, tt('chat.shippingNoticeSanitize.generateExcel'))
|
||||
.replace(/\bgenerate_shipment_excel\b/gi, tt('chat.shippingNoticeSanitize.generateExcel'))
|
||||
.replace(/\bupload_to_freight\b/gi, tt('chat.shippingNoticeSanitize.uploadFreight'))
|
||||
.replace(/\bapply_inventory_mapping\b/gi, tt('chat.shippingNoticeSanitize.applyInventoryMapping'))
|
||||
.replace(/\bget_inventory_schema_preview\b/gi, tt('chat.shippingNoticeSanitize.getSchemaPreview'))
|
||||
.replace(/\bschema_preview(?:\.headers)?\b/gi, tt('chat.shippingNoticeSanitize.schemaPreview'))
|
||||
// [NLU] Agent 偶发把已汉化的 schema_preview 再包一层 data.前缀
|
||||
.replace(/\bdata\.库存表头预览\b/gi, tt('chat.shippingNoticeSanitize.schemaPreview'))
|
||||
.replace(/\bmap_json\b/gi, tt('chat.shippingNoticeSanitize.mapJson'))
|
||||
.replace(/\bsample_rows\b/gi, tt('chat.shippingNoticeSanitize.sampleRows'))
|
||||
.replace(/\bretry_rpa\b/gi, tt('chat.shippingNoticeSanitize.retryRpa'))
|
||||
.replace(/\bretry_upload\b/gi, tt('chat.shippingNoticeSanitize.retryUpload'))
|
||||
.replace(/\bstructured\b/gi, tt('chat.shippingNoticeSanitize.structured'))
|
||||
.replace(/\braw_text\b/gi, tt('chat.shippingNoticeSanitize.rawText'));
|
||||
result = result.replace(/[((]\s*显示\s*[「"'`][^"'`]+[」"'`]\s*[))]/g, '');
|
||||
result = result.replace(
|
||||
/\b(process_status|pending_human_reason|review_status|checkpoint|match_status|human_options)\s*[::=]\s*[「"'`]?[\w.-]+[「"'`]?/gi,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingTurnActions.ts
|
||||
* 用途:将发货通知菜单/决策 action.id 映射为 Chat Turn action_type + payload。
|
||||
* 依赖:constants/shipping。
|
||||
* 依赖:constants/shipping、vue-i18n(displayText)。
|
||||
* 逻辑:useChatShippingDecision 与 useChatShippingMenuHandler 调用本模块,不再直调 workspace API 插消息。
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
import { SHIPPING_DECISION_ACTIONS } from '../constants/shipping';
|
||||
|
||||
export interface ShippingChatTurnSpec {
|
||||
@@ -11,6 +12,9 @@ export interface ShippingChatTurnSpec {
|
||||
payload: Record<string, unknown>;
|
||||
}
|
||||
|
||||
const tt = (key: string, params?: Record<string, unknown>) =>
|
||||
String(params ? i18n.global.t(key, params) : i18n.global.t(key));
|
||||
|
||||
/**
|
||||
* 将发货 UI 动作 id 解析为平台 Chat Turn 规格。
|
||||
* @param actionId - 状态机 action_buttons.id
|
||||
@@ -72,6 +76,7 @@ export function buildShippingSubmitDecisionTurn(
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造发货通知建批 Chat Turn(multipart 上传)。
|
||||
*/
|
||||
@@ -82,8 +87,10 @@ export function buildShippingCreateBatchTurn(
|
||||
): { actionType: string; displayText: string; payload: Record<string, unknown>; files: File[] } {
|
||||
const count = files.length;
|
||||
const displayText = count === 1
|
||||
? `上传发货通知:${files[0]?.name || '附件'}`
|
||||
: `上传 ${count} 份发货通知`;
|
||||
? tt('chat.shippingNoticeTurn.createBatchSingle', {
|
||||
fileName: files[0]?.name || tt('chat.shippingNoticeTurn.attachmentFallback'),
|
||||
})
|
||||
: tt('chat.shippingNoticeTurn.createBatchMulti', { count });
|
||||
return {
|
||||
actionType: 'shipping.create_batch_from_notices',
|
||||
displayText,
|
||||
@@ -106,8 +113,8 @@ export function buildShippingCreateBatchFromIntakesTurn(
|
||||
): { actionType: string; displayText: string; payload: Record<string, unknown> } {
|
||||
const count = intakeNos.length;
|
||||
const displayText = count === 1
|
||||
? `确认建单:${intakeNos[0]}`
|
||||
: `确认建单:${count} 份发货通知`;
|
||||
? tt('chat.shippingNoticeTurn.confirmBatchSingle', { intakeNo: intakeNos[0] })
|
||||
: tt('chat.shippingNoticeTurn.confirmBatchMulti', { count });
|
||||
return {
|
||||
actionType: 'shipping.create_batch_from_intakes',
|
||||
displayText,
|
||||
@@ -131,33 +138,42 @@ export function buildShippingTurnRefs(taskNo: string, batchNo?: string): Record<
|
||||
return refs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造库存上传 Chat Turn。
|
||||
*/
|
||||
export function buildShippingUploadInventoryTurn(taskNo: string, file: File) {
|
||||
const task = String(taskNo || '').trim().toUpperCase();
|
||||
return {
|
||||
actionType: 'shipping.upload_inventory',
|
||||
displayText: `上传库存文件:${file.name}`,
|
||||
displayText: tt('chat.shippingNoticeTurn.uploadInventory', { fileName: file.name }),
|
||||
payload: { task_no: task },
|
||||
files: [file],
|
||||
refs: buildShippingTurnRefs(task),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造重新上传发货通知 Chat Turn。
|
||||
*/
|
||||
export function buildShippingReplaceNoticeTurn(taskNo: string, file: File) {
|
||||
const task = String(taskNo || '').trim().toUpperCase();
|
||||
return {
|
||||
actionType: 'shipping.replace_notice',
|
||||
displayText: `重新上传发货通知:${file.name}`,
|
||||
displayText: tt('chat.shippingNoticeTurn.replaceNotice', { fileName: file.name }),
|
||||
payload: { task_no: task },
|
||||
files: [file],
|
||||
refs: buildShippingTurnRefs(task),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造应用库存列映射 Chat Turn。
|
||||
*/
|
||||
export function buildShippingApplyMappingTurn(taskNo: string, mapping: Record<string, string>) {
|
||||
const task = String(taskNo || '').trim().toUpperCase();
|
||||
return {
|
||||
actionType: 'shipping.apply_inventory_mapping',
|
||||
displayText: `应用库存列映射(任务 ${task})`,
|
||||
displayText: tt('chat.shippingNoticeTurn.applyMapping', { taskId: task }),
|
||||
payload: { task_no: task, map_json: mapping },
|
||||
refs: buildShippingTurnRefs(task),
|
||||
};
|
||||
|
||||
@@ -37,7 +37,12 @@ const createContext = (
|
||||
warning: vi.fn(),
|
||||
success: vi.fn(),
|
||||
},
|
||||
t: (key: string) => key,
|
||||
t: (key: string, params?: Record<string, unknown>) => {
|
||||
if (key === 'chat.shippingNoticeTurn.withTaskId' && params) {
|
||||
return `${params.text}\n任务编号:${params.taskId}`;
|
||||
}
|
||||
return key;
|
||||
},
|
||||
...overrides,
|
||||
});
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
const ok = await ctx.startChatTurn({
|
||||
agentId: ctx.currentAgentId.value,
|
||||
inputType: 'action',
|
||||
displayText: options?.silent ? userText : `${userText}\n任务编号:${taskId}`,
|
||||
displayText: options?.silent ? userText : ctx.t('chat.shippingNoticeTurn.withTaskId', { text: userText, taskId }),
|
||||
actionType: turnSpec.actionType,
|
||||
payload: turnSpec.payload,
|
||||
refs: buildShippingTurnRefs(taskId, ctx.getActiveShippingBatchNo()),
|
||||
@@ -121,7 +121,7 @@ export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
const normalizedTaskId = String(taskId || '').trim().toUpperCase();
|
||||
if (!normalizedTaskId || manualUploadInFlightTaskIds.has(normalizedTaskId)) return false;
|
||||
manualUploadInFlightTaskIds.add(normalizedTaskId);
|
||||
const userText = (displayText || '我已在货代系统完成上传').trim();
|
||||
const userText = (displayText || ctx.t('chat.shippingNoticeToast.manualUploadedDefault')).trim();
|
||||
try {
|
||||
const ok = await ctx.startChatTurn({
|
||||
agentId: ctx.currentAgentId.value,
|
||||
@@ -145,7 +145,7 @@ export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
});
|
||||
return ok;
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '标记手工上传失败';
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.markManualUploadFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
return false;
|
||||
} finally {
|
||||
|
||||
@@ -26,6 +26,7 @@ export interface ShippingMappingFormContext {
|
||||
currentAgentId: import('vue').ComputedRef<number>;
|
||||
refreshShippingActions: () => Promise<void>;
|
||||
msg: { warning: (text: string) => void };
|
||||
t: (key: string, params?: Record<string, unknown>) => string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +73,7 @@ export function createShippingMappingFormHandlers(ctx: ShippingMappingFormContex
|
||||
}
|
||||
const schemaPreview = ctx.shippingInventorySchemaPreviewCache.value[id];
|
||||
if (!schemaPreview || typeof schemaPreview !== 'object') {
|
||||
ctx.msg.warning('未找到表头预览,请重新上传库存文件后再点击“修改映射”');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.schemaPreviewMissing'));
|
||||
return false;
|
||||
}
|
||||
const detail = await getWorkspaceShippingTask(id).catch(() => null);
|
||||
@@ -87,8 +88,8 @@ export function createShippingMappingFormHandlers(ctx: ShippingMappingFormContex
|
||||
role: 'assistant',
|
||||
type: 'shipping-inventory-mapping',
|
||||
content: [
|
||||
'请用下拉框选择库存列映射(必须从表头中选择)。',
|
||||
`任务编号:${id}`,
|
||||
ctx.t('chat.shippingNoticeToast.mappingFormIntro'),
|
||||
ctx.t('chat.shippingNoticeDecisionFormat.taskIdLine', { taskId: id }),
|
||||
].filter(Boolean).join('\n'),
|
||||
payload: {
|
||||
taskId: id,
|
||||
@@ -116,7 +117,7 @@ export function createShippingMappingFormHandlers(ctx: ShippingMappingFormContex
|
||||
if (payload.applying) return;
|
||||
const taskId = String(payload.taskId || '').trim();
|
||||
if (!taskId) {
|
||||
ctx.msg.warning('未找到任务编号');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeMissingTaskId'));
|
||||
return;
|
||||
}
|
||||
const mapping: Record<string, string> = {
|
||||
@@ -125,7 +126,7 @@ export function createShippingMappingFormHandlers(ctx: ShippingMappingFormContex
|
||||
reservation_id: String(payload.form?.reservation_id || '').trim(),
|
||||
};
|
||||
if (!mapping.sku || !mapping.available_qty) {
|
||||
ctx.msg.warning('请先选择 SKU 列 与 可用数量列');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.selectSkuAndQty'));
|
||||
return;
|
||||
}
|
||||
if (!mapping.reservation_id) {
|
||||
@@ -148,9 +149,9 @@ export function createShippingMappingFormHandlers(ctx: ShippingMappingFormContex
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!ok) ctx.msg.warning('应用映射失败');
|
||||
if (!ok) ctx.msg.warning(ctx.t('chat.shippingNoticeToast.applyMappingFailed'));
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '应用映射失败';
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.applyMappingFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
} finally {
|
||||
payload.applying = false;
|
||||
|
||||
@@ -95,7 +95,7 @@ export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
const actionId = String(action.id || '').trim();
|
||||
const turnSpec = resolveShippingChatTurn(actionId, taskId, extra);
|
||||
if (!turnSpec) return false;
|
||||
const displayBase = String(action.message || actionId || '操作').trim();
|
||||
const displayBase = String(action.message || actionId || ctx.t('chat.shippingNoticeToast.actionFallback')).trim();
|
||||
const displayText = actionId === 'confirm_inventory_source'
|
||||
? ctx.t('chat.shippingNoticeUi.inventorySource.confirmWithTask', { taskId })
|
||||
: ctx.t('chat.shippingNoticeUi.inventorySource.actionWithTask', { message: displayBase, taskId });
|
||||
@@ -138,7 +138,7 @@ export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
try {
|
||||
await downloadWorkspaceShippingExcelFile(taskId);
|
||||
} catch (e: unknown) {
|
||||
ctx.msg.warning(e instanceof Error ? e.message : '下载 Excel 失败');
|
||||
ctx.msg.warning(e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.downloadExcelFailed'));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
}
|
||||
}
|
||||
if (action.id === 'mark_manual_uploaded') {
|
||||
await ctx.executeShippingManualUpload(taskId, '我已在货代系统完成上传');
|
||||
await ctx.executeShippingManualUpload(taskId, ctx.t('chat.shippingNoticeToast.manualUploadedDefault'));
|
||||
return;
|
||||
}
|
||||
const label = String(('label' in action ? action.label : '') || sourceCode).trim();
|
||||
@@ -187,7 +187,7 @@ export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
sourceCode ? { sourceCode } : undefined,
|
||||
);
|
||||
} catch (e: unknown) {
|
||||
ctx.msg.warning(e instanceof Error ? e.message : '操作失败');
|
||||
ctx.msg.warning(e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.operationFailed'));
|
||||
if (chatMsg) chatMsg.shipping_actions_used = false;
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -23,6 +23,7 @@ export interface ShippingParseReviewContext {
|
||||
saveLocalMessageToBackend: (msg: ChatMessage, userQuery?: string) => Promise<void>;
|
||||
refreshShippingActions: () => Promise<void>;
|
||||
msg: { warning: (text: string) => void };
|
||||
t: (key: string, params?: Record<string, unknown>) => string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,12 +64,12 @@ export function createShippingParseReviewHandlers(ctx: ShippingParseReviewContex
|
||||
payload.saving = true;
|
||||
const taskId = String(payload.taskId || '').trim().toUpperCase();
|
||||
try {
|
||||
await updateWorkspaceShippingNoticeFields(taskId, fields, '聊天区订单表修订');
|
||||
await updateWorkspaceShippingNoticeFields(taskId, fields, ctx.t('chat.shippingNoticeToast.auditCommentHeaderEdit'));
|
||||
await syncShippingParseReviewCard(taskId);
|
||||
await ctx.refreshShippingActions();
|
||||
return true;
|
||||
} catch (e: unknown) {
|
||||
ctx.msg.warning(e instanceof Error ? e.message : '更新解析结果失败');
|
||||
ctx.msg.warning(e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.updateParseFailed'));
|
||||
return false;
|
||||
} finally {
|
||||
const current = getShippingParseReviewPayload(msgObj);
|
||||
@@ -86,12 +87,12 @@ export function createShippingParseReviewHandlers(ctx: ShippingParseReviewContex
|
||||
payload.saving = true;
|
||||
const taskId = String(payload.taskId || '').trim().toUpperCase();
|
||||
try {
|
||||
await updateWorkspaceShippingNoticeLine(taskId, lineIndex, patch, '聊天区订单表修订');
|
||||
await updateWorkspaceShippingNoticeLine(taskId, lineIndex, patch, ctx.t('chat.shippingNoticeToast.auditCommentHeaderEdit'));
|
||||
await syncShippingParseReviewCard(taskId);
|
||||
await ctx.refreshShippingActions();
|
||||
return true;
|
||||
} catch (e: unknown) {
|
||||
ctx.msg.warning(e instanceof Error ? e.message : '更新解析结果失败');
|
||||
ctx.msg.warning(e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.updateParseFailed'));
|
||||
return false;
|
||||
} finally {
|
||||
const current = getShippingParseReviewPayload(msgObj);
|
||||
@@ -108,12 +109,12 @@ export function createShippingParseReviewHandlers(ctx: ShippingParseReviewContex
|
||||
payload.saving = true;
|
||||
const taskId = String(payload.taskId || '').trim().toUpperCase();
|
||||
try {
|
||||
await addWorkspaceShippingNoticeLine(taskId, line, '聊天区订单表新增行');
|
||||
await addWorkspaceShippingNoticeLine(taskId, line, ctx.t('chat.shippingNoticeToast.auditCommentLineAdd'));
|
||||
await syncShippingParseReviewCard(taskId);
|
||||
await ctx.refreshShippingActions();
|
||||
return true;
|
||||
} catch (e: unknown) {
|
||||
ctx.msg.warning(e instanceof Error ? e.message : '新增订单行失败');
|
||||
ctx.msg.warning(e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.addLineFailed'));
|
||||
return false;
|
||||
} finally {
|
||||
const current = getShippingParseReviewPayload(msgObj);
|
||||
@@ -130,12 +131,12 @@ export function createShippingParseReviewHandlers(ctx: ShippingParseReviewContex
|
||||
payload.saving = true;
|
||||
const taskId = String(payload.taskId || '').trim().toUpperCase();
|
||||
try {
|
||||
await removeWorkspaceShippingNoticeLine(taskId, lineIndex, '聊天区订单表删除行');
|
||||
await removeWorkspaceShippingNoticeLine(taskId, lineIndex, ctx.t('chat.shippingNoticeToast.auditCommentLineDelete'));
|
||||
await syncShippingParseReviewCard(taskId);
|
||||
await ctx.refreshShippingActions();
|
||||
return true;
|
||||
} catch (e: unknown) {
|
||||
ctx.msg.warning(e instanceof Error ? e.message : '删除订单行失败');
|
||||
ctx.msg.warning(e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.deleteLineFailed'));
|
||||
return false;
|
||||
} finally {
|
||||
const current = getShippingParseReviewPayload(msgObj);
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
getWorkspaceShippingBatch,
|
||||
getWorkspaceShippingTask,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { SHIPPING_DECISION_ACTIONS, SHIPPING_MENU_ACTION_SPECS } from '../constants/shipping';
|
||||
import { SHIPPING_DECISION_ACTIONS, resolveShippingMenuActionSpec } from '../constants/shipping';
|
||||
import { buildShippingApplyMappingTurn, buildShippingSwitchFocusTurn } from './shippingTurnActions';
|
||||
import { downloadWorkspaceShippingExcelFile } from './shippingDownload';
|
||||
import {
|
||||
@@ -137,14 +137,14 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
if (!intent) return false;
|
||||
const batchNo = ctx.getActiveShippingBatchNo();
|
||||
if (!batchNo) {
|
||||
ctx.msg.warning('当前没有可切换的批次');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.noBatchToSwitch'));
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const detail = await getWorkspaceShippingBatch(batchNo);
|
||||
const tasks = Array.isArray(detail.tasks) ? detail.tasks : [];
|
||||
if (tasks.length <= 1) {
|
||||
ctx.msg.info('当前批次只有 1 票,无需切换');
|
||||
ctx.msg.info(ctx.t('chat.shippingNoticeToast.batchOnlyOneTask'));
|
||||
return true;
|
||||
}
|
||||
const focusTaskNo = String(detail.focus_task?.task_no || detail.current_focus_task_no || '').trim().toUpperCase();
|
||||
@@ -158,11 +158,17 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
targetTaskNo = String(tasks[Math.max(currentIndex - 1, 0)]?.task_no || '').trim().toUpperCase();
|
||||
}
|
||||
if (!targetTaskNo) {
|
||||
ctx.msg.warning('未找到要切换的任务');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.taskNotFoundToSwitch'));
|
||||
return true;
|
||||
}
|
||||
if (targetTaskNo === focusTaskNo) {
|
||||
ctx.msg.info(intent.mode === 'next' ? '已经是最后一票' : intent.mode === 'prev' ? '已经是第一票' : '已在当前任务');
|
||||
ctx.msg.info(
|
||||
intent.mode === 'next'
|
||||
? ctx.t('chat.shippingNoticeToast.alreadyLastTask')
|
||||
: intent.mode === 'prev'
|
||||
? ctx.t('chat.shippingNoticeToast.alreadyFirstTask')
|
||||
: ctx.t('chat.shippingNoticeToast.alreadyOnCurrentTask'),
|
||||
);
|
||||
return true;
|
||||
}
|
||||
ctx.resolvedShippingTaskId.value = targetTaskNo;
|
||||
@@ -181,7 +187,7 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
},
|
||||
});
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '切换任务失败';
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.switchTaskFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
}
|
||||
return true;
|
||||
@@ -215,7 +221,7 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
try {
|
||||
await ctx.handleShippingAutoUploadNoticeBatch([]);
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '文件处理失败';
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.fileProcessFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
}
|
||||
return true;
|
||||
@@ -233,7 +239,7 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
const localFiles = ctx.attachments.value.filter((a) => a.kind === 'local') as Array<Extract<PendingAttachment, { kind: 'local' }>>;
|
||||
const first = localFiles[0];
|
||||
if (!first) {
|
||||
ctx.msg.warning('当前仅支持本地附件触发自动流程');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.localAttachmentOnly'));
|
||||
return true;
|
||||
}
|
||||
const kind = classifyShippingUploadFile(first.file, extractExt);
|
||||
@@ -241,12 +247,12 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
ctx.attachments.value = [];
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
if (localFiles.length > 1) {
|
||||
ctx.msg.warning('一次仅支持处理一个文件,将自动处理第一个');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.oneFileOnlyAutoFirst'));
|
||||
}
|
||||
try {
|
||||
await ctx.handleShippingAutoUploadFile(first.file);
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '文件处理失败';
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.fileProcessFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
}
|
||||
return true;
|
||||
@@ -257,7 +263,7 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
try {
|
||||
await ctx.handleShippingAutoUploadNoticeBatch(localFiles.map((item) => item.file));
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '文件处理失败';
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.fileProcessFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
}
|
||||
return true;
|
||||
@@ -310,11 +316,11 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
ctx.msg.info(ctx.t('chat.shippingNoticePasteHint'));
|
||||
return true;
|
||||
} else if (SHIPPING_DECISION_ACTIONS.has(menuChoice)) {
|
||||
const spec = SHIPPING_MENU_ACTION_SPECS[menuChoice];
|
||||
await ctx.executeShippingDecision(menuChoice, spec?.label || spec?.message || menuChoice);
|
||||
const spec = resolveShippingMenuActionSpec(menuChoice, ctx.t);
|
||||
await ctx.executeShippingDecision(menuChoice, spec.label || spec.message || menuChoice);
|
||||
return true;
|
||||
} else {
|
||||
await ctx.sendShippingMenuMessage(SHIPPING_MENU_ACTION_SPECS[menuChoice].message);
|
||||
await ctx.sendShippingMenuMessage(resolveShippingMenuActionSpec(menuChoice, ctx.t).message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -323,12 +329,13 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
if (await ctx.executeShippingDecision(shippingDecision, content.trim())) return true;
|
||||
}
|
||||
// [NLU] 助手上下文含中文「列映射/字段对齐」时进入映射文本解析
|
||||
if (assistantCtx.includes('schema_preview') || assistantCtx.includes('列映射') || assistantCtx.includes('字段对齐')) {
|
||||
const mapping = parseShippingColumnMappingFromText(content);
|
||||
if (mapping) {
|
||||
const taskId = ctx.getActiveShippingTaskId();
|
||||
if (!taskId) {
|
||||
ctx.msg.warning('未找到任务编号,请先上传库存文件');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.missingTaskIdUploadInventory'));
|
||||
return true;
|
||||
}
|
||||
ctx.resolvedShippingTaskId.value = taskId;
|
||||
@@ -338,7 +345,7 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
await ctx.startChatTurn({
|
||||
agentId: ctx.currentAgentId.value,
|
||||
inputType: 'form_submit',
|
||||
displayText: `${content.trim()}\n任务编号:${taskId}`,
|
||||
displayText: ctx.t('chat.shippingNoticeTurn.withTaskId', { text: content.trim(), taskId }),
|
||||
actionType: turn.actionType,
|
||||
payload: turn.payload,
|
||||
refs: turn.refs,
|
||||
@@ -354,7 +361,7 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
if (isShippingManualUploadIntent(content)) {
|
||||
const taskId = ctx.getActiveShippingTaskId();
|
||||
if (!taskId) {
|
||||
ctx.msg.warning('未找到任务编号,请先完成前面的步骤');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.missingTaskIdPreviousSteps'));
|
||||
return true;
|
||||
}
|
||||
ctx.resolvedShippingTaskId.value = taskId;
|
||||
@@ -370,7 +377,7 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
if (isShippingGenerateExcelIntent(content)) {
|
||||
const taskId = ctx.getActiveShippingTaskId();
|
||||
if (!taskId) {
|
||||
ctx.msg.warning('未找到任务编号,请先完成解析与库存匹配');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.missingTaskIdParseMatch'));
|
||||
return true;
|
||||
}
|
||||
ctx.resolvedShippingTaskId.value = taskId;
|
||||
@@ -382,7 +389,7 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
if (isShippingDownloadExcelIntent(content)) {
|
||||
const taskId = ctx.getActiveShippingTaskId();
|
||||
if (!taskId) {
|
||||
ctx.msg.warning('未找到任务编号,请先完成解析与库存匹配');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.missingTaskIdParseMatch'));
|
||||
return true;
|
||||
}
|
||||
ctx.resolvedShippingTaskId.value = taskId;
|
||||
@@ -391,7 +398,7 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
try {
|
||||
await downloadWorkspaceShippingExcelFile(taskId);
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '下载 Excel 失败';
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingNoticeToast.downloadExcelFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -382,7 +382,7 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
syncBatchContextFromNoticeResponse(created as unknown as Record<string, unknown>);
|
||||
taskId = String(created.task_id || '').trim();
|
||||
if (!taskId) {
|
||||
ctx.msg.warning('自动创建发货任务失败');
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.autoCreateTaskFailed'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/**
|
||||
* features/chat/training/trainingChatQuestions.ts
|
||||
* 用途:统一维护员工培训 Agent 的员工版 / HR 版聊天常见问题默认值与解析逻辑。
|
||||
* 依赖:被 Admin 后台培训配置表单与 Chat 欢迎区共同引用,避免默认问题与字段名出现多份散落副本。
|
||||
* 逻辑:优先读取 extra_config.training_config 中的角色化问题列表;未配置时回退到内置示例,显式保存空数组时尊重为空。
|
||||
* 依赖:vue-i18n(默认问题从 chat.training.defaultQuestions.* 读取)、Admin 培训配置表单与 Chat 欢迎区。
|
||||
* 逻辑:优先读取 extra_config.training_config 中的角色化问题列表;未配置时回退到 i18n 内置示例,显式保存空数组时尊重为空。
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
|
||||
export type TrainingChatQuestionRole = 'employee' | 'hr';
|
||||
|
||||
@@ -12,19 +13,25 @@ const TRAINING_ROLE_QUESTION_KEYS: Record<TrainingChatQuestionRole, string[]> =
|
||||
hr: ['hr_chat_suggested_questions', 'admin_chat_suggested_questions'],
|
||||
};
|
||||
|
||||
export const DEFAULT_TRAINING_EMPLOYEE_CHAT_QUESTIONS = [
|
||||
'这次员工培训主要学习什么内容?',
|
||||
'完成培训需要经过哪些步骤?',
|
||||
'员工培训的通过规则是什么?',
|
||||
'开始考试前需要注意什么?',
|
||||
];
|
||||
/**
|
||||
* 读取当前语言下的培训默认常见问题列表。
|
||||
* 核心逻辑:从 chat.training.defaultQuestions.{role} 取数组;非数组时回退空列表。
|
||||
* @param role - employee | hr
|
||||
*/
|
||||
const resolveLocalizedDefaultQuestions = (role: TrainingChatQuestionRole): string[] => {
|
||||
// tm 在严格 locale 类型下可能推断为 never;运行时仍为 string[]
|
||||
const raw = i18n.global.tm(`chat.training.defaultQuestions.${role}`) as unknown;
|
||||
if (Array.isArray(raw)) {
|
||||
return raw.map((item: unknown) => String(item || '').trim()).filter(Boolean);
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
export const DEFAULT_TRAINING_HR_CHAT_QUESTIONS = [
|
||||
'现在有多少人参加了培训?',
|
||||
'当前培训通过率是多少?',
|
||||
'哪些员工还没有完成培训?',
|
||||
'我想查看本月培训成绩统计',
|
||||
];
|
||||
/** @deprecated 兼容 Admin 表单旧引用:返回当前语言默认员工问题 */
|
||||
export const DEFAULT_TRAINING_EMPLOYEE_CHAT_QUESTIONS = resolveLocalizedDefaultQuestions('employee');
|
||||
|
||||
/** @deprecated 兼容 Admin 表单旧引用:返回当前语言默认 HR 问题(模块加载时快照) */
|
||||
export const DEFAULT_TRAINING_HR_CHAT_QUESTIONS = resolveLocalizedDefaultQuestions('hr');
|
||||
|
||||
const asRecord = (value: unknown): Record<string, unknown> => (
|
||||
value && typeof value === 'object' && !Array.isArray(value)
|
||||
@@ -49,10 +56,12 @@ const normalizeTrainingChatQuestionList = (value: unknown): string[] => {
|
||||
.filter(Boolean);
|
||||
};
|
||||
|
||||
const getDefaultQuestions = (role: TrainingChatQuestionRole) => (
|
||||
role === 'hr'
|
||||
? cloneQuestions(DEFAULT_TRAINING_HR_CHAT_QUESTIONS)
|
||||
: cloneQuestions(DEFAULT_TRAINING_EMPLOYEE_CHAT_QUESTIONS)
|
||||
/**
|
||||
* 获取培训角色默认常见问题(按当前 i18n 语言实时解析)。
|
||||
* @param role - employee | hr
|
||||
*/
|
||||
export const getDefaultTrainingChatQuestions = (role: TrainingChatQuestionRole): string[] => (
|
||||
cloneQuestions(resolveLocalizedDefaultQuestions(role))
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -69,7 +78,7 @@ export const resolveTrainingRoleChatQuestions = (
|
||||
if (!matchedKey) {
|
||||
return {
|
||||
configured: false,
|
||||
questions: getDefaultQuestions(role),
|
||||
questions: getDefaultTrainingChatQuestions(role),
|
||||
};
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/**
|
||||
* features/chat/utils/fileCheckExcelDownload.ts
|
||||
* 用途:解析文件检核 Excel 下载链接,并通过 Workspace 会话鉴权下载(不依赖短期 JWT)。
|
||||
* 依赖:getAuthHeaders。
|
||||
* 依赖:getAuthHeaders、vue-i18n。
|
||||
* 逻辑:ChatMessageBubble 点击 Dify 返回的 Tool API 链接时,改走 workspace 下载接口以支持历史对话。
|
||||
*/
|
||||
|
||||
import i18n from '@/i18n';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
|
||||
const FILE_CHECK_TOOL_EXCEL_PATH_RE = /\/api\/file-check\/tools\/runs\/(\d+)\/excel(?:\?.*)?$/i;
|
||||
@@ -71,6 +72,7 @@ const parseDownloadFilename = (disposition: string | null, fallback: string) =>
|
||||
|
||||
/**
|
||||
* 通过 Workspace 接口下载检核 Excel(使用登录态,不依赖 Tool API 短期 token)。
|
||||
* 核心逻辑:fetch blob;失败优先用后端 message,否则 chat.toolRun.downloadFailedStatus。
|
||||
* @param runId - 检核批次 ID。
|
||||
* @param fallbackName - 默认文件名。
|
||||
*/
|
||||
@@ -86,7 +88,7 @@ export async function downloadFileCheckExcelByRunId(
|
||||
? body.message
|
||||
: typeof body?.error?.message === 'string'
|
||||
? body.error.message
|
||||
: `下载失败:${res.status}`;
|
||||
: String(i18n.global.t('chat.toolRun.downloadFailedStatus', { status: res.status }));
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
/**
|
||||
* features/kb/api/kb.api.ts
|
||||
* 知识库 HTTP API。
|
||||
* 用途:知识库 HTTP API 封装。
|
||||
* 依赖:auth、requestJson/BusinessError、vue-i18n(错误 fallback 文案)。
|
||||
* 逻辑:KbWorkspace / composables 调用;失败时优先保留 BusinessError.message,否则回退本地化 fallback。
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { BusinessError, requestJson } from '@/shared/api/client';
|
||||
|
||||
const kbT = (key: string) => String(i18n.global.t(key));
|
||||
const kbErrorMessage = (e: unknown, fallbackKey: string) =>
|
||||
(e as Error).message || kbT(fallbackKey);
|
||||
|
||||
export interface KbGroup {
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -137,8 +144,6 @@ export interface KbListResponse<T> {
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
const jsonAuth = () => ({ headers: { 'Content-Type': 'application/json', ...getAuthHeaders() } });
|
||||
|
||||
const kbErrorMessage = (e: unknown, fallback: string) => (e as Error).message || fallback;
|
||||
|
||||
const getJson = async <T>(path: string, fallback: T): Promise<T> => {
|
||||
try {
|
||||
return await requestJson<T>(path, auth());
|
||||
@@ -156,7 +161,7 @@ const getJsonWithStatus = async <T>(path: string, fallback: T): Promise<KbListRe
|
||||
return {
|
||||
ok: false,
|
||||
data: fallback,
|
||||
error: kbErrorMessage(e, '知识库接口请求失败'),
|
||||
error: kbErrorMessage(e, 'kbWorkspace.errors.apiRequestFailed'),
|
||||
status: err.status,
|
||||
};
|
||||
}
|
||||
@@ -190,7 +195,7 @@ export const createKbGroup = async (payload: {
|
||||
});
|
||||
return { ok: true, group };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '创建知识库分组失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.createGroupFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -217,7 +222,7 @@ export const updateKbDifySettings = async (
|
||||
});
|
||||
return { ok: true, settings };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '保存 Dify 设置失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.saveDifySettingsFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -235,7 +240,7 @@ export const runKbJob = async (
|
||||
});
|
||||
return { ok: true, job, run_result: job.run_result };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '执行任务失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.executeJobFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -251,7 +256,7 @@ export const createKbDocument = async (
|
||||
});
|
||||
return { ok: true, document };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '创建文档失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.createDocumentFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -267,7 +272,7 @@ export const updateKbDocument = async (
|
||||
});
|
||||
return { ok: true, document };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '更新文档失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.updateDocumentFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -278,7 +283,7 @@ export const deleteKbDocument = async (
|
||||
await requestJson(`/api/kb/documents/${documentId}`, { method: 'DELETE', ...auth() });
|
||||
return { ok: true };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '删除文档失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.deleteDocumentFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -296,7 +301,7 @@ export const getKbDocumentVersionSourceFile = async (
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
if (!res.ok) {
|
||||
let message = '读取原始文件失败';
|
||||
let message = kbT('kbWorkspace.msg.readSourceFailed');
|
||||
try {
|
||||
const data = await res.json();
|
||||
if (typeof data?.error === 'string' && data.error.trim()) message = data.error;
|
||||
@@ -316,7 +321,7 @@ export const getKbDocumentVersionSourceFile = async (
|
||||
contentType: res.headers.get('content-type') || undefined,
|
||||
};
|
||||
} catch {
|
||||
return { ok: false, error: '知识库接口暂未就绪,请稍后再试' };
|
||||
return { ok: false, error: kbT('kbWorkspace.msg.apiNotReady') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -333,7 +338,7 @@ export const getKbDocumentMarkdown = async (
|
||||
const data = await requestJson<KbDocumentMarkdown>(`/api/kb/documents/${documentId}/markdown`, auth());
|
||||
return { ok: true, data };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '读取清洗后的 Markdown 失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.readMarkdownFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -349,7 +354,7 @@ export const updateKbDocumentMarkdown = async (
|
||||
});
|
||||
return { ok: true, data };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '保存 Markdown 失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.saveMarkdownFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -371,11 +376,11 @@ export const uploadKbDocumentVersion = async (
|
||||
if (err.status === 413) {
|
||||
return {
|
||||
ok: false,
|
||||
error: '文件过大,超过当前上传限制,请联系管理员放宽限制后重试',
|
||||
error: kbT('kbWorkspace.msg.fileTooLarge'),
|
||||
status: 413,
|
||||
};
|
||||
}
|
||||
return { ok: false, error: kbErrorMessage(e, '上传文档版本失败'), status: err.status };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.uploadVersionFailed'), status: err.status };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -390,7 +395,7 @@ export const submitKbDocumentClean = async (
|
||||
return { ok: true, job, message: job.message || undefined };
|
||||
} catch (e) {
|
||||
const err = e as BusinessError;
|
||||
return { ok: false, error: kbErrorMessage(e, '提交清洗任务失败'), status: err.status };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.submitCleanFailed'), status: err.status };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -411,7 +416,7 @@ export const createKbPathUploadJob = async (
|
||||
return { ok: true, job };
|
||||
} catch (e) {
|
||||
const err = e as BusinessError;
|
||||
return { ok: false, error: kbErrorMessage(e, '创建路径上传任务失败'), status: err.status };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.createPathJobFailed'), status: err.status };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -435,11 +440,11 @@ export const uploadKbPathJobFile = async (
|
||||
if (err.status === 413) {
|
||||
return {
|
||||
ok: false,
|
||||
error: '文件过大,超过当前上传限制,请联系管理员放宽限制后重试',
|
||||
error: kbT('kbWorkspace.msg.fileTooLarge'),
|
||||
status: 413,
|
||||
};
|
||||
}
|
||||
return { ok: false, error: kbErrorMessage(e, '上传路径文件失败'), status: err.status };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.uploadPathFileFailed'), status: err.status };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -455,7 +460,7 @@ export const markKbPathJobFileFailed = async (
|
||||
});
|
||||
return { ok: true, job };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '记录路径文件失败状态失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.markPathFileFailedStatusFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -469,7 +474,7 @@ export const finalizeKbPathUploadJob = async (
|
||||
});
|
||||
return { ok: true, job };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '提交路径上传任务失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.submitPathUploadFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -486,7 +491,7 @@ export const retryFailedKbPathUploadJob = async (
|
||||
return { ok: true, job };
|
||||
} catch (e) {
|
||||
const err = e as BusinessError;
|
||||
return { ok: false, error: kbErrorMessage(e, '重试失败文件失败'), status: err.status };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.retryPathFailed'), status: err.status };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -502,7 +507,7 @@ export const deleteKbPathJobFile = async (
|
||||
);
|
||||
return { ok: true, job: result.job, document_deleted: result.document_deleted };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '删除路径上传文件失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.deletePathFileFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -516,7 +521,7 @@ export const syncKbDocumentToDify = async (
|
||||
});
|
||||
return { ok: true, job };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '同步到 Dify 失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.syncDifyFailedGeneric') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -532,7 +537,7 @@ export const updateKbGroup = async (
|
||||
});
|
||||
return { ok: true, group };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '更新知识库分组失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.updateGroupFailed') };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -543,6 +548,6 @@ export const deleteKbGroup = async (
|
||||
await requestJson(`/api/kb/groups/${groupId}`, { method: 'DELETE', ...auth() });
|
||||
return { ok: true };
|
||||
} catch (e) {
|
||||
return { ok: false, error: kbErrorMessage(e, '删除知识库分组失败') };
|
||||
return { ok: false, error: kbErrorMessage(e, 'kbWorkspace.msg.deleteGroupFailed') };
|
||||
}
|
||||
};
|
||||
@@ -58,7 +58,9 @@ export const getDocumentDisplayDescription = (doc: KbDocumentItem, t: KbTranslat
|
||||
return text || getDocumentDisplayTitle(doc, t);
|
||||
};
|
||||
|
||||
/** 将后端重复文档错误归一为前端可展示的简短文案 */
|
||||
/** 将后端重复文档错误归一为前端可展示的简短文案。
|
||||
* [NLU] includes() 匹配后端中文错误原文,刻意保留;返回值走 i18n。
|
||||
*/
|
||||
export const normalizeDuplicateDocumentError = (message: string | null | undefined, t: KbTranslateFn) => {
|
||||
const text = String(message || '').trim();
|
||||
if (!text) return t('kbWorkspace.errors.apiRequestFailed');
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
/**
|
||||
* features/maintenance/components/MaintenanceRecordPanel.vue
|
||||
* 用途:设备维保助手右侧固定面板中的“新增维修记录”页面。
|
||||
* 依赖:maintenanceRecord.api、maintenanceLedger.api、MaintenanceDeviceSnapshotCard、useMessage。
|
||||
* 依赖:maintenanceRecord.api、maintenanceLedger.api、MaintenanceDeviceSnapshotCard、useMessage、vue-i18n。
|
||||
* 逻辑:管理员通过按钮进入固定面板后填写维修记录;设备编号失焦时查询台账快照,保存后刷新最近记录用于确认。
|
||||
*/
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import MaintenanceDeviceSnapshotCard from '@/features/maintenance/components/MaintenanceDeviceSnapshotCard.vue';
|
||||
import { listMaintenanceDevices } from '@/features/maintenance/api/maintenanceLedger.api';
|
||||
@@ -19,8 +20,10 @@ import type {
|
||||
MaintenanceRecordPayload,
|
||||
MaintenanceRepairStatus,
|
||||
} from '@/features/maintenance/types/record.types';
|
||||
import { repairStatusLabelKey } from '@/features/maintenance/utils/repair-status-display.utils';
|
||||
|
||||
const msg = useMessage();
|
||||
const { t } = useI18n();
|
||||
const saving = ref(false);
|
||||
const deviceLoading = ref(false);
|
||||
const recentLoading = ref(false);
|
||||
@@ -49,24 +52,28 @@ const form = reactive<MaintenanceRecordPayload>({
|
||||
});
|
||||
|
||||
const statusOptions: Array<{ value: MaintenanceRepairStatus | ''; label: string }> = [
|
||||
{ value: '', label: '全部状态' },
|
||||
{ value: 'pending', label: '待维修' },
|
||||
{ value: 'processing', label: '维修中' },
|
||||
{ value: 'done', label: '已完成' },
|
||||
{ value: 'cancelled', label: '已取消' },
|
||||
{ value: '', label: 'maintenance.record.status.all' },
|
||||
{ value: 'pending', label: 'maintenance.record.status.pending' },
|
||||
{ value: 'processing', label: 'maintenance.record.status.processing' },
|
||||
{ value: 'done', label: 'maintenance.record.status.done' },
|
||||
{ value: 'cancelled', label: 'maintenance.record.status.cancelled' },
|
||||
];
|
||||
|
||||
const selectedStatusLabel = computed(() => {
|
||||
return statusOptions.find((item) => item.value === form.repairStatus)?.label || form.repairStatus;
|
||||
const key = repairStatusLabelKey(form.repairStatus);
|
||||
return key ? t(key) : form.repairStatus;
|
||||
});
|
||||
|
||||
/**
|
||||
* 将状态值转换为中文展示。
|
||||
* 将状态值转换为当前语言展示文案。
|
||||
* @param value - 后端状态枚举。
|
||||
* @returns 页面展示文案。
|
||||
*/
|
||||
const formatStatus = (value: string): string => {
|
||||
return statusOptions.find((item) => item.value === value)?.label || value || '-';
|
||||
const key = repairStatusLabelKey(value);
|
||||
if (key) return t(key);
|
||||
const option = statusOptions.find((item) => item.value === value);
|
||||
return option ? t(option.label) : value || '-';
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -103,7 +110,7 @@ const loadDeviceSnapshot = async (): Promise<void> => {
|
||||
const result = await listMaintenanceDevices({ keyword: code, page: 1, pageSize: 5 });
|
||||
matchedDevice.value = result.items.find((item) => item.deviceCode === code) || null;
|
||||
} catch (error: any) {
|
||||
msg.error(error?.message || '查询设备台账失败');
|
||||
msg.error(error?.message || t('maintenance.record.messages.deviceLoadFailed'));
|
||||
} finally {
|
||||
deviceLoading.value = false;
|
||||
}
|
||||
@@ -121,12 +128,12 @@ const ensureDeviceExists = async (): Promise<boolean> => {
|
||||
const result = await listMaintenanceDevices({ keyword: code, page: 1, pageSize: 5 });
|
||||
matchedDevice.value = result.items.find((item) => item.deviceCode === code) || null;
|
||||
if (!matchedDevice.value) {
|
||||
msg.warning('设备不存在,不能新增维修记录');
|
||||
msg.warning(t('maintenance.record.messages.deviceNotFound'));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (error: any) {
|
||||
msg.error(error?.message || '鏌ヨ璁惧鍙拌处澶辫触');
|
||||
msg.error(error?.message || t('maintenance.record.messages.deviceLoadFailed'));
|
||||
return false;
|
||||
} finally {
|
||||
deviceLoading.value = false;
|
||||
@@ -147,7 +154,7 @@ const loadRecentRecords = async (): Promise<void> => {
|
||||
});
|
||||
recentRecords.value = result.items;
|
||||
} catch (error: any) {
|
||||
msg.error(error?.message || '查询维修记录失败');
|
||||
msg.error(error?.message || t('maintenance.record.messages.loadFailed'));
|
||||
} finally {
|
||||
recentLoading.value = false;
|
||||
}
|
||||
@@ -182,7 +189,7 @@ const resetForm = (): void => {
|
||||
const saveRecord = async (): Promise<void> => {
|
||||
const payload = buildPayload();
|
||||
if (!payload.deviceCode || !payload.reportDate || !payload.faultDescription) {
|
||||
msg.warning('设备编号、报修日期和故障描述不能为空');
|
||||
msg.warning(t('maintenance.record.messages.required'));
|
||||
return;
|
||||
}
|
||||
if (!await ensureDeviceExists()) {
|
||||
@@ -191,12 +198,12 @@ const saveRecord = async (): Promise<void> => {
|
||||
saving.value = true;
|
||||
try {
|
||||
await createMaintenanceRecord(payload);
|
||||
msg.success('维修记录已保存');
|
||||
msg.success(t('maintenance.record.messages.saved'));
|
||||
recordKeyword.value = payload.deviceCode;
|
||||
resetForm();
|
||||
await loadRecentRecords();
|
||||
} catch (error: any) {
|
||||
msg.error(error?.message || '保存维修记录失败');
|
||||
msg.error(error?.message || t('maintenance.record.messages.saveFailed'));
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
@@ -209,22 +216,22 @@ onMounted(loadRecentRecords);
|
||||
<section class="flex h-full min-h-0 flex-col gap-4">
|
||||
<form class="min-h-0 flex-1 overflow-auto" @submit.prevent="saveRecord">
|
||||
<div class="mb-4 rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900">
|
||||
维修记录为管理员配置入口,查询类问题仍建议通过会话直接提问。
|
||||
{{ t('maintenance.record.notice') }}
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 md:grid-cols-2">
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
设备编号 *
|
||||
{{ t('maintenance.record.fields.deviceCode') }} *
|
||||
<input
|
||||
v-model="form.deviceCode"
|
||||
class="admin-table-filter-input"
|
||||
placeholder="如 EQ-2026-001"
|
||||
:placeholder="t('maintenance.record.placeholder.deviceCode')"
|
||||
@blur="loadDeviceSnapshot"
|
||||
@keyup.enter.prevent="loadDeviceSnapshot"
|
||||
/>
|
||||
</label>
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
报修日期 *
|
||||
{{ t('maintenance.record.fields.reportDate') }} *
|
||||
<input v-model="form.reportDate" type="date" class="admin-table-filter-input" />
|
||||
</label>
|
||||
</div>
|
||||
@@ -239,94 +246,122 @@ onMounted(loadRecentRecords);
|
||||
|
||||
<div class="mt-4 grid gap-4 md:grid-cols-2">
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
维修类别
|
||||
<input v-model="form.repairCategory" class="admin-table-filter-input" placeholder="日常维修 / 保养 / 点检" />
|
||||
{{ t('maintenance.record.fields.repairCategory') }}
|
||||
<input
|
||||
v-model="form.repairCategory"
|
||||
class="admin-table-filter-input"
|
||||
:placeholder="t('maintenance.record.placeholder.repairCategory')"
|
||||
/>
|
||||
</label>
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
维修状态
|
||||
{{ t('maintenance.record.fields.repairStatus') }}
|
||||
<select v-model="form.repairStatus" class="admin-table-filter-input">
|
||||
<option value="pending">待维修</option>
|
||||
<option value="processing">维修中</option>
|
||||
<option value="done">已完成</option>
|
||||
<option value="cancelled">已取消</option>
|
||||
<option value="pending">{{ t('maintenance.record.status.pending') }}</option>
|
||||
<option value="processing">{{ t('maintenance.record.status.processing') }}</option>
|
||||
<option value="done">{{ t('maintenance.record.status.done') }}</option>
|
||||
<option value="cancelled">{{ t('maintenance.record.status.cancelled') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid gap-4 md:grid-cols-2">
|
||||
<label class="grid gap-1 text-sm text-secondary md:col-span-2">
|
||||
故障描述 *
|
||||
{{ t('maintenance.record.fields.faultDescription') }} *
|
||||
<textarea v-model="form.faultDescription" class="admin-table-filter-input min-h-24" />
|
||||
</label>
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
报修人
|
||||
{{ t('maintenance.record.fields.reporter') }}
|
||||
<input v-model="form.reporter" class="admin-table-filter-input" />
|
||||
</label>
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
审批人
|
||||
{{ t('maintenance.record.fields.approver') }}
|
||||
<input v-model="form.approver" class="admin-table-filter-input" />
|
||||
</label>
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
维修日期
|
||||
{{ t('maintenance.record.fields.repairDate') }}
|
||||
<input v-model="form.repairDate" type="date" class="admin-table-filter-input" />
|
||||
</label>
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
维修单位
|
||||
{{ t('maintenance.record.fields.repairUnit') }}
|
||||
<input v-model="form.repairUnit" class="admin-table-filter-input" />
|
||||
</label>
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
维修人
|
||||
{{ t('maintenance.record.fields.repairer') }}
|
||||
<input v-model="form.repairer" class="admin-table-filter-input" />
|
||||
</label>
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
来源工单号
|
||||
{{ t('maintenance.record.fields.sourceOrderNo') }}
|
||||
<input v-model="form.sourceOrderNo" class="admin-table-filter-input" />
|
||||
</label>
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
维修费用
|
||||
<input v-model="form.repairCost" class="admin-table-filter-input" placeholder="如 1200.00" />
|
||||
{{ t('maintenance.record.fields.repairCost') }}
|
||||
<input
|
||||
v-model="form.repairCost"
|
||||
class="admin-table-filter-input"
|
||||
:placeholder="t('maintenance.record.placeholder.repairCost')"
|
||||
/>
|
||||
</label>
|
||||
<label class="grid gap-1 text-sm text-secondary">
|
||||
维修工时
|
||||
<input v-model="form.repairHours" class="admin-table-filter-input" placeholder="如 3.5h" />
|
||||
{{ t('maintenance.record.fields.repairHours') }}
|
||||
<input
|
||||
v-model="form.repairHours"
|
||||
class="admin-table-filter-input"
|
||||
:placeholder="t('maintenance.record.placeholder.repairHours')"
|
||||
/>
|
||||
</label>
|
||||
<label class="grid gap-1 text-sm text-secondary md:col-span-2">
|
||||
维修说明
|
||||
{{ t('maintenance.record.fields.repairDescription') }}
|
||||
<textarea v-model="form.repairDescription" class="admin-table-filter-input min-h-24" />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="sticky bottom-0 mt-5 flex justify-end gap-2 border-t border-default bg-surface py-3">
|
||||
<button type="button" class="admin-report-page-btn" @click="resetForm">清空</button>
|
||||
<button type="button" class="admin-report-page-btn" @click="resetForm">
|
||||
{{ t('maintenance.record.actions.clear') }}
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
class="admin-report-page-btn admin-report-page-btn--active"
|
||||
:disabled="saving"
|
||||
>
|
||||
{{ saving ? '保存中...' : `保存为${selectedStatusLabel}` }}
|
||||
{{
|
||||
saving
|
||||
? t('maintenance.record.actions.saving')
|
||||
: t('maintenance.record.actions.saveAs', { status: selectedStatusLabel })
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="border-t border-default pt-4">
|
||||
<div class="mb-3 flex items-center justify-between gap-2">
|
||||
<h3 class="text-sm font-semibold text-primary">最近维修记录</h3>
|
||||
<button type="button" class="admin-report-page-btn" @click="loadRecentRecords">刷新</button>
|
||||
<h3 class="text-sm font-semibold text-primary">{{ t('maintenance.record.recentTitle') }}</h3>
|
||||
<button type="button" class="admin-report-page-btn" @click="loadRecentRecords">
|
||||
{{ t('common.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="mb-3 grid gap-2 md:grid-cols-[1fr_120px_72px]">
|
||||
<input v-model="recordKeyword" class="admin-table-filter-input" placeholder="筛选设备编号、故障、维修人" />
|
||||
<input
|
||||
v-model="recordKeyword"
|
||||
class="admin-table-filter-input"
|
||||
:placeholder="t('maintenance.record.filters.recentKeywordPlaceholder')"
|
||||
/>
|
||||
<select v-model="recordStatus" class="admin-table-filter-input">
|
||||
<option v-for="item in statusOptions" :key="item.value || 'all'" :value="item.value">
|
||||
{{ item.label }}
|
||||
{{ t(item.label) }}
|
||||
</option>
|
||||
</select>
|
||||
<button type="button" class="admin-report-page-btn admin-report-page-btn--active" @click="loadRecentRecords">
|
||||
查询
|
||||
{{ t('maintenance.record.actions.search') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="max-h-56 overflow-auto rounded-xl border border-default bg-surface">
|
||||
<div v-if="recentLoading" class="px-3 py-6 text-center text-sm text-secondary">加载中...</div>
|
||||
<div v-else-if="!recentRecords.length" class="px-3 py-6 text-center text-sm text-secondary">暂无维修记录</div>
|
||||
<div v-if="recentLoading" class="px-3 py-6 text-center text-sm text-secondary">
|
||||
{{ t('maintenance.record.table.loading') }}
|
||||
</div>
|
||||
<div v-else-if="!recentRecords.length" class="px-3 py-6 text-center text-sm text-secondary">
|
||||
{{ t('maintenance.record.table.empty') }}
|
||||
</div>
|
||||
<div
|
||||
v-for="record in recentRecords"
|
||||
v-else
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/maintenance/utils/repair-status-display.utils.ts
|
||||
* 用途:维修记录状态在列表、卡片中的标签配色映射。
|
||||
* 用途:维修记录状态在列表、卡片中的标签配色与 i18n key 映射。
|
||||
* 依赖:MaintenanceRepairStatus 类型。
|
||||
* 逻辑:MaintenanceRecordManagerPanel、MaintenanceDeviceResultCard 等组件统一引用,保证状态色一致。
|
||||
* 逻辑:MaintenanceRecordManagerPanel、MaintenanceRecordPanel、MaintenanceDeviceResultCard 等组件统一引用,保证状态色与文案一致。
|
||||
*/
|
||||
import type { MaintenanceRepairStatus } from '@/features/maintenance/types/record.types';
|
||||
|
||||
@@ -18,3 +18,16 @@ export function repairStatusBadgeClass(value: MaintenanceRepairStatus | string):
|
||||
if (value === 'cancelled') return 'border-slate-200 bg-slate-100 text-slate-600';
|
||||
return 'border-slate-200 bg-slate-50 text-slate-600';
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回维修状态对应的 i18n 文案 key,供组件内 t() 翻译。
|
||||
* @param value - 维修状态枚举值。
|
||||
* @returns maintenance.record.status.* 的 key 路径;未知状态返回空字符串。
|
||||
*/
|
||||
export function repairStatusLabelKey(value: MaintenanceRepairStatus | string): string {
|
||||
if (value === 'pending') return 'maintenance.record.status.pending';
|
||||
if (value === 'processing') return 'maintenance.record.status.processing';
|
||||
if (value === 'done') return 'maintenance.record.status.done';
|
||||
if (value === 'cancelled') return 'maintenance.record.status.cancelled';
|
||||
return '';
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/workspace/components/WorkspaceModals.vue
|
||||
* 工作台弹窗:公告详情、快捷问题删除、意见反馈。
|
||||
* 用途:工作台弹窗:公告详情、快捷问题删除、意见反馈。
|
||||
* 依赖:DeleteConfirmDialog、GeneralFeedbackDialog、workspace.context、vue-i18n。
|
||||
* 逻辑:由 WorkspaceLayout 挂载;反馈成功 toast 使用 feedback.msg.submitSuccess。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { X } from 'lucide-vue-next';
|
||||
@@ -52,7 +54,7 @@ const ws = inject(WORKSPACE_KEY)! as any;
|
||||
v-model="ws.showGeneralFeedbackDialog"
|
||||
:auth-headers="getAuthHeaders()"
|
||||
source-page="workspace"
|
||||
@submitted="ws.msg.success('反馈提交成功')"
|
||||
@submitted="ws.msg.success($t('feedback.msg.submitSuccess'))"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/workspace/composables/useWorkspace.ts
|
||||
* 工作台编排层:组合各子 composable,挂载生命周期,provide 给 Layout 与子页面。
|
||||
* 用途:工作台编排层:组合各子 composable,挂载生命周期,provide 给 Layout 与子页面。
|
||||
* 依赖:useWorkspaceHome/Session/Navigation/Locale、useUserProfile、useChatHistory、useWorkspaceSchedule。
|
||||
* 逻辑:登录校验后 fetchHome;知识库拒绝由 Navigation 内 t(KB_ACCESS_DENIED_KEY) 处理。
|
||||
*/
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
@@ -51,7 +53,6 @@ export function useWorkspace() {
|
||||
const navigation = useWorkspaceNavigation(deps, {
|
||||
isLoggedIn: session.isLoggedIn,
|
||||
hasKnowledgeBaseAccess: session.hasKnowledgeBaseAccess,
|
||||
KB_ACCESS_DENIED_MESSAGE: session.KB_ACCESS_DENIED_MESSAGE,
|
||||
agents: home.agents,
|
||||
layoutSections: home.layoutSections,
|
||||
profileUserId: computed(() => profile.profileUser.value.id),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/workspace/composables/useWorkspaceNavigation.ts
|
||||
* 子路由导航、移动端 Tab、聊天跳转、企微 deeplink 与旧 view 参数兼容。
|
||||
* 用途:子路由导航、移动端 Tab、聊天跳转、企微 deeplink 与旧 view 参数兼容。
|
||||
* 依赖:vue-router、config、auth、requestJson、workspace routes/types。
|
||||
* 逻辑:由 useWorkspace 注入;知识库无权限时 toast t('workspace.kb.accessDenied')。
|
||||
*/
|
||||
import { computed, nextTick, ref, watch, type ComputedRef, type Ref } from 'vue';
|
||||
import { config } from '@/config';
|
||||
@@ -8,7 +10,7 @@ import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { getLastChatAgentId } from '@/shared/utils/lastChatAgent';
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { WORKSPACE_PATHS, workspacePathFromLegacyView } from '../constants/routes';
|
||||
import { DEFAULT_POST_LOGIN_AGENT_ID, type WorkspaceAgent, type WorkspaceSidebarItem } from '../types/workspace.types';
|
||||
import { DEFAULT_POST_LOGIN_AGENT_ID, KB_ACCESS_DENIED_KEY, type WorkspaceAgent, type WorkspaceSidebarItem } from '../types/workspace.types';
|
||||
import type { WorkspaceLayoutSection } from '../types/workspace.types';
|
||||
import type { WorkspaceDeps } from './workspace.deps';
|
||||
|
||||
@@ -27,7 +29,6 @@ const ROUTE_NAME_TO_SIDEBAR: Record<string, WorkspaceSidebarItem> = {
|
||||
interface NavigationOptions {
|
||||
isLoggedIn: ComputedRef<boolean>;
|
||||
hasKnowledgeBaseAccess: ComputedRef<boolean>;
|
||||
KB_ACCESS_DENIED_MESSAGE: string;
|
||||
agents: Ref<WorkspaceAgent[]>;
|
||||
layoutSections: Ref<WorkspaceLayoutSection[]>;
|
||||
profileUserId: ComputedRef<number>;
|
||||
@@ -37,12 +38,17 @@ interface NavigationOptions {
|
||||
loadWorkspaceScheduleRuns: () => Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装工作台侧栏/移动端导航与路由副作用。
|
||||
* 核心逻辑:映射 route.name → sidebar item;无知识库权限时本地化 toast 并拦截跳转。
|
||||
* @param deps - t/msg/router/route
|
||||
* @param options - 登录态、权限与各模块加载回调
|
||||
*/
|
||||
export function useWorkspaceNavigation(deps: WorkspaceDeps, options: NavigationOptions) {
|
||||
const { t, msg, router, route } = deps;
|
||||
const {
|
||||
isLoggedIn,
|
||||
hasKnowledgeBaseAccess,
|
||||
KB_ACCESS_DENIED_MESSAGE,
|
||||
agents,
|
||||
layoutSections,
|
||||
profileUserId,
|
||||
@@ -97,8 +103,11 @@ export function useWorkspaceNavigation(deps: WorkspaceDeps, options: NavigationO
|
||||
const navigateToApplications = () => router.push(WORKSPACE_PATHS.applications);
|
||||
const navigateToUpdates = () => router.push(WORKSPACE_PATHS.updates);
|
||||
|
||||
/**
|
||||
* 弹出知识库无权限提示(四语言)。
|
||||
*/
|
||||
const showKnowledgeBaseAccessDenied = () => {
|
||||
msg.warning(KB_ACCESS_DENIED_MESSAGE);
|
||||
msg.warning(t(KB_ACCESS_DENIED_KEY));
|
||||
};
|
||||
|
||||
const navigateToKnowledgeBase = () => {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/**
|
||||
* features/workspace/composables/useWorkspaceSession.ts
|
||||
* 登录态:当前用户、知识库权限判断、登出与 401 清理。
|
||||
* 用途:登录态:当前用户、知识库权限判断、登出与 401 清理。
|
||||
* 依赖:auth utils、workspace.types.WorkspaceUser。
|
||||
* 逻辑:useWorkspace 组合本模块;知识库拒绝文案由导航层 t('workspace.kb.accessDenied') 解析。
|
||||
*/
|
||||
import { computed, type Ref } from 'vue';
|
||||
import { logoutAuth, getStoredAuthUser } from '@/shared/utils/auth';
|
||||
import { KB_ACCESS_DENIED_MESSAGE } from '../types/workspace.types';
|
||||
import type { WorkspaceUser } from '../types/workspace.types';
|
||||
import type { WorkspaceDeps } from './workspace.deps';
|
||||
|
||||
@@ -79,7 +80,6 @@ export function useWorkspaceSession(deps: WorkspaceDeps, options: SessionOptions
|
||||
currentUser,
|
||||
isLoggedIn,
|
||||
hasKnowledgeBaseAccess,
|
||||
KB_ACCESS_DENIED_MESSAGE,
|
||||
loadAuthUser,
|
||||
applyLoggedOutState,
|
||||
handleLogout,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/workspace/types/workspace.types.ts
|
||||
* 工作台相关 TypeScript 类型与业务常量。
|
||||
* 用途:工作台相关 TypeScript 类型与业务常量。
|
||||
* 依赖:wecom utils、chat.types(历史项 re-export)。
|
||||
* 逻辑:composables/views 共享类型;知识库拒绝文案 key 为 KB_ACCESS_DENIED_KEY,由导航层 t() 解析。
|
||||
*/
|
||||
import type { WecomMatchField } from '@/shared/utils/wecom';
|
||||
import type { WecomLoginDialogContent } from '@/shared/utils/wecom';
|
||||
@@ -85,5 +87,6 @@ export const SECTION_TITLE_KEY_MAP: Record<string, string> = {
|
||||
};
|
||||
|
||||
export const DEFAULT_POST_LOGIN_AGENT_ID = 16;
|
||||
export const KB_ACCESS_DENIED_MESSAGE = '需要管理员权限才能访问知识库。';
|
||||
/** 知识库无权限提示的 i18n key(在 toast 使用点调用 t()) */
|
||||
export const KB_ACCESS_DENIED_KEY = 'workspace.kb.accessDenied';
|
||||
export const WS_SCHEDULE_FILTER_INPUT_CLASS = 'admin-table-filter-input text-xs py-1.5 px-2';
|
||||
@@ -1,7 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/workspace/views/WorkspaceLayout.vue
|
||||
* 工作台布局壳:初始化 composable、侧边栏、子路由出口与全局弹窗。
|
||||
* 用途:工作台布局壳:初始化 composable、侧边栏、子路由出口与全局弹窗。
|
||||
* 依赖:useWorkspace、WorkspaceSidebar/Modals、ExternalSystemLinks。
|
||||
* 逻辑:provide WORKSPACE_KEY;移动端返回按钮文案走 workspace.nav.backShort。
|
||||
*/
|
||||
import { provide } from 'vue';
|
||||
import { LayoutGrid, Bot, User } from 'lucide-vue-next';
|
||||
@@ -40,7 +42,7 @@ const mobileTabs = [
|
||||
class="flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-brand-500 via-brand-600 to-purple-600 text-xs font-bold text-white shadow-sm shadow-brand-500/20"
|
||||
:title="$t('workspace.nav.backToChat')"
|
||||
>
|
||||
返
|
||||
{{ $t('workspace.nav.backShort') }}
|
||||
</button>
|
||||
<span class="text-sm font-semibold text-primary">{{ ws.mobileTabTitle }}</span>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user