feat(broadcast): finish multi-role insight experience

This commit is contained in:
2026-07-25 15:18:58 +08:00
parent 7990db6883
commit 230dfb4dfc
20 changed files with 552 additions and 81 deletions
+3
View File
@@ -7,6 +7,7 @@ type ApiResult<T> = {
};
export type BroadcastStatus = 'PUBLISHED' | 'WITHDRAWN';
export type BroadcastInsightStatus = 'NOT_PROCESSED' | 'PENDING' | 'READY' | 'PARTIAL' | 'FAILED';
export type BroadcastTargetRequest = {
projectCodes: string[];
@@ -51,6 +52,8 @@ export type BroadcastAttachment = {
summary?: string;
errorMessage?: string;
downloadUrl?: string;
insightStatus?: BroadcastInsightStatus;
perspectiveLabels?: string[];
};
export type BroadcastAdminPage = {
@@ -15,6 +15,12 @@ describe('公司文件提炼发布契约', () => {
expect(page).toContain('上传并提炼文件');
expect(page).toContain('refreshAttachment');
expect(page).toContain("attachment.value?.status !== 'READY'");
expect(api).toContain('insightStatus?: BroadcastInsightStatus');
expect(api).toContain('perspectiveLabels?: string[]');
expect(page).toContain('多岗位解读');
expect(page).toContain("response.data.insightStatus === 'PENDING'");
expect(page).toContain('attachment.perspectiveLabels?.length');
expect(page).toContain('刷新状态');
expect(page).toContain('attachmentId: form.attachmentId');
expect(pending).toContain('attachmentId?: number');
});
+35 -1
View File
@@ -166,6 +166,18 @@
show-icon
:title="`提炼摘要:${attachment.summary}`"
/>
<div v-if="attachment?.status === 'READY'" class="insight-status-line">
<span>多岗位解读:{{ insightStatusText(attachment.insightStatus) }}</span>
<div v-if="attachment.perspectiveLabels?.length" class="insight-labels">
<el-tag v-for="label in attachment.perspectiveLabels" :key="label" size="small" type="info">{{ label }}</el-tag>
</div>
<el-button
v-if="attachment.insightStatus === 'PENDING'"
link
type="primary"
@click="refreshAttachment(attachment.id)"
>刷新状态</el-button>
</div>
<el-alert
v-if="attachment?.status === 'FAILED'"
type="error"
@@ -673,6 +685,13 @@ const formatFileSize = (bytes: number) => {
if (bytes < 1024 * 1024) return `${Math.max(1, Math.round(bytes / 1024))} KB`;
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
};
const insightStatusText = (status?: BroadcastAttachment['insightStatus']) => ({
NOT_PROCESSED: '未生成',
PENDING: '正在生成',
READY: '已完成',
PARTIAL: '部分完成',
FAILED: '生成失败,不影响发布'
}[status || 'NOT_PROCESSED']);
const stopAttachmentPolling = () => {
if (attachmentPollTimer !== undefined) window.clearTimeout(attachmentPollTimer);
@@ -685,7 +704,9 @@ const refreshAttachment = async (id: number, attemptsLeft = 80) => {
const response = await getBroadcastAttachment(id);
attachment.value = response.data;
form.attachmentId = response.data.id;
if ((response.data.status === 'QUEUED' || response.data.status === 'PROCESSING') && attemptsLeft > 0) {
if ((response.data.status === 'QUEUED'
|| response.data.status === 'PROCESSING'
|| response.data.insightStatus === 'PENDING') && attemptsLeft > 0) {
attachmentPollTimer = window.setTimeout(() => void refreshAttachment(id, attemptsLeft - 1), 1500);
}
} catch {
@@ -820,6 +841,19 @@ onUnmounted(stopAttachmentPolling);
font-size: 12px;
}
.insight-status-line,
.insight-labels {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.insight-status-line {
color: #606266;
font-size: 13px;
}
.table-card {
padding: 18px;
border-radius: 8px;