<script setup lang="ts">
import {onMounted} from 'vue';
import ApprovalAction from '/@//components/workbench/common/ApprovalAction.vue';
import ProjectPlanApplyFormDetails from '/@/components/investment/common/ProjectPlanApplyFormDetails.vue'
import {useRoute} from 'vue-router';
import {ProjectPlanApplyFormData} from '/@/components/investment/interface/types';
import {getInvestmentProjectsPlanByProcessInstanceId} from "/@/api/common";
const route = useRoute();
const isPreview = route.query.isPreview === 'true'
const taskId = ref<string>();
const projectId = ref<string>();
const projectDetail = ref<ProjectPlanApplyFormData>({} as ProjectPlanApplyFormData);
const getProjectDetail = (id:string) =>{
	getInvestmentProjectsPlanByProcessInstanceId(id).then(res =>{
		projectDetail.value.entity = res.data;
		projectDetail.value.investmentProjects = res.data.projectInvestmentEntities;
	});
}
onMounted(() =>{
	if (route.query.processInstanceId){
		taskId.value = <string>route.query.taskId;
		projectId.value = <string>route.query.processInstanceId;
		getProjectDetail(projectId.value);
	}
});
</script>

<template>
	<el-card>
		<el-row :gutter="20">
			<el-col :span="isPreview ? 24 : 18">
				<el-scrollbar>
						<project-plan-apply-form-details :processInstanceId="projectId" v-model="projectDetail" :is-edit="false" title="投资项目计划审核"/>
				</el-scrollbar>
			</el-col>
			<el-col :span="6" v-if="!isPreview">
				<ApprovalAction status="pending" :process-instance-id="projectId"/>
			</el-col>
		</el-row>
	</el-card>
</template>

<style scoped lang="scss"></style>
