|
|
|
@ -1,24 +1,31 @@ |
|
|
|
|
<template> |
|
|
|
|
<div> |
|
|
|
|
<el-dialog :title="diaTitle" :visible.sync="quesVisible" :modal-append-to-body="false" width="1000px" |
|
|
|
|
:close-on-click-modal="false" custom-class="ques-dia" @closed="closeDia"> |
|
|
|
|
<el-form :model="form" :rules="rules" ref="form" label-width="110px" :disabled="detailType === 2"> |
|
|
|
|
<div class="page"> |
|
|
|
|
<Breadcrumb :data="crumbs" /> |
|
|
|
|
<p class="page-name mb">试题</p> |
|
|
|
|
<el-form :model="form" :rules="rules" class="input-form model" ref="form" label-width="110px" |
|
|
|
|
:disabled="detailType === 2"> |
|
|
|
|
<div class="item-line"> |
|
|
|
|
<el-form-item label="题库分类"> |
|
|
|
|
<el-input v-model="questionBankCategory" disabled /> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="题库"> |
|
|
|
|
<el-input v-model="questionBankName" disabled /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</div> |
|
|
|
|
<div class="item-line"> |
|
|
|
|
<el-form-item prop="specialtyIds" label="所属专业"> |
|
|
|
|
<el-select v-model="form.specialtyIds" clearable multiple placeholder="请选择所属专业"> |
|
|
|
|
<el-select v-model="form.specialtyIds" clearable multiple filterable placeholder="请选择所属专业"> |
|
|
|
|
<el-option v-for="(item, i) in professionals" :key="i" :label="item.professionalName" |
|
|
|
|
:value="item.professionalId" filter></el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item prop="knowledgePointIds" label="所属知识点"> |
|
|
|
|
<el-cascader placeholder="请选择所属知识点" v-model="form.knowledgePointIds" :options="knowledges" |
|
|
|
|
:props="{ value: 'id', label: 'name', multiple: true, checkStrictly: true }" clearable></el-cascader> |
|
|
|
|
:props="{ value: 'id', label: 'name', multiple: true, checkStrictly: true }" :show-all-levels="false" |
|
|
|
|
clearable></el-cascader> |
|
|
|
|
</el-form-item> |
|
|
|
|
</div> |
|
|
|
|
<div class="item-line"> |
|
|
|
|
<el-form-item prop="givenYear" label="年份"> |
|
|
|
|
<el-date-picker v-model="form.givenYear" type="year" placeholder="请选择年份" format="yyyy" value-format="yyyy"> |
|
|
|
|
</el-date-picker> |
|
|
|
@ -28,6 +35,7 @@ |
|
|
|
|
<el-option v-for="(item, i) in difficults" :key="i" :label="item.name" :value="item.id"></el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
</div> |
|
|
|
|
<el-form-item prop="questionType" label="题型"> |
|
|
|
|
<el-radio-group v-model="form.questionType" @change="questionTypeChange"> |
|
|
|
|
<el-radio v-for="(item, i) in questionTypes" :key="i" :label="item.id">{{ item.name }}</el-radio> |
|
|
|
@ -51,7 +59,7 @@ |
|
|
|
|
<!-- 单选、多选、判断特有 --> |
|
|
|
|
<el-form-item v-if="form.questionType !== 'fill_blank' && form.questionType !== 'essay'" label="正确答案" required> |
|
|
|
|
<div class="opts"> |
|
|
|
|
<div v-for="(item, i) in form.questionAnswerVersions" :key="i" class="line"> |
|
|
|
|
<div v-for="(item, i) in form.questionAnswerVersions" :key="i" class="opt"> |
|
|
|
|
<el-checkbox v-if="form.questionType === 'multiple_choice'" class="correct-check" |
|
|
|
|
v-model="item.answerIsCorrect" :true-label="1">选项{{ numToLetter(i) }}</el-checkbox> |
|
|
|
|
<el-radio v-else v-model="item.answerIsCorrect" :true-label="1" :label="1" @change="correctChange(i)">选项{{ |
|
|
|
@ -75,7 +83,7 @@ |
|
|
|
|
<template v-if="form.questionType === 'fill_blank'"> |
|
|
|
|
<el-form-item label="正确答案" required> |
|
|
|
|
<div class="opts fill-blanks"> |
|
|
|
|
<div v-for="(item, i) in fillBlanks" :key="i" class="line j-between"> |
|
|
|
|
<div v-for="(item, i) in fillBlanks" :key="i" class="opt j-between"> |
|
|
|
|
<div class="fills"> |
|
|
|
|
<span>填空{{ i + 1 }}:</span> |
|
|
|
|
<div v-for="(fill, j) in item.fills" :key="j" class="fill-item"> |
|
|
|
@ -117,7 +125,7 @@ |
|
|
|
|
|
|
|
|
|
<!-- 问答题特有 --> |
|
|
|
|
<template v-if="form.questionType === 'essay'"> |
|
|
|
|
<el-form-item prop="allowAttachment" label="支持学生上传附件" label-width="130px"> |
|
|
|
|
<el-form-item prop="allowAttachment" label="支持学生上传附件" label-width="140px"> |
|
|
|
|
<el-radio-group v-model="form.allowAttachment"> |
|
|
|
|
<el-radio :label="0">否</el-radio> |
|
|
|
|
<el-radio :label="1">是</el-radio> |
|
|
|
@ -143,21 +151,19 @@ |
|
|
|
|
v-model="answerAnalysis" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form> |
|
|
|
|
<span v-if="detailType !== 2" slot="footer" class="dialog-footer"> |
|
|
|
|
<div v-if="detailType !== 2" class="btns"> |
|
|
|
|
<el-button v-if="detailType === 1" type="primary" :loading="submiting && keep === 0" |
|
|
|
|
@click="submit(1)">保存</el-button> |
|
|
|
|
<template v-else> |
|
|
|
|
<el-button type="primary" :loading="submiting && keep === 0" @click="submit(0)">{{ row.questionId ? '仅更新此题' : |
|
|
|
|
<el-button type="primary" :loading="submiting && keep === 0" @click="submit(0)">{{ questionId ? '仅更新此题' : |
|
|
|
|
'保存' |
|
|
|
|
}}</el-button> |
|
|
|
|
<el-button type="primary" :loading="submiting && keep === 1" @click="submit(1)">{{ row.questionId ? '同步更新相似题' |
|
|
|
|
<el-button type="primary" :loading="submiting && keep === 1" @click="submit(1)">{{ questionId ? '同步更新相似题' |
|
|
|
|
: |
|
|
|
|
'保存并继续新增' }}</el-button> |
|
|
|
|
</template> |
|
|
|
|
<el-button @click="quesVisible = false">取消</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
|
|
<el-button @click="back">取消</el-button> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<el-dialog title="提示" :visible.sync="repeatVisible" width="800px" :close-on-click-modal="false"> |
|
|
|
|
<el-alert title="与当前题库中已有的试题重复(如下),是否继续保存?" type="warning" effect="dark" :closable="false" /> |
|
|
|
@ -194,6 +200,7 @@ |
|
|
|
|
<script> |
|
|
|
|
import Setting from '@/setting' |
|
|
|
|
import Util from '@/libs/util' |
|
|
|
|
import Breadcrumb from '@/components/breadcrumb' |
|
|
|
|
import UeditorPlus from '@/components/ueditorPlus' |
|
|
|
|
import Upload from '@/components/upload' |
|
|
|
|
import Oss from '@/components/upload/upload.js' |
|
|
|
@ -201,13 +208,16 @@ import dayjs from 'dayjs' |
|
|
|
|
import _ from 'lodash' |
|
|
|
|
import Const from '@/const/ques' |
|
|
|
|
export default { |
|
|
|
|
props: ['visible', 'row', 'detailType'], |
|
|
|
|
components: { UeditorPlus, Upload }, |
|
|
|
|
components: { Breadcrumb, UeditorPlus, Upload }, |
|
|
|
|
data () { |
|
|
|
|
return { |
|
|
|
|
typeId: this.$route.query.id, // 题库id |
|
|
|
|
crumbs: [], |
|
|
|
|
questionId: this.$route.query.questionId, // 试题id |
|
|
|
|
version: this.$route.query.version, // 试题版本id |
|
|
|
|
questionBankId: this.$route.query.questionBankId, // 题库id |
|
|
|
|
questionBankName: this.$route.query.questionBankName, |
|
|
|
|
questionBankCategory: this.$route.query.questionBankCategory, |
|
|
|
|
detailType: this.$route.query.detailType, |
|
|
|
|
numToLetter: Util.numToLetter, |
|
|
|
|
detailTypes: ['', '复制', '查看', '编辑', '编辑'], |
|
|
|
|
types: [], |
|
|
|
@ -222,9 +232,7 @@ export default { |
|
|
|
|
questionTypes: Const.questionTypes, |
|
|
|
|
knowledges: [], |
|
|
|
|
|
|
|
|
|
editorConfig: { |
|
|
|
|
zIndex: 2500, |
|
|
|
|
}, |
|
|
|
|
editorConfig: {}, |
|
|
|
|
richEditor: { |
|
|
|
|
object: null, |
|
|
|
|
parameterName: '', |
|
|
|
@ -249,7 +257,7 @@ export default { |
|
|
|
|
questionAnswerVersions: [], |
|
|
|
|
questionBankId: '', |
|
|
|
|
questionType: 'single_choice', |
|
|
|
|
specialtyIds: [1], |
|
|
|
|
specialtyIds: [], |
|
|
|
|
stem: '', |
|
|
|
|
allowAttachment: 0, |
|
|
|
|
stemAttachment: '', |
|
|
|
@ -267,7 +275,6 @@ export default { |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
templateVisible: false, |
|
|
|
|
quesVisible: false, |
|
|
|
|
submiting: false, |
|
|
|
|
tempForm: {}, |
|
|
|
|
keep: 0, |
|
|
|
@ -291,15 +298,24 @@ export default { |
|
|
|
|
'') + '试题' |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
|
visible () { |
|
|
|
|
this.quesVisible = this.visible |
|
|
|
|
this.visible && this.init() |
|
|
|
|
mounted () { |
|
|
|
|
this.crumbs = [ |
|
|
|
|
{ |
|
|
|
|
name: '试题管理', |
|
|
|
|
route: 'list', |
|
|
|
|
query: { |
|
|
|
|
id: this.questionBankId |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted () { |
|
|
|
|
{ |
|
|
|
|
name: this.diaTitle |
|
|
|
|
}, |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
this.originForm = _.cloneDeep(this.form) |
|
|
|
|
// this.originFillBlank = _.cloneDeep(this.fillBlanks[0]) |
|
|
|
|
|
|
|
|
|
this.init() |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 初始化 |
|
|
|
@ -309,18 +325,16 @@ export default { |
|
|
|
|
|
|
|
|
|
const type = this.detailType |
|
|
|
|
// 外面知识点树形选中的知识点默认选中到表单里(选的是知识点才需要默认选中,知识点分类不用) |
|
|
|
|
if (type < 4) { |
|
|
|
|
const knowledgeCheck = this.$parent.$refs.typeTree.getCurrentNode() |
|
|
|
|
if (knowledgeCheck && knowledgeCheck.type) this.form.knowledgePointIds = [knowledgeCheck.path.split('/').map(e => +e)] |
|
|
|
|
if (!type) { |
|
|
|
|
const { path } = this.$route.query |
|
|
|
|
if (path) this.form.knowledgePointIds = [path.split('/').map(e => +e)] |
|
|
|
|
} else if (type === 4) { |
|
|
|
|
this.typeId = this.row.questionBankId |
|
|
|
|
// this.questionBankId = this.row.questionBankId |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 富文本重置 |
|
|
|
|
this.$refs.stem && this.$refs.stem.setText('') |
|
|
|
|
this.$refs.answerAnalysis && this.$refs.answerAnalysis.setText('') |
|
|
|
|
this.$refs.uploadInstructions && this.$refs.uploadInstructions.setText('') |
|
|
|
|
this.$refs.referenceAnswer && this.$refs.referenceAnswer.setText('') |
|
|
|
|
const { stem, answerAnalysis } = this.$refs |
|
|
|
|
stem && stem.instance && stem.setText('') |
|
|
|
|
answerAnalysis && answerAnalysis.instance && answerAnalysis.setText('') |
|
|
|
|
this.answerAnalysis = '' |
|
|
|
|
|
|
|
|
|
this.getDetail() |
|
|
|
|
this.getKnowledge() |
|
|
|
@ -329,9 +343,9 @@ export default { |
|
|
|
|
// 获取题目详情 |
|
|
|
|
async getDetail () { |
|
|
|
|
try { |
|
|
|
|
const { row } = this |
|
|
|
|
if (row.questionId) { |
|
|
|
|
const res = await this.$post(`${this.api.findQuestion}?questionId=${this.row.questionId}&version=${this.row.version}`) |
|
|
|
|
const { questionId, version } = this |
|
|
|
|
if (questionId) { |
|
|
|
|
const res = await this.$post(`${this.api.findQuestion}?questionId=${questionId}&version=${version}`) |
|
|
|
|
const r = res.message |
|
|
|
|
const opts = r.questionAnswerVersionsList |
|
|
|
|
|
|
|
|
@ -352,7 +366,7 @@ export default { |
|
|
|
|
knowledgePointIds: r.knowledgePointList ? r.knowledgePointList.map(e => { |
|
|
|
|
return e.path.split('/').map(n => +n) |
|
|
|
|
}) : [], |
|
|
|
|
specialtyIds: r.professionalList.map(e => e.specialtyId), |
|
|
|
|
specialtyIds: r.professionalList ? r.professionalList.map(e => e.specialtyId) : [], |
|
|
|
|
allowAttachment: r.allowAttachment, |
|
|
|
|
stemAttachment: r.stemAttachment, |
|
|
|
|
uploadInstructions: r.uploadInstructions, |
|
|
|
@ -374,11 +388,11 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 获取知识点 |
|
|
|
|
async getKnowledge () { |
|
|
|
|
if (this.typeId) { |
|
|
|
|
if (this.questionBankId) { |
|
|
|
|
try { |
|
|
|
|
const { data } = await this.$post(this.api.TreeStructure, { |
|
|
|
|
createSource: 1, |
|
|
|
|
questionBankId: this.typeId, |
|
|
|
|
questionBankId: this.questionBankId, |
|
|
|
|
keyword: '', |
|
|
|
|
}) |
|
|
|
|
this.handleType(data) |
|
|
|
@ -394,6 +408,7 @@ export default { |
|
|
|
|
pageSize: 1000, |
|
|
|
|
}) |
|
|
|
|
this.professionals = res.pageList.records |
|
|
|
|
if (!this.questionId) this.form.specialtyIds = [1] |
|
|
|
|
} catch (e) { } |
|
|
|
|
}, |
|
|
|
|
// 处理树形 |
|
|
|
@ -456,19 +471,19 @@ export default { |
|
|
|
|
editor.addListener('contentChange', () => { |
|
|
|
|
this.questionItemReset(editor.getContent()) |
|
|
|
|
}) |
|
|
|
|
this.form.stem && editor.setContent(this.form.stem) |
|
|
|
|
editor.setContent(this.form.stem) |
|
|
|
|
}, |
|
|
|
|
// 解析富文本加载完毕回调 |
|
|
|
|
answerAnalysisReady (editor) { |
|
|
|
|
this.answerAnalysis && editor.setContent(this.answerAnalysis) |
|
|
|
|
editor.setContent(this.answerAnalysis) |
|
|
|
|
}, |
|
|
|
|
// 上传说明富文本加载完毕回调 |
|
|
|
|
uploadInstructionsReady (editor) { |
|
|
|
|
this.form.uploadInstructions && editor.setContent(this.form.uploadInstructions) |
|
|
|
|
editor.setContent(this.form.uploadInstructions) |
|
|
|
|
}, |
|
|
|
|
// 参考答案富文本加载完毕回调 |
|
|
|
|
referenceAnswerReady (editor) { |
|
|
|
|
this.form.questionAnswerVersions[0].referenceAnswer && editor.setContent(this.form.questionAnswerVersions[0].referenceAnswer) |
|
|
|
|
editor.setContent(this.form.questionAnswerVersions[0].referenceAnswer) |
|
|
|
|
}, |
|
|
|
|
// 正确答案选择回调 |
|
|
|
|
correctChange (i) { |
|
|
|
@ -588,7 +603,7 @@ export default { |
|
|
|
|
this.submiting = true |
|
|
|
|
try { |
|
|
|
|
form.stem = stem |
|
|
|
|
form.questionBankId = this.typeId |
|
|
|
|
form.questionBankId = this.questionBankId |
|
|
|
|
form.knowledgePointIds = form.knowledgePointIds.map(e => { |
|
|
|
|
return e[e.length - 1] |
|
|
|
|
}) |
|
|
|
@ -654,16 +669,15 @@ export default { |
|
|
|
|
type === 4 && this.$emit('updateQues', this.tempForm, res.questionVersionId) |
|
|
|
|
|
|
|
|
|
Util.successMsg('保存成功') |
|
|
|
|
!form.questionId && this.keep ? this.init() : (this.quesVisible = false) |
|
|
|
|
!form.questionId && this.keep ? this.init() : this.back() |
|
|
|
|
this.repeatVisible = false |
|
|
|
|
} finally { |
|
|
|
|
this.submiting = false |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 弹框关闭回调 |
|
|
|
|
closeDia () { |
|
|
|
|
this.$emit('update:visible', false) |
|
|
|
|
} |
|
|
|
|
back () { |
|
|
|
|
this.$router.back() |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
@ -698,12 +712,6 @@ export default { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/deep/.ques-dia { |
|
|
|
|
z-index: 500; |
|
|
|
|
|
|
|
|
|
.fill-blanks { |
|
|
|
|
.fills { |
|
|
|
|
display: inline-flex; |
|
|
|
@ -737,7 +745,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.opts { |
|
|
|
|
.line { |
|
|
|
|
.opt { |
|
|
|
|
display: flex; |
|
|
|
|
align-items: center; |
|
|
|
|
margin-bottom: 15px; |
|
|
|
@ -773,8 +781,7 @@ export default { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/deep/.correct-check { |
|
|
|
|
.correct-check { |
|
|
|
|
margin-right: 15px; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</style> |