提交 2e2e967a authored 作者: lihuihui's avatar lihuihui

修改选项

上级 2e3003dc
......@@ -26,11 +26,11 @@
</el-form-item>
<el-form-item label="选项" prop="question_options" v-if="ruleForm.question_type != 3">
<!-- 单选题 -->
<radio ref="options" :option="ruleForm.question_options" v-if="ruleForm.question_type == 1"></radio>
<radio :option="ruleForm.question_options" v-if="ruleForm.question_type == 1"></radio>
<!-- 多选题 -->
<checkbox ref="options" :option="ruleForm.question_options" v-if="ruleForm.question_type == 2"></checkbox>
<checkbox :option="ruleForm.question_options" v-if="ruleForm.question_type == 2"></checkbox>
<!-- 判断题 -->
<judgment ref="options" :option="ruleForm.question_options" v-if="ruleForm.question_type == 6"></judgment>
<judgment :option="ruleForm.question_options" v-if="ruleForm.question_type == 6"></judgment>
</el-form-item>
<el-form-item label="标签" prop="question_tag">
<el-input v-model="ruleForm.question_tag"></el-input>
......@@ -163,10 +163,11 @@ export default {
},
methods: {
submitForm(formName) {
if (parseInt(this.ruleForm.question_type) !== 3) {
const isValue = this.$refs.options.datas.find(item => item.option === '')
if (!isValue) this.ruleForm.question_options = this.$refs.options.datas
}
// if (parseInt(this.ruleForm.question_type) !== 3) {
// const isValue = this.$refs.options.datas.find(item => item.option === '')
// if (!isValue) this.ruleForm.question_options = this.$refs.options.datas
// }
console.log(this.ruleForm.question_options)
this.$refs[formName].validate(valid => {
if (valid) {
// console.log(JSON.stringify(this.ruleForm))
......@@ -244,6 +245,12 @@ export default {
})
},
questionTypeChange() {
if (parseInt(this.ruleForm.question_type) === 6) {
this.ruleForm.question_options = [
{ option: '正确', checked: true },
{ option: '错误', checked: false }
]
}
this.$emit('questionType', this.ruleForm.question_type)
}
}
......
......@@ -6,8 +6,10 @@
<el-tag>{{ A_Z()[index] }}</el-tag>
<el-input v-model="item.option" maxlength="80" show-word-limit></el-input>
</el-checkbox>
<i class="el-icon-remove-outline icon-style" v-if="index != option.length - 1" @click="remove(index)"></i>
<i class="el-icon-circle-plus-outline icon-style" v-else @click="add"></i>
<template v-if="!!!($route.query.type === 'view')">
<i class="el-icon-remove-outline icon-style" v-if="index != option.length - 1" @click="remove(index)"></i>
<i class="el-icon-circle-plus-outline icon-style" v-else @click="add"></i>
</template>
</div>
</template>
</div>
......@@ -22,35 +24,14 @@ export default {
},
data() {
return {
checkboxValue: [0],
datas: [
{
checked: true,
option: ''
},
{
checked: false,
option: ''
},
{
checked: false,
option: ''
},
{
checked: false,
option: ''
}
]
checkboxValue: [0]
}
},
mounted() {
// if (this.option) {
// this.datas = this.option
this.checkboxValue = [0]
this.option.forEach((item, index) => {
if (item.checked) this.checkboxValue.push(index)
})
// }
},
methods: {
add() {
......
......@@ -14,30 +14,17 @@ export default {
},
data() {
return {
radio: 0,
datas: [
{
option: '正确',
checked: true
},
{
option: '错误',
checked: false
}
]
radio: 0
}
},
mounted() {
if (this.option) {
this.datas = this.option
this.radio = this.datas.findIndex(item => item.checked)
}
this.radio = this.option.findIndex(item => item.checked)
},
methods: {
radioChange() {
this.datas.map(item => {
this.option.map(item => {
item.checked = false
this.datas[this.radio].checked = true
this.option[this.radio].checked = true
return item
})
}
......
......@@ -6,8 +6,10 @@
<el-tag>{{ A_Z()[index] }}</el-tag>
<el-input v-model="item.option" maxlength="80" show-word-limit></el-input>
</el-radio>
<i class="el-icon-remove-outline icon-style" v-if="index != option.length - 1" @click="remove(index)"></i>
<i class="el-icon-circle-plus-outline icon-style" v-else @click="add"></i>
<template v-if="!!!($route.query.type === 'view')">
<i class="el-icon-remove-outline icon-style" v-if="index != option.length - 1" @click="remove(index)"></i>
<i class="el-icon-circle-plus-outline icon-style" v-else @click="add"></i>
</template>
</div>
</template>
</div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论