<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.visitTime }
					]"
				></ServiceInfoList>
			</ServicePanel>

			<ServicePanel title="评估结果摘要">
				<view class="summary-card">
					<text class="summary-line">风险等级：{{ detail.riskLevel }}</text>
					<text class="summary-line">护理等级：{{ detail.careLevel }}</text>
					<text class="summary-line">结论摘要：{{ detail.assessmentSummary }}</text>
				</view>
			</ServicePanel>

			<ServicePanel title="评估标签">
				<view class="tag-row">
					<view v-for="item in detail.requirementTags" :key="item" class="tag-item">{{ item }}</view>
				</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 { fetchAdminAssessmentDetail } from '@/services/homeServiceService.uts'
import { HomeServiceAssessmentType } from '@/types/home-service.uts'

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

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

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

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

.tag-row {
	flex-direction: row;
	flex-wrap: wrap;
	gap: 16rpx;
}

.tag-item {
	padding: 14rpx 20rpx;
	border-radius: 999rpx;
	background: #eef2f6;
}
</style>
