Files
ylst-h5/src/views/Survey/views/Preview/components/questions/PreviewSign.vue
陈昱达 73889c73d4 refactor(Design): 重构问卷预览功能
- 在 Choice、Completion、FileUpload、MatrixQuestion、NPS、Rate、SignQuestion 和 TextWithImages 组件中添加 isPreview 属性
- 根据 isPreview 属性决定是否显示题号或题目标题
- 更新 PreviewCompletion、PreviewFileUpload 和 PreviewSign 组件,设置 isPreview 为 true
2025-03-22 15:00:33 +08:00

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>