feat(admin): 弹窗未保存内容保护与空状态引导扩展
- 新增 useDirtyGuard hook:关闭弹窗时若表单被修改,先确认再关闭 - 接入 17 个弹窗:账号/密码/档案、角色、教室、宿舍/床位/柜子、 考勤机、机构、班级、教师、考试、排课、入住/退宿/换房、费用 (子组件弹窗用 useEffect 在回填后快照,时序正确) - 学生列表空状态带「添加学生」引导动作 - 排课创建成功提示「同步钉钉」,考试创建成功提示「去详情录成绩」 aislop scan: 5 引擎 0 issues
This commit is contained in:
@@ -13,6 +13,7 @@ import PermissionButton from '../../components/PermissionButton';
|
||||
import { usePermission } from '../../hooks/usePermission';
|
||||
import { QueryErrorState } from '../../components/QueryState';
|
||||
import { useVisibleRefetch } from '../../hooks/usePageVisible';
|
||||
import { useDirtyGuard } from '../../hooks/useDirtyGuard';
|
||||
|
||||
interface TeacherRow {
|
||||
id: number;
|
||||
@@ -64,6 +65,7 @@ const TeachersPage: React.FC = () => {
|
||||
const [search, setSearch] = useState('');
|
||||
const [profileModal, setProfileModal] = useState<TeacherRow | null>(null);
|
||||
const [form] = Form.useForm<ProfileFormValues>();
|
||||
const profileFormGuard = useDirtyGuard(form);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const {
|
||||
@@ -222,6 +224,7 @@ const TeachersPage: React.FC = () => {
|
||||
joinedAt: r.profile?.joinedAt ? dayjs(r.profile.joinedAt) : null,
|
||||
qualifications: r.profile?.qualifications || '',
|
||||
});
|
||||
profileFormGuard.snapshot();
|
||||
}}
|
||||
>
|
||||
档案
|
||||
@@ -229,7 +232,7 @@ const TeachersPage: React.FC = () => {
|
||||
),
|
||||
},
|
||||
],
|
||||
[saveProfileCell, form],
|
||||
[saveProfileCell, form, profileFormGuard],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -295,7 +298,7 @@ const TeachersPage: React.FC = () => {
|
||||
title={`编辑档案 — ${profileModal?.name || ''}`}
|
||||
open={!!profileModal && canEditTeachers}
|
||||
onOk={canEditTeachers ? handleSaveProfile : undefined}
|
||||
onCancel={() => setProfileModal(null)}
|
||||
onCancel={() => profileFormGuard.confirmClose(() => setProfileModal(null))}
|
||||
okText="保存"
|
||||
confirmLoading={saving}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user