fix: 修复矩阵填空内容选择一个就可以跳过的问题
- 添加行记录和对比选项,如果不一致则不传递答案 - 修正错误泛型 - 行和列数据获取调整
This commit is contained in:
4
src/types/question.d.ts
vendored
4
src/types/question.d.ts
vendored
@@ -81,7 +81,7 @@ export declare interface IQuestionConfig {
|
||||
}
|
||||
|
||||
// 答案 question
|
||||
export declare interface IQuestion<QuestionConfig> {
|
||||
export declare interface IQuestion<QuestionConfig = IBaseConfig> {
|
||||
error: string;
|
||||
answer?: unknown;
|
||||
id?: string;
|
||||
@@ -93,7 +93,7 @@ export declare interface IQuestion<QuestionConfig> {
|
||||
question_index?: number;
|
||||
question_type?: number;
|
||||
// 如果没有自定义类型,那么就直接用基础 config 类型
|
||||
config?: QuestionConfig extends undefined ? IBaseConfig : QuestionConfig;
|
||||
config?: QuestionConfig;
|
||||
created_at?: string;
|
||||
created_user_id?: number;
|
||||
updated_user_id?: number | null;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<MatrixQuestion
|
||||
v-model:rowRecord="rowRecord"
|
||||
:rows="rows"
|
||||
:cols="cols"
|
||||
:rows="rows.options"
|
||||
:cols="cols.options"
|
||||
:index="answerIndex"
|
||||
:element="question"
|
||||
:is-preview="true"
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import MatrixQuestion from '@/views/Design/components/Questions/MatrixQuestion.vue';
|
||||
import type { IQuestion } from '@/types/question';
|
||||
// const questionType = defineModel<number>('questionType', { required: false });
|
||||
|
||||
// 矩阵单选的答案类型
|
||||
@@ -26,7 +26,10 @@ type answerType = {
|
||||
// const stem = defineModel('stem');
|
||||
// const list = defineModel<questionsList[]>('list', { required: false });
|
||||
// const config = defineModel<OptionConfigType>('config', { required: false });
|
||||
const question = defineModel<question>('question', { default: () => {} });
|
||||
const question = defineModel<IQuestion>('question', { default: () => {} });
|
||||
|
||||
// console.log(`question`, question.value);
|
||||
|
||||
const answerIndex = computed(() => question.value?.title ?? 0);
|
||||
// console.log(question.value);
|
||||
const emit = defineEmits(['changeAnswer', 'previous', 'next']);
|
||||
@@ -70,8 +73,7 @@ function parseAnswer(answer: answerType) {
|
||||
* 行的内容在 question.list[0].options
|
||||
* 列的内容在 question.list[1].options
|
||||
*/
|
||||
const rows = computed(() => question.value?.list[0]?.options ?? []);
|
||||
const cols = computed(() => question.value?.list[1]?.options ?? []);
|
||||
const [rows, cols] = question.value?.list;
|
||||
|
||||
watch(
|
||||
rowRecord,
|
||||
@@ -82,6 +84,10 @@ watch(
|
||||
rowRecord.value.forEach((row, col) => {
|
||||
newAnswer[`${col + 1}_${row + 1}`] = 1;
|
||||
});
|
||||
|
||||
// 如果行记录答案不够,那么就不进行传递答案
|
||||
if (rowRecord.value.length !== rows.options.length) return;
|
||||
|
||||
answer.value = newAnswer;
|
||||
emit('changeAnswer', newAnswer);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user