|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import React, { Component } from 'react'; |
|
|
|
|
import { Form, Input, Button, Radio, Checkbox, Select, message, Modal, Table } from 'antd'; |
|
|
|
|
import { getRandomQuestions, addExamPaper, editExamPaper, getExamPaperDetail} from 'api/examPaper'; |
|
|
|
|
import { getRandomQuestions, addExamPaper, editExamPaper, getExamPaperDetail, geIndustryQuestions} from 'api/examPaper'; |
|
|
|
|
import { getList ,findIndustry} from 'api/question'; |
|
|
|
|
import { dictionary } from "../../api/dict"; |
|
|
|
|
import TextArea from "antd/es/input/TextArea"; |
|
|
|
@ -339,6 +339,22 @@ class ExamPaperAdd extends Component<any, States> { |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 题目数量
|
|
|
|
|
compareQuestionCount = async (industryId: string, questionCount: number) => { |
|
|
|
|
if (industryId === null || industryId === undefined || questionCount === null || questionCount === undefined) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
const data = { |
|
|
|
|
industryId: industryId |
|
|
|
|
}; |
|
|
|
|
const res = await geIndustryQuestions(data); |
|
|
|
|
if (res.data) { |
|
|
|
|
const dbCount = res.data; |
|
|
|
|
return questionCount <= dbCount; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
const { |
|
|
|
|
industryDict, |
|
|
|
@ -428,9 +444,22 @@ class ExamPaperAdd extends Component<any, States> { |
|
|
|
|
label="题目数量:" |
|
|
|
|
name="questionCount" |
|
|
|
|
style={{ width: 240 }} |
|
|
|
|
rules={[{ required: true, message: '请输入题目数量' }]} |
|
|
|
|
rules={[ |
|
|
|
|
{ required: true, message: '请输入题目数量' }, |
|
|
|
|
{ |
|
|
|
|
message: '输入的题目数量大于该监管行业可获取的题目数量', |
|
|
|
|
validator: async (_, value) => { |
|
|
|
|
const { industryId } = this.formRef.current.getFieldsValue(); |
|
|
|
|
const isValid= await this.compareQuestionCount(industryId, value); |
|
|
|
|
if (!isValid) { |
|
|
|
|
return Promise.reject(new Error('输入的题目数量大于该监管行业可获取的题目数量')); |
|
|
|
|
} |
|
|
|
|
return Promise.resolve(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
<Input type="number" style={{ textAlign: 'right' }} placeholder="请输入题目数量" min={1} /> |
|
|
|
|
<Input type="number" style={{ textAlign: 'right' }} placeholder="请输入题目数量" min={1} /> |
|
|
|
|
</Form.Item> |
|
|
|
|
<Form.Item |
|
|
|
|
label="总分值:" |
|
|
|
|