Compare commits

..

No commits in common. "92a86efe739a7b12c34f9db6126d142c1c8a40ed" and "5582f168c23cc9b0794fd2f1be975f84c9137560" have entirely different histories.

11 changed files with 89 additions and 284 deletions

View File

@ -29,10 +29,6 @@ export function fetchConversation(id: number, offset = 0) {
});
}
export function deleteConversation(id: number) {
return http.delete<ApiResponse<null>>(`/v1/conversations/${id}`);
}
export function sendConversationMessage(
id: number,
content: string,

View File

@ -11,8 +11,6 @@ import {
Search,
} from "@lucide/vue";
import { ref } from "vue";
import { featureFlags } from "@/config/features";
defineProps<{ modelValue: string; loading: boolean; canUpload: boolean }>();
@ -33,13 +31,6 @@ const emit = defineEmits<{
| "voice",
];
}>();
const textarea = ref<HTMLTextAreaElement | null>(null);
function focus() {
textarea.value?.focus();
}
defineExpose({ focus });
const functions: Array<{
title: string;
@ -124,7 +115,6 @@ const functions: Array<{
<Camera :size="16" />
</button>
<textarea
ref="textarea"
:value="modelValue"
rows="1"
placeholder="输入产品参数或问题…"
@ -155,11 +145,7 @@ const functions: Array<{
:key="item.title"
class="function-card"
type="button"
@click="
item.tool === 'assessment' || !item.prompt
? emit('tool', item.tool)
: emit('select', item.prompt)
"
@click="emit('tool', item.tool)"
>
<span class="function-dot" :class="`function-dot--${item.tone}`"></span>
<component :is="item.icon" :size="13" />

View File

@ -258,6 +258,7 @@ function generateReport() {
<b>{{ standard.riskPoint }}</b
><small>{{ standard.rule }} · {{ standard.source }}</small>
</div>
<strong>{{ standard.status }}</strong>
</div>
</template>
<p v-else class="empty">暂无直接匹配规则</p>
@ -316,6 +317,12 @@ function generateReport() {
{{ standard.source || "标准文件.xlsx" }}</small
>
</div>
<strong
:class="{
ok: standard.status === '合规' || standard.status === '打样必测',
}"
>{{ standard.status }}</strong
>
</button>
<p v-if="!data.standards?.length" class="empty">
当前标准库暂无可匹配规则,请补充产品品类、包材或检测指标。
@ -689,6 +696,11 @@ function generateReport() {
color: var(--color-text-faint);
font-size: 9px;
}
.standard-row > strong {
flex: 0 0 auto;
color: var(--color-warning);
font-size: 10px;
}
.solution-standard-row {
display: flex;
width: 100%;
@ -741,6 +753,14 @@ function generateReport() {
color: var(--color-text-faint);
font-size: 10px;
}
.solution-standard-row > strong {
flex: 0 0 auto;
color: var(--color-warning);
font-size: 11px;
}
.solution-standard-row > strong.ok {
color: var(--color-success);
}
.suggestion-list {
margin: 12px 0 0;
padding-left: 18px;

View File

@ -13,10 +13,7 @@ import { computed } from "vue";
import { featureFlags } from "@/config/features";
const emit = defineEmits<{
select: [prompt: string];
tool: [value: "assessment" | "ocr"];
}>();
const emit = defineEmits<{ select: [prompt: string] }>();
const props = defineProps<{ canUpload: boolean }>();
const actions = [
@ -26,7 +23,6 @@ const actions = [
prompt: "帮我评估一款500ml PET瓶洗发水,泵头用祥印的,加工厂博元",
icon: Search,
tone: "blue",
tool: "assessment" as const,
},
{
title: "查供应商",
@ -73,7 +69,6 @@ const actions = [
icon: Camera,
tone: "sky",
requiresUpload: true,
tool: "ocr" as const,
},
...(featureFlags.voiceEntry
? [
@ -95,14 +90,6 @@ const visibleActions = computed(() =>
props.canUpload,
),
);
function handleAction(action: (typeof actions)[number]) {
if ("tool" in action && action.tool) {
emit("tool", action.tool);
return;
}
emit("select", action.prompt);
}
</script>
<template>
@ -120,7 +107,7 @@ function handleAction(action: (typeof actions)[number]) {
:key="action.title"
class="welcome-action"
type="button"
@click="handleAction(action)"
@click="emit('select', action.prompt)"
>
<span class="welcome-action__icon" :class="`tone-${action.tone}`">
<component :is="action.icon" :size="16" />

View File

@ -108,6 +108,13 @@ const standardCategories = computed(() => [
(props.result.standardJudgment ?? []).map((item) => item.category),
),
]);
const pendingStandardCount = computed(
() =>
(props.result.standardJudgment ?? []).filter(
(item) => !["合规", "合格", "达标"].includes(item.status),
).length,
);
function openStandards(category = "all", keyword?: string) {
void router.push({
name: "standards",
@ -280,12 +287,18 @@ function openSupplier() {
{{ standard.source || "标准文件.xlsx" }}</small
>
</div>
<strong :class="{ 'status-action': standard.status !== '待检测' }">{{
standard.status
}}</strong>
</button>
<footer>
<span class="standards-card__engine-icon">↻</span>
<span
><b>双引擎融合:</b
>历史数据(经验引擎)提供风险优先级与相似案例;标准库(规则引擎)给出量化阈值与检测依据。</span
>历史数据(经验引擎)提供风险优先级与相似案例;标准库(规则引擎)给出量化阈值与检测依据。<template
v-if="pendingStandardCount"
>{{ pendingStandardCount }} 项待检标准已加入检测任务清单</template
></span
>
<span class="standards-card__links">
<button
@ -882,6 +895,16 @@ h3 {
font-size: 9px;
}
.standard-row > strong {
flex: 0 0 auto;
color: var(--color-warning);
font-size: 10px;
}
.standard-row > .status-action {
color: var(--color-success);
}
.standards-card__empty,
.case-empty {
margin: 8px 0;

View File

@ -14,18 +14,18 @@ const { user } = storeToRefs(auth);
const router = useRouter();
const route = useRoute();
const navigation = ["对话", "看板", "供应商", "标准库", "报告", "风险项管理"];
const navigation = ["对话", "看板", "供应商", "标准库", "报告", "管理"];
const navigationRoutes: Record<string, string> = {
对话: "assessment",
看板: "overview",
供应商: "supplier",
标准库: "standards",
报告: "report",
风险项管理: "review",
管理: "review",
};
const visibleNavigation = computed(() =>
navigation.filter(
(item) => item !== "风险项管理" || auth.hasPermission("risk_item.review"),
(item) => item !== "管理" || auth.hasPermission("risk_item.review"),
),
);
@ -34,7 +34,7 @@ const routeChunks: Record<string, () => Promise<unknown>> = {
供应商: () => import("@/pages/SupplierProfilePage.vue"),
标准库: () => import("@/pages/StandardsPage.vue"),
报告: () => import("@/pages/ReportPage.vue"),
风险项管理: () => import("@/pages/ReviewPage.vue"),
管理: () => import("@/pages/ReviewPage.vue"),
};
const prefetched = new Set<string>();
function prefetch(item: string) {
@ -67,7 +67,7 @@ function prefetch(item: string) {
(item === '供应商' && route.name === 'supplier') ||
(item === '标准库' && route.name === 'standards') ||
(item === '报告' && route.name === 'report') ||
(item === '风险项管理' && route.name === 'review') ||
(item === '管理' && route.name === 'review') ||
(item === '对话' && route.name === 'assessment'),
}"
@mouseenter="prefetch(item)"

View File

@ -95,18 +95,6 @@ async function openConversation(id: number) {
}
}
async function removeConversation(item: { id: number; title: string }) {
if (!window.confirm(`确定删除会话“${item.title}”吗?删除后无法恢复。`)) return;
try {
await conversationStore.remove(item.id);
if (conversationStore.current === null) {
await router.push({ name: "assessment", query: { new: String(Date.now()) } });
}
} catch {
// The store exposes the request error.
}
}
function searchConversations() {
void conversationStore.loadList(search.value.trim() || undefined);
}
@ -143,15 +131,14 @@ function searchConversations() {
<p v-else-if="!conversations.length" class="sidebar-state">
暂无历史对话
</p>
<div
<button
v-for="item in conversations"
:key="item.id"
class="sidebar-item"
:class="{
'sidebar-item--active': conversationStore.current?.id === item.id,
}"
role="button"
tabindex="0"
type="button"
@click="openConversation(item.id)"
>
<span
@ -161,16 +148,7 @@ function searchConversations() {
></span>
<span v-else class="risk-dot risk-dot--empty"></span>
<span class="sidebar-item__label">{{ item.title }}</span>
<button
type="button"
class="sidebar-item__delete"
title="删除会话"
aria-label="删除会话"
@click.stop="removeConversation(item)"
>
×
</button>
</div>
</section>
<section>
@ -286,32 +264,6 @@ section h2 {
white-space: nowrap;
}
.sidebar-item__delete {
display: none;
width: 22px;
height: 22px;
flex: 0 0 22px;
margin-left: auto;
border: 0;
border-radius: 6px;
background: transparent;
color: var(--color-text-faint);
font-size: 18px;
line-height: 1;
cursor: pointer;
}
.sidebar-item:hover .sidebar-item__delete,
.sidebar-item:focus-within .sidebar-item__delete {
display: inline-grid;
place-items: center;
}
.sidebar-item__delete:hover {
background: var(--color-danger-subtle);
color: var(--color-danger);
}
.risk-dot {
width: 5px;
height: 5px;

View File

@ -220,7 +220,11 @@ function dimensionConclusion(item: {
蝶雅产品部 · 风险预警系统 · 自动生成 · {{ generatedAt }}
</p>
<div class="report-meta">
<span
<span><b>产品/评估对象:</b>{{ report.subjectId }}</span>
><span
><b>供应商:</b
>{{ report.supplierFreq?.supplierName || "未指定" }}</span
><span
><b>报告编号:</b>RP-{{ report.subjectId.slice(0, 8) }}-{{
report.score.toFixed(0)
}}</span

View File

@ -264,8 +264,8 @@ onMounted(() => {
<div class="admin-page">
<header class="admin-header">
<div>
<p class="eyebrow">RISK ITEM CONSOLE</p>
<h1>风险项管理工作台</h1>
<p class="eyebrow">ADMIN CONSOLE</p>
<h1>管理工作台</h1>
<p class="admin-description">风险项录入、审核与数据质量管理</p>
</div>
<div class="admin-header-actions">
@ -692,8 +692,8 @@ onMounted(() => {
><ClipboardCheck :size="16"
/></span>
<div>
<h3>风险项表单录入</h3>
<p>填写风险项并提交审核</p>
<h3>风险项录入</h3>
<p>表单录入并提交审核</p>
</div>
</header>
<button
@ -701,7 +701,7 @@ onMounted(() => {
type="button"
@click="router.push({ name: 'risk-item-entry' })"
>
<Plus :size="14" />新建风险项
<Plus :size="14" />打开录入表单
</button>
</article>
<article
@ -713,20 +713,20 @@ onMounted(() => {
><ImagePlus :size="16"
/></span>
<div>
<h3>风险项 OCR 录入</h3>
<p>识别报告并生成待审核风险项</p>
<h3>OCR 识别录入</h3>
<p>上传检测报告、巡检单或异常报告</p>
</div>
</header>
<button class="tool-link" type="button" @click="ocrOpen = true">
<Upload :size="14" />识别并录入风险项
<Upload :size="14" />开始 OCR 识别
</button>
</article>
<article v-if="featureFlags.voiceEntry" class="tool-card">
<header>
<span class="tool-icon tool-icon--purple"><Mic :size="16" /></span>
<div>
<h3>风险项语音录入</h3>
<p>口述异常并生成待审核风险项</p>
<h3>语音录入</h3>
<p>口述异常信息,自动提取字段</p>
</div>
</header>
<button class="voice-entry" type="button">
@ -742,12 +742,12 @@ onMounted(() => {
><FileSpreadsheet :size="16"
/></span>
<div>
<h3>风险项 Excel 批量导入</h3>
<p>按模板批量生成待审核风险项</p>
<h3>Excel 批量导入</h3>
<p>按模板批量进入审核队列</p>
</div>
</header>
<button class="tool-link" type="button">
<Upload :size="14" />批量导入风险项</button
<Upload :size="14" />上传 Excel 文件</button
><small class="tool-hint">单次最多 1000 条,自动去重校验</small>
</article>
<article class="tool-card config-card">

View File

@ -1,6 +1,6 @@
<script setup lang="ts">
import axios from "axios";
import { computed, nextTick, onActivated, onMounted, ref, watch } from "vue";
import { computed, nextTick, onMounted, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import AssistantComposer from "@/components/assistant/AssistantComposer.vue";
@ -31,7 +31,6 @@ const withdrawingId = ref<number | null>(null);
const prompt = ref("");
const ocrOpen = ref(false);
const scrollArea = ref<HTMLElement | null>(null);
const composer = ref<InstanceType<typeof AssistantComposer> | null>(null);
const tool = ref<
| "assessment"
| "supplier"
@ -45,7 +44,6 @@ const tool = ref<
const toolInput = ref("");
const toolError = ref("");
const toolFile = ref<File | null>(null);
const expandedReplies = ref(new Set<number>());
const assessmentFields = ref({
category: "",
specification: "",
@ -111,12 +109,6 @@ onMounted(async () => {
await openFromRoute();
});
onActivated(async () => {
// MainLayout keeps this page alive. Returning from report/dashboard therefore
// does not remount it, so explicitly reveal the newest message on re-entry.
if (conversation.value?.messages.length) await scrollToBottom("auto");
});
watch(
() => route.query.conversation,
async () => {
@ -124,45 +116,9 @@ watch(
},
);
async function usePrompt(value: string) {
const current = prompt.value.trim();
prompt.value = current ? `${current}\n${value}` : value;
await nextTick();
composer.value?.focus();
}
function toggleReply(messageId: number) {
const next = new Set(expandedReplies.value);
if (next.has(messageId)) next.delete(messageId);
else next.add(messageId);
expandedReplies.value = next;
}
function canCollapseReply(content: string) {
return content.trim().length > 90;
}
function isMessageThinking(messageId: number, index: number) {
const messages = conversation.value?.messages ?? [];
return (
generating.value &&
index === messages.length - 1 &&
messages[index]?.id === messageId &&
messages[index]?.role === "assistant"
);
}
function thinkingDuration(index: number) {
const messages = conversation.value?.messages ?? [];
const message = messages[index];
const previous = messages[index - 1];
if (!message || !previous || previous.role !== "user") return null;
const elapsed = Math.round(
(new Date(message.createdAt).getTime() -
new Date(previous.createdAt).getTime()) /
1000,
);
return elapsed > 0 ? elapsed : null;
function usePrompt(value: string) {
prompt.value = value;
void submit();
}
function openTool(
@ -254,9 +210,14 @@ function submitTool() {
return;
}
closeTool();
void usePrompt(
finalValue || `${selectedTitle}:${toolFile.value?.name ?? "附件"}`,
);
prompt.value =
finalValue || `${selectedTitle}:${toolFile.value?.name ?? "附件"}`;
const messageType = toolFile.value
? selectedTool === "ocr"
? "image"
: "audio"
: "text";
void submit(messageType);
}
function selectFile(event: Event) {
@ -316,11 +277,7 @@ async function openFromRoute() {
const rawId = route.query.conversation;
if (typeof rawId !== "string") return;
const id = Number(rawId);
if (Number.isSafeInteger(id) && id > 0 && conversation.value?.id === id) {
await scrollToBottom("auto");
return;
}
if (Number.isSafeInteger(id) && id > 0) {
if (Number.isSafeInteger(id) && id > 0 && conversation.value?.id !== id) {
try {
await conversationStore.open(id);
await scrollToBottom("auto");
@ -477,11 +434,10 @@ async function scrollToBottom(behavior: "smooth" | "auto" = "smooth") {
v-if="!conversation?.messages.length"
:can-upload="auth.hasPermission('risk_item.submit')"
@select="usePrompt"
@tool="openTool"
/>
<template
v-for="(message, messageIndex) in conversation?.messages ?? []"
v-for="message in conversation?.messages ?? []"
:key="message.id"
>
<div class="message" :class="`message--${message.role}`">
@ -530,72 +486,15 @@ async function scrollToBottom(behavior: "smooth" | "auto" = "smooth") {
>
</div>
<div
v-if="
message.content &&
(message.riskResult ||
message.responseCard ||
isMessageThinking(message.id, messageIndex))
"
class="assistant-thinking"
>
<button
type="button"
class="assistant-thinking__header"
:disabled="
isMessageThinking(message.id, messageIndex) ||
!canCollapseReply(message.content)
"
@click="toggleReply(message.id)"
>
<span v-if="isMessageThinking(message.id, messageIndex)"
>思考中…</span
>
<span v-else>
已完成<span v-if="thinkingDuration(messageIndex)">
{{ thinkingDuration(messageIndex) }}s</span
>
</span>
<span
v-if="canCollapseReply(message.content)"
class="assistant-thinking__arrow"
>{{ expandedReplies.has(message.id) ? "⌄" : "›" }}</span
>
</button>
<div
class="assistant-bubble"
:class="{
'assistant-bubble--collapsed':
canCollapseReply(message.content) &&
!expandedReplies.has(message.id),
}"
>
{{ message.content }}
</div>
</div>
<div
v-else-if="message.content"
class="assistant-bubble"
:class="{
'assistant-bubble--collapsed':
canCollapseReply(message.content) &&
!expandedReplies.has(message.id),
}"
>
{{ message.content }}
</div>
<button
v-if="
message.content &&
!message.riskResult &&
!message.responseCard &&
canCollapseReply(message.content)
!message.responseCard
"
type="button"
class="reply-toggle"
@click="toggleReply(message.id)"
class="assistant-bubble"
>
{{ expandedReplies.has(message.id) ? "收起" : "展开全文" }}
</button>
{{ message.content }}
</div>
<RiskAnalysisCard
v-if="message.riskResult"
:result="message.riskResult"
@ -634,7 +533,6 @@ async function scrollToBottom(behavior: "smooth" | "auto" = "smooth") {
</div>
<AssistantComposer
ref="composer"
v-model="prompt"
:loading="loading"
:can-upload="auth.hasPermission('risk_item.submit')"
@ -842,7 +740,6 @@ async function scrollToBottom(behavior: "smooth" | "auto" = "smooth") {
}
.assistant-bubble {
position: relative;
width: fit-content;
max-width: 82%;
border: 1px solid var(--color-border);
@ -854,54 +751,6 @@ async function scrollToBottom(behavior: "smooth" | "auto" = "smooth") {
line-height: 1.65;
}
.assistant-bubble--collapsed {
display: -webkit-box;
max-height: calc(2 * 1.65em + 22px);
overflow: hidden;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.assistant-thinking {
margin-bottom: 8px;
}
.assistant-thinking__header {
display: flex;
width: auto;
align-items: center;
gap: 5px;
border: 0;
margin: 0 0 5px 2px;
padding: 0;
background: transparent;
color: var(--color-text-muted);
font-size: 11px;
font-family: inherit;
cursor: pointer;
}
.assistant-thinking__header:disabled {
cursor: default;
}
.assistant-thinking__arrow {
color: var(--color-text-faint);
font-size: 15px;
line-height: 1;
}
.reply-toggle {
display: block;
margin-top: 4px;
border: 0;
padding: 0;
background: transparent;
color: var(--color-accent);
font-size: 11px;
cursor: pointer;
}
.semantic-strip {
margin-bottom: 8px;
color: var(--color-text-muted);

View File

@ -3,7 +3,6 @@ import { computed, reactive, ref } from "vue";
import {
createConversation,
deleteConversation,
fetchConversation,
fetchConversations,
withdrawConversationMessage,
@ -133,16 +132,6 @@ export const useConversationStore = defineStore("conversation", () => {
return current.value;
}
async function remove(id: number) {
const active = current.value?.id === id;
await deleteConversation(id);
streamStates.get(id)?.controller.abort();
streamStates.delete(id);
conversationCache.delete(id);
items.value = items.value.filter((item) => item.id !== id);
if (active) current.value = null;
}
async function send(
content: string,
messageType: ConversationMessageType = "text",
@ -439,7 +428,6 @@ export const useConversationStore = defineStore("conversation", () => {
open,
loadOlder,
create,
remove,
send,
streamSend,
stopGeneration,