<template>
	<view class="h100vh page-bg-color">
		<u-navbar :customBack="handleBackHome" :title="typeLabel[currentType]"></u-navbar>
		<view class="workflow-page" :style="{height: `calc(100vh - ${diStatusBarHeight}px - 48px)`}">
			<view class="workflow-main">
				<start-workflow v-if="currentType === 'start'"></start-workflow>
				<approve-center v-else :type='currentType'></approve-center>
			</view>
		</view>
	</view>	
</template>

<script>
	import startWorkflow from './startWorkflow/startWorkflow'
	import approveCenter from './approveCenter/index'
    import constant from '@/utils/constant.js'
	export default {
		data() {
			return {
				currentType: 'start',
				typeLabel: {
					start: '发起申请',
					myLaunch: '我发起的',
					todo: '我的待办',
					done: '我的已办',
					cc: '抄送我的',
					manager: '流程干预',
				},
				diStatusBarHeight: 0
			};
		},
		onLoad(options) {
			this.diStatusBarHeight = uni.getSystemInfoSync().statusBarHeight
			this.currentType = options.type
            console.log('类型',options.type)
		},
		components: {
			startWorkflow,
			approveCenter
		},
		methods: {
			handleBackHome() {
				console.log('000000')
                let url=constant.host()
                window.parent.postMessage('/pages/index/index',url+'/mobile/pages/flow/flow')

				// uni.switchTab({
				// 	url: '/pages/home/home'
				// })
			}
		}
	}
</script>

<style lang="scss">
	.h100vh {
		height: 100vh;
	}
	.workflow-page {
		.workflow-main {
			height: 100%;
			overflow: hidden;
		}
	}
	
</style>
