<template>
	<view class="patientInformationInfo" v-if="Object.keys(infoDATA).length > 0">
		<view class="page_head">
			<view class="title">{{ infoDATA.patientName }}</view>
			<view class="patientCode">{{ infoDATA.patientCode }}</view>
			<view class="info">
				<view class="bedNum">
					<text class="info_h">床号</text>
					<text class="info_b">{{ infoDATA.bedNum || "-" }}</text>
				</view>
				<view :class="infoDATA.careLevel?'bedNum':'waitingCount'">
					<text class="info_h">待检查数</text>
					<text class="info_b">{{ infoDATA.watingCount }}</text>
				</view>
				<view class="bedNum" v-if="infoDATA.careLevel">
					<text class="info_h">护理等级</text>
					<text class="info_b">{{ infoDATA.careLevel.name }}</text>
				</view>
				<view class="waitingCount" v-if="infoDATA.illnessState">
					<text class="info_h">病情级别</text>
					<text class="info_b">{{ infoDATA.illnessState.name }}</text>
				</view>
			</view>
		</view>
		<view class="page_item" v-for="item in infoDATA.inspects" :key="item.id">
			<view class="page_item_info">
				<view class="page_item_info_title">检查项目：<text>{{ item.inspectName || "-" }}</text></view>
				<view class="page_item_info_title">检查科室：<text>{{
            item.execDept ? item.execDept.dept : "-"
          }}</text></view>
				<view class="page_item_info_title btn">预约时间：<text>{{ item.yyTime || "-" }}</text><button
						@click="changeYyTime(item)" v-if="item.inspectState.value == 1 || item.inspectState.value == 30">修改</button></view>
				<view class="page_item_info_title">预约叫号：<text>{{ item.reservationNumber || "-" }}</text></view>
				<view class="page_item_info_title">是否紧急：<text
						:class="{red:item.priority===1||item.priority==='1'}">{{ (item.priority===1||item.priority==='1')?'是':'否' }}</text>
				</view>
			</view>
		</view>
		<view v-if="!infoDATA.inspects || infoDATA.inspects.length == 0" class="zwsj">
			<image class="zwsj-img" mode="widthFix" src="../../static/img/zanwushuju.png"></image>
			<view class="zwsj-txt">暂无检查信息</view>
		</view>
		<!-- 弹窗 -->
		<inspectRemoveModel :title="models1.title" :icon="models1.icon" :disjunctor="models1.disjunctor" :content="models1.content" @know="know1" :operate="models1.operate" @ok="ok1" @cancel="cancel1"></inspectRemoveModel>
	</view>
</template>
<script>
	import {
		get,
		post,
		SM,
		webHandle
	} from "../../http/http.js";
	export default {
		data() {
			return {
				options: {},
				infoDATA: {},
				// 弹窗model1
				models1: {
				  disjunctor: false,
				},
			};
		},
		methods: {
			// 修改预约时间->知道了
			know1() {
			  this.models1.disjunctor = false;
			},
			// 修改预约时间->确定
			ok1(data) {
				console.log(data);
				const { yyTime} = data;//暂时这样
				if (!yyTime) {
				  //没有填写预约时间
				  uni.showModal({
				    title: "提示",
				    content: "请填写预约时间！",
				    showCancel: false,
				    success: function(res) {
				      if (res.confirm) {
				        console.log("用户点击确定");
				      } else if (res.cancel) {
				        console.log("用户点击取消");
				      }
				    },
				  });
				  return;
				}
			  this.models1.disjunctor = false;
			  let postData = {
			    inspectCode: this.currentInspect.inspectCode,
			  	yyTime
			  };
			  uni.showLoading({
			    title: '加载中',
			    mask: true,
			  })
			  post('/workerOrder/updateInspectYytime', postData).then(res => {
			    uni.hideLoading();
			    if (res.status == 200) {
						this.getInfo(this.options.patientCode);
			    } else {
			      uni.showToast({
			        icon: "none",
			        title: "修改失败",
			      });
			    }
			  })
			},
			// 修改预约时间->取消
			cancel1() {
			  this.models1.disjunctor = false;
			},
			// 修改预约时间
			changeYyTime(item) {
			  this.currentInspect = item;
			  this.models1 = {
			    disjunctor: true,
			    content: `您要修改[${item.inspectName||''}]的预约时间`,
			    icon: "warn",
			    operate: {
			      ok: "确定",
			      cancel: "取消",
			    },
			  };
			},
			// 请求详细页面的数据
			getInfo(patientCode) {
				uni.showLoading({
					title: "加载中",
					mask: true,
				});
				post("/nurse/workOrder/getPatientInspectInfo", {
					patientCode,
				}).then((res) => {
					uni.hideLoading();
					if (res.status == 200) {
						if (res.data.inspects && Array.isArray(res.data.inspects)) {
							res.data.inspects = res.data.inspects.map(v => {
								if (v.yyTime) {
									let [date, time] = v.yyTime.split(" ");
									v.yyTime = new Date(date).Format('yyyy-MM-dd') + " " + time.slice(0, -
										3);
								}
								return v;
							})
						}
						this.infoDATA = res.data;
					} else {
						uni.showToast({
							icon: "none",
							title: "请求失败！",
						});
					}
				});
			},
		},
		onLoad(options) {
			this.options = options;
			this.getInfo(this.options.patientCode);
			// #ifdef APP-PLUS
			webHandle("no", "app");
			// #endif
			// #ifdef H5
			webHandle("no", "wx");
			// #endif
		},
	};
</script>
<style lang="less">
	.patientInformationInfo {
		padding: 0 20rpx;

		.zwsj {
			text-align: center;

			.zwsj-img {
				width: 560rpx;
			}

			.zwsj-txt {
				font-size: 36rpx;
				font-weight: 700;
				margin-top: 20rpx;
				text-align: center;
			}
		}

		.page_head {
			background-color: #49b856;
			color: #fff;

			.title {
				font-size: 48rpx;
				padding-top: 24rpx;
				text-align: center;
			}

			.patientCode {
				padding-bottom: 12rpx;
				font-size: 28rpx;
				text-align: center;
			}

			.info {
				padding-bottom: 24rpx;
				margin: 8rpx 0;
				height: 80rpx;
				display: flex;
				justify-content: center;
				align-items: center;

				.bedNum,
				.waitingCount {
					width: 300rpx;
					height: 100%;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;

					.info_h {
						font-size: 30rpx;
					}

					.info_b {
						font-size: 26rpx;
					}
				}

				.bedNum {
					position: relative;

					&:after {
						content: "";
						position: absolute;
						width: 4rpx;
						height: 50rpx;
						right: -2rpx;
						top: 15rpx;
						background-color: #fff;
					}
				}
			}
		}

		.page_item {
			margin-top: 16rpx;
			margin-bottom: 16rpx;
			background: #fff;
			border-radius: 8rpx;
			overflow: hidden;
			padding: 0 16rpx;
			border: 2rpx solid #e5e9ed;

			.page_item_info {
				padding: 20rpx 16rpx;
				text-align: left;
				line-height: 60rpx;
				font-size: 30rpx;

				.page_item_info_title {
					font-weight: 700;

					&.btn {
						display: flex;
						button {
							font-size: 28rpx;
							color: #49b856;
							height: 50rpx;
							line-height: 50rpx;
							margin: 0;
						}
					}

					text {
						font-weight: normal;

						&.red {
							color: red;
						}
					}
				}
			}
		}
	}
</style>
