<template>
	<view v-if="question" class="phone-tiankong-box">
		<view class="phone-shiti-question">
			<view class="question-num">{{question.onlyNum}}、</view>
			<!-- 题干区域 -->
			<rich-text :nodes="question.name"></rich-text>
		</view>
		<!-- 选项区域 -->
		<view v-for="(item,index) in question.reply" class="tiankong-option-box" :key="index" :class="formatClass(index)">
			<text class="option-question">填空{{index+1}}:</text>
			<input type="text" v-model="question.reply[index]" class="option-question-text" :placeholder="`请输入填空${index+1}答案`">
		</view>
	</view>
</template>

<script setup>
	const props = defineProps({
		question: {
			type: Object,
		},
		showError: {
			type: Boolean,
			default: false
		}
	})

	function formatClass(index) {
		if (props.showError) {
			return {
				active_right: props.question.result[index].some(item => item == props.question.reply[index]?props.question.reply[index].trim(): ''),
				showError: !props.question.result[index].some(item => item == props.question.reply[index]?props.question.reply[index].trim(): '')
			}
		}
	}
</script>
