|
|
@@ -9,6 +9,7 @@ import ProList from '@ant-design/pro-list';
|
|
|
import { history } from '@@/core/history';
|
|
|
import CourseImage from '@/assets/img/course_image.png';
|
|
|
import { useLocation } from '@@/exports';
|
|
|
+import { getTeachers } from '@/services/side/SideController';
|
|
|
|
|
|
|
|
|
interface SideMenuProps {
|
|
|
@@ -21,30 +22,9 @@ function SideMenu ({
|
|
|
}: SideMenuProps) {
|
|
|
const location = useLocation();
|
|
|
const [isLessionPage, setIsLessionPage] = useState<boolean>(false);
|
|
|
- const [activeKey, setActiveKey] = useState<string | number>('');
|
|
|
- const teacherData = [
|
|
|
- {
|
|
|
- teacherName: '张三',
|
|
|
- schoolName: '清华大学',
|
|
|
- },
|
|
|
- {
|
|
|
- teacherName: '李四',
|
|
|
- schoolName: '北京大学',
|
|
|
- },
|
|
|
- {
|
|
|
- teacherName: '王五',
|
|
|
- schoolName: '南京大学',
|
|
|
- },
|
|
|
- {
|
|
|
- teacherName: '麻六',
|
|
|
- schoolName: '上海大学',
|
|
|
- }
|
|
|
- ].map((item) => ({
|
|
|
- title: item.teacherName,
|
|
|
- description: item.schoolName,
|
|
|
- actions: [],
|
|
|
- avatar: false,
|
|
|
- }));
|
|
|
+ const [activeKey, setActiveKey] = useState<string>('');
|
|
|
+ const [teacherName, setTeacherName] = useState<string>('');
|
|
|
+ const [teacherData, setTeacherData] = useState<API.Teacher[]>([]);
|
|
|
|
|
|
const lessonData = [
|
|
|
{
|
|
|
@@ -87,6 +67,26 @@ function SideMenu ({
|
|
|
}
|
|
|
}, [location.pathname]);
|
|
|
|
|
|
+ async function getTeacherList() {
|
|
|
+ const data: API.SideRes = await getTeachers({
|
|
|
+ teacherName: teacherName,
|
|
|
+ })
|
|
|
+ if (data.code === 200) {
|
|
|
+ setTeacherData(data.data)
|
|
|
+ if (data.data.length > 0) {
|
|
|
+ setActiveKey(data.data[0].teacherName as string)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ const onData = async () => {
|
|
|
+ await getTeacherList()
|
|
|
+ }
|
|
|
+ onData()
|
|
|
+ }, []);
|
|
|
+
|
|
|
+
|
|
|
return (
|
|
|
<div style={{ width: initWidth, height: '100vh' }}>
|
|
|
<div className="side-header">
|
|
|
@@ -125,8 +125,16 @@ function SideMenu ({
|
|
|
参评教师
|
|
|
</div>
|
|
|
<Space direction="horizontal" style={{ padding: '0 10px' }}>
|
|
|
- <Input placeholder="输入教师姓名搜索" />
|
|
|
- <Button icon={<SearchOutlined />} type="primary" />
|
|
|
+ <Input
|
|
|
+ value={teacherName}
|
|
|
+ onChange={(e) => setTeacherName(e.target.value)}
|
|
|
+ placeholder="输入教师姓名搜索"
|
|
|
+ />
|
|
|
+ <Button
|
|
|
+ icon={<SearchOutlined />}
|
|
|
+ type="primary"
|
|
|
+ onClick={getTeacherList}
|
|
|
+ />
|
|
|
</Space>
|
|
|
</div>
|
|
|
)
|
|
|
@@ -142,16 +150,13 @@ function SideMenu ({
|
|
|
onItem={(record) => {
|
|
|
return {
|
|
|
onClick: () => {
|
|
|
- setActiveKey(record.lessonId);
|
|
|
+ console.log(record);
|
|
|
},
|
|
|
};
|
|
|
}}
|
|
|
- rowClassName={(record: { lessonId: string }) =>
|
|
|
- record.lessonId === activeKey ? 'active' : ''
|
|
|
- }
|
|
|
renderItem={(item) => (
|
|
|
<div
|
|
|
- style={{ backgroundColor: '#F8FAFC', cursor: 'pointer', margin: '0 10px' }}
|
|
|
+ style={{ backgroundColor: '#F8FAFC', cursor: 'pointer' }}
|
|
|
onClick={() => {
|
|
|
history.push('/play?courseId=1&lessonId=' + item.lessonId);
|
|
|
}}
|
|
|
@@ -179,24 +184,27 @@ function SideMenu ({
|
|
|
/>
|
|
|
) : (
|
|
|
<ProList<any>
|
|
|
+ className={'list-box'}
|
|
|
pagination={false}
|
|
|
showActions="hover"
|
|
|
onItem={(record) => {
|
|
|
return {
|
|
|
onClick: () => {
|
|
|
- setActiveKey(record.title);
|
|
|
+ setActiveKey(record.teacherName);
|
|
|
},
|
|
|
};
|
|
|
}}
|
|
|
- rowClassName={(record: { title: string }) =>
|
|
|
- record.title === activeKey ? 'active' : ''
|
|
|
+ rowClassName={(record: { teacherName: string }) =>
|
|
|
+ record.teacherName === activeKey ? 'active' : ''
|
|
|
}
|
|
|
metas={{
|
|
|
- title: {},
|
|
|
+ title: {
|
|
|
+ dataIndex: 'teacherName',
|
|
|
+ },
|
|
|
description: {
|
|
|
+ dataIndex: 'schoolName',
|
|
|
render: (text) => <div style={{ textAlign: 'left' }}>{text}</div>,
|
|
|
},
|
|
|
- avatar: {},
|
|
|
}}
|
|
|
dataSource={teacherData}
|
|
|
/>
|