<template>
	<xn-form-container
		:width="620"
		:get-container="false"
		:visible="visible"
		:destroy-on-close="true"
		@close="onClose"
		:mask="false"
	>
		<div v-if="itemObj.key == 2" style="height: 100%">
			<handouts :itemObj="itemObj" :hourId="idsObj.hourId"></handouts>
		</div>
		<note v-if="itemObj.type == 2" :idsObj="idsObj" ref="noteRef" @videoSpeed="videoSpeed" @videoStopTime="videoStopTime"></note>
		<div v-if="itemObj.key == 3" style="height: 100%">
			<subtitleBox :url="itemObj.url" @videoSpeed="videoSpeed"></subtitleBox>
		</div>
		<askDiv v-if="itemObj.type == 4" :idsObj="idsObj" ref="noteRef" @videoSpeed="videoSpeed" @videoStopTime="videoStopTime"></askDiv>
	</xn-form-container>
</template>

<script setup>
	import classCentre from '@/api/student/classCentre'
	import note from './note.vue'
	import askDiv from './ask.vue'
	import handouts from './handouts.vue'
	import subtitleBox from './subtitle.vue'
	const props = defineProps({
		rightItem: {
			type: [Array, Object],
			required: () => {}
		},
		idsObj: {
			type: [Array, Object],
			required: () => {}
		}
	})
	const itemObj = computed(() => {
		return props.rightItem
	})
	const noteRef = ref()

	//tabs
	const activeKey = ref('1')
	// 默认是关闭状态
	const visible = ref(false)
	const emit = defineEmits({ videoSpeed: null ,videoStopTime:null})
	// 打开抽屉
	const onOpen = (edit) => {
		visible.value = true
		if (edit) {
			if (itemObj.value.type == 2) {
				formData.value.noteId = edit.noteId
				formData.value.noteContent = edit.noteContent
			} else {
				formData.value.info = edit.info
				formData.value.id = edit.id
			}
		}
	}
	// 关闭抽屉
	const onClose = () => {
		visible.value = false
	}
	const videoSpeed = (e) => {
		emit('videoSpeed', e)
	}
	const videoStopTime = (e) => {
		emit('videoStopTime', e)
	}
	const showPdf = ref(true)
	function errorHandler() {
		showPdf.value = false
	}
	// 调用这个函数将子组件的一些数据和方法暴露出去
	defineExpose({
		onOpen,
		onClose
	})
</script>
<style scoped lang="less"></style>
