Merge branch 'develop' into 'sit'
修改问答题关键词展示 See merge request K17_AITS/tra-app!180
This commit is contained in:
@@ -6,7 +6,6 @@ import common from '@/common/common.js'
|
||||
const ENV = import.meta.env
|
||||
|
||||
export const get_base_url = (url = '') => {
|
||||
return ''
|
||||
if (ENV.MODE === 'development') { // 开发环境
|
||||
// #ifdef H5
|
||||
if (url) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<view class="line" v-for="item in evalSettingVos">
|
||||
<text class="tr">{{ item.gradeDimens }}:</text>
|
||||
<text class="td">{{ item.anlyGrade }}</text>
|
||||
<view class="your_answer" v-if="item.dimensCode === '01' && passKeyword">
|
||||
<view class="your_answer" v-if="item.dimensCode === '01'">
|
||||
<rich-text :nodes="highlightedText" class="content" />
|
||||
</view>
|
||||
</view>
|
||||
@@ -33,9 +33,13 @@
|
||||
type: Boolean,
|
||||
default: false,
|
||||
required: false
|
||||
},
|
||||
anserResult: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
});
|
||||
const passKeyword = computed(() => props.value.passKeyword);
|
||||
|
||||
const evalSettingVos = computed(() => props.value.evalSettingVos);
|
||||
const status = computed(() => (props.judgeResult ? 'success' : 'error'));
|
||||
const select_status_icon = computed(() => {
|
||||
@@ -45,14 +49,15 @@
|
||||
return optionErrorIcon();
|
||||
}
|
||||
});
|
||||
|
||||
const keywords = computed(() => {
|
||||
if (!props.value.relKeyword) return [];
|
||||
return props.value.relKeyword.split(/[,、]/).map((key) => key.trim());
|
||||
return props.value.relKeyword.split(/[,、/]/).map((key) => key.trim());
|
||||
});
|
||||
|
||||
const highlightedText = computed(() => {
|
||||
// 如果没有关键词,直接返回原文本
|
||||
if (!keywords.value.length) return '你的答案:' + props.answerText;
|
||||
if (!keywords.value.length) return '你的答案:' + props.anserResult;
|
||||
// 构建正则表达式,匹配所有关键词(不区分大小写)
|
||||
// 对关键词进行转义,避免特殊字符影响正则
|
||||
const escapedKeywords = keywords.value.map((keyword) => keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
||||
@@ -61,7 +66,7 @@
|
||||
const regex = new RegExp(`(${escapedKeywords.join('|')})`, 'gi');
|
||||
|
||||
// 替换匹配到的关键词,用span包裹并添加高亮样式
|
||||
return '你的答案:' + props.answerText.replace(regex, (match) => `<span class="highlight">${match}</span>`);
|
||||
return '你的答案:' + props.anserResult.replace(regex, (match) => `<span class="highlight">${match}</span>`);
|
||||
});
|
||||
const dimension_all_score = computed(() => {
|
||||
return (
|
||||
|
||||
@@ -98,6 +98,7 @@
|
||||
v-if="qnsTyp === 'ES'"
|
||||
:value="subject_data.itemVos[0]"
|
||||
:judgeResult="judgeResultStatus"
|
||||
:anserResult="subject_data.anserResult"
|
||||
></esAnalysis>
|
||||
|
||||
<!-- 问答题专属参考答案 -->
|
||||
|
||||
Reference in New Issue
Block a user