<template>
	<div style="overflow-y: auto">
		<a-layout>
			<Header @onChangeCurrent="onChangeCurrent" />
			<div style="width: 71%; margin-left: 10%">
				<BreadCrumb />
				<VideoDetails :isState="isState" ref="VideoDetailsRef" />
				<TallList v-if="!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>
		</a-layout>
		<Footer />
	</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 } from '@/api/portal'
	import resourceAuditApi from '@/api/resourceAudit.js'
	import EventBus from '@/utils/EventBus'

	const router = useRouter()

	const indexType = ref('resourceCenter')
	const itemData = ref({})
	const VideoDetailsRef = ref(null)
	const route = useRoute()
	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 handlerItemSidebar = (item) => {
		// emit('handlerItemSidebar', 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 != '') {
			addViewCount({ id: id })
			getData({ id: id })
		}
	})
	defineExpose({
		setData
	})
</script>

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