<template>
	<div class="workflow-container">
		<!-- <van-nav-bar title="请假申请审批" left-arrow @click-left="onClickLeft" /> -->

		<van-tabs v-model:active="activeTab" sticky>
			<van-tab title="业务详情">
				<BusinessDetail :key="'business'" v-if="activeTab === 0" />
			</van-tab>
			<van-tab title="审批流程">
				<ApprovalProcess :key="'approval'" v-if="activeTab === 1" />
			</van-tab>
			<van-tab title="流程图">
				<FlowChart :key="'flow'" v-if="activeTab === 2" />
			</van-tab>
		</van-tabs>
	</div>
</template>

<script setup lang="ts">
	import { ref, onMounted, provide, getCurrentInstance } from 'vue'
	import { useRouter, useRoute } from 'vue-router'
	import BusinessDetail from '@/view/workflow/business-detail.vue'
	import ApprovalProcess from '@/view/workflow/approval-process.vue'
	import FlowChart from '@/view/workflow/flow-chart.vue'
	const {
		proxy
	} = getCurrentInstance()
	// 定义工作流参数的接口
	interface WorkflowParams {
		userId : string
		flowId : string
		workId : string
	}

	const router = useRouter()
	const route = useRoute()
	const activeTab = ref(0)

	// 从查询参数中获取值
	const workflowParams = {
		userId: route.query.userId as string,
		flowId: route.query.flowId as string,
		workId: route.query.workId as string,
		trackId: route.query.trackId as string,
		subjectionId: route.query.subjectionId as string
	}

	// 提供给子组件使用
	provide('workflowParams', workflowParams)

	onMounted(() => {
		// 验证参数
		if (!workflowParams.userId || !workflowParams.flowId || !workflowParams.workId) {
			console.error('缺少必要的参数')
			return
		}

		// 初始化数据
		// fetchWorkflowData()
	})

	// 使用参数的示例函数
	async function fetchWorkflowData() {
		try {
			// 使用参数调用 API
			// const data = await getWorkflowData({ userId, flowId, workId })
			// ... 处理数据


			// 		var url = 'framework/SysLogin/queryPublicKey'
			// 		var param = {

			// 		}
			// 		proxy.$axios.post(url, param).then(response => {
			// 			console.log('publicKey---' + response.data.data)
			// 		}) 
			console.log('framework/SysUser/query')
			var url = 'framework/SysUser/query'
			var param = {
				page: 1,
				rows: 10,
				userDesc: ''
			}
			proxy.$axios.get(url, param).then(response => {
				if (response.data.code == '0') {
					console.log('records----' + JSON.stringify(response.data.data.records))
					console.log('total' + response.data.data.total)
				} else {
					console.log(response.data.code + response.data.msg)
				}
			})


		} catch (error) {
			console.error('获取工作流数据失败:', error)
		}
	}

	function onClickLeft() {
		router.back()
	}
</script>

<style lang="scss" scoped>
	.workflow-container {
		min-height: 100vh;
		background-color: #f7f8fa;
	}
</style>