<template>
	<view class="dljt-page-box xzzx-page">
		<MtaNavbar></MtaNavbar>
		<view class="dljt-container-box">
			<view class="dljt-page-title">下载中心</view>
			<view class="dljt-page-content-box">
				<view class="dljt-breadcrumb-box">
					<view class="breadcrumb-text" @click="handleGo()">首页</view>
					<icon class="breadcrumb-jt"></icon>
					<view class="breadcrumb-active">下载中心</view>
				</view>
				<view class="dljt-detail-box">
					<!-- 查询 -->
					<view class="xzzx-search-box">
						<uni-data-select v-model="data.activeId" :localdata="data.treeList"></uni-data-select>
						<view @click="handleClick" class="xzzx-search-btn">查询</view>
					</view>
					<view class="dljt-table-box">
						<view class="table-th-row">
							<view style="width: 15%">序号</view>
							<view style="width: 20%">类别</view>
							<view style="width: 40%">文件</view>
							<view style="width: 25%">文件下载</view>
						</view>
						<MtaScrollViewVue ref="myRef" :refreshFn="getList" :size="10"
							:otherOption="{classifyId: data.activeId}">
							<template v-slot="{ list }">
								<view class="table-td-row" v-for="(item,index) in list" :key="item.id">
									<view style="width: 15%">{{index+1}}</view>
									<view style="width: 20%">{{item.classifyName}}</view>
									<view style="width: 40%">{{item.title}}</view>
									<view style="width: 25%" @click="handleDownFile(item)">下载</view>
								</view>
							</template>
						</MtaScrollViewVue>
					</view>
				</view>
			</view>
			<!-- 底部导航 -->
			<MtaFooter></MtaFooter>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from "vue";
	import {
		onLoad
	} from "@dcloudio/uni-app"
	import * as httpApi from "@/api/common.js"
	import MtaScrollViewVue from "@/components/MtaScrollView/MtaScrollView.vue";
	import MtaFooter from "@/components/MtaFooter.vue"

	const myRef = ref(null);

	const data = reactive({
		content: '',
		activeId: null,
		treeList: []
	})

	onLoad(() => {
		pageInit();
	})

	function handleDownFile(item) {
		window.location.href = item.pdfUrl
	}

	function getList(data) {
		return httpApi.getCommonZsjyXXazaiList(data)
	}

	function handleClick() {
		myRef.value.onRefresh()
	}

	function pageInit() {
		httpApi.getCommonZsjyXXazaiTree().then(res => {
			data.treeList = res.data.children.map(item => {
				return {
					value: item.id,
					text: item.lable
				}
			});
		})
		httpApi.getCommonZsjyXXazaiList(data).then(res => {})
	}
</script>

<style>

</style>