修复数据库连接错误,用户组功能待测试

This commit is contained in:
2025-12-21 01:56:54 +08:00
parent 41f7474f2b
commit b5262fc13a
15 changed files with 162 additions and 198 deletions

View File

@@ -76,8 +76,8 @@ const ExamTaskPage = () => {
}, []);
// Watch form values for real-time calculation
const selectedUserIds = Form.useWatch('userIds', form) || [];
const selectedGroupIds = Form.useWatch('groupIds', form) || [];
const selectedUserIds = Form.useWatch<string[]>('userIds', form) || [];
const selectedGroupIds = Form.useWatch<string[]>('groupIds', form) || [];
// Fetch members when groups are selected
useEffect(() => {

View File

@@ -86,7 +86,7 @@ const QuestionManagePage = () => {
setQuestions(response.data);
setPagination(prev => ({
...prev,
total: (response as any).pagination.total
total: (response as any).pagination?.total || response.data.length
}));
// 提取并更新可用的题型和类别列表
@@ -311,6 +311,7 @@ const QuestionManagePage = () => {
'Authorization': localStorage.getItem('survey_admin') ? `Bearer ${JSON.parse(localStorage.getItem('survey_admin') || '{}').token}` : '',
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (!response.ok) {

View File

@@ -24,7 +24,7 @@ const UserGroupManage = () => {
setLoading(true);
try {
const res = await userGroupAPI.getAll();
setGroups(res);
setGroups(res.data);
} catch (error) {
message.error('获取用户组列表失败');
} finally {

View File

@@ -72,7 +72,7 @@ const UserManagePage = () => {
setPagination({
current: page,
pageSize,
total: res.pagination?.total || res.data.length,
total: (res as any).pagination?.total || res.data.length,
});
} catch (error) {
message.error('获取用户列表失败');
@@ -85,7 +85,7 @@ const UserManagePage = () => {
const fetchUserGroups = async () => {
try {
const res = await userGroupAPI.getAll();
setUserGroups(res);
setUserGroups(res.data);
} catch (error) {
console.error('获取用户组失败');
}
@@ -233,7 +233,7 @@ const UserManagePage = () => {
setRecordsPagination({
current: page,
pageSize,
total: res.pagination?.total || res.data.length,
total: (res as any).pagination?.total || res.data.length,
});
} catch (error) {
message.error('获取答题记录失败');