<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.serviceName },
						{ label: '方案标题：', value: detail.planTitle }
					]"
				></ServiceInfoList>
			</ServicePanel>

			<ServicePanel title="执行安排">
				<view class="summary-card">
					<text class="summary-line">服务频次：{{ detail.serviceFrequency }}</text>
					<text class="summary-line">服务周期：{{ detail.serviceCycle }}</text>
					<text class="summary-line">方案摘要：{{ detail.planSummary }}</text>
				</view>
			</ServicePanel>

			<ServicePanel title="补充说明">
				<view class="summary-card muted-card">
					<text class="summary-line">执行建议：{{ detail.executorAdvice }}</text>
					<text class="summary-line">收费说明：{{ detail.billingSummary }}</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 { fetchAdminServicePlanDetail } from '@/services/homeServiceService.uts'
import { HomeServicePlanType } from '@/types/home-service.uts'

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

async function loadData() {
	detail.value = await fetchAdminServicePlanDetail(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,
.summary-line {
	font-size: 28rpx;
	line-height: 40rpx;
	color: #16324f;
}

.summary-card {
	padding: 24rpx;
	border-radius: 20rpx;
	background: #f8fbfc;
}

.muted-card {
	background: #eef5fb;
}

.summary-line + .summary-line {
	margin-top: 12rpx;
}
</style>
