forked from wangziqi/gongxue-base
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:
@@ -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="选择教师"
|
||||
|
||||
@@ -42,11 +42,6 @@ interface ClassFormValues {
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
interface ClassQueryParams {
|
||||
status?: string;
|
||||
classType?: string;
|
||||
}
|
||||
|
||||
// ---- Constants ----
|
||||
|
||||
const STATUS_MAP: Record<string, { color: string; text: string }> = {
|
||||
|
||||
@@ -226,6 +226,7 @@ const RolesPage: React.FC = () => {
|
||||
</PermissionButton>
|
||||
</div>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={data}
|
||||
rowKey="id"
|
||||
loading={loading}
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user