refactor(Design): 重构问卷预览功能
- 在 Choice、Completion、FileUpload、MatrixQuestion、NPS、Rate、SignQuestion 和 TextWithImages 组件中添加 isPreview 属性 - 根据 isPreview 属性决定是否显示题号或题目标题 - 更新 PreviewCompletion、PreviewFileUpload 和 PreviewSign 组件,设置 isPreview 为 true
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
class="contenteditable-question-title base-select"
|
||||
>
|
||||
<template #left-icon>
|
||||
{{ index + 1 }}
|
||||
{{ isPreview ? element.title : index + 1 }}
|
||||
</template>
|
||||
<template #label>
|
||||
<contenteditable
|
||||
@@ -112,6 +112,10 @@ const value = defineModel('checkboxAnswer', { default: [], type: Array });
|
||||
const errorMessage = defineModel('errorMessage', { default: '', type: String });
|
||||
const Contenteditable = defineAsyncComponent(() => import('@/components/contenteditable.vue'));
|
||||
defineProps({
|
||||
isPreview: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
class="contenteditable-question-title"
|
||||
>
|
||||
<template #left-icon>
|
||||
{{ index + 1 }}
|
||||
{{ isPreview ? element.title : index + 1 }}
|
||||
</template>
|
||||
<template #label>
|
||||
<contenteditable
|
||||
@@ -36,6 +36,10 @@ import { toRefs } from 'vue';
|
||||
|
||||
const completionValue = defineModel('completionValue', { default: '', type: String });
|
||||
const props = defineProps({
|
||||
isPreview: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
element: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
|
||||
@@ -5,6 +5,10 @@ const props = defineProps<{
|
||||
element: any;
|
||||
index: number;
|
||||
active: boolean;
|
||||
isPreview: {
|
||||
type: Boolean;
|
||||
default: false;
|
||||
};
|
||||
}>();
|
||||
const { element } = toRefs(props);
|
||||
|
||||
@@ -72,9 +76,7 @@ const emitValue = () => {
|
||||
input-align="center"
|
||||
class="contenteditable-question-title"
|
||||
>
|
||||
<template #left-icon>
|
||||
{{ index + 1 }}
|
||||
</template>
|
||||
<template #left-icon> {{ isPreview ? element.title : index + 1 }} {{ index + 1 }} </template>
|
||||
<!-- 使用 title 插槽来自定义标题 -->
|
||||
<template #label>
|
||||
<contenteditable
|
||||
|
||||
@@ -17,7 +17,6 @@ const element = defineModel<question>('element', {
|
||||
return {};
|
||||
}
|
||||
});
|
||||
|
||||
// table 宽度
|
||||
const tableWidth = defineModel<number>('tableWidth', { required: false, default: 110 });
|
||||
// 行记录(相关答案的记录)
|
||||
@@ -117,7 +116,7 @@ const errorMessage = defineModel('errorMessage', {
|
||||
class="contenteditable-question-title"
|
||||
>
|
||||
<template #left-icon>
|
||||
{{ index + 1 }}
|
||||
{{ isPreview ? element.title : index + 1 }}
|
||||
</template>
|
||||
<!-- 使用 title 插槽来自定义标题 -->
|
||||
<template #label>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
class="contenteditable-question-title"
|
||||
>
|
||||
<template #left-icon>
|
||||
{{ index + 1 }}
|
||||
{{ isPreview ? element.title : index + 1 }}
|
||||
</template>
|
||||
<template #label>
|
||||
<contenteditable
|
||||
@@ -55,6 +55,10 @@ import RateCharacter from './RateCharacter.vue';
|
||||
const value = defineModel('value', { default: -1, type: Number });
|
||||
const isPreview = defineModel('isPreview', { default: false, type: Boolean });
|
||||
/* const props = */ defineProps({
|
||||
isPreview: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
default: 0
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
class="contenteditable-question-title"
|
||||
>
|
||||
<template #left-icon>
|
||||
{{ index + 1 }}
|
||||
{{ isPreview ? element.title : index + 1 }}
|
||||
</template>
|
||||
<template #label>
|
||||
<contenteditable
|
||||
|
||||
@@ -12,6 +12,7 @@ const answer = defineModel<string>('answer', { default: '' });
|
||||
// 错误信息
|
||||
const errorMessage = defineModel<string>('errorMessage', { default: '' });
|
||||
|
||||
const isPreview = defineModel('isPreview', { default: false });
|
||||
const signatureCanvas = useTemplateRef('signatureCanvas');
|
||||
|
||||
const canvasWidth = ref(100);
|
||||
@@ -204,7 +205,7 @@ async function handleUploadImg() {
|
||||
readonly
|
||||
>
|
||||
<template #left-icon>
|
||||
{{ index + 1 }}
|
||||
{{ isPreview ? element.title : index + 1 }}
|
||||
</template>
|
||||
<template #label>
|
||||
<contenteditable
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
class="base-select contenteditable-question-title"
|
||||
>
|
||||
<template #left-icon>
|
||||
{{ index + 1 }}
|
||||
{{ isPreview ? element.title : index + 1 }}
|
||||
</template>
|
||||
<template #label>
|
||||
<contenteditable
|
||||
@@ -26,6 +26,10 @@
|
||||
import contenteditable from '@/components/contenteditable.vue';
|
||||
import { defineModel, toRefs } from 'vue';
|
||||
const props = defineProps({
|
||||
isPreview: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
element: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
v-model:completionValue="completionValue"
|
||||
:index="answerIndex"
|
||||
:element="question"
|
||||
:isPreview="true"
|
||||
:errorMessage="question.error"
|
||||
></completion>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { defineEmits, ref, watch } from 'vue';
|
||||
import Completion from '@/views/Design/components/Questions/Completion.vue';
|
||||
import Rate from '@/views/Design/components/Questions/Rate.vue';
|
||||
// 预览新增 v-model
|
||||
// const config = defineModel('config');
|
||||
const answer = defineModel<{ value: string | number }>('answer', { default: { value: '' } });
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import FileUpload from '@/views/Design/components/Questions/FileUpload.vue';
|
||||
import Rate from '@/views/Design/components/Questions/Rate.vue';
|
||||
const questionIndex = defineModel<number>('questionIndex', { default: NaN });
|
||||
const answerIndex = defineModel<number>('answerIndex', { default: NaN });
|
||||
const question = defineModel<question>('question', { default: () => {} });
|
||||
@@ -8,6 +9,7 @@ const question = defineModel<question>('question', { default: () => {} });
|
||||
<!-- 文件上传题 -->
|
||||
<file-upload
|
||||
:element="question"
|
||||
:isPreview="true"
|
||||
:index="answerIndex ?? questionIndex"
|
||||
:errorMessage="question.error"
|
||||
:active="false"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<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 });
|
||||
@@ -34,6 +35,7 @@ function parseAnswer() {
|
||||
<sign-question
|
||||
:element="question"
|
||||
:active="false"
|
||||
:isPreview="true"
|
||||
:index="answerIndex"
|
||||
v-model:answer="answerValue"
|
||||
:error-message="question.error"
|
||||
|
||||
Reference in New Issue
Block a user