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

修改选项

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