|
@@ -5,7 +5,11 @@
|
|
|
<span class="question-number">{{ data.property.question_number }}.</span>
|
|
|
<span v-html="sanitizeHTML(data.stem)"></span>
|
|
|
</div>
|
|
|
- <div v-if="isEnable(data.property.is_enable_description)" class="description">{{ data.description }}</div>
|
|
|
+ <div v-if="isEnable(data.property.is_enable_description)" class="description">
|
|
|
+ <span v-for="(text, i) in descriptionList" :key="i" class="description-item" @click="selectedDescription(text)">
|
|
|
+ {{ text }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
|
|
|
<AudioPlay
|
|
|
v-if="isEnable(data.property.is_enable_listening) && data.file_id_list.length > 0"
|
|
@@ -16,7 +20,13 @@
|
|
|
<p v-for="(item, i) in data.model_essay" :key="i">
|
|
|
<template v-for="(li, j) in item">
|
|
|
<span v-if="li.type === 'text'" :key="j" v-html="sanitizeHTML(li.content)"></span>
|
|
|
- <el-input v-if="li.type === 'input'" :key="j" v-model="li.content" @blur="handleTone(li.content, i, j)" />
|
|
|
+ <el-input
|
|
|
+ v-if="li.type === 'input'"
|
|
|
+ :key="j"
|
|
|
+ v-model="li.content"
|
|
|
+ @focus="handleInputFocus(i, j)"
|
|
|
+ @blur="handleTone(li.content, i, j)"
|
|
|
+ />
|
|
|
</template>
|
|
|
</p>
|
|
|
</div>
|
|
@@ -33,7 +43,18 @@ export default {
|
|
|
name: 'FillPreview',
|
|
|
mixins: [PreviewMixin],
|
|
|
data() {
|
|
|
- return {};
|
|
|
+ return {
|
|
|
+ inputFocus: false,
|
|
|
+ focusPostion: {
|
|
|
+ i: -1,
|
|
|
+ j: -1,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ descriptionList() {
|
|
|
+ return this.data.description.split(/\s+/);
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
'data.model_essay': {
|
|
@@ -58,7 +79,37 @@ export default {
|
|
|
immediate: true,
|
|
|
},
|
|
|
},
|
|
|
+ created() {
|
|
|
+ document.addEventListener('click', this.handleBlur);
|
|
|
+ document.addEventListener('keydown', this.handleBlurTab);
|
|
|
+ },
|
|
|
+ beforeDestroy() {
|
|
|
+ document.removeEventListener('click', this.handleBlur);
|
|
|
+ document.removeEventListener('keydown', this.handleBlurTab);
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ handleBlur(e) {
|
|
|
+ if (e.target.tagName === 'INPUT') return;
|
|
|
+ this.inputFocus = false;
|
|
|
+ },
|
|
|
+ handleBlurTab(e) {
|
|
|
+ if (e.keyCode !== 9 || e.key !== 'Tab') return;
|
|
|
+ this.inputFocus = false;
|
|
|
+ },
|
|
|
+ handleInputFocus(i, j) {
|
|
|
+ this.inputFocus = true;
|
|
|
+ this.focusPostion = {
|
|
|
+ i,
|
|
|
+ j,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ selectedDescription(text) {
|
|
|
+ console.log(2);
|
|
|
+ if (!this.inputFocus) return;
|
|
|
+ const { i, j } = this.focusPostion;
|
|
|
+ this.data.model_essay[i][j].content = text;
|
|
|
+ this.inputFocus = false;
|
|
|
+ },
|
|
|
handleTone(value, i, j) {
|
|
|
if (!/^[a-zA-Z0-9\s]+$/.test(value)) return;
|
|
|
this.data.model_essay[i][j].content = value
|
|
@@ -83,6 +134,21 @@ export default {
|
|
|
.fill-preview {
|
|
|
@include preview;
|
|
|
|
|
|
+ .description {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ gap: 4px 24px;
|
|
|
+
|
|
|
+ &-item {
|
|
|
+ cursor: pointer;
|
|
|
+
|
|
|
+ &:hover,
|
|
|
+ &:active {
|
|
|
+ color: $light-main-color;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
.fill-wrapper {
|
|
|
.el-input {
|
|
|
width: 120px;
|