<template>
	<view class="p-row-32">
		<u-navbar title="处方溯源" back-icon-color="#fff" title-size="34" title-color="#fff"
			:background="{background:'#6ACDBB'}"></u-navbar>
		<block v-if="!loading">
			<view class="m-t-4 info p-32 b-r-8">
				<d-text :text="`${type} ${prescription.prescription_no}`" className="fs-32 w-c"></d-text>
				<!-- .replace(/^.{2}/, '**') -->
				<d-text :text="`${info.doctor.store} ${info.doctor.depart}`" className="m-t-16 w-c">
				</d-text>
				<image src="../../static/image/rx.png"></image>
			</view>
			<view class="p-row-32 m-t-4 flex-row">
				<view class="step flex-col flex-ali-center">
					<view class="step_dot"></view>
					<view class="step_dot"></view>
					<view class="step_dot"></view>
					<view class="step_line"></view>
				</view>
				<view class="m-l-4 flex-1">
					<view class="flex-row flex-ali-center flex-jus-sp">
						<d-text text="就诊" className="fs-36 content-c"></d-text>
						<d-text :text="$u.timeFormat(prescription.patients.updated_at, 'yyyy-mm-dd hh:MM')"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-32">
						<d-text text="姓名"></d-text>
						<d-text :text="prescription.patients['name']"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
						<d-text text="性别"></d-text>
						<d-text :text="prescription.patients['sex']==1?'男':'女'"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
						<d-text text="年龄"></d-text>
						<d-text :text="prescription.patients.age"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
						<d-text text="诊断"></d-text>
						<d-text :text="prescription.clinical_diagnose"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-48">
						<d-text text="开具" className="fs-36 content-c"></d-text>
						<d-text :text="$u.timeFormat(prescription.created_at, 'yyyy-mm-dd hh:MM')"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-32">
						<d-text text="处方编号"></d-text>
						<d-text :text="prescription.prescription_no"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
						<d-text text="类型"></d-text>
						<d-text :text="type"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
						<d-text text="开具机构"></d-text>
						<d-text :text="`${info.doctor.store}`">
						</d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
						<d-text text="开具科室"></d-text>
						<d-text :text="info.doctor.depart"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
						<d-text text="开具医生"></d-text>
						<d-text :text="info.doctor.name"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
						<d-text text="开具时间"></d-text>
						<d-text :text="$u.timeFormat(prescription.created_at, 'yyyy-mm-dd hh:MM')"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-48">
						<d-text text="审核" className="fs-36 content-c"></d-text>
						<d-text :text="$u.timeFormat(prescription.pharmacist_view_time, 'yyyy-mm-dd hh:MM')"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-32">
						<d-text text="审核状态"></d-text>
						<d-text :text="status[prescription.status]"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
						<d-text text="审核药师"></d-text>
						<d-text :text="prescription.pharmacistInfo.name"></d-text>
					</view>
					<view class="flex-row flex-ali-center flex-jus-sp m-t-16">
						<d-text text="驳回原因"></d-text>
						<d-text :text="prescription.reject_reason"></d-text>
					</view>
				</view>
			</view>
		</block>
		
		<d-loading-page :loading="loading"></d-loading-page>
	</view>
</template>

<script>
	import {
		source,
	} from '@/api/all.js'
	export default {
		data() {
			return {
				status: ['待审核', '已通过', '未通过', '待使用', '已使用', '未使用', '已失效'],
				numList: [{
					name: '就诊'
				}, {
					name: '开具'
				}, {
					name: '初审'
				}],
				loading: true,
				info: [],
				prescription: [],
				type: "",
			}
		},
		onLoad(op) {
			this.source({
				prescription_id: op['prescription_id'],
				prescription_no: op['prescription_no'],
				store_id: uni.getStorageSync('store_id') || '11001',
			})
		},
		methods: {
			source(data) {
				source(data).then(res => {
					if (res.errcode == 0) {
						this.info = res.data;
						this.prescription = res.data.prescription
						this.type = res.data.type
						// this.info['age'] = this.$d.getAge(this.info.prescription['patients']['id_card'])
						this.loading = false
					} else {
						this.$toast(res.msg);
						this.loading = false
					}
				})
			}
		}
	}
</script>
<style scoped lang="scss">
	.info {
		background: linear-gradient(90deg, #00BFA6 0%, #6ACDBB 93%);
		position: relative;

		image {
			width: 184rpx;
			height: 132rpx;
			position: absolute;
			right: 0;
			bottom: 0;
		}
	}

	.step {
		position: relative;
		width: 22rpx;

		&_dot {
			background-color: #E8E9EB;
			width: 22rpx;
			height: 22rpx;
			border-radius: 22rpx;
		}

		&_dot:nth-child(2) {
			margin-top: 300rpx;
		}

		&_dot:nth-child(3) {
			margin-top: 400rpx;
		}

		&_line {
			position: absolute;
			top: 12rpx;
			width: 2px;
			height: 750rpx;
			background: #E8E9EB;
		}
	}
</style>
