- 在 Choice、Completion、FileUpload、MatrixQuestion、NPS、Rate、SignQuestion 和 TextWithImages 组件中添加 isPreview 属性 - 根据 isPreview 属性决定是否显示题号或题目标题 - 更新 PreviewCompletion、PreviewFileUpload 和 PreviewSign 组件,设置 isPreview 为 true
45 lines
1.1 KiB
Vue
45 lines
1.1 KiB
Vue
<script setup lang="ts">
|
|
import SignQuestion from '@/views/Design/components/Questions/SignQuestion.vue';
|
|
import { ref, watch } from 'vue';
|
|
import Rate from '@/views/Design/components/Questions/Rate.vue';
|
|
|
|
const question = defineModel<question>('question', { default: {} });
|
|
const answer = defineModel<{ value: string }>('answer', { default: undefined });
|
|
const answerValue = ref<string>('');
|
|
const answerIndex = defineModel<number>('answerIndex', { default: 0 });
|
|
// emit
|
|
const emit = defineEmits(['changeAnswer']);
|
|
|
|
// 如果 answer 不为空,需要解析答案
|
|
answer.value?.value && parseAnswer();
|
|
|
|
/**
|
|
* 监听答案,如果答案变动,重新生成答案,然后提交
|
|
*/
|
|
watch(answerValue, (newValue) => {
|
|
emit('changeAnswer', { value: newValue });
|
|
});
|
|
/**
|
|
* 解析答案
|
|
* answer 格式
|
|
* {
|
|
* value: 'url'
|
|
* }
|
|
*/
|
|
function parseAnswer() {
|
|
answerValue.value = answer.value.value;
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<sign-question
|
|
:element="question"
|
|
:active="false"
|
|
:isPreview="true"
|
|
:index="answerIndex"
|
|
v-model:answer="answerValue"
|
|
:error-message="question.error"
|
|
/>
|
|
</template>
|
|
<style scoped lang="scss"></style>
|