<template>
	<div style="overflow-y: auto; height: 100vh;width: 100vw">
				<!-- <BreadCrumb /> -->
				<VideoDetails :isState="isState" ref="VideoDetailsRef" @onGetPageCommentNew="onGetPageCommentNew" />
				<TallList ref="tallList" v-show="!isState" />
				<div style="display: flex; justify-content: flex-end; margin-top: 10px" v-if="isAudit && isState">
					<a-button @click="handleAuditResult(3)" style="margin-right: 10px">不同意</a-button>
					<a-button type="primary" @click="handleAuditResult(2)">同意</a-button>
				</div>
				<!-- <ResourceDetails v-if="indexType == 'resourceDetails'" ref="ResourceDetailsRef" /> -->
			</div>
</template>

<script setup>
	import Header from '@/views/portal/components/Header.vue'
	import BreadCrumb from '@/views/portal/components/BreadCrumb.vue'
	import Footer from '@/views/portal/components/Footer.vue'
	import VideoDetails from './components/VideoDetails.vue'
	import { useRoute, useRouter } from 'vue-router'
	import TallList from './components/TallList.vue'
	import { addViewCount, detail, add, queryList ,isHaveAuth} from '@/api/portal'
	import resourceAuditApi from '@/api/resourceAudit.js'
	import EventBus from '@/utils/EventBus'

	const router = useRouter()
	const route = useRoute()
	const indexType = ref('resourceCenter')
	const itemData = ref({})
	const tallList = ref(null)
	const VideoDetailsRef = ref(null)

	const isState = ref(route.query.state || null)
	const isAudit = ref(route.query.audit || null)
	//     {
	//     "fileName": "Kettle文档",
	//     "courseType": "0",
	//     "courseTypeName": "必修",
	//     "collegeAllId": "1938796923484962817,1938796975385280513,1938797957397676033",
	//     "suffix": "doc",
	//     "collegeTwoId": "1938796975385280513",
	//     "verifyStatus": "2",
	//     "collegeThreeIdName": "维修部",
	//     "collegeThreeId": "1938797957397676033",
	//     "collegeId": "1938796923484962817",
	//     "resourceCreaterUserName": "超管",
	//     "coverImage": "",
	//     "coverImagePath": "",
	//     "fileUrl": "upload/20250626/a37672e03659d06fa618842c9c443910.doc",
	//     "courseIdName": "胸口碎大石2",
	//     "id": "1938857816211292161",
	//     "viewCount": 100,
	//     "courseId": "1937326992873689091",
	//     "collegeAllIdName": "汽车工程学院,汽车部门,维修部",
	//     "FILESIZE": 1105920,
	//     "majorId": "1",
	//     "uploadTime": "2025-06-26 18:32:18",
	//     "verifyStatusName": "已发布",
	//     "resourceDesc": "大东北，是我的家乡，唢呐吹出了美美滴模样",
	//     "collegeIdName": "汽车工程学院",
	//     "majorIdName": "草台班子",
	//     "collegeTwoIdName": "汽车部门",
	//     "fileId": "1938183534250917888"
	// }
	const onGetPageCommentNew = (item) => {
		// emit('handlerItemSidebar', item)
		console.log('发消息去请求网卡罗2', item)
		tallList.value.onGetPageCommentNew(item)
	}
	const handleAuditResult = (val) => {
		const params = {
			ids: route.query.id,
			verifyStatus: val
		}
		resourceAuditApi
			.updateStatus(params)
			.then((res) => {
				if (res.code == 200) {
					// auditModalVisible.value = false
					router.go(-1)
				}
				// getListData()
			})
			.catch((err) => {
				console.error(err)
			})
	}
	// const onChangeCurrent = (current) => {
	// 	indexType.value = current
	//
	// 	router.push({
	// 		path: '/' + current
	// 	})
	// }

	const setData = (item) => {
		// emit('handlerItemSidebar', item)

		getData(item)
	}
	const getData = (item) => {
		detail({ id: item.id })
			.then((res) => {
				if (res.code == 200) {
					itemData.value = res.data

					VideoDetailsRef.value.setData(res.data)
				}
			})
			.catch((err) => {})
	}

	onMounted(() => {
		const id = route.query.id
		if (id != undefined && id != '') {

			isHaveAuth({ id: id }).then((res)=>{
				if(res.code == 200){
					if(res.data.isHaveAuth == 1){
						addViewCount({ id: id })
						getData({ id: id })
					}else{
						router.replace({
							path: '/notLook'
						})
					}
				}
			})


		}
	})
	defineExpose({
		setData
	})
</script>

<style scoped>
	.content {
		border: 1px solid #00000011; /* 灰色细边框 */
	}
	.scroll-container {
		height: 100vh;
		overflow-y: auto;
	}
</style>
