<template>
	<view>
		<view>
			<!--====sl修改开始====-->
			<view class="jdt_style" v-for="(item,index) in current_timu.right_answer_arr" :key="index">
				<textarea placeholder="请输入答案" :value="current_timu.my_answer_arr[index]"
					@input="post_answer($event, index)" auto-height />
			</view>
			<!--====sl修改结束====-->
		</view>
		<view class="tkt_button" :class="is_jianda_sub ? 'duoxuan_checked' : 'duoxuan' "
			v-if="current_timu.right_answer_arr.length > 0" @tap="post_answer_req()">确定</view>
	</view>
</template>

<script>
	export default {
		props: {
			current_timu: {
				type: Object,
				default: function() {
					return {}
				},
			},
			is_jianda_sub: {
				type: Boolean,
				default: false,
			},
			show_beiti: {
				type: Boolean,
				default: true,
			},
			copy_user_answer: {
				type: Array,
				default: function() {
					return [];
				},
			}
		},
		watch: {
			current_timu: {
				handler(newVal, oldVal) {},
				deep: true,
				immediate: true
			}
		},
		methods: {
			// 提交答案
			post_answer(item, index) {
				if (this.is_jianda_sub) {
					this.$emit('set_sub_button_style', 'is_jianda_sub', false)
				}
				let timu = this.current_timu,
					my_answer_arr = this.current_timu.my_answer_arr;

				this.$set(my_answer_arr, index, item.detail.value)
				this.$set(timu, index, 'my_answer_arr', my_answer_arr)

				this.$set(timu, 'show_right_answer', true)
				if (timu.my_answer_arr.length > 0) {
					this.$set(timu, 'my_answer', timu.my_answer_arr.join('|'))
				}
				this.$emit('set_current_timu', timu)
				let copy_user_answer_this = this.copy_user_answer;
				if (copy_user_answer_this[this.current_timu.id]) {
					copy_user_answer_this[this.current_timu.id] = timu.my_answer_arr
				}
				this.$emit('set_copy_user_answer', copy_user_answer_this)
			},
			post_answer_req() {
				this.$emit('post_answer_req', true)
			},
		}
	}
</script>

<style>
</style>
