统一AI分析入口及双任务安全确认,采用全量载入的可见行渲染,保留完整原文。 右侧非模态详情固定五项质量字段,清理冗余展示并对齐查询和同步按钮。 默认4并发由数据库准入与逐任务租约保护,保留共享限流冷却、截断归因和有界重试。 兼容真实引用标题字段,不伪造证据或准确率,不修改源生产问答与公司区域规则。 验证:完整make verify退出0,710项Go通过、124项已声明可选跳过且必需0跳过; 另全量mirror隔离PostgreSQL race退出0,AI单元race退出0。 真实本地浏览器通过六项交互、390px内滚动及显式AI部分失败/零缺口故障夹具。 治理原生备份已真实恢复,schema57、72表计数与29张QA内容哈希一致。 候选镜像、精确提交CI与正式上线验收待本次提交后执行,不宣称已部署。
This commit is contained in:
+90
-92
@@ -4,13 +4,13 @@ import { useOptionalAuth } from './auth'
|
||||
import { fetchQARecord, fetchAllQARecords, fetchQAStatus, qaCellValue, qaColumns } from './qaOps'
|
||||
import type { QAQuery, QARecord, QARecordPage, QAStatus } from './qaOps'
|
||||
import './qaOps.css'
|
||||
import { ledgerWindow, ledgerCellPreview } from './qaLedgerRendering'
|
||||
import { QARegionalStatistics } from './QADepartmentStatistics'
|
||||
import { QADashboard } from './QADashboard'
|
||||
import { QAWeekly } from './QAWeekly'
|
||||
import { QAQualityEditor } from './QAQuality'
|
||||
import { qaFieldColors, qaTagColumns } from './qaFieldColors'
|
||||
import { qualityLabels } from './qaQuality'
|
||||
import { usageLabels } from './qaUsage'
|
||||
import { QAWeekPicker } from './QAWeekPicker'
|
||||
import { QAAnswerMarkdown } from './QAAnswerMarkdown'
|
||||
import { QAMirrorSync } from './QAMirrorSync'
|
||||
@@ -24,7 +24,7 @@ export function QAOperationsTabs({ view, onChange }: { view: QAOpsView; onChange
|
||||
<nav className="qa-region-tabs" aria-label="问答运营视图">
|
||||
{(
|
||||
[
|
||||
['records', '问题流水'],
|
||||
['records', '问题流水表'],
|
||||
['dashboard', '问题统计看板'],
|
||||
['regions', '区域统计'],
|
||||
['weekly', '周报生成'],
|
||||
@@ -58,12 +58,6 @@ const warningLabels: Record<string, string> = {
|
||||
database_transport_unencrypted: '数据库连接未启用 TLS:上线前须完成传输安全审核',
|
||||
}
|
||||
const stamp = (value: string) => new Date(value).toLocaleString('zh-CN', { hour12: false })
|
||||
const statusLabels: Record<string, string> = {
|
||||
succeeded: '成功',
|
||||
failed: '失败',
|
||||
running: '处理中',
|
||||
cancelled: '已取消',
|
||||
}
|
||||
const sourceCoverageLabels: Record<string, string> = { covered: '已覆盖', uncovered: '未覆盖' }
|
||||
|
||||
function tasksFor(item: QARecord, updates: AIWorkState[] | undefined) {
|
||||
@@ -78,17 +72,21 @@ function tasksFor(item: QARecord, updates: AIWorkState[] | undefined) {
|
||||
const QARow = memo(
|
||||
function QARow({
|
||||
item,
|
||||
rowIndex,
|
||||
tasks,
|
||||
onSelect,
|
||||
}: {
|
||||
item: QARecord
|
||||
rowIndex: number
|
||||
tasks: AIWorkState[]
|
||||
signature: string
|
||||
onSelect: (id: string) => void
|
||||
}) {
|
||||
return (
|
||||
<tr
|
||||
className="qa-ops-record-row"
|
||||
data-qa-row={item.id}
|
||||
aria-rowindex={rowIndex}
|
||||
onDoubleClick={(event) => {
|
||||
if (!(event.target as HTMLElement).closest('button,a,input,select,textarea,summary')) onSelect(item.id)
|
||||
}}
|
||||
@@ -106,26 +104,55 @@ const QARow = memo(
|
||||
className={qaTagColumns.has(key) ? 'qa-field-tag' : key === 'trigger_person' ? 'qa-person-name' : ''}
|
||||
style={qaTagColumns.has(key) ? qaFieldColors(key, qaCellValue(item, key) ?? '—') : undefined}
|
||||
>
|
||||
{qaCellValue(item, key) ?? '—'}
|
||||
{['answer', 'question', 'question_chinese', 'department'].includes(key)
|
||||
? ledgerCellPreview(qaCellValue(item, key) ?? '—')
|
||||
: (qaCellValue(item, key) ?? '—')}
|
||||
</span>
|
||||
</td>
|
||||
))}
|
||||
<td>
|
||||
<button type="button" onClick={() => onSelect(item.id)} aria-label={`查看问答 ${item.id} 的详情`}>
|
||||
详情
|
||||
</button>
|
||||
{item.quality ? <small className="qa-quality-state">{qualityLabels[item.quality.state]}</small> : null}
|
||||
<QAAITaskBadges tasks={tasks} />
|
||||
<div className="qa-ledger-actions">
|
||||
<button type="button" onClick={() => onSelect(item.id)} aria-label={`查看问答 ${item.id} 的详情`}>
|
||||
详情
|
||||
</button>
|
||||
{item.quality ? <small className="qa-quality-state">{qualityLabels[item.quality.state]}</small> : null}
|
||||
<QAAITaskBadges tasks={tasks} />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
},
|
||||
(before, after) =>
|
||||
before.item === after.item && before.signature === after.signature && before.onSelect === after.onSelect
|
||||
before.item === after.item &&
|
||||
before.rowIndex === after.rowIndex &&
|
||||
before.signature === after.signature &&
|
||||
before.onSelect === after.onSelect
|
||||
)
|
||||
|
||||
const ledgerColumnWidth = (key: string) =>
|
||||
['answer', 'question', 'question_chinese'].includes(key)
|
||||
? 320
|
||||
: key === 'asked_at'
|
||||
? 185
|
||||
: key === 'department'
|
||||
? 240
|
||||
: key === 'root_cause'
|
||||
? 155
|
||||
: 125
|
||||
export function QAOperationsView(props: ViewProps) {
|
||||
const page = props.page
|
||||
const scrollRef = useRef<HTMLDivElement>(null)
|
||||
const [viewport, setViewport] = useState({ top: 0, height: 600 })
|
||||
const visible = ledgerWindow(page?.items.length ?? 0, viewport.top, viewport.height)
|
||||
useEffect(() => {
|
||||
const element = scrollRef.current
|
||||
if (!element) return
|
||||
const observer = new ResizeObserver(() =>
|
||||
setViewport({ top: Math.max(0, element.scrollTop - 40), height: element.clientHeight })
|
||||
)
|
||||
observer.observe(element)
|
||||
return () => observer.disconnect()
|
||||
}, [Boolean(page?.items.length)])
|
||||
const columns = qaColumns
|
||||
const updates = useMemo(() => {
|
||||
const map = new Map<string, AIWorkState[]>()
|
||||
@@ -145,7 +172,7 @@ export function QAOperationsView(props: ViewProps) {
|
||||
{props.loading
|
||||
? `正在读取全部问答…${props.progress ? `(${props.progress.loaded} / ${props.progress.total})` : ''}`
|
||||
: page
|
||||
? `共 ${page.total} 条 · 已展示 ${page.items.length} 条`
|
||||
? `共 ${page.total} 条 · 已载入 ${page.items.length} 条`
|
||||
: '尚未读取问答'}
|
||||
</span>
|
||||
<small className="qa-ops-muted">双击行查看详情</small>
|
||||
@@ -167,8 +194,27 @@ export function QAOperationsView(props: ViewProps) {
|
||||
</div>
|
||||
) : null}
|
||||
{page && page.items.length > 0 ? (
|
||||
<div className="qa-ops-table-scroll" aria-label="问答表格滚动区" tabIndex={0}>
|
||||
<table className="qa-ops-table">
|
||||
<div
|
||||
ref={scrollRef}
|
||||
className="qa-ops-table-scroll"
|
||||
aria-label="问答表格滚动区"
|
||||
tabIndex={0}
|
||||
onScroll={(event) => {
|
||||
const element = event.currentTarget
|
||||
setViewport({ top: Math.max(0, element.scrollTop - 40), height: element.clientHeight })
|
||||
}}
|
||||
>
|
||||
<table
|
||||
className="qa-ops-table"
|
||||
aria-rowcount={page.items.length + 1}
|
||||
style={{ width: qaColumns.reduce((sum, c) => sum + ledgerColumnWidth(c.key), 160) }}
|
||||
>
|
||||
<colgroup>
|
||||
{qaColumns.map((c) => (
|
||||
<col key={c.key} style={{ width: ledgerColumnWidth(c.key) }} />
|
||||
))}
|
||||
<col style={{ width: 160 }} />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
{columns.map(({ key, label }) => (
|
||||
@@ -178,18 +224,29 @@ export function QAOperationsView(props: ViewProps) {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{page.items.map((item) => {
|
||||
{visible.padTop > 0 ? (
|
||||
<tr aria-hidden="true" className="qa-ledger-spacer">
|
||||
<td colSpan={columns.length + 1} style={{ height: visible.padTop }} />
|
||||
</tr>
|
||||
) : null}
|
||||
{page.items.slice(visible.start, visible.end).map((item, index) => {
|
||||
const tasks = tasksFor(item, updates.get(item.id))
|
||||
return (
|
||||
<QARow
|
||||
key={item.id}
|
||||
item={item}
|
||||
rowIndex={visible.start + index + 2}
|
||||
tasks={tasks}
|
||||
signature={JSON.stringify(tasks)}
|
||||
onSelect={props.onSelect}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
{visible.padBottom > 0 ? (
|
||||
<tr aria-hidden="true" className="qa-ledger-spacer">
|
||||
<td colSpan={columns.length + 1} style={{ height: visible.padBottom }} />
|
||||
</tr>
|
||||
) : null}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -199,36 +256,13 @@ export function QAOperationsView(props: ViewProps) {
|
||||
|
||||
{showDrawer ? (
|
||||
<>
|
||||
<button
|
||||
className="qa-ops-backdrop"
|
||||
type="button"
|
||||
onClick={props.onCloseDetail}
|
||||
aria-label="关闭问答详情遮罩"
|
||||
/>
|
||||
<aside
|
||||
className="qa-ops-drawer"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-modal="false"
|
||||
aria-label="问答详情"
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'Escape') props.onCloseDetail()
|
||||
if (event.key === 'Tab') {
|
||||
const buttons = Array.from(
|
||||
event.currentTarget.querySelectorAll<HTMLElement>(
|
||||
'button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex="0"]'
|
||||
)
|
||||
)
|
||||
const first = buttons[0],
|
||||
last = buttons[buttons.length - 1]
|
||||
if (event.shiftKey && document.activeElement === first) {
|
||||
event.preventDefault()
|
||||
last?.focus()
|
||||
}
|
||||
if (!event.shiftKey && document.activeElement === last) {
|
||||
event.preventDefault()
|
||||
first?.focus()
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
<header>
|
||||
@@ -237,6 +271,18 @@ export function QAOperationsView(props: ViewProps) {
|
||||
关闭详情
|
||||
</button>
|
||||
</header>
|
||||
{detail ? (
|
||||
<div className="qa-detail-quality" aria-label="固定质量字段">
|
||||
{(['coverage', 'is_correct', 'product_category', 'problem_type', 'root_cause'] as const).map((key) => (
|
||||
<div key={key} data-quality-field={key}>
|
||||
<span>{qaColumns.find((column) => column.key === key)!.label}</span>
|
||||
<strong className="qa-field-tag" style={qaFieldColors(key, qaCellValue(detail, key) ?? '—')}>
|
||||
{qaCellValue(detail, key) ?? '—'}
|
||||
</strong>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
{props.detailLoading ? <p role="status">正在读取完整问答…</p> : null}
|
||||
{props.detailError ? (
|
||||
<p className="error-banner" role="alert">
|
||||
@@ -258,55 +304,7 @@ export function QAOperationsView(props: ViewProps) {
|
||||
{detail.department || '未匹配'}
|
||||
{detail.organization?.department_origin === 'current_directory' ? '(当前通讯录补全)' : ''}
|
||||
</dd>
|
||||
<dt>区域</dt>
|
||||
<dd>
|
||||
{detail.region || '未配置/待核对'}
|
||||
{detail.organization?.region_origin === 'current_directory' ? '(当前配置补全)' : ''}
|
||||
</dd>
|
||||
{detail.organization ? (
|
||||
<>
|
||||
<dt>当前组织关联</dt>
|
||||
<dd>
|
||||
{detail.organization.state === 'matched'
|
||||
? '已关联'
|
||||
: (usageLabels[detail.organization.state] ?? detail.organization.state)}
|
||||
</dd>
|
||||
<dt>当前通讯录部门/区域</dt>
|
||||
<dd>
|
||||
{detail.organization.departments.join(';') || '未匹配'} /{' '}
|
||||
{detail.organization.region || '未配置或待核对'}
|
||||
</dd>
|
||||
<dt>组织版本</dt>
|
||||
<dd>
|
||||
{detail.organization.version.directory_id || '无完整目录'} /{' '}
|
||||
{detail.organization.version.revision_id || '未保存区域配置'}
|
||||
</dd>
|
||||
<dt>源端组织快照</dt>
|
||||
<dd>
|
||||
{detail.organization.source_department || '空'} / {detail.organization.source_region || '空'}
|
||||
</dd>
|
||||
</>
|
||||
) : null}
|
||||
{detail.record_origin ? (
|
||||
<>
|
||||
<dt>记录来源</dt>
|
||||
<dd>
|
||||
{detail.record_origin === 'historical_excel'
|
||||
? '历史 Excel 导入(原标注保留)'
|
||||
: 'DobotAI 2.0 收录副本'}
|
||||
;主表不随源同步覆盖或删除
|
||||
</dd>
|
||||
</>
|
||||
) : null}
|
||||
<dt>问答状态</dt>
|
||||
<dd>{statusLabels[detail.status] ?? detail.status}</dd>
|
||||
<dt>流程触发人员信息</dt>
|
||||
<dd>{qaCellValue(detail, 'trigger_person') || '未记录'}</dd>
|
||||
</dl>
|
||||
<details>
|
||||
<summary>原始人员信息</summary>
|
||||
<pre>{detail.master_fields?.trigger_person ?? detail.trigger_person ?? '未记录'}</pre>
|
||||
</details>
|
||||
<h4>原始问题</h4>
|
||||
<div className="qa-ops-full-text">{detail.question || '无文本问题'}</div>
|
||||
<h4>AI答案</h4>
|
||||
@@ -582,7 +580,7 @@ export function QAOperations() {
|
||||
onChange={(e) => setDraft({ ...draft, keyword: e.target.value })}
|
||||
/>
|
||||
</label>
|
||||
<button type="submit" disabled={loading}>
|
||||
<button className="qa-query-action" type="submit" disabled={loading}>
|
||||
查询
|
||||
</button>
|
||||
<QAMirrorSync
|
||||
|
||||
Reference in New Issue
Block a user