<template>
	<view class="choosePrescription">
		<view class="searchPrescription">
			<uni-forms class="search_forms">
				<uni-forms-item label="处方编号">
					<uni-easyinput v-model="pageData.cfbh" placeholder="请输入处方编号" />
				</uni-forms-item>
				<uni-forms-item label="患者姓名">
					<uni-easyinput v-model="pageData.hzxm" placeholder="请输入患者姓名" />
				</uni-forms-item>
			</uni-forms>
			<view class="search_button_group">
				<button class="reset_button" @click="reset">重置</button>
				<button class="search_button" @click="search">搜索</button>
			</view>
		</view>
		<uni-card v-for="(item,index) in pageData.cfInfo" class="cfInfo" @click="chooseCf(item)">
			<view class="cfInfo_title">
				<view class="cfInfo_text">处方编号</view>
				<view class="cfInfo_text">{{item.cfbm}}</view>
			</view>
			<view class="cfInfo_title">
				<view class="cfInfo_text">患者姓名</view>
				<view class="cfInfo_text">{{item.hzxm}}</view>
			</view>
			<view class="cfInfo_title">
				<view class="cfInfo_text">医疗机构</view>
				<view class="cfInfo_text">{{item.yljg}}</view>
			</view>
			<view class="cfInfo_title">
				<view class="cfInfo_text">开方日期</view>
				<view class="cfInfo_text">{{item.kfrq}}</view>
			</view>
			<view class="cfInfo_title">
				<view class="cfInfo_text">贴数</view>
				<view class="cfInfo_text">{{item.ts}}</view>
			</view>
			<view class="cfInfo_title">
				<view class="cfInfo_text">处方内容</view>
				<view class="cfInfo_text">{{item.cfnr}}</view>
			</view>
		</uni-card>
		<!-- 对话框 -->
		<uni-popup ref="chooseDialog" type="dialog">
			<uni-popup-dialog type="info" confirmText="确定" cancelText="取消" title="选择处方" :content="pageData.popupMessage.showMessage" @confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script setup>
import { reactive,ref } from "vue";
import http from "../../../utils/request";	

const pageData=reactive({
	// 处方编号
	cfbh:'',
	// 患者姓名
	hzxm:'',
	// 处方信息列表
	cfInfo:[
		{
			cfbm:'11111111',
			hzxm:'患者1',
			yljg:'机构1',
			kfrq:'11111',
			ts:'1',
			cfnr:'熟附片 3g、丹参 10g、大枣9g、海藻 6g、蜜炙甘草9...'
		},
		{
			cfbm:'22222222',
			hzxm:'患者2',
			yljg:'机构2',
			kfrq:'22222',
			ts:'2',
			cfnr:'熟附片 3g、丹参 10g、大枣9g、海藻 6g、蜜炙甘草9...'
		},
		{
			cfbm:'333333333',
			hzxm:'患者3',
			yljg:'机构3',
			kfrq:'3333333',
			ts:'3',
			cfnr:'12，13'
		}
	],
	chooseDialog:'',
	// 弹出框内容
	popupMessage:{
		showMessage:''
	}
	
})

// 定义弹出框
const chooseDialog = ref()

// 弹出框确定事件
const dialogConfirm=()=>{
	// 跳转到下一个页面
	
}

// 弹出框取消事件
const dialogClose=()=>{
	chooseDialog._value.close()
}

const formData=reactive({
	
})

// 重置
const reset=()=>{
	pageData.cfbh=''
	pageData.hzxm=''
}

// 搜索
const search=()=>{
	
}

// 选择处方
const chooseCf=(e)=>{
	// 点击处方，弹出对话框
	chooseDialog._value.open()
	pageData.popupMessage.showMessage="处方编号："+e.cfbm+"\n"+"患者姓名："+e.hzxm+"\n"+"是否确认选择该处方？"
}
</script>

<style lang="scss" scoped>
@import './index.scss'
</style>
