fix(admin): repair class, role, and room views

Use the RBAC user endpoint for teacher selection, restore role table columns, correct Ant Design props, and add typed room bed and locker responses.
This commit is contained in:
2026-07-10 14:12:08 +08:00
parent e26a8e816e
commit 50b3608db4
4 changed files with 19 additions and 9 deletions

View File

@@ -286,7 +286,7 @@ const ClassDetailPage: React.FC = () => {
const openTeacherModal = async () => {
try {
const res = await api.get('/users') as UserItem[];
const res = await api.get('/rbac/users') as UserItem[];
setAllUsers(res || []);
setTeacherUserId(undefined);
setTeacherRole('subject_teacher');
@@ -576,7 +576,7 @@ const ClassDetailPage: React.FC = () => {
onOk={handleAddTeacher}
onCancel={() => setTeacherModalOpen(false)}
>
<Space orientation="vertical" style={{ width: '100%' }}>
<Space direction="vertical" style={{ width: '100%' }}>
<Select
style={{ width: '100%' }}
placeholder="选择教师"

View File

@@ -42,11 +42,6 @@ interface ClassFormValues {
notes?: string;
}
interface ClassQueryParams {
status?: string;
classType?: string;
}
// ---- Constants ----
const STATUS_MAP: Record<string, { color: string; text: string }> = {

View File

@@ -226,6 +226,7 @@ const RolesPage: React.FC = () => {
</PermissionButton>
</div>
<Table
columns={columns}
dataSource={data}
rowKey="id"
loading={loading}

View File

@@ -39,6 +39,20 @@ const statusMap: Record<string, { text: string; color: string }> = {
archived: { text: '已归档', color: '#999' },
};
interface BedItem {
id: number;
bedNumber: string;
status: string;
notes?: string | null;
}
interface LockerItem {
id: number;
lockerNumber: string;
status: string;
notes?: string | null;
}
function parseRoomNumber(input: string) {
const cleaned = input.replace(/[(].*?[)]/g, '').trim();
const familyMatch = cleaned.match(/^(\d+)-(\d+)-(\d+)$/);
@@ -166,7 +180,7 @@ const RoomsPage: React.FC = () => {
};
const fetchBeds = useCallback(async (roomId: number) => {
try {
const res = await api.get(`/rooms/${roomId}/beds`);
const res = await api.get<BedItem[]>(`/rooms/${roomId}/beds`);
setBeds(res);
} catch (e: unknown) {
const err = e as { message?: string };
@@ -176,7 +190,7 @@ const RoomsPage: React.FC = () => {
const fetchLockers = useCallback(async (roomId: number) => {
try {
const res = await api.get(`/rooms/${roomId}/lockers`);
const res = await api.get<LockerItem[]>(`/rooms/${roomId}/lockers`);
setLockers(res);
} catch (e: unknown) {
const err = e as { message?: string };