From 7de06d5ff48093f72ae9b608bb640a8239550a7b Mon Sep 17 00:00:00 2001 From: Huangzhe Date: Tue, 1 Apr 2025 14:12:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8A=BD=E7=A6=BB=E7=AD=94=E9=A2=98?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 现在可以自由控制校验答题时间. - 增加 useValidateQuestion hooks. - 多选矩阵应用这个逻辑,组件添加时添加到验证列表,卸载时移除对应的函数 validateFun --- src/views/Survey/views/Preview/Index.vue | 6 +++++ .../questions/PreviewMatrixCheckbox.vue | 27 +++++++++++++++---- .../Preview/hooks/useValidateQuestion.ts | 17 ++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 src/views/Survey/views/Preview/hooks/useValidateQuestion.ts diff --git a/src/views/Survey/views/Preview/Index.vue b/src/views/Survey/views/Preview/Index.vue index 3d9ae44..c17a325 100644 --- a/src/views/Survey/views/Preview/Index.vue +++ b/src/views/Survey/views/Preview/Index.vue @@ -538,6 +538,10 @@ import PreviewCheckbox from '@/views/Survey/views/Preview/components/questions/P import PreviewRate from '@/views/Survey/views/Preview/components/questions/PreviewRate.vue'; import PreviewSign from '@/views/Survey/views/Preview/components/questions/PreviewSign.vue'; import PreviewTextWithImages from '@/views/Survey/views/Preview/components/questions/PreviewTextWithImages.vue'; +import { + startValidate, + validateList +} from '@/views/Survey/views/Preview/hooks/useValidateQuestion'; const isPreview = defineModel('isPreview', { type: Boolean, @@ -610,6 +614,8 @@ async function previous() { // 下一页 async function next(callbackBeforePage) { + // 开始校验答案 + startValidate(); // console.log(`click next button`, prevLoading.value || loading.value); // if (prevLoading.value || loading.value) { // return; diff --git a/src/views/Survey/views/Preview/components/questions/PreviewMatrixCheckbox.vue b/src/views/Survey/views/Preview/components/questions/PreviewMatrixCheckbox.vue index 37fdba5..669b994 100644 --- a/src/views/Survey/views/Preview/components/questions/PreviewMatrixCheckbox.vue +++ b/src/views/Survey/views/Preview/components/questions/PreviewMatrixCheckbox.vue @@ -3,8 +3,8 @@ :index="answerIndex" v-model:rowRecord="rowRecord" v-model:matrix-radio-answer="answer!" - :rows="rows" - :cols="cols" + :rows="rows.options" + :cols="cols.options" :is-preview="true" :errorMessage="question.error" :element="question" @@ -13,11 +13,12 @@