|
|
@@ -5,7 +5,10 @@
|
|
|
<li v-for="(item, i) in data.option_list" :key="item.mark" class="option-item">
|
|
|
<span class="serial-number">{{ computedOptionNumber(i) }}.</span>
|
|
|
<div class="option-contnet">
|
|
|
- <span :class="['checkbox', { active: isAnswer(item.mark) }]" @click="selectAnswer(item.mark)">
|
|
|
+ <span
|
|
|
+ :class="[isSingle ? 'radio' : 'checkbox', { active: isAnswer(item.mark) }]"
|
|
|
+ @click="selectAnswer(item.mark)"
|
|
|
+ >
|
|
|
<SvgIcon icon-class="check-mark" width="10" height="7" />
|
|
|
</span>
|
|
|
<RichText
|
|
|
@@ -57,7 +60,7 @@
|
|
|
import ModuleMixin from '../../common/ModuleMixin';
|
|
|
import PinyinText from '@/components/PinyinText.vue';
|
|
|
|
|
|
-import { getSelectData, getOption, arrangeTypeList } from '@/views/book/courseware/data/select';
|
|
|
+import { getSelectData, getOption, arrangeTypeList, selectTypeList } from '@/views/book/courseware/data/select';
|
|
|
import { serialNumberTypeList, computeOptionMethods } from '@/views/book/courseware/data/common';
|
|
|
|
|
|
export default {
|
|
|
@@ -72,6 +75,11 @@ export default {
|
|
|
curSelectIndex: -1,
|
|
|
};
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ isSingle() {
|
|
|
+ return this.data.property?.select_type === selectTypeList[0].value;
|
|
|
+ },
|
|
|
+ },
|
|
|
watch: {
|
|
|
'data.property.arrange_type': 'handlerMindMap',
|
|
|
'data.answer.answer_list': 'handlerMindMap',
|
|
|
@@ -97,6 +105,13 @@ export default {
|
|
|
},
|
|
|
deep: true,
|
|
|
},
|
|
|
+ 'data.property.select_type': {
|
|
|
+ handler() {
|
|
|
+ if (this.isSingle && this.data.answer.answer_list.length > 1) {
|
|
|
+ this.data.answer.answer_list = [this.data.answer.answer_list[0]];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
computedOptionNumber(number) {
|
|
|
@@ -120,12 +135,17 @@ export default {
|
|
|
* @param {string} mark 选项标记
|
|
|
*/
|
|
|
selectAnswer(mark) {
|
|
|
- const index = this.data.answer.answer_list.indexOf(mark);
|
|
|
- if (index === -1) {
|
|
|
- this.data.answer.answer_list.push(mark);
|
|
|
- } else {
|
|
|
- this.data.answer.answer_list.splice(index, 1);
|
|
|
+ if (mark === null || mark === undefined) return;
|
|
|
+
|
|
|
+ const list = this.data.answer.answer_list || [];
|
|
|
+ const isSelected = list.includes(mark);
|
|
|
+
|
|
|
+ if (this.isSingle) {
|
|
|
+ this.data.answer.answer_list = isSelected ? [] : [mark];
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+ this.data.answer.answer_list = isSelected ? list.filter((item) => item !== mark) : list.concat(mark);
|
|
|
},
|
|
|
/**
|
|
|
* @description 添加选项
|
|
|
@@ -146,7 +166,8 @@ export default {
|
|
|
},
|
|
|
handlerMindMap() {
|
|
|
const direction = this.data.property.arrange_type === arrangeTypeList[0].value ? '横排' : '竖排';
|
|
|
- const select = this.data.answer.answer_list.length > 1 ? '多选' : '单选';
|
|
|
+ const select =
|
|
|
+ this.data.property?.select_type === selectTypeList[1].value ? selectTypeList[1].label : selectTypeList[0].label;
|
|
|
this.data.mind_map.node_list = [{ name: `${direction}${select}选择题` }];
|
|
|
},
|
|
|
openMultilingual(i) {
|
|
|
@@ -190,6 +211,7 @@ export default {
|
|
|
overflow: hidden;
|
|
|
background-color: $fill-color;
|
|
|
|
|
|
+ .radio,
|
|
|
.checkbox {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
@@ -214,6 +236,15 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .radio {
|
|
|
+ border-radius: 50%;
|
|
|
+
|
|
|
+ &.active {
|
|
|
+ background-color: #fff;
|
|
|
+ box-shadow: inset 0 0 0 4px #000;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.delete,
|