feat: AI PRO 本地 Web 控制台与聚合报表

持久化常驻复用现有 hose-aipro service start(detached + pid 文件、
127.0.0.1:8889),本次只补前端与数据出口,不做端口/K8s 化改造。
是否映射公网由使用者自行决定,工具仍只监听回环地址。

- web/:Vue 3.5 + Vite 6 + TS + vue-router + Tailwind 3 子工程,配置对齐
  本机 twc-approval-go-bridge/web(base /static/、outDir 到后端内嵌目录、
  dev proxy → 8889、hash 路由)。5 个视图:总览、审批会话、规则与要点、
  审计流水、命令终端;统一经 POST /api/cli 调用现有 CLI 能力。
- scripts/build/build-webui.mjs:把 Vite 产物 JS/CSS 内联成单文件 HTML,
  生成 src/packaging/generated/webui.txt。生成物随 git 提交,编译二进制
  与 CI 不需要安装前端依赖;.webui-dist/ 为忽略的中间产物。
- src/packaging/embedded-webui.ts:with { type: text } 内嵌。用 .txt 后缀
  而非 .html,避开 Bun 对 .html 的 HTMLBundle 类型推断导致 tsc 报错。
- src/http/routes.ts:AI Pro daemon 暴露 GET /report(含 /report/* 兜底);
  server.ts 启动日志补控制台地址;hose-use daemon 不暴露该路由。
- src/cli/commands/aipro/report.ts:新增 report --json 聚合命令,一次返回
  场景/规则/会话/要点/流水/授权状态;单据快照等大字段不下发,避免撑爆
  浏览器。命令在统一门禁之后,未激活仍会被拦截。
- 新增 embedded-webui / webui 路由 / report 聚合三组测试;同步
  SKILL.md、README.md、packaging README、.gitignore 与 package.json 脚本。

校验:bun test 1108 pass / 0 fail,bun run check、check:readme 全通过;
编译二进制实测 GET /report 返回 200 且资源全内联(140KB、零外链),
POST /api/cli report --json 返回真实聚合数据(2 场景/3 规则/45 条流水)。

本次不打 tag、不发版,留待 0.9.4。
This commit is contained in:
gitea committed 2026-11-05 19:25:52 +08:00
1 parent b51152276d
commit 36e21e5dc2
34 files changed
+1668 -1

No files matched your search

+69
View File
@@ -0,0 +1,69 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { RouterLink, RouterView, useRoute } from 'vue-router'
import { Activity, ClipboardList, LayoutDashboard, ScrollText, TerminalSquare } from 'lucide-vue-next'
import { getHealth } from './api/client'
const route = useRoute()
const health = ref<Record<string, unknown> | null>(null)
const healthError = ref('')
const nav = [
{ to: '/', label: '总览', icon: LayoutDashboard },
{ to: '/sessions', label: '审批会话', icon: ClipboardList },
{ to: '/rules', label: '规则与要点', icon: Activity },
{ to: '/audit', label: '审计流水', icon: ScrollText },
{ to: '/console', label: '命令终端', icon: TerminalSquare },
]
const online = computed(() => health.value !== null)
onMounted(async () => {
try {
health.value = await getHealth()
} catch (err) {
healthError.value = err instanceof Error ? err.message : String(err)
}
})
</script>
<template>
<div class="min-h-screen flex">
<aside class="w-56 shrink-0 border-r border-border bg-card flex flex-col">
<div class="px-5 py-5 border-b border-border">
<div class="flex items-center gap-2">
<div class="h-8 w-8 rounded-lg bg-accent text-white flex items-center justify-center font-bold">H</div>
<div>
<div class="text-sm font-semibold leading-tight">AI PRO 控制台</div>
<div class="text-xs text-text-muted">本地网关</div>
</div>
</div>
</div>
<nav class="flex-1 px-3 py-4 space-y-1">
<RouterLink
v-for="item in nav"
:key="item.to"
:to="item.to"
class="flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm transition-colors"
:class="route.path === item.to ? 'bg-accent-soft text-accent font-medium' : 'text-text-muted hover:bg-bg'"
>
<component :is="item.icon" :size="16" />
{{ item.label }}
</RouterLink>
</nav>
<div class="px-5 py-4 border-t border-border text-xs text-text-muted space-y-1">
<div class="flex items-center gap-2">
<span class="h-2 w-2 rounded-full" :class="online ? 'bg-success' : 'bg-danger'" />
{{ online ? '网关在线' : '网关不可达' }}
</div>
<div v-if="health?.version">v{{ health.version }}</div>
<div v-if="healthError" class="text-danger">{{ healthError }}</div>
<div class="pt-1 opacity-70">仅监听 127.0.0.1</div>
</div>
</aside>
<main class="flex-1 min-w-0">
<RouterView />
</main>
</div>
</template>
+89
View File
@@ -0,0 +1,89 @@
export interface CliResponse {
success: boolean
stdout: string
stderr: string
exitCode: number
data?: unknown
}
export interface GatewayStatus {
tool: string
version: string
corp: Record<string, unknown> | null
operator: string
ruleEngine: {
scopesCount: number
rulesCount: number
scopes: Array<{ index: number; scope: string; ruleCount: number }>
}
sessions: { total: number; pending: number }
recentLogsCount: number
}
export interface AiProReport {
version: string
generatedAt: string
corp: Record<string, unknown> | null
operator: string
license: Record<string, unknown>
summary: {
scopes: number
rules: number
runs: number
pending: number
findings: number
logs: number
}
scopes: unknown[]
rules: unknown[]
runs: unknown[]
findings: unknown[]
logs: unknown[]
}
/** 统一走本地 daemon 的 CLI 网关;未激活或鉴权失败时抛出可读错误。 */
export async function runCommand<T = unknown>(command: string): Promise<T> {
const response = await fetch('/api/cli', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify({ command }),
})
if (response.status === 401) {
throw new Error('HTTP 服务要求 Bearer Token,请检查 HOSE_HTTP_TOKEN 配置')
}
let payload: CliResponse
try {
payload = (await response.json()) as CliResponse
} catch {
throw new Error(`网关返回无法解析的响应 (HTTP ${response.status})`)
}
if (!response.ok || !payload.success) {
const detail = payload.stderr?.trim() || payload.stdout?.trim()
throw new Error(detail || `命令执行失败 (HTTP ${response.status}, exit ${payload.exitCode})`)
}
if (payload.data !== undefined) return payload.data as T
const raw = payload.stdout?.trim()
if (!raw) return undefined as T
try {
return JSON.parse(raw) as T
} catch {
return raw as unknown as T
}
}
export function getStatus(): Promise<GatewayStatus> {
return runCommand<GatewayStatus>('status --json')
}
export function getReport(): Promise<AiProReport> {
return runCommand<AiProReport>('report --json')
}
export function getVersion(): Promise<Record<string, unknown>> {
return runCommand<Record<string, unknown>>('version --json')
}
export async function getHealth(): Promise<Record<string, unknown>> {
const response = await fetch('/health')
return (await response.json()) as Record<string, unknown>
}
+7
View File
@@ -0,0 +1,7 @@
/// <reference types="vite/client" />
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>
export default component
}
+6
View File
@@ -0,0 +1,6 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import './styles/main.css'
createApp(App).use(router).mount('#app')
+19
View File
@@ -0,0 +1,19 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import OverviewView from '../views/OverviewView.vue'
import SessionsView from '../views/SessionsView.vue'
import RulesView from '../views/RulesView.vue'
import AuditView from '../views/AuditView.vue'
import ConsoleView from '../views/ConsoleView.vue'
// 页面挂在 daemon 的 /report 下,用 hash 模式避免服务端处理前端子路由。
export default createRouter({
history: createWebHashHistory(),
routes: [
{ path: '/', name: 'overview', component: OverviewView },
{ path: '/sessions', name: 'sessions', component: SessionsView },
{ path: '/rules', name: 'rules', component: RulesView },
{ path: '/audit', name: 'audit', component: AuditView },
{ path: '/console', name: 'console', component: ConsoleView },
{ path: '/:pathMatch(.*)*', redirect: '/' },
],
})
+39
View File
@@ -0,0 +1,39 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
color-scheme: light;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
body {
margin: 0;
}
@layer components {
.card {
@apply bg-card border border-border rounded-card shadow-card p-5;
}
.btn {
@apply inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed;
}
.btn-primary {
@apply btn bg-accent text-white hover:bg-accent-hover;
}
.btn-ghost {
@apply btn border border-border bg-white text-text hover:bg-accent-soft;
}
.btn-danger {
@apply btn bg-danger text-white hover:bg-danger-hover;
}
.input {
@apply w-full rounded-lg border border-border bg-white px-3 py-2 text-sm text-text outline-none focus:border-accent;
}
.label {
@apply block text-xs font-medium text-text-muted mb-1;
}
.tag {
@apply inline-flex items-center rounded-md px-2 py-0.5 text-xs font-medium;
}
}
+82
View File
@@ -0,0 +1,82 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { RefreshCw, Search } from 'lucide-vue-next'
import { getReport, runCommand, type AiProReport } from '../api/client'
const report = ref<AiProReport | null>(null)
const error = ref('')
const keyword = ref('')
function row(value: unknown): Record<string, unknown> {
return (value ?? {}) as Record<string, unknown>
}
const filtered = computed(() => {
const rows = (report.value?.logs ?? []) as unknown[]
const kw = keyword.value.trim().toLowerCase()
if (!kw) return rows
return rows.filter((item) => JSON.stringify(item).toLowerCase().includes(kw))
})
async function load() {
error.value = ''
try {
report.value = await getReport()
} catch (err) {
error.value = err instanceof Error ? err.message : String(err)
}
}
async function queryBySn() {
if (!keyword.value.trim()) return
error.value = ''
try {
const result = await runCommand<unknown>(`logs ${keyword.value.trim()} --json --limit=200`)
const rows = Array.isArray(result) ? result : []
if (report.value) report.value = { ...report.value, logs: rows }
} catch (err) {
error.value = err instanceof Error ? err.message : String(err)
}
}
onMounted(load)
</script>
<template>
<div class="p-7 space-y-5 max-w-6xl">
<header class="flex items-start justify-between gap-4">
<div>
<h1 class="text-xl font-semibold">审计流水</h1>
<p class="text-sm text-text-muted mt-1">全链路操作留痕,含网关阻断与裁决记录</p>
</div>
<button class="btn-ghost" @click="load"><RefreshCw :size="15" />刷新</button>
</header>
<div v-if="error" class="card border-danger/30 bg-danger-soft text-danger text-sm whitespace-pre-wrap">{{ error }}</div>
<div class="card flex flex-wrap items-center gap-2">
<input v-model="keyword" class="input max-w-sm" placeholder="按单号检索摘要(本地过滤)" @keydown.enter="queryBySn" />
<button class="btn-ghost" :disabled="!keyword.trim()" @click="queryBySn"><Search :size="15" />按单号查询</button>
<span class="text-xs text-text-muted ml-auto">{{ filtered.length }} 条记录</span>
</div>
<section class="card overflow-x-auto">
<table class="w-full text-sm">
<thead><tr class="text-left text-xs text-text-muted border-b border-border">
<th class="py-2 pr-3">时间</th><th class="py-2 pr-3">动作</th><th class="py-2 pr-3">单号</th><th class="py-2 pr-3">状态</th><th class="py-2 pr-3">裁决</th><th class="py-2">摘要</th>
</tr></thead>
<tbody>
<tr v-for="(log, i) in filtered" :key="i" class="border-b border-border/60 last:border-0">
<td class="py-2 pr-3 text-xs text-text-muted whitespace-nowrap">{{ new Date(Number(row(log).createdAt) || 0).toLocaleString('zh-CN') }}</td>
<td class="py-2 pr-3"><span class="tag bg-accent-soft text-accent">{{ row(log).action }}</span></td>
<td class="py-2 pr-3 font-mono text-xs">{{ row(log).documentSn || '—' }}</td>
<td class="py-2 pr-3"><span class="tag" :class="row(log).status === 'SUCCESS' ? 'bg-success-soft text-success' : row(log).status === 'BLOCKED' ? 'bg-warning-soft text-warning' : 'bg-danger-soft text-danger'">{{ row(log).status }}</span></td>
<td class="py-2 pr-3 text-xs">{{ row(log).decision || '—' }}</td>
<td class="py-2 text-xs text-text-muted">{{ row(log).summary || '—' }}</td>
</tr>
<tr v-if="!filtered.length"><td colspan="6" class="py-6 text-center text-sm text-text-muted">暂无记录</td></tr>
</tbody>
</table>
</section>
</div>
</template>
+57
View File
@@ -0,0 +1,57 @@
<script setup lang="ts">
import { ref } from 'vue'
import { Play, RotateCcw } from 'lucide-vue-next'
import { runCommand } from '../api/client'
const command = ref('status --json')
const output = ref('')
const error = ref('')
const busy = ref(false)
const presets = ['status --json', 'report --json', 'version --json', 'scopes --json', 'rules --json', 'logs --json --limit=20', 'help --json']
async function execute() {
if (!command.value.trim()) return
busy.value = true
error.value = ''
try {
const result = await runCommand<unknown>(command.value.trim())
output.value = typeof result === 'string' ? result : JSON.stringify(result, null, 2)
} catch (err) {
error.value = err instanceof Error ? err.message : String(err)
output.value = ''
} finally {
busy.value = false
}
}
function reset() {
command.value = ''
output.value = ''
error.value = ''
}
</script>
<template>
<div class="p-7 space-y-5 max-w-5xl">
<header>
<h1 class="text-xl font-semibold">命令终端</h1>
<p class="text-sm text-text-muted mt-1">直接调用本地 CLI 网关,覆盖 AI PRO 全部命令能力</p>
</header>
<div class="card space-y-3">
<label class="label">命令(不需要 hose-aipro 前缀,默认追加 --json 由命令自行决定)</label>
<div class="flex gap-2">
<input v-model="command" class="input font-mono" placeholder="status --json" @keydown.enter="execute" />
<button class="btn-primary" :disabled="busy" @click="execute"><Play :size="15" />执行</button>
<button class="btn-ghost" @click="reset"><RotateCcw :size="15" /></button>
</div>
<div class="flex flex-wrap gap-1.5">
<button v-for="preset in presets" :key="preset" class="tag bg-bg border border-border text-text-muted hover:text-accent" @click="command = preset">{{ preset }}</button>
</div>
</div>
<div v-if="error" class="card border-danger/30 bg-danger-soft text-danger text-sm whitespace-pre-wrap">{{ error }}</div>
<pre v-if="output" class="card bg-[#0f172a] text-[#e2e8f0] text-xs overflow-auto max-h-[60vh] whitespace-pre-wrap">{{ output }}</pre>
</div>
</template>
+91
View File
@@ -0,0 +1,91 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { RefreshCw, ShieldCheck, ShieldAlert, Building2, Layers, ScrollText, ClipboardList, Activity } from 'lucide-vue-next'
import { getReport, type AiProReport } from '../api/client'
const report = ref<AiProReport | null>(null)
const error = ref('')
const loading = ref(false)
async function load() {
loading.value = true
error.value = ''
try {
report.value = await getReport()
} catch (err) {
error.value = err instanceof Error ? err.message : String(err)
} finally {
loading.value = false
}
}
onMounted(load)
</script>
<template>
<div class="p-7 space-y-6 max-w-6xl">
<header class="flex items-start justify-between gap-4">
<div>
<h1 class="text-xl font-semibold">运行总览</h1>
<p class="text-sm text-text-muted mt-1">AI PRO 确定性审批网关的本地运行态与审计概览</p>
</div>
<button class="btn-ghost" :disabled="loading" @click="load">
<RefreshCw :size="15" :class="loading ? 'animate-spin' : ''" /> 刷新
</button>
</header>
<div v-if="error" class="card border-danger/30 bg-danger-soft text-danger text-sm whitespace-pre-wrap">{{ error }}</div>
<template v-if="report">
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3">
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><Layers :size="14" />规约场景</div><div class="text-2xl font-semibold mt-2">{{ report.summary.scopes }}</div></div>
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><Activity :size="14" />仲裁规则</div><div class="text-2xl font-semibold mt-2">{{ report.summary.rules }}</div></div>
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><ClipboardList :size="14" />审批会话</div><div class="text-2xl font-semibold mt-2">{{ report.summary.runs }}</div></div>
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><ClipboardList :size="14" />待决断</div><div class="text-2xl font-semibold mt-2">{{ report.summary.pending }}</div></div>
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><ShieldCheck :size="14" />审核要点</div><div class="text-2xl font-semibold mt-2">{{ report.summary.findings }}</div></div>
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><ScrollText :size="14" />审计流水</div><div class="text-2xl font-semibold mt-2">{{ report.summary.logs }}</div></div>
</div>
<div class="grid md:grid-cols-2 gap-4">
<section class="card space-y-3">
<h2 class="text-sm font-semibold">授权与环境</h2>
<div class="flex items-center gap-2 text-sm">
<ShieldCheck v-if="report.license.activated" :size="16" class="text-success" />
<ShieldAlert v-else :size="16" class="text-danger" />
<span :class="report.license.activated ? 'text-success' : 'text-danger'">
{{ report.license.activated ? '已激活' : '未激活' }}
</span>
<span class="text-text-muted">· v{{ report.version }}</span>
</div>
<div v-if="report.license.activated" class="text-xs text-text-muted space-y-1">
<div>授权对象:{{ report.license.subject }}</div>
<div>到期时间:{{ String(report.license.expiresAt).slice(0, 10) }}</div>
<div>版本上限:v{{ report.license.maxVersion }}</div>
</div>
<div v-else class="text-xs text-danger">{{ report.license.message }}</div>
<div class="border-t border-border pt-3 flex items-center gap-2 text-sm">
<Building2 :size="15" class="text-text-muted" />
{{ report.corp?.name || '未指定企业' }}
<span class="text-xs text-text-muted">{{ report.corp?.id || '' }}</span>
</div>
<div class="text-xs text-text-muted">操作员:{{ report.operator }}</div>
</section>
<section class="card">
<h2 class="text-sm font-semibold mb-3">最近审计流水</h2>
<div v-if="!report.logs.length" class="text-sm text-text-muted">暂无记录</div>
<div v-else class="space-y-2 max-h-64 overflow-auto">
<div v-for="(log, i) in report.logs.slice(0, 8)" :key="i" class="flex items-start gap-2 text-xs border-b border-border pb-2 last:border-0">
<span class="tag bg-accent-soft text-accent shrink-0">{{ (log as Record<string, unknown>).action ?? 'log' }}</span>
<span class="text-text-muted truncate flex-1">{{ (log as Record<string, unknown>).summary ?? (log as Record<string, unknown>).documentSn ?? '—' }}</span>
<span class="text-text-muted shrink-0">{{ String((log as Record<string, unknown>).status ?? '') }}</span>
</div>
</div>
</section>
</div>
<p class="text-xs text-text-muted">数据生成于 {{ report.generatedAt }} · 全部来自本机 SQLite,不上传任何数据</p>
</template>
<div v-else-if="!loading" class="card text-sm text-text-muted">尚未加载数据</div>
</div>
</template>
+116
View File
@@ -0,0 +1,116 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { RefreshCw, Search } from 'lucide-vue-next'
import { getReport, runCommand, type AiProReport } from '../api/client'
const report = ref<AiProReport | null>(null)
const error = ref('')
const pointQuery = ref('1')
const pointResult = ref('')
const checklistSn = ref('')
const checklistResult = ref('')
function row(value: unknown): Record<string, unknown> {
return (value ?? {}) as Record<string, unknown>
}
async function load() {
error.value = ''
try {
report.value = await getReport()
} catch (err) {
error.value = err instanceof Error ? err.message : String(err)
}
}
async function query(target: 'points' | 'checklist') {
try {
const result = await runCommand<unknown>(
target === 'points' ? `points ${pointQuery.value} --json` : `checklist ${checklistSn.value} --json`
)
const text = typeof result === 'string' ? result : JSON.stringify(result, null, 2)
if (target === 'points') pointResult.value = text
else checklistResult.value = text
error.value = ''
} catch (err) {
error.value = err instanceof Error ? err.message : String(err)
}
}
onMounted(load)
</script>
<template>
<div class="p-7 space-y-5 max-w-6xl">
<header class="flex items-start justify-between gap-4">
<div>
<h1 class="text-xl font-semibold">规则与审核要点</h1>
<p class="text-sm text-text-muted mt-1">规约场景库、仲裁规则与单据核验清单</p>
</div>
<button class="btn-ghost" @click="load"><RefreshCw :size="15" />刷新</button>
</header>
<div v-if="error" class="card border-danger/30 bg-danger-soft text-danger text-sm whitespace-pre-wrap">{{ error }}</div>
<div class="grid md:grid-cols-2 gap-4">
<section class="card">
<h2 class="text-sm font-semibold mb-3">规约场景 ({{ report?.summary.scopes ?? 0 }})</h2>
<div class="space-y-1.5 max-h-72 overflow-auto">
<div v-for="(scope, i) in report?.scopes ?? []" :key="i" class="flex items-center justify-between text-sm border-b border-border/60 pb-1.5">
<span>{{ row(scope).scope }}</span>
<span class="text-xs text-text-muted">#{{ row(scope).index }} · {{ row(scope).ruleCount }} 条规则</span>
</div>
</div>
</section>
<section class="card">
<h2 class="text-sm font-semibold mb-3">仲裁规则 ({{ report?.summary.rules ?? 0 }})</h2>
<div class="space-y-2 max-h-72 overflow-auto">
<div v-for="(rule, i) in report?.rules ?? []" :key="i" class="text-xs border-b border-border/60 pb-2">
<div class="flex justify-between text-text-muted"><span>#{{ row(rule).code }} · {{ row(rule).scope }}</span><span>{{ row(rule).status }}</span></div>
<div class="mt-1 text-text whitespace-pre-wrap">{{ row(rule).body }}</div>
</div>
</div>
</section>
</div>
<div class="grid md:grid-cols-2 gap-4">
<section class="card space-y-2">
<h2 class="text-sm font-semibold">查询场景要点</h2>
<div class="flex gap-2">
<input v-model="pointQuery" class="input" placeholder="索引号或场景名" />
<button class="btn-ghost" @click="query('points')"><Search :size="15" /></button>
</div>
<pre v-if="pointResult" class="text-xs bg-bg rounded-lg p-3 overflow-auto max-h-56 whitespace-pre-wrap">{{ pointResult }}</pre>
</section>
<section class="card space-y-2">
<h2 class="text-sm font-semibold">单据核验清单</h2>
<div class="flex gap-2">
<input v-model="checklistSn" class="input" placeholder="单号" />
<button class="btn-ghost" :disabled="!checklistSn" @click="query('checklist')"><Search :size="15" /></button>
</div>
<pre v-if="checklistResult" class="text-xs bg-bg rounded-lg p-3 overflow-auto max-h-56 whitespace-pre-wrap">{{ checklistResult }}</pre>
</section>
</div>
<section v-if="report?.findings.length" class="card">
<h2 class="text-sm font-semibold mb-3">已挂载审核要点 ({{ report.findings.length }})</h2>
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead><tr class="text-left text-xs text-text-muted border-b border-border">
<th class="py-2 pr-3">单号</th><th class="py-2 pr-3">状态</th><th class="py-2 pr-3">严格程度</th><th class="py-2">条款</th>
</tr></thead>
<tbody>
<tr v-for="(f, i) in report?.findings ?? []" :key="i" class="border-b border-border/60 last:border-0">
<td class="py-2 pr-3 font-mono text-xs">{{ row(f).documentSn }}</td>
<td class="py-2 pr-3"><span class="tag" :class="row(f).status === 'PASS' ? 'bg-success-soft text-success' : row(f).status === 'FAIL' ? 'bg-danger-soft text-danger' : 'bg-warning-soft text-warning'">{{ row(f).status }}</span></td>
<td class="py-2 pr-3 text-xs">{{ row(f).strictness }}</td>
<td class="py-2 text-xs text-text-muted">{{ row(f).content }}</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</template>
+106
View File
@@ -0,0 +1,106 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { RefreshCw, Link2, CheckCheck, Gavel, AlertTriangle } from 'lucide-vue-next'
import { getReport, runCommand, type AiProReport } from '../api/client'
const report = ref<AiProReport | null>(null)
const error = ref('')
const notice = ref('')
const busy = ref(false)
const bindSn = ref('')
const bindScope = ref('1')
const reviewSn = ref('')
const reviewPayload = ref('1=PASS')
const decideSn = ref('')
function row(value: unknown): Record<string, unknown> {
return (value ?? {}) as Record<string, unknown>
}
async function load() {
error.value = ''
try {
report.value = await getReport()
} catch (err) {
error.value = err instanceof Error ? err.message : String(err)
}
}
async function execute(command: string, needsConfirm = false) {
if (needsConfirm && !window.confirm('该操作会驱动真实审批流转,确认继续?')) return
busy.value = true
error.value = ''
notice.value = ''
try {
const result = await runCommand<unknown>(command)
notice.value = typeof result === 'string' ? result : JSON.stringify(result, null, 2)
await load()
} catch (err) {
error.value = err instanceof Error ? err.message : String(err)
} finally {
busy.value = false
}
}
onMounted(load)
</script>
<template>
<div class="p-7 space-y-5 max-w-6xl">
<header class="flex items-start justify-between gap-4">
<div>
<h1 class="text-xl font-semibold">审批会话</h1>
<p class="text-sm text-text-muted mt-1">挂载单据、录入事实证据、执行确定性仲裁</p>
</div>
<button class="btn-ghost" :disabled="busy" @click="load"><RefreshCw :size="15" />刷新</button>
</header>
<div v-if="error" class="card border-danger/30 bg-danger-soft text-danger text-sm whitespace-pre-wrap">{{ error }}</div>
<div v-if="notice" class="card border-success/30 bg-success-soft text-success text-xs whitespace-pre-wrap max-h-48 overflow-auto">{{ notice }}</div>
<section class="card">
<h2 class="text-sm font-semibold mb-3">会话列表</h2>
<div v-if="!report?.runs.length" class="text-sm text-text-muted">暂无审批会话</div>
<div v-else class="overflow-x-auto">
<table class="w-full text-sm">
<thead><tr class="text-left text-xs text-text-muted border-b border-border">
<th class="py-2 pr-3">单号</th><th class="py-2 pr-3">会话</th><th class="py-2 pr-3">裁决</th><th class="py-2 pr-3">要点数</th><th class="py-2">创建时间</th>
</tr></thead>
<tbody>
<tr v-for="(run, i) in report?.runs ?? []" :key="i" class="border-b border-border/60 last:border-0">
<td class="py-2 pr-3 font-mono text-xs">{{ row(run).documentSn }}</td>
<td class="py-2 pr-3 text-xs text-text-muted">{{ row(run).shortId || row(run).id }}</td>
<td class="py-2 pr-3"><span class="tag" :class="row(run).decision === 'PENDING' ? 'bg-warning-soft text-warning' : 'bg-success-soft text-success'">{{ row(run).decision }}</span></td>
<td class="py-2 pr-3">{{ row(run).findingsCount }}</td>
<td class="py-2 text-xs text-text-muted">{{ new Date(Number(row(run).createdAt) || 0).toLocaleString('zh-CN') }}</td>
</tr>
</tbody>
</table>
</div>
</section>
<div class="grid md:grid-cols-3 gap-4">
<section class="card space-y-2">
<h2 class="text-sm font-semibold flex items-center gap-2"><Link2 :size="15" />绑定单据</h2>
<label class="label">单号</label><input v-model="bindSn" class="input" placeholder="S26000001" />
<label class="label">场景索引</label><input v-model="bindScope" class="input" placeholder="1" />
<button class="btn-primary w-full mt-2" :disabled="busy || !bindSn" @click="execute(`bind ${bindSn} ${bindScope} --json`)">执行绑定</button>
</section>
<section class="card space-y-2">
<h2 class="text-sm font-semibold flex items-center gap-2"><CheckCheck :size="15" />事实核验</h2>
<label class="label">单号</label><input v-model="reviewSn" class="input" placeholder="S26000001" />
<label class="label">打标表达式</label><input v-model="reviewPayload" class="input font-mono" placeholder="1=PASS; 2=FAIL:证据不足" />
<button class="btn-primary w-full mt-2" :disabled="busy || !reviewSn" @click="execute(`review ${reviewSn} --eval '${reviewPayload}' --json`)">录入证据</button>
</section>
<section class="card space-y-2">
<h2 class="text-sm font-semibold flex items-center gap-2"><Gavel :size="15" />确定性仲裁</h2>
<label class="label">单号</label><input v-model="decideSn" class="input" placeholder="S26000001" />
<p class="text-xs text-warning flex items-start gap-1"><AlertTriangle :size="13" class="mt-0.5 shrink-0" />带 --apply 会驱动真实流转,执行前需二次确认</p>
<button class="btn-danger w-full mt-2" :disabled="busy || !decideSn" @click="execute(`decide ${decideSn} --apply --yes --json`, true)">执行仲裁</button>
</section>
</div>
</div>
</template>