fix: 修复预览显示页数异常
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed, watch } from 'vue';
|
||||||
|
|
||||||
export const useQuestionStore = defineStore('questionStore', () => {
|
export const useQuestionStore = defineStore('questionStore', () => {
|
||||||
const questionsData = ref();
|
const questionsData = ref();
|
||||||
|
|
||||||
|
// 是否是模板模式
|
||||||
|
const isTemplate = ref<boolean>(true);
|
||||||
// styleInfo 主题样式
|
// styleInfo 主题样式
|
||||||
const styleInfo = computed(() => questionsData.value?.survey?.style || {});
|
const styleInfo = computed(() => questionsData.value?.survey?.style || {});
|
||||||
// 当前页数
|
// 当前页数
|
||||||
@@ -18,6 +20,7 @@ export const useQuestionStore = defineStore('questionStore', () => {
|
|||||||
const localPageTimer = ref({});
|
const localPageTimer = ref({});
|
||||||
// 当前页问卷
|
// 当前页问卷
|
||||||
const questions = computed(() => {
|
const questions = computed(() => {
|
||||||
|
if (isTemplate.value) return questionsData.value?.questions;
|
||||||
const currentPages = pages.value[page.value - 1] || [];
|
const currentPages = pages.value[page.value - 1] || [];
|
||||||
return (questionsData.value?.questions || []).filter((quetion: any) =>
|
return (questionsData.value?.questions || []).filter((quetion: any) =>
|
||||||
currentPages.find((index: any) => quetion.question_index === index)
|
currentPages.find((index: any) => quetion.question_index === index)
|
||||||
@@ -48,6 +51,7 @@ export const useQuestionStore = defineStore('questionStore', () => {
|
|||||||
prevLoading,
|
prevLoading,
|
||||||
localPageTimer,
|
localPageTimer,
|
||||||
questions,
|
questions,
|
||||||
showPage
|
showPage,
|
||||||
|
isTemplate
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -560,7 +560,8 @@ const {
|
|||||||
prevLoading,
|
prevLoading,
|
||||||
localPageTimer,
|
localPageTimer,
|
||||||
questions,
|
questions,
|
||||||
translatedText
|
translatedText,
|
||||||
|
isTemplate
|
||||||
} = storeToRefs(questionStore);
|
} = storeToRefs(questionStore);
|
||||||
|
|
||||||
// 第一次进入页面清空答案
|
// 第一次进入页面清空答案
|
||||||
@@ -581,6 +582,10 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 初始化 isTemplate
|
||||||
|
isTemplate.value = props.isTemplate ? props.isTemplate : route.query.is_template === '1';
|
||||||
|
|
||||||
|
console.log(`now page is template? ${isTemplate.value}`);
|
||||||
// 开始更新数据
|
// 开始更新数据
|
||||||
getQuestions();
|
getQuestions();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user