fix: DEMO_RESUME declared before use

This commit is contained in:
root
2026-10-17 16:08:55 +08:00
parent caa5cac7b7
commit 595be0d928
22 changed files with 113 additions and 116 deletions
+23 -9
View File
@@ -4,7 +4,7 @@ import { Download, Printer, RotateCcw } from 'lucide-react';
import { attachmentList, attachmentThumb, footprintList, gradesOverview, profileGet, profileUpsert } from '@/lib/api';
import type { FootprintRow, ProfileInfo, ZcOverrides } from '@/lib/types';
import { computeZongce, gradeLabel, ZC_DEFAULT_RULES, type ZcRules, type ZcResult } from '@/lib/zongce';
import { Button, Select, useToast } from '@/components/ui';
import { Button, Dialog, Select, useToast } from '@/components/ui';
interface Evidence { recordId: number; title: string; images: string[] }
@@ -72,6 +72,7 @@ export function AssessmentPage() {
const [year, setYear] = useState('');
const [ovMap, setOvMap] = useState<Record<string, ZcOverrides>>({});
const [evidence, setEvidence] = useState<Evidence[]>([]);
const [initOpen, setInitOpen] = useState(false);
useEffect(() => {
if (!stored) return;
@@ -124,13 +125,6 @@ export function AssessmentPage() {
setOvMap(m => ({ ...m, [year]: next }));
void profileUpsert({ info: profile, zongce: { rules, overrides: { ...ovMap, [year]: next } } }).catch(e => toast('error', e.message));
};
const resetOverrides = () => {
const next = { ...ovMap };
delete next[year];
setOvMap(next);
void profileUpsert({ info: profile, zongce: { rules, overrides: next } }).then(() => toast('success', '已恢复自动计算')).catch(e => toast('error', e.message));
};
const termLabel = year === 'all' ? '全部学年' : gradeLabel(year, profile.eduStart);
const exportWord = () => {
@@ -149,8 +143,8 @@ export function AssessmentPage() {
<div className="flex flex-wrap items-center gap-2">
<Select className="w-[190px]" value={year} onChange={e => setYear(e.target.value)}
options={[...Array.from(new Set((gradesQ.data?.semesters ?? []).map(x => x.term.slice(0, 7)))).map(y => ({ value: y, label: gradeLabel(y, profile.eduStart) })), { value: 'all', label: '全部学年' }]} />
<Button variant="secondary" onClick={resetOverrides}><RotateCcw size={13} /> 恢复自动</Button>
<Button variant="secondary" onClick={exportWord}><Download size={13} /> 导出材料</Button>
<Button variant="secondary" onClick={() => setInitOpen(true)}><RotateCcw size={13} /> 初始化</Button>
<Button variant="primary" onClick={() => window.print()}><Printer size={13} /> 打印</Button>
</div>
</div>
@@ -216,6 +210,26 @@ export function AssessmentPage() {
「恢复自动」清除本学年全部手动修正。导出材料前请核对每条加分记录与证明材料一致。
</div>
</div>
<Dialog
open={initOpen}
onClose={() => setInitOpen(false)}
width={440}
title="初始化综测"
footer={<>
<Button variant="ghost" onClick={() => setInitOpen(false)}>取消</Button>
<Button variant="primary" onClick={() => {
const next = { ...ovMap };
delete next[year];
setOvMap(next);
void profileUpsert({ info: profile, zongce: { rules, overrides: next } }).then(() => { setInitOpen(false); toast('success', '已恢复自动计算'); }).catch(e => toast('error', e.message));
}}>恢复自动计算</Button>
</>}>
<div className="text-[12.5px] leading-relaxed text-ink-2">
将清除 <b>{year === 'all' ? '全部学年' : gradeLabel(year, profile.eduStart)}</b> 的全部手动修正
(分值覆盖、操行/诚信分修改),恢复为按细则规则的自动计算结果。
<div className="mt-2 text-ink-3">记录数据与个人信息不受影响。</div>
</div>
</Dialog>
</div>
);
}