|
|
@ -1,9 +1,10 @@ |
|
|
|
import React, { Component } from "react"; |
|
|
|
import React, { Component } from "react"; |
|
|
|
import { Form, Input, Button, Radio, Checkbox, Select, message } from "antd"; |
|
|
|
import {Form, Input, Button, Radio, Checkbox, Select, message, Modal} from "antd"; |
|
|
|
import { dictionary } from "api/dict/index"; |
|
|
|
import { dictionary } from "api/dict/index"; |
|
|
|
import { addQuestion, findIndustry } from "api/question"; |
|
|
|
import { addQuestion, findIndustry } from "api/question"; |
|
|
|
import { CloseCircleOutlined } from '@ant-design/icons'; |
|
|
|
import { CloseCircleOutlined } from '@ant-design/icons'; |
|
|
|
import * as XLSX from "xlsx"; |
|
|
|
import * as XLSX from "xlsx"; |
|
|
|
|
|
|
|
import {addExamPaper} from "../../api/examPaper"; |
|
|
|
|
|
|
|
|
|
|
|
const { Option } = Select; |
|
|
|
const { Option } = Select; |
|
|
|
|
|
|
|
|
|
|
@ -136,37 +137,44 @@ class QuestionAdd extends Component<any, States> { |
|
|
|
this.formRef.current.validateFields().then((values: any) => { |
|
|
|
this.formRef.current.validateFields().then((values: any) => { |
|
|
|
const questions: any = []; |
|
|
|
const questions: any = []; |
|
|
|
const { formIds } = this.state; |
|
|
|
const { formIds } = this.state; |
|
|
|
|
|
|
|
Modal.confirm({ |
|
|
|
|
|
|
|
title: `确认保存`, |
|
|
|
|
|
|
|
content: `是否保存试题?`, |
|
|
|
|
|
|
|
onOk: async () => { |
|
|
|
|
|
|
|
formIds.forEach((formId) => { |
|
|
|
|
|
|
|
let answer = values[`answer_${formId}`]; |
|
|
|
|
|
|
|
if (Array.isArray(answer)) { |
|
|
|
|
|
|
|
answer.sort(); |
|
|
|
|
|
|
|
answer = answer.join(","); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
formIds.forEach((formId) => { |
|
|
|
questions.push({ |
|
|
|
let answer = values[`answer_${formId}`]; |
|
|
|
questionTypes: values[`questionTypes_${formId}`], |
|
|
|
if (Array.isArray(answer)) { |
|
|
|
industryId: values[`industryId_${formId}`], |
|
|
|
answer.sort(); |
|
|
|
serviceTypeId: values[`serviceTypeId_${formId}`], |
|
|
|
answer = answer.join(","); |
|
|
|
questionContent: values[`questionContent_${formId}`], |
|
|
|
} |
|
|
|
optionA: values[`optionA_${formId}`], |
|
|
|
|
|
|
|
optionB: values[`optionB_${formId}`], |
|
|
|
|
|
|
|
optionC: values[`optionC_${formId}`], |
|
|
|
|
|
|
|
optionD: values[`optionD_${formId}`], |
|
|
|
|
|
|
|
answer: answer |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
questions.push({ |
|
|
|
addQuestion(questions).then((res) => { |
|
|
|
questionTypes: values[`questionTypes_${formId}`], |
|
|
|
const success = res["success"]; |
|
|
|
industryId: values[`industryId_${formId}`], |
|
|
|
if (success) { |
|
|
|
serviceTypeId: values[`serviceTypeId_${formId}`], |
|
|
|
message.success(`新增成功`); |
|
|
|
questionContent: values[`questionContent_${formId}`], |
|
|
|
this.props.history.push("/questionList"); |
|
|
|
optionA: values[`optionA_${formId}`], |
|
|
|
} else { |
|
|
|
optionB: values[`optionB_${formId}`], |
|
|
|
message.error("新增试题失败,请稍后重试"); |
|
|
|
optionC: values[`optionC_${formId}`], |
|
|
|
} |
|
|
|
optionD: values[`optionD_${formId}`], |
|
|
|
}).catch(() => { |
|
|
|
answer: answer |
|
|
|
message.error("新增试题时发生错误,请检查"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
onCancel: () => { |
|
|
|
addQuestion(questions).then((res) => { |
|
|
|
}, |
|
|
|
const success = res["success"]; |
|
|
|
|
|
|
|
if (success) { |
|
|
|
|
|
|
|
message.success(`新增成功`); |
|
|
|
|
|
|
|
this.props.history.push("/questionList"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
message.error("新增试题失败,请稍后重试"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).catch(() => { |
|
|
|
|
|
|
|
message.error("新增试题时发生错误,请检查"); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|