<template>
	<view>
		<!-- 动态加载表单组件 -->
		<component :is="currentForm" :taskForm="taskForm" :taskName="taskName" :startUserName="startUserName" />
	</view>
</template>

<script>
	import {
		getProcessVariables
	} from "@/api/flowable/definition";
	import Declare from './components/declare/declare.vue';
	export default {
		components: {
			Declare,
		},
		data() {
			return {
				procDefName: '', // 流程名称
				taskName: '', // 当前节点
				startUserName: '', // 流程发起人
				formId: '',
				taskForm: {},
				currentForm: null // 当前加载的表单组件
			};
		},
		onLoad(options) {
			// 接收传递的参数
			this.procDefName = options.procDefName;
			this.taskName = options.taskName;
			this.startUserName = options.startUserName;
			// 根据流程名称加载不同的表单组件
			getProcessVariables(options.taskId).then(res => {
				this.taskForm = res.data;
				this.loadForm();
			})

		},
		methods: {
			loadForm() {
				switch (this.procDefName) {
					case '工作填报':
						this.currentForm = 'Declare';
						break;
					case '流程B':
						this.currentForm = 'ProcessBForm';
						break;
					default:
						console.log('未知流程');
						break;
				}
			}
		}
	}
</script>

<style lang="scss">

</style>