<template>
	<ServicePageScaffold title="结算归档" fallback-url="/pages/mall/consumer/home-service/index">
		<view v-if="detail == null" class="empty-box">
			<text class="empty-text">未找到结算信息</text>
		</view>
		<view v-else>
			<ServicePanel title="结算归档" subtitle="查看服务账单和归档状态。">
				<ServiceInfoList
					:items="[
						{ label: '服务单号：', value: detail.caseNo },
						{ label: '服务对象：', value: detail.elderName },
						{ label: '账期：', value: detail.billingPeriod },
						{ label: '归档状态：', value: detail.archiveStatusText }
					]"
				></ServiceInfoList>
			</ServicePanel>

			<ServicePanel title="费用明细">
				<view class="amount-card">
					<text class="amount-line">服务总额：{{ detail.totalAmount }}</text>
					<text class="amount-line">长护险 / 补贴：{{ detail.insuranceAmount }}</text>
					<text class="amount-line">个人自付：{{ detail.selfPayAmount }}</text>
				</view>
			</ServicePanel>

			<ServicePanel title="归档说明">
				<view class="archive-box">
					<text class="archive-text">已包含执行记录、验收反馈、结算单与电子档案索引，方便家属追踪服务闭环。</text>
				</view>
			</ServicePanel>
		</view>
	</ServicePageScaffold>
</template>

<script setup lang="uts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import ServiceInfoList from '@/components/homeService/ServiceInfoList.uvue'
import ServicePageScaffold from '@/components/homeService/ServicePageScaffold.uvue'
import ServicePanel from '@/components/homeService/ServicePanel.uvue'
import { fetchAdminSettlementDetail } from '@/services/homeServiceService.uts'
import { HomeServiceSettlementType } from '@/types/home-service.uts'

const caseId = ref('case-001')
const detail = ref<HomeServiceSettlementType | null>(null)

async function loadData() {
	detail.value = await fetchAdminSettlementDetail(caseId.value)
}

onLoad((options) => {
	const id = options['id']
	if (id != null && id != '') {
		caseId.value = id as string
	}
	loadData()
})
</script>

<style scoped>
.empty-box {
	padding: 120rpx 0;
	align-items: center;
}

.empty-text,
.amount-line,
.archive-text {
	font-size: 28rpx;
	line-height: 40rpx;
	color: #16324f;
}

.amount-card,
.archive-box {
	padding: 24rpx;
	border-radius: 20rpx;
	background: #f8fbfc;
}

.amount-line + .amount-line {
	margin-top: 12rpx;
}

.archive-text {
	color: #66788a;
}
</style>
