<template>
	<view class="ezy-jstx-ziliao-page">
		<view class="icon-title-navBar-box">
			<text class="nav-bar-title">{{data.ziliaoName}}</text>
		</view>
		<!--<view class="ezy-page-body">
			<scroll-view scroll-y="true" class="level-list-container">
				<view v-for="(item, index) in data.dengjiList" :key="item.dengjiId" class="level-item">
					<view class="level-item-content">
						&lt;!&ndash; 图标 &ndash;&gt;
						<view @click="selectDjBtn(item)"
						:class="{active: item.dengjiId == data.dengjiActiveSelect}">{{ item.dengjiName }}</view>

						<view>
							<view class="ziliao-card-box">
								&lt;!&ndash; <img/> &ndash;&gt;
								&lt;!&ndash; 内容区 &ndash;&gt;
								<view class="content-box">
									<text class="title">{{ ziliaoName }}</text>
									<text class="version">{{ getFirstVersion(item.banbenList) }}</text>
								</view>

								&lt;!&ndash; PDF 按钮 &ndash;&gt;
								<view class="pdf-btn">
									<icon>PDF</icon>
								</view>
							</view>

						</view>

					</view>
				</view>
			</scroll-view>
		</view>-->
		<!--<jstxDownDialog ref="jiaocaiRef" @confirm-btn="jcConfirm" :content="jcContent"></jstxDownDialog>-->
	</view>
</template>

<script setup>
import {reactive, ref} from "vue";
import {onLoad,onShow} from "@dcloudio/uni-app"
import {jisuanInfo,jisuanPdf} from '@/api/ziliao.js'
import jstxDownDialog from './jstxDownDialog.vue';
const data = reactive({
	id: '',
	ziliaoName: '',
	dengjiList: [],
	dengjiActiveSelect: '',
})

// jisuantexun Info data
function getJisuanInfo() {
  jisuanInfo({ziliaoId:data.id}).then(res => {
	  data.ziliaoName = res.data.ziliaoName;
	  data.dengjiList = res.data.dengjiList;
	  // 默认为等级list中第一个
	  data.dengjiActiveSelect = res.data.dengjiList[0].dengjiId;
  })
}

// 获取第一个版本名称
function getFirstVersion(banbenList) {
	if (banbenList && banbenList.length > 0) {
		return banbenList[0].banbenName;
	}
	return '未知版本';
}

function selectDjBtn(item){
	data.dengjiActiveSelect = item.dengjiId
}

onLoad((options) => {
	data.id = options.ziliaoId;
	console.log('options',options);
	getJisuanInfo()
})
</script>
