保留复制排版内容与自动保存;列表页的完整明细导出不受影响。
This commit is contained in:
+2
-39
@@ -1,10 +1,9 @@
|
||||
import { useDeferredValue, useEffect, useRef, useState, useSyncExternalStore } from 'react'
|
||||
import type { QAQuery } from './qaOps'
|
||||
import { fetchAllQARecords } from './qaOps'
|
||||
import { currentQAWeekValue, qaDateTimeToISO, qaWeekQueryRange } from './qaWeeks'
|
||||
import { WeeklyDraftEditorModel } from './qaWeeklyDrafts'
|
||||
import { weeklyTransport } from './qaWeeklyDraftAPI'
|
||||
import { buildQAWeeklyCSV, downloadQAWeekly, weeklyQualitySourceLabel } from './qaWeekly'
|
||||
import { weeklyQualitySourceLabel } from './qaWeekly'
|
||||
import { QAAnswerMarkdown } from './QAAnswerMarkdown'
|
||||
import { copyRenderedWeeklyReport } from './qaWeeklyClipboard'
|
||||
import { QAWeeklyMail } from './QAWeeklyMail'
|
||||
@@ -20,9 +19,7 @@ export function QAWeekly({ onBeforeLeave }: Props) {
|
||||
const state = useSyncExternalStore(model.subscribe, model.getSnapshot, model.getSnapshot)
|
||||
const [replaceConfirm, setReplaceConfirm] = useState(false),
|
||||
[reloadConfirm, setReloadConfirm] = useState(false),
|
||||
[periodReset, setPeriodReset] = useState(0),
|
||||
[exporting, setExporting] = useState(false),
|
||||
[exportError, setExportError] = useState('')
|
||||
[periodReset, setPeriodReset] = useState(0)
|
||||
const [copying, setCopying] = useState(false)
|
||||
const [copyFeedback, setCopyFeedback] = useState<{ error: boolean; message: string } | null>(null)
|
||||
const copyBody = useRef<HTMLDivElement>(null)
|
||||
@@ -91,22 +88,6 @@ export function QAWeekly({ onBeforeLeave }: Props) {
|
||||
setCopying(false)
|
||||
}
|
||||
}
|
||||
const csv = async () => {
|
||||
if (exporting) return
|
||||
setExporting(true)
|
||||
setExportError('')
|
||||
try {
|
||||
const range = qaWeekQueryRange(Number(state.week.slice(0, 4)), Number(state.week.slice(6)))
|
||||
const start = typeof source?.start === 'string' ? source.start : qaDateTimeToISO(range.start),
|
||||
end = typeof source?.end === 'string' ? source.end : qaDateTimeToISO(range.end)
|
||||
const page = await fetchAllQARecords({ dataset: 'master', start, end, keyword: '', cursor: '' })
|
||||
downloadQAWeekly(buildQAWeeklyCSV(page), `DobotAI-Questions-${state.week}.csv`, 'text/csv;charset=utf-8')
|
||||
} catch (e) {
|
||||
setExportError(e instanceof Error ? e.message : '明细导出失败')
|
||||
} finally {
|
||||
setExporting(false)
|
||||
}
|
||||
}
|
||||
return (
|
||||
<section className="qa-weekly qa-weekly-editor" aria-label="周报生成" data-weekly-week={state.week}>
|
||||
<header className="qa-weekly-editor-header">
|
||||
@@ -122,7 +103,6 @@ export function QAWeekly({ onBeforeLeave }: Props) {
|
||||
onChange={(week) => {
|
||||
setReplaceConfirm(false)
|
||||
setReloadConfirm(false)
|
||||
setExportError('')
|
||||
void model.switchWeek(week).then((ok) => {
|
||||
if (!ok) setPeriodReset((v) => v + 1)
|
||||
})
|
||||
@@ -162,18 +142,6 @@ export function QAWeekly({ onBeforeLeave }: Props) {
|
||||
{copying ? '正在复制…' : '复制排版内容'}
|
||||
</button>
|
||||
{copyFeedback ? <span role={copyFeedback.error ? 'alert' : 'status'}>{copyFeedback.message}</span> : null}
|
||||
<button
|
||||
type="button"
|
||||
disabled={!state.document}
|
||||
onClick={() =>
|
||||
downloadQAWeekly(state.text, `DobotAI_KB_Weekly_Report_${state.week}.md`, 'text/markdown;charset=utf-8')
|
||||
}
|
||||
>
|
||||
下载 MD
|
||||
</button>
|
||||
<button type="button" disabled={!state.document || exporting || state.busy} onClick={() => void csv()}>
|
||||
{exporting ? '导出中…' : '下载明细 CSV'}
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
<QAWeeklyMail week={state.week} busy={blocked} />
|
||||
@@ -243,11 +211,6 @@ export function QAWeekly({ onBeforeLeave }: Props) {
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
{exportError ? (
|
||||
<p role="alert" className="error-banner">
|
||||
{exportError}
|
||||
</p>
|
||||
) : null}
|
||||
<div ref={copyBody} hidden aria-hidden="true">
|
||||
<QAAnswerMarkdown answer={state.text} />
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,8 @@ describe('weekly report editor surface', () => {
|
||||
expect(html).not.toMatch(new RegExp('<button[^>]*>' + label + '</button>'))
|
||||
expect(html).not.toContain('qa-weekly-mode')
|
||||
expect(html).toContain('复制排版内容')
|
||||
expect(html).toContain('下载 MD')
|
||||
expect(html).not.toContain('下载 MD')
|
||||
expect(html).not.toContain('下载明细 CSV')
|
||||
expect(html).not.toContain('复制 Markdown 原文')
|
||||
expect(html).not.toContain('发送周报')
|
||||
expect(html).not.toContain('发布周报')
|
||||
|
||||
Reference in New Issue
Block a user