2020-05-26 15:59:11 +08:00
|
|
|
<template>
|
|
|
|
<div class="page">
|
|
|
|
<div class="page__container">
|
|
|
|
<el-card class="page__container-body">
|
2020-05-27 14:13:47 +08:00
|
|
|
<question-form ref="info" :option="formModel" :remove="true" :update="true" @modify="doModify" />
|
2020-05-26 15:59:11 +08:00
|
|
|
</el-card>
|
|
|
|
</div>
|
|
|
|
<div class="page__container-footer">
|
2020-05-27 14:13:47 +08:00
|
|
|
<el-button type="primary" :is-create="true" @click="update">更 新</el-button>
|
2020-05-26 15:59:11 +08:00
|
|
|
<el-button @click="back">返 回</el-button>
|
|
|
|
</div>
|
2020-05-27 14:13:47 +08:00
|
|
|
<dialog-modify-rich ref="rich" />
|
2020-05-26 15:59:11 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-05-27 14:13:47 +08:00
|
|
|
import QuestionForm from './question-form.vue';
|
2020-05-26 15:59:11 +08:00
|
|
|
import DialogModifyRich from './dialog-modify-rich';
|
2020-05-27 14:13:47 +08:00
|
|
|
import { getQuestionInfo, updateOption } from '@/api/questionBank.js';
|
2020-05-26 15:59:11 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2020-05-27 14:13:47 +08:00
|
|
|
QuestionForm,
|
2020-05-26 15:59:11 +08:00
|
|
|
DialogModifyRich
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
formModel: {
|
|
|
|
id: '',
|
|
|
|
topic: '',
|
2020-05-27 14:13:47 +08:00
|
|
|
type: 'select',
|
2020-05-26 18:12:42 +08:00
|
|
|
answer: 0,
|
2020-05-27 14:13:47 +08:00
|
|
|
optionList: []
|
2020-05-26 15:59:11 +08:00
|
|
|
},
|
|
|
|
optionList: []
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
questionId() {
|
|
|
|
return this.$route.params.questionId;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'$router': function() {
|
|
|
|
this.loadInitData();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.loadInitData();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
loadInitData() {
|
|
|
|
getQuestionInfo(this.questionId).then(resp => {
|
|
|
|
this.formModel = resp.data;
|
2020-10-20 16:48:28 +08:00
|
|
|
// this.formModel.answer = this.formModel.optionList.findIndex(ele => ele.correct);
|
2020-05-26 15:59:11 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
doBack() {
|
|
|
|
this.$router.go(-1);
|
|
|
|
},
|
|
|
|
doModify(node) {
|
|
|
|
this.$refs.rich.doShow(node);
|
|
|
|
},
|
2020-05-27 14:13:47 +08:00
|
|
|
update() {
|
|
|
|
this.$refs.info.validate().then(valid => {
|
|
|
|
if (valid) {
|
|
|
|
updateOption(this.formModel).then(resp => {
|
|
|
|
this.doBack();
|
|
|
|
}).catch(error => {
|
|
|
|
this.$message.error(`创建试题失败: ${error.message}`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}).catch(error => { this.$message.warning(error.message); });
|
2020-05-26 15:59:11 +08:00
|
|
|
},
|
|
|
|
back() {
|
|
|
|
this.$router.go(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.page {
|
|
|
|
width: 100%;
|
|
|
|
&__container {
|
|
|
|
width: 55%;
|
|
|
|
margin: auto;
|
|
|
|
&-header {
|
|
|
|
margin-bottom: 10px;
|
|
|
|
.step-group {
|
|
|
|
margin: 10px 0;
|
|
|
|
.box {
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&-body {
|
|
|
|
padding: 40px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&-footer {
|
|
|
|
margin-top: 20px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|