修正筛选入口位置:五项条件在表头就地选择,保持完整集筛选与无感续载。 统一固定规则:未覆盖一律待确认,原问答/人工模型证据不改写,已覆盖仍保留点踩优先。 验证:行为红绿、前端/Go全套及隔离PostgreSQL全mirror竞态通过;完整本地门禁与原生备份真实恢复通过。
This commit is contained in:
@@ -9,7 +9,9 @@ import { QARegionalStatistics } from './QADepartmentStatistics'
|
||||
import { QADashboard } from './QADashboard'
|
||||
import { QAWeekly } from './QAWeekly'
|
||||
import { QAInlineFields } from './QAInlineFields'
|
||||
import { QAFieldFilters } from './QAFieldFilters'
|
||||
import { QAHeaderFieldFilter, useQAFieldFilterOptions } from './QAFieldFilters'
|
||||
import { editableFieldKeys } from './qaInlineFields'
|
||||
import type { EditableField } from './qaInlineFields'
|
||||
import { buildQAWeeklyCSV, downloadQAWeekly } from './qaWeekly'
|
||||
import { qaFieldColors, qaTagColumns } from './qaFieldColors'
|
||||
import { qualityLabels } from './qaQuality'
|
||||
@@ -40,6 +42,8 @@ export function QAOperationsTabs({ view, onChange }: { view: QAOpsView; onChange
|
||||
)
|
||||
}
|
||||
interface ViewProps {
|
||||
filters?: QAQuery['filters']
|
||||
onFiltersChange?: (value: NonNullable<QAQuery['filters']>) => void
|
||||
taskUpdates?: AIWorkState[]
|
||||
onQualitySaved?: (record: QARecord) => void
|
||||
onReloadDetail?: () => void
|
||||
@@ -143,6 +147,8 @@ const ledgerColumnWidth = (key: string) =>
|
||||
: 125
|
||||
export function QAOperationsView(props: ViewProps) {
|
||||
const page = props.page
|
||||
const items = page?.items ?? []
|
||||
const filterOptions = useQAFieldFilterOptions(Boolean(props.onFiltersChange))
|
||||
const scrollRef = useRef<HTMLDivElement>(null)
|
||||
const [viewport, setViewport] = useState({ top: 0, height: 600 })
|
||||
const visible = ledgerWindow(page?.items.length ?? 0, viewport.top, viewport.height)
|
||||
@@ -150,7 +156,10 @@ export function QAOperationsView(props: ViewProps) {
|
||||
const element = scrollRef.current
|
||||
if (!element) return
|
||||
const observer = new ResizeObserver(() =>
|
||||
setViewport({ top: Math.max(0, element.scrollTop - 40), height: element.clientHeight })
|
||||
setViewport({
|
||||
top: Math.max(0, element.scrollTop - (element.querySelector('thead')?.getBoundingClientRect().height ?? 40)),
|
||||
height: element.clientHeight,
|
||||
})
|
||||
)
|
||||
observer.observe(element)
|
||||
return () => observer.disconnect()
|
||||
@@ -178,6 +187,11 @@ export function QAOperationsView(props: ViewProps) {
|
||||
: '尚未读取问答'}
|
||||
</span>
|
||||
<small className="qa-ops-muted">双击行查看详情</small>
|
||||
{props.onFiltersChange && Object.keys(props.filters ?? {}).length ? (
|
||||
<button type="button" onClick={() => props.onFiltersChange?.({})}>
|
||||
清除字段筛选
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{props.status?.warnings
|
||||
@@ -187,6 +201,14 @@ export function QAOperationsView(props: ViewProps) {
|
||||
{warningLabels[warning] ?? '数据源有待审核的安全告警'}
|
||||
</p>
|
||||
))}
|
||||
{filterOptions.error ? (
|
||||
<p className="error-banner" role="alert">
|
||||
{filterOptions.error}{' '}
|
||||
<button type="button" onClick={filterOptions.retry}>
|
||||
重试选项
|
||||
</button>
|
||||
</p>
|
||||
) : null}
|
||||
{props.error ? (
|
||||
<div className="error-banner" role="alert">
|
||||
{props.error}{' '}
|
||||
@@ -195,7 +217,7 @@ export function QAOperationsView(props: ViewProps) {
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
{page && page.items.length > 0 ? (
|
||||
{items.length > 0 || props.onFiltersChange ? (
|
||||
<div
|
||||
ref={scrollRef}
|
||||
className="qa-ops-table-scroll"
|
||||
@@ -203,12 +225,18 @@ export function QAOperationsView(props: ViewProps) {
|
||||
tabIndex={0}
|
||||
onScroll={(event) => {
|
||||
const element = event.currentTarget
|
||||
setViewport({ top: Math.max(0, element.scrollTop - 40), height: element.clientHeight })
|
||||
setViewport({
|
||||
top: Math.max(
|
||||
0,
|
||||
element.scrollTop - (element.querySelector('thead')?.getBoundingClientRect().height ?? 40)
|
||||
),
|
||||
height: element.clientHeight,
|
||||
})
|
||||
}}
|
||||
>
|
||||
<table
|
||||
className="qa-ops-table"
|
||||
aria-rowcount={page.items.length + 1}
|
||||
aria-rowcount={items.length + 1}
|
||||
style={{ width: qaColumns.reduce((sum, c) => sum + ledgerColumnWidth(c.key), 160) }}
|
||||
>
|
||||
<colgroup>
|
||||
@@ -220,18 +248,36 @@ export function QAOperationsView(props: ViewProps) {
|
||||
<thead>
|
||||
<tr>
|
||||
{columns.map(({ key, label }) => (
|
||||
<th key={key}>{label}</th>
|
||||
<th key={key}>
|
||||
{props.onFiltersChange && editableFieldKeys.includes(key as EditableField) ? (
|
||||
<QAHeaderFieldFilter
|
||||
field={key as EditableField}
|
||||
options={filterOptions.options}
|
||||
value={props.filters ?? {}}
|
||||
onChange={props.onFiltersChange}
|
||||
/>
|
||||
) : (
|
||||
label
|
||||
)}
|
||||
</th>
|
||||
))}
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{!items.length && page && !props.loading && !props.error ? (
|
||||
<tr>
|
||||
<td colSpan={columns.length + 1} className="qa-ops-empty">
|
||||
没有符合条件的问答,请调整表头筛选、时间范围或关键词。
|
||||
</td>
|
||||
</tr>
|
||||
) : null}
|
||||
{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) => {
|
||||
{items.slice(visible.start, visible.end).map((item, index) => {
|
||||
const tasks = tasksFor(item, updates.get(item.id))
|
||||
return (
|
||||
<QARow
|
||||
@@ -490,6 +536,10 @@ export function QAOperations() {
|
||||
setError(reason instanceof Error ? reason.message : '时间格式无效')
|
||||
}
|
||||
}
|
||||
const changeFilters = useCallback((next: NonNullable<QAQuery['filters']>) => {
|
||||
setFilters(next)
|
||||
setQuery((current) => (current ? { ...current, cursor: '', filters: { ...next } } : current))
|
||||
}, [])
|
||||
const select = useCallback(async (id: string) => {
|
||||
detailRequest.current?.abort()
|
||||
returnFocus.current = document.activeElement as HTMLElement | null
|
||||
@@ -611,7 +661,6 @@ export function QAOperations() {
|
||||
<button className="qa-query-action" type="submit">
|
||||
查询
|
||||
</button>
|
||||
<QAFieldFilters value={filters} onChange={setFilters} />
|
||||
<QAMirrorSync
|
||||
onChanged={() => {
|
||||
if (detail || detailLoading) {
|
||||
@@ -666,6 +715,8 @@ export function QAOperations() {
|
||||
/>
|
||||
) : (
|
||||
<QAOperationsView
|
||||
filters={query?.filters ?? filters}
|
||||
onFiltersChange={changeFilters}
|
||||
page={page}
|
||||
status={status}
|
||||
taskUpdates={aiStatus?.recent_tasks}
|
||||
|
||||
Reference in New Issue
Block a user