|
@@ -64,6 +64,15 @@
|
|
|
</template>
|
|
|
</p>
|
|
|
</div>
|
|
|
+ <span class="multilingual" v-if="showLang">
|
|
|
+ {{
|
|
|
+ multilingualTextList[getLang()] &&
|
|
|
+ multilingualTextList[getLang()][i] &&
|
|
|
+ multilingualTextList[getLang()][i][j]
|
|
|
+ ? multilingualTextList[getLang()][i][j]
|
|
|
+ : ''
|
|
|
+ }}
|
|
|
+ </span>
|
|
|
</td>
|
|
|
</template>
|
|
|
</tr>
|
|
@@ -86,6 +95,7 @@ export default {
|
|
|
return {
|
|
|
data: getTableData(),
|
|
|
table_width: 0,
|
|
|
+ multilingualTextList: {}, // 多语言对应的切割后的翻译
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -107,7 +117,13 @@ export default {
|
|
|
return obj;
|
|
|
},
|
|
|
},
|
|
|
- watch: {},
|
|
|
+ watch: {
|
|
|
+ 'data.col_width': {
|
|
|
+ handler(val) {
|
|
|
+ this.handleData();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
created() {
|
|
|
this.handleData();
|
|
|
},
|
|
@@ -119,6 +135,22 @@ export default {
|
|
|
this.data.col_width.forEach((item) => {
|
|
|
this.table_width += Number(item.value);
|
|
|
});
|
|
|
+ if (this.showLang) {
|
|
|
+ this.data.multilingual.forEach((item) => {
|
|
|
+ let trans_arr = item.translation.split('\n');
|
|
|
+ let chunkSize = this.data.property.column_count;
|
|
|
+ let chunkedArr = trans_arr.reduce((acc, curr, index) => {
|
|
|
+ // 当索引是chunkSize的倍数时,开始一个新的子数组
|
|
|
+ if (index % chunkSize === 0) {
|
|
|
+ acc.push([curr]); // 开始新的子数组并添加当前元素
|
|
|
+ } else {
|
|
|
+ acc[acc.length - 1].push(curr); // 将当前元素添加到最后一个子数组中
|
|
|
+ }
|
|
|
+ return acc;
|
|
|
+ }, []);
|
|
|
+ this.$set(this.multilingualTextList, item.type, chunkedArr);
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
computedAnswerText(mark) {
|
|
|
if (!this.isShowRightAnswer) return '';
|
|
@@ -216,6 +248,10 @@ $border-color: #e6e6e6;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .multilingual {
|
|
|
+ word-break: break-word;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</style>
|