提交 c97143ce authored 作者: matian's avatar matian

Merge remote-tracking branch 'origin/master'

......@@ -27,10 +27,10 @@
<template v-else>
<div class="radio-box">
<div class="tips-tit">请选择子题目类型:</div>
<el-radio v-model="type" label="1">单选题</el-radio>
<el-radio v-model="type" label="2">多选题</el-radio>
<el-radio v-model="type" label="6">判断题</el-radio>
<el-radio v-model="type" label="3">简答题</el-radio>
<el-radio v-model="type" :label='1'>单选题</el-radio>
<el-radio v-model="type" :label='2'>多选题</el-radio>
<el-radio v-model="type" :label='6'>判断题</el-radio>
<el-radio v-model="type" :label='3'>简答题</el-radio>
</div>
<div class="btn-box" style="padding-top:50px;">
<el-button type="primary" @click="addQuestionConfirm">&nbsp;&nbsp;&nbsp;&nbsp;确定&nbsp;&nbsp;&nbsp;&nbsp;</el-button>
......@@ -60,7 +60,7 @@ export default {
filterInput: '',
source: '1',
questionBank: '1',
type: '1',
type: 1,
visible: false,
treeList: [],
defaultProps: '',
......@@ -172,12 +172,11 @@ export default {
handleSelectionChange(data) {
this.checkedList = data.reduce((a, b) => {
const data = {}
console.log(typeof b.child_question_type)
data.question_title = b.question_title
data.child_question_type = b.child_question_type || '1'
data.child_question_type = b.child_question_type || 1
data.question_content = b.question_content
data.question_analysis = b.question_analysis
if (this.type !== '3') data.question_options = b.question_options
if (this.type !== 3) data.question_options = b.question_options
a.push(data)
return a
}, [])
......@@ -193,8 +192,8 @@ export default {
question_analysis: ''
}
let options = []
if (this.type !== '3') {
if (this.type === '1' || this.type === '2') {
if (this.type !== 3) {
if (this.type === 1 || this.type === 2) {
options = [
{ option: '', checked: true },
{ option: '', checked: false },
......
<template>
<div>
<!-- <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm"> -->
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form :disabled="!!($route.query.type === 'view')" :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm" >
<el-form-item label="题库范围" prop="permission">
<el-radio v-model="ruleForm.permission" label="1">我的题库</el-radio>
<el-radio v-model="ruleForm.permission" label="2">公共题库</el-radio>
......@@ -22,7 +22,7 @@
<el-input v-model="ruleForm.question_title"></el-input>
</el-form-item>
<el-form-item label="题干内容" prop="question_content" required>
<v-editor v-model="ruleForm.question_content"></v-editor>
<v-editor :disabled="!!($route.query.type === 'view')" v-model="ruleForm.question_content"></v-editor>
</el-form-item>
<el-form-item label="选项" prop="question_options" v-if="ruleForm.question_type != 3">
<!-- 单选题 -->
......@@ -36,7 +36,7 @@
<el-input v-model="ruleForm.question_tag"></el-input>
</el-form-item>
<el-form-item label="题目解析" prop="question_analysis">
<v-editor v-model="ruleForm.question_analysis"></v-editor>
<v-editor :disabled="!!($route.query.type === 'view')" v-model="ruleForm.question_analysis"></v-editor>
</el-form-item>
<el-form-item label="试题分类" prop="question_category">
<div class="filter-input">
......@@ -112,7 +112,11 @@ export default {
question_difficulty: '',
question_title: '',
question_content: '',
question_options: [],
question_options: [
{ option: '', checked: true },
{ option: '', checked: false },
{ option: '', checked: false }
],
question_analysis: '',
question_category: '',
knowledge_point: '',
......@@ -139,24 +143,35 @@ export default {
}
}
},
mounted() {
created() {
if (this.detailData) {
this.ruleForm = this.detailData
this.treeValue.name = this.detailData.question_category.category_name
this.treeValue.id = this.detailData.question_category.id
this.ruleForm.question_category = this.detailData.question_category.id
this.pointOptions.push(this.detailData.knowledge_point)
this.ruleForm.knowledge_point = this.detailData.knowledge_point.id
}
},
mounted() {
this.getTreeList()
},
computed: {
activeProject() {
return this.$store.state.activeProject || {}
}
},
methods: {
submitForm(formName) {
if (parseInt(this.ruleForm.question_type) !== 3) {
console.log(this.$refs.options.datas, '123')
const isValue = this.$refs.options.datas.find(item => item.option === '')
if (!isValue) this.ruleForm.question_options = this.$refs.options.datas
}
this.$refs[formName].validate(valid => {
if (valid) {
// console.log(JSON.stringify(this.ruleForm))
if (this.$router.query.id) {
updateQuestion(this.ruleForm).then(res => {
if (this.$route.query.id) {
updateQuestion(this.$route.query.id, this.ruleForm).then(res => {
this.$router.push({
path: '/question/list'
})
......
......@@ -79,13 +79,16 @@
import QuestionsChidren from './QuestionsChidren.vue'
import VEditor from '@/components/tinymce/Index.vue'
import AddChidren from './AddChidren.vue'
import { getQuestionCategory, searchTag, addQuestion } from '../api'
import { getQuestionCategory, searchTag, addQuestion, updateQuestion } from '../api'
export default {
components: { AddChidren, VEditor, QuestionsChidren },
props: {
questionTypeNumber: {
type: Number,
default: 1
},
detailData: {
type: Object
}
},
data() {
......@@ -131,6 +134,18 @@ export default {
]
}
},
created() {
if (this.detailData) {
this.ruleForm = this.detailData
this.treeValue.name = this.detailData.question_category.category_name
this.treeValue.id = this.detailData.question_category.id
this.ruleForm.question_category = this.detailData.question_category.id
this.pointOptions.push(this.detailData.knowledge_point)
this.ruleForm.knowledge_point = this.detailData.knowledge_point.id
this.chidrenList = this.ruleForm.children
console.log(this.ruleForm, '123')
}
},
mounted() {
this.ruleForm.question_type = this.questionTypeNumber
this.getTreeList()
......@@ -141,12 +156,19 @@ export default {
},
submitForm(formName) {
this.ruleForm.children = this.chidrenList
if (this.$route.query.id) {
updateQuestion(this.$route.query.id, this.ruleForm).then(res => {
this.$router.push({
path: '/question/list'
})
})
} else {
addQuestion(this.ruleForm).then(res => {
// 11
this.$router.push({
path: '/question/list'
})
})
}
},
resetForm(formName) {
this.$refs[formName].validate(valid => {
......
......@@ -9,10 +9,10 @@
</el-form-item>
<el-form-item label="子题目类型" prop="child_question_type">
<el-select v-model="ruleForm.child_question_type" disabled placeholder="请选择活动区域">
<el-option label="单选题" value="1"></el-option>
<el-option label="多选题" value="2"></el-option>
<el-option label="判断题" value="6"></el-option>
<el-option label="问答题" value="3"></el-option>
<el-option label="单选题" :value='1'></el-option>
<el-option label="多选题" :value='2'></el-option>
<el-option label="判断题" :value='6'></el-option>
<el-option label="问答题" :value='3'></el-option>
</el-select>
</el-form-item>
<el-form-item label="子题目标题" prop="question_title">
......@@ -71,7 +71,7 @@ export default {
},
mounted() {
this.dataList = this.chidrenList
console.log(this.chidrenList)
console.log(this.chidrenList, 'chi')
},
methods: {
removeChidren(n) {
......
......@@ -33,9 +33,7 @@ export default {
this.questionTypeNum = res.data.question_type
res.data.permission = res.data.permission.toString()
res.data.question_difficulty = res.data.question_difficulty.toString()
res.data.question_category = res.data.question_category.category_name
this.detailData = res.data
console.log(this.detailData)
})
}
},
......
......@@ -215,10 +215,9 @@ export default {
},
// 查看
handleView(row) {
this.$router.push({ name: 'appView', params: { id: row.id }, query: { appid: row.id } })
this.$router.push({ path: '/question/create', query: { id: row.id, type: 'view' } })
},
handleSettings(row) {
// tan ~~~~~
this.$router.push({ path: '/question/create', query: { id: row.id, type: 'edit' } })
},
handleNodeClick(data) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论