<template>
	<el-container class="approve-form-container is-vertical">
		<template v-if="businessId && !isNullStringValue(businessId) && typeDic[mode]">
			<component :is="allComps[typeDic[mode]]" :id="businessId" :mode="mode" isIframe disabled></component>
		</template>
	</el-container>
</template>

<script>
import allComps from "@/components/scChengTou/purchase";

export default {
	data() {
		return {
			allComps, // plan, apply, handler 表单组件
			typeDic: {
				purchase_plan: "plan",
				purchase: "apply",
				purchase_matter: "handler",
				purchase_bid_sign: "handler",
				purchase_answer_sign: "handler",
				purchase_bid_notice: "handler"
			},

			businessId: "",
			mode: ""
		}
	},

	mounted() {
		this.getBusinessId();
	},

	methods: {
		async getBusinessId() {
			const { type, processInstanceId } = this.$route.query;

			if (type && processInstanceId && this.$TOOL.data.get("USER_INFO") && this.typeDic[type]) {
				this.mode = type;
            	this.businessId = await this.$API.procurement.ledger.getBusinessId({ type, instanceId: processInstanceId });
			}
		},

		isNullStringValue(str) {
			try {
				return JSON.parse(str) === null;
			} catch (e) {
				return false;
			}
		}
	}
}
</script>

<style lang="scss" scoped>
.approve-form-container {
  height: auto;
  background: #fff;

  :deep(.iframe-detail-title) {
    margin-bottom: 6px;
    padding-left: 0;
    line-height: 32px;

    &::before {
      display: none;
    }
  }
}
</style>