试题和试卷代码修改

main
hujunpeng 3 months ago
parent c5862c589d
commit 09876b72ee
  1. 11
      packages/examination/src/views/examPaper/examPaperAdd.tsx
  2. 8
      packages/examination/src/views/examPaper/examPaperList.tsx
  3. 8
      packages/examination/src/views/question/questionList.tsx

@ -206,7 +206,7 @@ class ExamPaperAdd extends Component<any, States> {
// 手动选题 // 手动选题
handleOpenModal = () => { handleOpenModal = () => {
const { questions, selectedQuestionList } = this.state; const { questions, selectedQuestionList } = this.state;
this.formRef.current.validateFields(['industryId']) this.formRef.current.validateFields(['industryId', 'questionCount'])
.then((values: any) => { .then((values: any) => {
const industryId = values.industryId; const industryId = values.industryId;
const questionCount = values.questionCount; const questionCount = values.questionCount;
@ -313,7 +313,6 @@ class ExamPaperAdd extends Component<any, States> {
if (this.formRefSub.current) { if (this.formRefSub.current) {
this.formRefSub.current.resetFields(); this.formRefSub.current.resetFields();
} }
this.formRef.current.setFieldsValue({ questionCount : selectedQuestionList.length });
}; };
// 保存试卷 // 保存试卷
@ -367,7 +366,7 @@ class ExamPaperAdd extends Component<any, States> {
selectedRowKeys, selectedRowKeys,
skipValidation, skipValidation,
questionCountSum, questionCountSum,
total selectedParams
} = this.state; } = this.state;
const changePage = (current: number, pageSize: number) => { const changePage = (current: number, pageSize: number) => {
@ -695,7 +694,7 @@ class ExamPaperAdd extends Component<any, States> {
<div> <div>
<h3 style={{fontWeight: 'bold'}}></h3> <h3 style={{fontWeight: 'bold'}}></h3>
<div style={{textAlign: 'right'}}> <div style={{textAlign: 'right'}}>
{selectedQuestionList.length}/{total} {selectedQuestionList.length}/{selectedParams.questionCount}
</div> </div>
<Table <Table
dataSource={selectedQuestionList} dataSource={selectedQuestionList}
@ -777,6 +776,10 @@ class ExamPaperAdd extends Component<any, States> {
item => !deselectedIds.includes(item.id) item => !deselectedIds.includes(item.id)
); );
if(finalSelectedQuestionList.length > selectedParams.questionCount){
message.warning('选择的问题数量超过了允许的最大题目数量');
return;
}
const selectedRowKeys = finalSelectedQuestionList.map(item => String(item.id)); const selectedRowKeys = finalSelectedQuestionList.map(item => String(item.id));
this.setState({ this.setState({
selectedQuestionList: finalSelectedQuestionList, selectedQuestionList: finalSelectedQuestionList,

@ -323,6 +323,10 @@ class ExamPaperList extends Component<any, States> {
width: 200, width: 200,
render: (record: any) => [ render: (record: any) => [
<span className='mr10 link' onClick={() => { <span className='mr10 link' onClick={() => {
Modal.confirm({
title: `确认修改`,
content: `是否修改试卷?`,
onOk: () => {
this.props.history.push({ this.props.history.push({
pathname: '/examPaperAdd', pathname: '/examPaperAdd',
state: { state: {
@ -330,6 +334,10 @@ class ExamPaperList extends Component<any, States> {
isEdit: "true" isEdit: "true"
} }
}); });
},
onCancel: () => {
},
});
}}></span>, }}></span>,
<span className='mr10 link' onClick={() => { <span className='mr10 link' onClick={() => {
this.props.history.push({ this.props.history.push({

@ -266,10 +266,18 @@ class QuestionList extends Component<any, States> {
this.handleDeleteQuestion(record.id); this.handleDeleteQuestion(record.id);
}}></span>, }}></span>,
<span className="mr10 link" onClick={() => { <span className="mr10 link" onClick={() => {
Modal.confirm({
title: `确认修改`,
content: `是否修改试题?`,
onOk: () => {
this.props.history.push({ this.props.history.push({
pathname: '/questionEdit', pathname: '/questionEdit',
state: { id: record.id } state: { id: record.id }
}); });
},
onCancel: () => {
},
});
}}></span> }}></span>
] ]
}, },

Loading…
Cancel
Save