<template>
	<view class="visit-note-page">
		<view class="navbox">
			<view class="status_bar"></view>
			<uni-nav-bar
			left-icon="left"
			title="添加随访计划"
			@clickLeft="goBack"
			color="#8B2316"
			:border="false"
			backgroundColor="#eee"
		>
			<template #right>
				<view class="nav-right" @click="submit" v-if="!followUpUuid">
					<text class="submit-text">添加</text>
				</view>
			</template>
		</uni-nav-bar>
		</view>

		<view class="contentbox">
			<!-- 患者行 -->
		<view class="row" @click="noop">
			<text class="row-label">患者</text>
			<text class="row-value">{{ patientName?patientName:'' }}</text>
		</view>

		<!-- 标题栏 -->
		<view class="section-title">随访内容</view>

		<!-- 输入框区域 -->
		<view class="note-box">
			<textarea class="note-textarea" v-model.trim="note" placeholder="请填写随访内容" auto-height :maxlength="200" :adjust-position="false"/>
		</view>
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'

	const patientName = ref('')
	const note = ref('请近日来医院复诊、复查')
	const idx = ref(0)
	onLoad((options) => {
		console.log(options.patient_name)
		patientName.value =options.patient_name ?decodeURIComponent(options.patient_name):'';
		console.log(patientName.value)
		if (options?.note) note.value = decodeURIComponent(options.note)
		if (options?.idx) idx.value = options.idx
		
	})

	const goBack = () => uni.navigateBack()
	const submit = () => {
		try {
			const pages = getCurrentPages()
			const curr = pages[pages.length - 1]
			const ec = curr?.getOpenerEventChannel?.()
			ec?.emit && ec.emit('onVisitNoteSubmit', { note: note.value, idx: Number(idx.value) })
		} catch (e) {}
		uni.showToast({ title: '已添加', icon: 'none' })
		setTimeout(() => goBack(), 600)
	}
	const noop = () => {}
</script>

<style lang="scss" scoped>
.contentbox{
	position: fixed;
	left: 0;
	right:0;
	overflow-y: scroll;
	top: calc(var(--status-bar-height) + 44px);
}
	.visit-note-page{
		 background:#f5f5f5;
	}
	.nav-right{ display:flex; align-items:center; }
	.submit-text{ color:#8B2316; font-size: 30rpx; }

	.row{
		margin-top: 20rpx; background:#fff; padding: 26rpx 30rpx; display:flex; align-items:center; justify-content:space-between; border-bottom: 1rpx solid #eee;
		.row-label{ font-size: 32rpx; color:#8B2316; font-weight: 500; }
		.row-value{ font-size: 32rpx; color:#333; }
	}

	.section-title{box-sizing: border-box; margin-top: 20rpx; background:#fff; padding: 22rpx 30rpx; color:#8B2316; font-size: 30rpx; border-top: 1rpx solid #eee; border-bottom: 1rpx solid #eee; }

	.note-box{ background:#fff; padding: 20rpx 24rpx; }
	.note-textarea{
		box-sizing: border-box;width: 100%; min-height: 260rpx; background:#e5e5e5; border-radius: 0; padding: 20rpx; font-size: 32rpx; color:#111;
	}
</style>

