Merge branch 'dev' into hugo-shipping-notice
# Conflicts: # backend/app/api/chat.py # backend/app/services/shipping_notice/chat_actions.py
This commit is contained in:
commit
7a9c36d16b
17 files changed
+1014
-357
No files matched your search
@@ -162,17 +162,17 @@ const FIXED_ASSET_HEADER_LABELS: Record<string, string> = {
|
||||
specification: '规格型号',
|
||||
account_period: '账套',
|
||||
operating_center_code: '账套',
|
||||
custodian_person: '保管人姓名',
|
||||
custodian_name: '保管人姓名',
|
||||
custodian_dept: '保管部门名称',
|
||||
department_name: '保管部门名称',
|
||||
custodian_person: '保管人',
|
||||
custodian_name: '保管人',
|
||||
custodian_dept: '保管部门',
|
||||
department_name: '保管部门',
|
||||
storage_location: '存放位置名称',
|
||||
location_name: '存放位置名称',
|
||||
asset_status: '资产状态',
|
||||
reserved_field: '预留残值',
|
||||
residual_value: '预留残值',
|
||||
supplier: '供应厂商',
|
||||
vendor_name: '供应厂商',
|
||||
supplier: '供应商',
|
||||
vendor_name: '供应商',
|
||||
asset_nature: '资产性质',
|
||||
nature: '资产性质',
|
||||
amount_local: '本币金额(元)',
|
||||
@@ -180,8 +180,8 @@ const FIXED_ASSET_HEADER_LABELS: Record<string, string> = {
|
||||
quantity: '数量',
|
||||
unit: '计量单位',
|
||||
unit_of_measurement: '计量单位',
|
||||
acquisition_date: '取得日期',
|
||||
acquired_date: '取得日期',
|
||||
acquisition_date: '取得时间',
|
||||
acquired_date: '取得时间',
|
||||
accounting_date: '入账日期',
|
||||
recorded_date: '入账日期',
|
||||
created_at: '创建时间',
|
||||
@@ -189,6 +189,18 @@ const FIXED_ASSET_HEADER_LABELS: Record<string, string> = {
|
||||
updated_at: '更新时间',
|
||||
snapshot_time: '快照时间',
|
||||
};
|
||||
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: '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'] },
|
||||
] as const;
|
||||
const INLINE_DIALOG_PAGE_SIZE = 15;
|
||||
|
||||
/**
|
||||
@@ -237,6 +249,24 @@ function localizeInlineTableHeader(header: string): string {
|
||||
return FIXED_ASSET_HEADER_LABELS[normalizedHeader] || header || '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* 将固定资产时间字段统一裁剪为“年月日”。
|
||||
* 核心逻辑:优先提取 `YYYY-MM-DD` 或 `YYYY/MM/DD` 形式;若无法识别标准日期,则保留原始值避免误改内容。
|
||||
* @param value - 原始时间文本。
|
||||
* @returns 仅保留年月日的展示值。
|
||||
*/
|
||||
function formatInlineDateOnly(value: string): string {
|
||||
const normalized = String(value ?? '').trim();
|
||||
if (!normalized) return '';
|
||||
const dateMatch = normalized.match(/(\d{4})[-/](\d{1,2})[-/](\d{1,2})/);
|
||||
if (!dateMatch) return normalized;
|
||||
const year = dateMatch[1] || '';
|
||||
const month = dateMatch[2] || '';
|
||||
const day = dateMatch[3] || '';
|
||||
if (!year || !month || !day) return normalized;
|
||||
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一表格中的空值展示。
|
||||
* 核心逻辑:对空串、短横线、null/none 等占位值统一显示“无”,但保留数字 0 与正常文本。
|
||||
@@ -262,6 +292,19 @@ function findInlineTableHeaderIndex(headers: string[], aliases: string[]): numbe
|
||||
return headers.findIndex((header) => normalizedAliases.includes(String(header || '').trim().toLowerCase()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前 CSV 是否为固定资产明细导出结构。
|
||||
* 核心逻辑:按业务关键列做命中检测,只有命中固定资产列集时才收敛为指定 10 列,避免影响其他 Agent 的 CSV 预览。
|
||||
* @param headers - CSV 原始表头。
|
||||
* @returns 是否按固定资产明细规则处理。
|
||||
*/
|
||||
function isFixedAssetInlineTable(headers: string[]): boolean {
|
||||
return FIXED_ASSET_CANONICAL_COLUMNS
|
||||
.filter((column) => column.key !== 'id')
|
||||
.filter((column) => findInlineTableHeaderIndex(headers, [...column.aliases]) >= 0)
|
||||
.length >= 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将用户输入与单元格内容统一成可搜索的文本。
|
||||
* 核心逻辑:统一 trim + lowerCase,避免筛选时受大小写和首尾空白干扰。
|
||||
@@ -288,9 +331,37 @@ function serializeCsvRows(rows: string[][]): string {
|
||||
}).join(',')).join('\r\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* 按固定资产业务要求抽取并重排列顺序。
|
||||
* 核心逻辑:只输出指定的 10 个业务字段;若某列缺失则补“无”,并把取得时间统一裁剪为年月日。
|
||||
* @param rawHeaders - CSV 原始表头。
|
||||
* @param dataRows - 原始数据行。
|
||||
* @returns 规范化后的表头与数据行。
|
||||
*/
|
||||
function buildFixedAssetInlineTable(rawHeaders: string[], dataRows: string[][]): InlinePreviewTable {
|
||||
const headers = FIXED_ASSET_CANONICAL_COLUMNS.map((column) => column.label);
|
||||
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);
|
||||
const columnIndex = findInlineTableHeaderIndex(rawHeaders, [...column.aliases]);
|
||||
const rawValue = columnIndex >= 0 ? row[columnIndex] ?? '' : '';
|
||||
const normalizedValue = column.key === 'acquisition_date'
|
||||
? formatInlineDateOnly(rawValue)
|
||||
: rawValue;
|
||||
return normalizeInlineTableCell(normalizedValue);
|
||||
}));
|
||||
return {
|
||||
rawHeaders: canonicalHeaders,
|
||||
headers,
|
||||
allRows,
|
||||
totalRows: dataRows.length,
|
||||
isCsv: true,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 CSV 文本转成结构化表格,供聊天文件弹窗展示全部数据。
|
||||
* 核心逻辑:首行先做中文列名转换;若存在 id 列则重写为从 1 递增的序号,确保弹窗与下载文件显示一致。
|
||||
* 核心逻辑:固定资产明细优先收敛为指定业务列与日期格式;其他 CSV 保持原表头映射,避免误伤通用附件预览。
|
||||
* @param file - 当前预览文件。
|
||||
* @returns 表头、完整数据行和总行数。
|
||||
*/
|
||||
@@ -313,6 +384,9 @@ function buildInlinePreviewTable(file: InlineDownloadFile): InlinePreviewTable {
|
||||
const headerLine = lines[0] || '';
|
||||
const rawHeaders = parseCsvLine(headerLine);
|
||||
const dataRows = lines.slice(1).map((line) => parseCsvLine(line));
|
||||
if (isFixedAssetInlineTable(rawHeaders)) {
|
||||
return buildFixedAssetInlineTable(rawHeaders, dataRows);
|
||||
}
|
||||
const idColumnIndex = rawHeaders.findIndex((header) => String(header || '').trim().toLowerCase() === 'id');
|
||||
const headers = rawHeaders.map((header) => localizeInlineTableHeader(header));
|
||||
const allRows = dataRows.map((row, rowIndex) => rawHeaders.map((_, columnIndex) => {
|
||||
|
||||
@@ -246,6 +246,22 @@ export function useChat() {
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* 判断当前消息列表里是否已经出现“用户可感知为完成态”的上一轮回答。
|
||||
*
|
||||
* 说明:
|
||||
* - 固资管理的第一轮大结果常常已经把完整表格和分析展示出来,但 SSE 终态还会晚 1~2 秒;
|
||||
* - 若这时用户继续提问,不应再把发送动作死锁在 `isThinking=true` 上。
|
||||
*/
|
||||
const hasVisibleCompletedAssistantReply = (items: ChatMessage[]) => {
|
||||
for (let i = items.length - 1; i >= 0; i -= 1) {
|
||||
const message = items[i];
|
||||
if (message?.role !== 'assistant') continue;
|
||||
return looksLikeCompletedAssistantReply(String(message.content || ''));
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* 对“已看到完整报告但流未结束”的情况做兜底收尾。
|
||||
*
|
||||
@@ -330,6 +346,41 @@ export function useChat() {
|
||||
return String(message ?? 'Unknown error');
|
||||
};
|
||||
|
||||
/**
|
||||
* 从 workflow_finished 失败事件中提取用户可读错误。
|
||||
*
|
||||
* 说明:
|
||||
* - Dify Chatflow 失败时常以 `workflow_finished + data.status=failed` 返回,HTTP 仍是 200;
|
||||
* - 若这里只按“终态成功”处理,页面会出现“没有任何响应”;
|
||||
* - 因此需要优先从 top-level / nested data / error 对象里抽取失败文案。
|
||||
*/
|
||||
const extractWorkflowFailureMessage = (data: Record<string, unknown>) => {
|
||||
if (String(data.event || '') !== 'workflow_finished') return '';
|
||||
const workflowData = data.data && typeof data.data === 'object'
|
||||
? data.data as Record<string, unknown>
|
||||
: {};
|
||||
const isFailed = String(workflowData.status || '').toLowerCase() === 'failed';
|
||||
if (!isFailed) return '';
|
||||
const candidates = [
|
||||
data.message,
|
||||
data.description,
|
||||
data.error,
|
||||
workflowData.message,
|
||||
workflowData.description,
|
||||
workflowData.error,
|
||||
workflowData.errmsg,
|
||||
];
|
||||
for (const candidate of candidates) {
|
||||
const normalized = formatStreamError(candidate).trim();
|
||||
if (!normalized || normalized === 'Unknown error') continue;
|
||||
if (/maximum context length|input_tokens/i.test(normalized)) {
|
||||
return '当前会话上下文过长,模型无法继续回答。请新建对话后重新查询该资产编号。';
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
return '工作流执行失败,请稍后重试';
|
||||
};
|
||||
|
||||
const streamErrorLabels = (): StreamErrorLabels => ({
|
||||
networkDisconnectedEmpty: t('chat.streamError.networkDisconnectedEmpty'),
|
||||
partialInterrupted: t('chat.streamError.partialInterrupted'),
|
||||
@@ -350,7 +401,12 @@ export function useChat() {
|
||||
) => {
|
||||
const displayQuery = String(context?.display_query || query || '').trim();
|
||||
clearLikelyCompletedStreamTimer();
|
||||
cancelActiveStream();
|
||||
const shouldDetachPreviousStream = Boolean(activeStreamController.value) && hasVisibleCompletedAssistantReply(messages.value);
|
||||
if (shouldDetachPreviousStream) {
|
||||
detachActiveStreamFromView();
|
||||
} else {
|
||||
cancelActiveStream();
|
||||
}
|
||||
const controller = new AbortController();
|
||||
activeStreamController.value = controller;
|
||||
const runViewId = viewId.value;
|
||||
@@ -478,8 +534,13 @@ export function useChat() {
|
||||
if (currentBotMsg) applyEventMetadata(currentBotMsg, data);
|
||||
}
|
||||
} else if (eventName === 'message_end' || eventName === 'workflow_finished') {
|
||||
const workflowFailureMessage = extractWorkflowFailureMessage(data);
|
||||
hasTerminalEvent = true;
|
||||
ignoreFurtherStreamEvents = true;
|
||||
// [STEP 2] 一旦拿到终态事件,当前轮回答在用户视角已经结束;
|
||||
// 这里立刻把旧流从活动视图脱离,允许用户继续提问,同时让底层连接在后台自然读到 EOF,
|
||||
// 避免下一次 sendMessage 先 abort 旧请求,导致网络面板残留 ERR_ABORTED。
|
||||
detachActiveStreamFromView();
|
||||
const relay = (data.hxops_relay || {}) as Record<string, unknown>;
|
||||
if (relay.total_relay_ms != null) {
|
||||
// eslint-disable-next-line no-console
|
||||
@@ -487,9 +548,14 @@ export function useChat() {
|
||||
`[chat-perf] hxops relay first_chunk=${String(relay.first_chunk_ms ?? '')}ms total=${String(relay.total_relay_ms ?? '')}ms`,
|
||||
);
|
||||
}
|
||||
run.status = 'done';
|
||||
run.status = workflowFailureMessage ? 'error' : 'done';
|
||||
clearLikelyCompletedStreamTimer();
|
||||
if (messages.value === runMessages) isThinking.value = false;
|
||||
if (workflowFailureMessage) {
|
||||
const botMsg = ensureBotMessage();
|
||||
if (!botMsg) continue;
|
||||
applyStreamErrorToMessage(botMsg, workflowFailureMessage, streamErrorLabels());
|
||||
}
|
||||
if (typeof data.answer === 'string' && data.answer.length > 0) {
|
||||
const botMsg = ensureBotMessage();
|
||||
if (!botMsg) continue;
|
||||
@@ -523,6 +589,9 @@ export function useChat() {
|
||||
} else if (eventName === 'error') {
|
||||
const botMsg = ensureBotMessage();
|
||||
if (!botMsg) continue;
|
||||
// [STEP 2] SSE error 对用户来说也是当前轮终态,脱离活动视图后可继续发下一问,
|
||||
// 同时保留底层连接在后台自然收尾,避免后续交互误触 abort。
|
||||
detachActiveStreamFromView();
|
||||
applyStreamErrorToMessage(botMsg, formatStreamError(data.message), streamErrorLabels());
|
||||
run.status = 'error';
|
||||
clearLikelyCompletedStreamTimer();
|
||||
|
||||
@@ -8,6 +8,29 @@ import type { ChatMessage } from '../types/chat.types';
|
||||
import type { ChatUploadFileSpec } from '../types/shipping.types';
|
||||
import type { ComputedRef, Ref } from 'vue';
|
||||
|
||||
const looksLikeCompletedAssistantReply = (content: string) => {
|
||||
if (!content) return false;
|
||||
return (
|
||||
content.includes('<details>')
|
||||
|| content.includes('**查询结果如下:**')
|
||||
|| content.includes('**错误详情**')
|
||||
|| content.includes('[FILE_START]')
|
||||
|| content.includes('【💡 数据概述】')
|
||||
|| content.includes('【📊 数据预览】')
|
||||
|| content.includes('【📈 数据分析汇总报告】')
|
||||
|| content.includes('系统为您从数据库中检索到共计')
|
||||
);
|
||||
};
|
||||
|
||||
const canContinueSendWhileThinking = (messages: ChatMessage[]) => {
|
||||
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
||||
const message = messages[i];
|
||||
if (message?.role !== 'assistant') continue;
|
||||
return looksLikeCompletedAssistantReply(String(message.content || ''));
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
export interface ChatPageSendContext {
|
||||
input: Ref<string>;
|
||||
messages: Ref<ChatMessage[]>;
|
||||
@@ -52,8 +75,9 @@ export interface ChatPageSendContext {
|
||||
|
||||
export function createChatPageSendApi(ctx: ChatPageSendContext) {
|
||||
const canSendMessage = computed(() => {
|
||||
if (ctx.isThinking.value || ctx.isUploadingAttachments.value) return false;
|
||||
if (ctx.input.value.trim()) return true;
|
||||
const allowSendWhileThinking = canContinueSendWhileThinking(ctx.messages.value);
|
||||
if (ctx.isUploadingAttachments.value) return false;
|
||||
if (ctx.input.value.trim()) return !ctx.isThinking.value || allowSendWhileThinking;
|
||||
if (ctx.allowsSendWithAttachmentsOnly.value) return true;
|
||||
return false;
|
||||
});
|
||||
@@ -61,10 +85,11 @@ export function createChatPageSendApi(ctx: ChatPageSendContext) {
|
||||
const handleSend = async (textOrEvent?: string | Event) => {
|
||||
const content = (typeof textOrEvent === 'string' ? textOrEvent : null) || ctx.input.value;
|
||||
const trimmed = content.trim();
|
||||
const allowSendWhileThinking = canContinueSendWhileThinking(ctx.messages.value);
|
||||
if (await ctx.tryHandleShippingAttachmentAutoFlow(textOrEvent, content, trimmed)) {
|
||||
return;
|
||||
}
|
||||
if (!trimmed || ctx.isThinking.value || ctx.isUploadingAttachments.value) {
|
||||
if (!trimmed || ctx.isUploadingAttachments.value || (ctx.isThinking.value && !allowSendWhileThinking)) {
|
||||
return;
|
||||
}
|
||||
if (ctx.tryHandleLeaveSend(content)) {
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* features/kb/views/KbWorkspaceView.vue
|
||||
* 知识库作业面视图壳:模板与弹窗布局,业务逻辑见 useKbWorkspace。
|
||||
*/
|
||||
import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, Info, RefreshCw, Search, Settings, Trash2, Upload } from 'lucide-vue-next';
|
||||
import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, Info, RefreshCw, Search, Settings, SquareCheck, Trash2, Upload } from 'lucide-vue-next';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import KbWorkspaceOverlays from '../components/KbWorkspaceOverlays.vue';
|
||||
import { useKbWorkspace } from '../composables/useKbWorkspace';
|
||||
|
||||
@@ -45,14 +46,6 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<button
|
||||
v-if="kb.viewMode !== 'group_overview'"
|
||||
@click="kb.refreshCurrentView"
|
||||
class="btn-secondary"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />
|
||||
{{ kb.t('kbWorkspace.actions.refreshDocuments') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.viewMode === 'group_overview'"
|
||||
type="button"
|
||||
@@ -233,12 +226,6 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
<ChevronUp v-else class="h-4 w-4" />
|
||||
</button>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
@click="kb.openPathUploadHistoryModal(kb.latestPathUploadJob?.id || null)"
|
||||
class="inline-flex items-center rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.pathUpload.viewHistory') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.latestPathUploadJob && kb.hasRetryablePathUploadFailure(kb.latestPathUploadJob) && !kb.pathUploadRunning"
|
||||
@click="kb.handleRetryFailedPathUpload(kb.latestPathUploadJob)"
|
||||
@@ -293,57 +280,6 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
>
|
||||
<div class="flex flex-col gap-3 xl:flex-row xl:items-center xl:justify-between">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
v-for="tab in kb.stageFilterTabs"
|
||||
:key="tab.key"
|
||||
@click="kb.documentStageFilter = tab.key"
|
||||
class="inline-flex items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium transition-colors"
|
||||
:class="kb.documentStageFilter === tab.key
|
||||
? 'border-brand-200 bg-brand-50 text-brand-700'
|
||||
: 'border-default bg-surface text-secondary hover:bg-surface-soft'"
|
||||
>
|
||||
<span>{{ tab.label }}</span>
|
||||
<span class="rounded-full bg-surface-soft px-2 py-0.5 text-xs">{{ tab.count }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm text-muted">
|
||||
<label class="relative min-w-[260px] flex-1 xl:w-80 xl:flex-none">
|
||||
<Search class="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted" />
|
||||
<input
|
||||
v-model.trim="kb.documentKeyword"
|
||||
type="text"
|
||||
class="w-full rounded-2xl border border-default bg-surface py-2.5 pl-10 pr-4 text-sm text-primary outline-none transition-colors focus:border-brand-300"
|
||||
:placeholder="kb.t('kbWorkspace.documents.searchPlaceholder')"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
v-if="kb.documentKeyword"
|
||||
type="button"
|
||||
@click="kb.documentKeyword = ''"
|
||||
class="inline-flex items-center rounded-xl border border-default bg-surface px-3 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.documents.clearSearch') }}
|
||||
</button>
|
||||
<label class="inline-flex items-center gap-2">
|
||||
<span>{{ kb.t('kbWorkspace.common.perPage') }}</span>
|
||||
<select
|
||||
v-model.number="kb.documentListPageSize"
|
||||
class="rounded-xl border border-default bg-surface px-3 py-1.5 text-sm text-secondary outline-none transition-colors focus:border-brand-300"
|
||||
>
|
||||
<option v-for="size in kb.DOCUMENT_PAGE_SIZE_OPTIONS" :key="size" :value="size">{{ size }}</option>
|
||||
</select>
|
||||
<span>{{ kb.t('kbWorkspace.common.countUnit') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-3 border-t border-default pt-3 lg:flex-row lg:items-center lg:justify-between">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
@click="kb.toggleSelectAllFiltered"
|
||||
class="inline-flex items-center gap-2 rounded-full border border-default bg-surface px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
>
|
||||
{{ kb.isAllFilteredSelected ? kb.t('kbWorkspace.pathUpload.deselectAllFiltered') : kb.t('kbWorkspace.pathUpload.selectAllFiltered') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.isKbAdmin"
|
||||
@click="kb.handleBatchClean"
|
||||
@@ -370,17 +306,52 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
<Trash2 class="h-4 w-4" />
|
||||
{{ kb.batchActionLabel('delete', kb.batchSubmitting, kb.selectedDocuments.length) }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.openPathUploadHistoryModal()"
|
||||
class="inline-flex items-center gap-2 rounded-full border border-default bg-surface px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
>
|
||||
<FileText class="h-4 w-4" />
|
||||
{{ kb.t('kbWorkspace.documents.historyBatches') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm text-muted">
|
||||
<span>{{ kb.t('kbWorkspace.documents.selectedCount', { selected: kb.selectedDocuments.length, total: kb.filteredDocuments.length }) }}</span>
|
||||
<span v-if="kb.filteredDocuments.length > 0">{{ kb.t('kbWorkspace.documents.showingRange', { start: kb.pagedDocumentRange.start, end: kb.pagedDocumentRange.end }) }}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm text-muted">
|
||||
<label class="relative w-full max-w-md">
|
||||
<Search class="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted" />
|
||||
<input
|
||||
v-model.trim="kb.documentKeyword"
|
||||
type="text"
|
||||
class="w-full rounded-2xl border border-default bg-surface py-2.5 pl-10 pr-4 text-sm text-primary outline-none transition-colors focus:border-brand-300"
|
||||
:placeholder="kb.t('kbWorkspace.documents.searchPlaceholder')"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
v-if="kb.documentKeyword"
|
||||
type="button"
|
||||
@click="kb.documentKeyword = ''"
|
||||
class="inline-flex items-center rounded-xl border border-default bg-surface px-3 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.documents.clearSearch') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3 border-t border-default pt-3 xl:flex-row xl:items-center xl:justify-between">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
@click="kb.toggleSelectAllFiltered"
|
||||
class="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-muted transition-colors hover:bg-surface hover:text-brand-600"
|
||||
:class="kb.isAllFilteredSelected ? 'bg-brand-50 text-brand-600' : ''"
|
||||
:title="kb.isAllFilteredSelected ? kb.t('kbWorkspace.pathUpload.deselectAllFiltered') : kb.t('kbWorkspace.pathUpload.selectAllFiltered')"
|
||||
:aria-label="kb.isAllFilteredSelected ? kb.t('kbWorkspace.pathUpload.deselectAllFiltered') : kb.t('kbWorkspace.pathUpload.selectAllFiltered')"
|
||||
>
|
||||
<SquareCheck class="h-[18px] w-[18px]" />
|
||||
</button>
|
||||
<button
|
||||
v-for="tab in kb.stageFilterTabs.filter((item) => item.key !== 'all')"
|
||||
:key="tab.key"
|
||||
@click="kb.documentStageFilter = kb.documentStageFilter === tab.key ? 'all' : tab.key"
|
||||
class="inline-flex items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium transition-colors"
|
||||
:class="kb.documentStageFilter === tab.key
|
||||
? 'border-brand-200 bg-brand-50 text-brand-700'
|
||||
: 'border-default bg-surface text-secondary hover:bg-surface-soft'"
|
||||
>
|
||||
<span>{{ tab.label }}</span>
|
||||
<span class="rounded-full bg-surface-soft px-2 py-0.5 text-xs">{{ tab.count }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -403,121 +374,111 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
? 'border-brand-200 bg-brand-50/50 border-brand-200'
|
||||
: 'border-default'"
|
||||
>
|
||||
<div class="grid gap-3 xl:grid-cols-[minmax(0,1.3fr)_minmax(360px,0.9fr)_auto] xl:items-center">
|
||||
<div class="flex min-w-0 gap-3">
|
||||
<label class="mt-1 inline-flex shrink-0 cursor-pointer items-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
|
||||
:checked="kb.selectedDocumentIds.includes(doc.id)"
|
||||
@change="kb.toggleDocumentSelection(doc.id)"
|
||||
/>
|
||||
</label>
|
||||
<div class="min-w-0 flex-1">
|
||||
<button
|
||||
@click="kb.openMarkdownEditor(doc)"
|
||||
class="block max-w-full truncate text-left font-semibold text-primary transition-colors hover:text-brand-600 hover:text-brand-600"
|
||||
>
|
||||
{{ kb.getDocumentDisplayTitle(doc) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@click="kb.openSourceInfo(doc)"
|
||||
class="mt-1 block max-w-full truncate text-left text-sm text-muted transition-colors hover:text-brand-600 hover:text-brand-600"
|
||||
>
|
||||
{{ kb.getDocumentDisplayDescription(doc) }}
|
||||
</button>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted">
|
||||
<span>{{ kb.t('kbWorkspace.documents.versionCount', { count: doc.version_count ?? 0 }) }}</span>
|
||||
<span v-if="doc.latest_version">{{ kb.t('kbWorkspace.documents.currentVersion', { version: doc.latest_version.version_no }) }}</span>
|
||||
<div class="space-y-3">
|
||||
<div class="grid gap-3 lg:grid-cols-[minmax(360px,1fr)_auto] lg:items-start">
|
||||
<div class="flex min-w-0 gap-3">
|
||||
<label class="mt-1 inline-flex shrink-0 cursor-pointer items-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
|
||||
:checked="kb.selectedDocumentIds.includes(doc.id)"
|
||||
@change="kb.toggleDocumentSelection(doc.id)"
|
||||
/>
|
||||
</label>
|
||||
<div class="min-w-0 flex-1">
|
||||
<button
|
||||
@click="kb.openMarkdownEditor(doc)"
|
||||
class="block max-w-full truncate text-left font-semibold text-primary transition-colors hover:text-brand-600 hover:text-brand-600"
|
||||
>
|
||||
{{ kb.getDocumentDisplayTitle(doc) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="doc.latest_version"
|
||||
type="button"
|
||||
@click="kb.openSourceInfo(doc)"
|
||||
class="max-w-full truncate text-xs text-muted underline-offset-2 transition-colors hover:text-brand-600 hover:underline hover:text-brand-600"
|
||||
class="mt-1 block max-w-full truncate text-left text-sm text-muted transition-colors hover:text-brand-600 hover:text-brand-600"
|
||||
>
|
||||
{{ doc.latest_version.source_file_name }}
|
||||
{{ kb.getDocumentDisplayDescription(doc) }}
|
||||
</button>
|
||||
<span>{{ kb.t('kbWorkspace.documents.updatedAt', { time: kb.formatDateTime(doc.updated_at) }) }}</span>
|
||||
<div class="mt-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted">
|
||||
<span class="shrink-0">{{ kb.t('kbWorkspace.documents.versionCount', { count: doc.version_count ?? 0 }) }}</span>
|
||||
<span v-if="doc.latest_version" class="shrink-0">{{ kb.t('kbWorkspace.documents.currentVersion', { version: doc.latest_version.version_no }) }}</span>
|
||||
<button
|
||||
v-if="doc.latest_version"
|
||||
type="button"
|
||||
@click="kb.openSourceInfo(doc)"
|
||||
class="min-w-0 max-w-full truncate text-xs text-muted underline-offset-2 transition-colors hover:text-brand-600 hover:underline hover:text-brand-600"
|
||||
>
|
||||
{{ doc.latest_version.source_file_name }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="kb.getDocumentWorkflowState(doc).primaryError"
|
||||
class="mt-1 max-w-xl text-xs text-rose-500"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.failureReason', { reason: kb.getDocumentWorkflowState(doc).primaryError }) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-2 lg:justify-end">
|
||||
<button
|
||||
@click="kb.openDocumentDetail(doc.id)"
|
||||
class="inline-flex shrink-0 items-center gap-1 rounded-xl border border-violet-200 px-3 py-2 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-50"
|
||||
>
|
||||
<FileText class="h-3.5 w-3.5" />
|
||||
{{ kb.t('kbWorkspace.documents.viewRecord') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.triggerUploadForDocument(doc.id)"
|
||||
class="inline-flex shrink-0 items-center gap-1 rounded-xl border border-brand-200 px-3 py-2 text-xs font-medium text-brand-700 transition-colors hover:bg-brand-50 border-brand-200 hover:bg-brand-50"
|
||||
>
|
||||
<Upload class="h-3.5 w-3.5" />
|
||||
{{ kb.t('kbWorkspace.documents.uploadVersion') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.isKbAdmin"
|
||||
@click="kb.handleSyncDocument(doc.id)"
|
||||
:disabled="kb.syncingDocumentId === doc.id || !doc.latest_version"
|
||||
class="inline-flex shrink-0 items-center gap-1 rounded-xl border border-emerald-200 px-3 py-2 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50 disabled:cursor-not-allowed disabled:opacity-60 border-emerald-200"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ kb.syncingDocumentId === doc.id ? kb.t('kbWorkspace.documents.syncingDify') : kb.t('kbWorkspace.documents.syncDify') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.handleDeleteDocument(doc)"
|
||||
class="inline-flex shrink-0 items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 border-rose-200 hover:bg-rose-50"
|
||||
>
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
{{ kb.t('kbWorkspace.common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-3 border-t border-default pt-3 lg:grid-cols-[minmax(260px,1fr)_auto] lg:items-center">
|
||||
<span class="min-w-0 text-xs text-muted">
|
||||
{{ kb.t('kbWorkspace.documents.updatedAt', { time: kb.formatDateTime(doc.updated_at) }) }}
|
||||
</span>
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-2 lg:justify-end">
|
||||
<div
|
||||
v-if="kb.getDocumentWorkflowState(doc).primaryError"
|
||||
class="mt-1 max-w-xl text-xs text-rose-500"
|
||||
v-for="badge in kb.getWorkflowBadges(doc)"
|
||||
:key="`${doc.id}-${badge.label}`"
|
||||
class="inline-flex shrink-0 items-center rounded-full border px-3 py-1 text-xs font-semibold"
|
||||
:class="badge.className"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.failureReason', { reason: kb.getDocumentWorkflowState(doc).primaryError }) }}
|
||||
{{ badge.label }}:{{ badge.value }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2 xl:justify-end">
|
||||
<div
|
||||
v-for="badge in kb.getWorkflowBadges(doc)"
|
||||
:key="`${doc.id}-${badge.label}`"
|
||||
class="inline-flex items-center rounded-full border px-3 py-1 text-xs font-semibold"
|
||||
:class="badge.className"
|
||||
>
|
||||
{{ badge.label }}:{{ badge.value }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2 xl:justify-end">
|
||||
<button
|
||||
@click="kb.openDocumentDetail(doc.id)"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-violet-200 px-3 py-2 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-50"
|
||||
>
|
||||
<FileText class="h-3.5 w-3.5" />
|
||||
{{ kb.t('kbWorkspace.documents.viewRecord') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.triggerUploadForDocument(doc.id)"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-brand-200 px-3 py-2 text-xs font-medium text-brand-700 transition-colors hover:bg-brand-50 border-brand-200 hover:bg-brand-50"
|
||||
>
|
||||
<Upload class="h-3.5 w-3.5" />
|
||||
{{ kb.t('kbWorkspace.documents.uploadVersion') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.isKbAdmin"
|
||||
@click="kb.handleSyncDocument(doc.id)"
|
||||
:disabled="kb.syncingDocumentId === doc.id || !doc.latest_version"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-emerald-200 px-3 py-2 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50 disabled:cursor-not-allowed disabled:opacity-60 border-emerald-200"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ kb.syncingDocumentId === doc.id ? kb.t('kbWorkspace.documents.syncingDify') : kb.t('kbWorkspace.documents.syncDify') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.handleDeleteDocument(doc)"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 border-rose-200 hover:bg-rose-50"
|
||||
>
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
{{ kb.t('kbWorkspace.common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
<PaginationBar
|
||||
v-if="kb.filteredDocuments.length > 0"
|
||||
class="flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-default px-4 py-3 "
|
||||
>
|
||||
<div class="text-sm text-muted">
|
||||
{{ kb.t('kbWorkspace.documents.pageInfo', { page: kb.documentListPage, totalPages: kb.filteredDocumentTotalPages, total: kb.filteredDocuments.length }) }}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
@click="kb.documentListPage = Math.max(1, kb.documentListPage - 1)"
|
||||
:disabled="kb.documentListPage === 1"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60 hover-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.prevPage') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.documentListPage = Math.min(kb.filteredDocumentTotalPages, kb.documentListPage + 1)"
|
||||
:disabled="kb.documentListPage === kb.filteredDocumentTotalPages"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60 hover-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.nextPage') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
v-model:page="kb.documentListPage"
|
||||
v-model:page-size="kb.documentListPageSize"
|
||||
:total="kb.filteredDocuments.length"
|
||||
:pages="kb.filteredDocumentTotalPages"
|
||||
:page-size-options="[...kb.DOCUMENT_PAGE_SIZE_OPTIONS]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"kbDifySettings": {
|
||||
"title": "Dify Settings",
|
||||
"subtitle": "Manage Dify connection and default sync parameters for the knowledge base module.",
|
||||
@@ -168,8 +168,8 @@
|
||||
"infoTip": "Basic document entries in this group. Uploading files creates documents and starts cleaning automatically.",
|
||||
"uploadPath": "Upload path",
|
||||
"uploadFile": "Upload file",
|
||||
"batchClean": "Clean data",
|
||||
"batchCleanCount": "Clean data ({count})",
|
||||
"batchClean": "Batch clean",
|
||||
"batchCleanCount": "Batch clean ({count})",
|
||||
"batchSync": "Batch sync",
|
||||
"batchSyncCount": "Batch sync ({count})",
|
||||
"batchDelete": "Batch delete",
|
||||
@@ -390,3 +390,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"kbDifySettings": {
|
||||
"title": "ตั้งค่า Dify",
|
||||
"subtitle": "จัดการการเชื่อมต่อ Dify และค่าซิงค์เริ่มต้นของโมดูลคลังความรู้",
|
||||
@@ -168,8 +168,8 @@
|
||||
"infoTip": "รายการเอกสารพื้นฐานในกลุ่มนี้ การอัปโหลดไฟล์จะสร้างเอกสารและเริ่มทำความสะอาดอัตโนมัติ",
|
||||
"uploadPath": "อัปโหลดจาก path",
|
||||
"uploadFile": "อัปโหลดไฟล์",
|
||||
"batchClean": "ทำความสะอาดข้อมูล",
|
||||
"batchCleanCount": "ทำความสะอาดข้อมูล ({count})",
|
||||
"batchClean": "ทำความสะอาดเป็นชุด",
|
||||
"batchCleanCount": "ทำความสะอาดเป็นชุด ({count})",
|
||||
"batchSync": "ซิงค์เป็นชุด",
|
||||
"batchSyncCount": "ซิงค์เป็นชุด ({count})",
|
||||
"batchDelete": "ลบเป็นชุด",
|
||||
@@ -390,3 +390,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"kbDifySettings": {
|
||||
"title": "Dify 设置",
|
||||
"subtitle": "管理知识库模块使用的 Dify 连接和默认同步参数。",
|
||||
@@ -168,8 +168,8 @@
|
||||
"infoTip": "当前分组下的基础文档条目,上传文件后将自动创建文档并开始清洗流程。",
|
||||
"uploadPath": "上传路径",
|
||||
"uploadFile": "上传文件",
|
||||
"batchClean": "清洗数据",
|
||||
"batchCleanCount": "清洗数据({count})",
|
||||
"batchClean": "批量清洗",
|
||||
"batchCleanCount": "批量清洗({count})",
|
||||
"batchSync": "批量同步",
|
||||
"batchSyncCount": "批量同步({count})",
|
||||
"batchDelete": "批量删除",
|
||||
@@ -390,3 +390,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"kbDifySettings": {
|
||||
"title": "Dify 設定",
|
||||
"subtitle": "管理知識庫模組使用的 Dify 連線和預設同步參數。",
|
||||
@@ -168,8 +168,8 @@
|
||||
"infoTip": "當前分組下的基礎文檔條目,上傳文件後將自動創建文檔並開始清洗流程。",
|
||||
"uploadPath": "上傳路徑",
|
||||
"uploadFile": "上傳文件",
|
||||
"batchClean": "清洗數據",
|
||||
"batchCleanCount": "清洗數據({count})",
|
||||
"batchClean": "批量清洗",
|
||||
"batchCleanCount": "批量清洗({count})",
|
||||
"batchSync": "批量同步",
|
||||
"batchSyncCount": "批量同步({count})",
|
||||
"batchDelete": "批量刪除",
|
||||
@@ -390,3 +390,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user