<template>
	<view class="dljt-page-box">
		<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-text">教育教学</view>
					<icon class="breadcrumb-jt"></icon>
					<view class="breadcrumb-active">专业建设</view>
				</view>
				
				<view>
					<view :class="{active: data.type == 1}" @click="changeType(1)">专业发展</view>
					<view :class="{active: data.type == 2}" @click="changeType(2)">人培方案</view>
					<view :class="{active: data.type == 3}" @click="changeType(3)">课程标准</view>
					<view :class="{active: data.type == 4}" @click="changeType(4)">实训安全</view>
					<view :class="{active: data.type == 5}" @click="changeType(5)">教材管理</view>
				</view>
				
				<MtaScrollViewVue :refreshFn="getList" :other-option="{type: data.type}" ref="listRef">
					<template v-slot="{ list }">
						<view class="data-content-item" v-for="item in list" :key="item.id" @click="handleClick(item)">
							<view class="list-time-box">
								<view class="time-data">{{formatDateToYearMonthDay(item.createTime)[1]}}</view>
								<view class="time-year">{{formatDateToYearMonthDay(item.createTime)[0]}}</view>
							</view>
							<view class="list-title-box"> {{item.title}} </view>
						</view>
					</template>
				</MtaScrollViewVue>
			</view>
			<!-- 底部导航 -->
			<MtaFooter></MtaFooter>
		</view>
	</view>
</template>

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

	const data = reactive({
		list: '',
		total: '',
		page: 1,
		size: 5,
		type: 1
	})
	
	const listRef = ref(null)
	
	onLoad(({type}) => {
		data.type = type;
	})

	function handleClick(data) {
		uni.navigateTo({
			url: `/pages/jyjxZhuanyejiansheInfo/jyjxZhuanyejiansheInfo?id=${data.id}&type=${data.type}`
		})
	}

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

	function handleGo() {
		uni.navigateTo({
			url: '/pages/index/index'
		})
	}
	
	function changeType(code) {
		data.type = code;
		data.page = 1;
		nextTick(() => {
			listRef.value.onRefresh()
		})
	}
	
	function pageInit() {
		httpApi.getJiaoyuZhuanyejiansheList({page:data.page,size:data.size,type: data.type}).then(res => {
			data.list = res.data.data;
			data.total = res.data.total;
		})
	}
</script>

<style>

</style>
