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