<template>
	<view class="examination-item">
		<u-card padding="32" full :showHead="false">
			<view slot="body">
				<view>
					<u-button type="primary" size="mini" disabled>{{questionObj.questionType == 1 ? '单选题' : questionObj.questionType == 2 ? '多选题' : '判断题'}}</u-button>
				</view>
				<!-- 题干 -->
				<view class="question">
				  {{itemIndex + 1}}. {{questionObj.questionContent}}
				</view>
				<!-- 选项- for循环每个选项 -->
				<block v-for="item in questionObj.questionOptionList" :key="item.id">
					<view
						class="question-option"
						@click="choose(item)"
						:class="selectCode === item.optionCode ? 'question-option-active' : ''"
					>
						{{item.optionCode}}. {{item.optionContent}}
					</view>
				</block>
			</view>
		</u-card>
	</view>
</template>

<script>
	export default {
		props: {
			questionObj: {
				type: Object,
				default: () => {}
			},
			itemIndex: {
				type: Number,
				default: 0
			},
		},
		data() {
			return {
				selectCode: null,
				testValue: 'lxp',
			};
		},
		methods: {
			choose(e) {
				const originalCode = this.selectCode
				this.selectCode = e.optionCode
				this.$emit('selected', originalCode, e.optionCode, this.questionObj.id, this.itemIndex)
			},
		}
	}
</script>

<style lang="scss">
	.examination-item {
		
		.question {
			margin: 16rpx 0;
			color: #1F2937;
			line-height: 56rpx;
			font-size: 36rpx;
		}
		.question-option {
			margin: 24rpx 0;
			padding: 24rpx 0 24rpx 26rpx;
			box-sizing: border-box;
			border: 1px solid #E4E7ED;
			border-radius: 8rpx;
		}
		.question-option-active {
			background-color: #E8FBF6;
			border: 1px solid #00C18A;
		}
	}
</style>