Ver Fonte

多选类问题也要默认隐藏

wangjian há 6 horas atrás
pai
commit
f4fcabc082

+ 16 - 4
pagesAdmin/satisfaction/business/satisfactionQuestions/satisfactionQuestions.vue

@@ -344,6 +344,7 @@ const point = ref('');
 const complete = ref(false);
 const subtitleSatisfactionOptions = ['非常满意', '比较满意', '一般', '不太满意', '很不满意'];
 const subtitleSatisfaction = reactive({} as Record<string, number | null>);
+const subtitleHiddenQuestionTypes = ['Radio', 'Scale', 'Checkbox'];
 const anonymousType = ref(0);
 const showModal_Anonymous = ref(false); // 是否实名填写弹窗显示
 const showModal_User = ref(false); // 实名用户选择弹窗显示
@@ -632,7 +633,7 @@ const bySort = (list: any[]) => {
 			item.SubTitleIndex = currentSubTitleIndex;
 			item.Sort = sort + 1;
 			sort++;
-			if (item.QuestType == 'Scale' && currentSubTitleItem) {
+			if (isSubtitleHiddenQuestion(item) && currentSubTitleItem) {
 				currentSubTitleItem.HasScaleInSubtitle = true;
 			}
 		}
@@ -681,8 +682,12 @@ const isSubtitleSatisfactionActive = (subtitleIndex, childIndex) => {
 	return Number(subtitleSatisfaction[subtitleIndex]) === Number(childIndex);
 };
 
+const isSubtitleHiddenQuestion = (item) => {
+	return subtitleHiddenQuestionTypes.includes(item?.QuestType);
+};
+
 const isQuestionHidden = (item) => {
-	return item?.QuestType == 'Scale' && item.SubTitleIndex > -1 && !isSubtitleScaleExpanded(item.SubTitleIndex);
+	return isSubtitleHiddenQuestion(item) && item.SubTitleIndex > -1 && !isSubtitleScaleExpanded(item.SubTitleIndex);
 };
 
 const getAnswerIndex = (answerList, questId) => {
@@ -699,9 +704,16 @@ const setSingleQuestionAnswer = (question, answerList, childIndex) => {
 	if (!question?.QuestionItemList?.[childIndex]) return;
 	const answerIndex = getAnswerIndex(answerList, question.QuestId);
 	const answer = question.QuestionItemList[childIndex].ItemId;
+	if (question.QuestType == 'Checkbox' && !question.MustQuest) {
+		question.AnswerList = [];
+		if (answerIndex > -1) {
+			answerList[answerIndex].Answer = [];
+		}
+		return;
+	}
 	question.AnswerList = [answer];
 	if (answerIndex > -1) {
-		answerList[answerIndex].Answer = answer;
+		answerList[answerIndex].Answer = question.QuestType == 'Checkbox' ? [answer] : answer;
 	}
 };
 
@@ -714,7 +726,7 @@ const choiceSubtitleSatisfaction = (e) => {
 
 	if (childIndex == 0) {
 		questionList.forEach((item) => {
-			if (item.SubTitleIndex == subtitleIndex && item.QuestType == 'Scale') {
+			if (item.SubTitleIndex == subtitleIndex && isSubtitleHiddenQuestion(item)) {
 				setSingleQuestionAnswer(item, answerList, 0);
 			}
 		});