Commit 01753870 authored by zhengke's avatar zhengke

修改

parent 459dbe9a
<style>
.singleQuestion {
width: 100%;
}
</style>
<!--单选题-->
<template>
<div class="singleQuestion">
<table v-if="data&&data.length>0" class="common_TiTable">
<tr v-for="(item,index) in data">
<td style="width:40px;text-align:center;">
<div class="Answer_List" :class="{'Is_Answer':item.IsAnswer}">
{{item.Name}}
</div>
</td>
<td>
<div class="InpDIV" style="border:0;" v-html="item.Content"></div>
</td>
</tr>
</table>
</div>
</template>
<script>
import {
getOptionList, //获取选择标签【A,B,C,D....】
} from '../../api/question/questionconfig'
import UeEditor from '../editor/UeEditor'
export default {
props: {
questionData: {
type: Array,
},
setOption: {
type: Object,
}
},
components: {
UeEditor
},
data() {
return {
data: this.questionData,
config: {
initialFrameWidth: null,
initialFrameHeight: 90,
},
optionTitleList: [],
commonIndex: -1,
};
},
created() {
this.initConfig();
},
mounted() {},
methods: {
initConfig() {
this.optionTitleList = getOptionList();
},
//删除选项
deleteOpion(index) {
this.$q.dialog({
title: '提示信息',
message: '是否确定删除?',
cancel: true,
persistent: true,
ok: "确定",
cancel: "取消",
}).onOk(() => {
this.data.splice(index, 1);
this.commonIndex = -1;
this.calcOptionTitle();
}).onCancel(() => {
});
},
//新增选项
addOption() {
if (this.data.length < 7) {
this.data.push({
Name: "",
Content: "",
IsAnswer: false
});
this.calcOptionTitle()
} else {
this.$q.notify({
type: 'warning',
position: 'center',
timeout: 1500,
message: `最多只能添加7个选项`
})
return
}
},
//重新计算选择Title[A,B,C,D....]
calcOptionTitle() {
if (this.data && this.data.length > 0) {
this.data.forEach((item, index) => {
if (this.setOption.QuestionTypeKey == "single-number") {
item.Name = index + 1;
} else {
item.Name = this.optionTitleList[index];
}
})
}
},
//返回数据到父组件
returnDataToParent() {
this.getAnswer();
this.$emit('getChild', this.data);
},
ChangeItem(item) {
if (this.data && this.data.length > 0) {
this.data.forEach(item => {
item.IsAnswer = false;
})
}
item.IsAnswer = true;
},
//获取正确答案
getAnswer() {
this.setOption.Answer = "";
if (this.data && this.data.length > 0) {
this.data.forEach(item => {
if (item.IsAnswer) {
this.setOption.Answer = item.Name;
}
})
}
},
//点击切换输入
changeEdit(index) {
this.commonIndex = index;
}
},
mounted() {
},
watch: {
data: {
handler(newValue) {
this.returnDataToParent();
},
deep: true
},
}
};
</script>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment