diff --git a/src/components/question-list/index.jsx b/src/components/question-list/index.jsx index 23b2551..4e784f4 100644 --- a/src/components/question-list/index.jsx +++ b/src/components/question-list/index.jsx @@ -123,7 +123,7 @@ const QuestionList = (props) => { const onChangeAction = (item, index) => () => { let { isNotToDetail, difficulty, primaryCategoryId, labelList, pageIndex } = props; - !isNotToDetail && navigate("/brush-question") + !isNotToDetail && navigate("/brush-question/" + item.id) // this.props.history.push( // splicingQuery("/brush-questions", { // id: item?.id, @@ -191,9 +191,10 @@ const QuestionList = (props) => { }} columns={questionColumns} dataSource={questionList} - rowKey={(record) => record.id} + rowKey="id" pagination={false} rowClassName="question-table-row" + /> {/* {total > 10 && ( , }, { - path: "brush-question", + path: "brush-question/:id", element: , }, { diff --git a/src/views/brush-questions/index.tsx b/src/views/brush-questions/index.tsx index 0944fbb..1e16a0d 100644 --- a/src/views/brush-questions/index.tsx +++ b/src/views/brush-questions/index.tsx @@ -1,11 +1,83 @@ import { Pagination, Button, Modal, Input, Radio, message } from 'antd' -import React, { Component, Fragment } from 'react' -import { queryParse } from '@utils' +import React, { Component, Fragment, useState, useEffect } from 'react' +import { useParams } from 'react-router-dom' import GoodCollectionError from '@components/good-collection-error' import './index.less' import req from '@utils/request' -export default class BrushQuestions extends Component { +const grade: Record = { + 1: '初级', + 2: '中级', + 3: '高级', + 4: '资深', + 5: '专家', +} + +const BrushQuestions = () => { + + const { id } = useParams() + const [question, setQuestion] = useState>(null) + const [index, setIndex] = useState(1) + + useEffect(() => { + if (!id) return + req({ + method: 'post', + data: { + id + }, + url: '/querySubjectInfo', + }) + .then((res) => { + if (res.success && res.data) { + setQuestion(res.data) + } + }) + .catch((err) => console.log(err)) + }, [id]) + + return ( + + + + + {index} + 问答题 + + + + { + question ? + + + {grade[question.subjectDifficult]}-{question?.labelName.join('、')} + + {question.subjectName} + + + 参考答案 + + + + + + + : null + } + + ) +} + +export default BrushQuestions + +class BrushQuestions1 extends Component { constructor(props) { super(props) this.state = { @@ -64,7 +136,7 @@ export default class BrushQuestions extends Component { return await req({ method: 'post', data: params, - url: '/admin/question/subject/getSubjectList', + url: '/querySubjectInfo', }) .then((res) => { if (res.data && res.data?.pageList?.length > 0) { diff --git a/src/views/question-bank/index.tsx b/src/views/question-bank/index.tsx index 9b1b70e..c621bcb 100644 --- a/src/views/question-bank/index.tsx +++ b/src/views/question-bank/index.tsx @@ -7,7 +7,6 @@ import RankingList from './components/ranking-list' import { apiName } from './constant'; import req from '@utils/request'; import { Spin } from 'antd'; -import { mockDataList } from './mock'; import './index.less'; const QuestionBank = () => { @@ -132,8 +131,8 @@ const QuestionBank = () => { - + );