<template>
	<template v-if="option.type == schemeTypeEnum['服务告知']">
		<announcementsVue
			:content="content"
			:date="option.date"
			:index="option.index"
		></announcementsVue>
	</template>
	<template v-if="option.type == schemeTypeEnum['注意事项']">
		<announcements-vue
			:content="content"
			:date="option.date"
			:index="option.index"
		></announcements-vue>
	</template>
	<template v-if="option.type == schemeTypeEnum['复诊提醒']">
		<return-visit-vue
			:content="content"
			:date="option.date"
			:index="option.index"
		></return-visit-vue>
	</template>
	<template v-if="option.type == schemeTypeEnum['宣教']">
		<health-education-vue
			:content="content"
			:date="option.date"
			:index="option.index"
		></health-education-vue>
	</template>
	<template v-if="option.type == schemeTypeEnum['问卷']">
		<questionnaire-vue
			:content="content"
			:date="option.date"
			:index="option.index"
		></questionnaire-vue>
	</template>
</template>

<script lang="ts" setup>
import { getCurrentInstance, nextTick, reactive, ref, computed } from 'vue';
import { useStore } from 'vuex';
import { useOnLoad } from '@/hook';
import { schemeTypeEnum } from '../../static/schemeDetail';
import AnnouncementsVue from './template/announcements.vue';
import HealthEducationVue from './template/health-education.vue';
import QuestionnaireVue from './template/questionnaire.vue';
import ReturnVisitVue from './template/return-visit.vue';
import { GetPatientGroupPlanDetailList, GetPatientGroupPlanDetail } from '../../service';

defineOptions({
	components: {
		AnnouncementsVue,
		HealthEducationVue,
		QuestionnaireVue,
		ReturnVisitVue,
	},
});

const option = reactive({
	type: '',
	planuuid: '',
	id: '',
	memberName: '',
	date: '',
	index: '',
});
const content = ref([]);

/** 查询患者组内执行计划详情列表 */
const getPatientGroupPlanDetailList = async () => {
	const params = {
		PlanUuid: option.planuuid,
		TempType: option.type,
	};
	const resp = await GetPatientGroupPlanDetailList(params);
	content.value = resp;
};
/** 查询患者执行计划详情 */
const getPatientGroupPlanDetail = async () => {
	const params = {
		Id: option.id,
	};
	const resp = await GetPatientGroupPlanDetail(params);
	content.value = resp;
};

useOnLoad((options: any) => {
	uni.setNavigationBarTitle({
		title: schemeTypeEnum[options.type],
	});
	Object.keys(options).map((key) => {
		option[key] = options[key];
	});
	if ([schemeTypeEnum['宣教'], schemeTypeEnum['问卷']].includes(option.type)) {
		getPatientGroupPlanDetail();
	} else {
		getPatientGroupPlanDetailList();
	}
});
</script>

<style lang="scss" scoped></style>
