<template>
	<div class="bill-original-text-page">
		<div class="page-header">
			<div class="page-title">法案原文</div>
			<div class="page-actions">
				<div class="action-btn" @click="handleBack">返回</div>
			</div>
		</div>

		<div class="page-content">
			<iframe v-if="billFullText" :src="billFullText" width="100%" height="100%" frameborder="0"></iframe>
			<div v-else class="empty-state">暂无原文</div>
		</div>
	</div>
</template>

<script setup>
import { onMounted, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import { getBillFullText } from "@/api/bill";

const route = useRoute();
const router = useRouter();

const billFullText = ref("");

const getBillFullTextFn = async () => {
	const res = await getBillFullText({
		id: route.query.billId
	});
	if (res.code === 200 && res.data) {
		billFullText.value = typeof res.data === "string" ? res.data.trim() : res.data;
	}
};

const handleBack = () => {
	router.back();
};

onMounted(() => {
	getBillFullTextFn();
});
</script>

<style lang="scss" scoped>
.bill-original-text-page {
	width: 100%;
	box-sizing: border-box;
	background: rgba(248, 249, 250, 1);
	padding: 0 0 20px;

	.page-header {
		width: 100%;
		height: 64px;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.page-title {
			color: rgba(59, 65, 75, 1);
			font-family: Microsoft YaHei;
			font-size: 18px;
			font-weight: 700;
		}

		.page-actions {
			display: flex;
			justify-content: flex-end;

			.action-btn {
				cursor: pointer;
				height: 32px;
				line-height: 32px;
				padding: 0 12px;
				border-radius: 6px;
				border: 1px solid rgba(230, 231, 232, 1);
				background: rgba(255, 255, 255, 1);
				color: rgba(95, 101, 108, 1);
				font-family: Microsoft YaHei;
				font-size: 14px;
				font-weight: 400;
			}
		}
	}

	.page-content {
		width: 100%;
		height: calc(100vh - 320px);
		min-height: 600px;
		background: #fff;
		box-shadow: 0px 0px 20px 0px rgba(25, 69, 130, 0.1);
		overflow: hidden;

		iframe {
			display: block;
		}

		.empty-state {
			height: 100%;
			display: flex;
			align-items: center;
			justify-content: center;
			color: rgba(132, 136, 142, 1);
			font-family: Microsoft YaHei;
			font-size: 14px;
		}
	}
}
</style>

