<template>
    <!--pages/mine//myPrescription/prescriptionDetail/prescriptionDetail.wxml-->
    <nav-bar :navbar-data="navbarData" />
    <view class="prescriptionDetail" :style="{ marginTop: 'calc('+ height +'px + 20rpx)', marginBottom: '20rpx' }">
        <view class="top">
            <view class="buttom">{{ PrescDataMainInfo.prescType }}</view>
            <view class="tit">{{ PrescDataMainInfo.hospDesc }}</view>
            <view class="tit-small">互联网医院处方筏</view>
            <view class="NO">
                <text>处方编号： <text class="k">{{ PrescDataMainInfo.ordPrescNo }}</text></text>
            </view>
            <view class="userInfo">
                <view class="left">
                    <view>
                        <text class="room">科室：</text> {{ PrescDataMainInfo.ordLocDesc }}
                    </view>
                    <view>
                        <text class="room">患者：</text> {{ PrescDataMainInfo.patName }}
                    </view>
                    <view>
                        <text class="room">年龄：</text> {{ PrescDataMainInfo.patAge }}
                    </view>

                </view>
                <view class="right">
                    <view> <text class="room">费别：</text> {{ PrescDataMainInfo.admReasonDesc }}</view>
                    <view> <text class="room">性别：</text> {{ PrescDataMainInfo.patSexDesc }}</view>
                    <view> <text class="room">日期：</text>{{ PrescDataMainInfo.ordDate }}</view>
                </view>
                <view>
                    <text class="room">诊断：</text> {{ PrescDataMainInfo.admDiag }}
                </view>
            </view>
            <view class="RP" style="height: calc(100vh - 840rpx)">
                <view class="T">Rp:</view>
                <block v-if="PrescDataMainInfo.cmPrescFlag == 0">
                    <view class="content" v-for="(item, index) in PrescDataDetail" :key="index">
                        <view class="content-tit">
                            <text class="Y">{{ index + 1 }}.{{ item.medDesc }}</text>
                            <text class="A">{{ item.medSpec }}</text>
                            <text class="N">X{{ item.ordQty }}{{ item.ordUnitDesc }}</text>
                        </view>
                        <view class="content-bottom">
                            <text>用法： {{ item.ordFreqDesc }} {{ item.ordDurationDesc }}</text>
                        </view>
                    </view>
                </block>

                <block v-if="PrescDataMainInfo.cmPrescFlag == 1">
                    <view class="content" v-for="(item, index) in PrescDataDetail" :key="index">
                        <view class="content-tit">{{ index + 1 }}.{{ item.medDesc }} {{ item.ordDoseUnitDesc }} </view>
                    </view>
                </block>

                <view class="content-bottom">
                    <view v-if="PrescDataMainInfo.cmPrescFlag == 1">用法： {{ PrescDataMainInfo.cmFreqDesc }} ,
                        {{ PrescDataMainInfo.cmExplainDesc }} , {{ PrescDataMainInfo.cmUsageDesc }} 共：
                        {{ PrescDataMainInfo.cmFac }}剂 {{ PrescDataMainInfo.cmCookTypeDesc }}</view>
                    <view class="blank"> (以下空白)</view>
                </view>
            </view>
            <view class="userInfo doctor">
                <view class="left">
                    <view> <text class="room">医师：</text>
                        <image v-if="PrescDataMainInfo.docStamp.length > 10" style="width:180rpx;height:66rpx"
                            :src="PrescDataMainInfo.docStamp" />
                        <text v-if="PrescDataMainInfo.docStamp.length < 10" class="room">{{ PrescDataMainInfo.ordDocDesc
                        }}</text>
                    </view>
                    <!-- <view> <text class="room">复核：</text> {{PrescDataMainInfo.ordDocDesc}}</view> -->
                    <view> <text class="room">金额： </text> {{ PrescDataMainInfo.prescAmt }}</view>
                </view>
                <view class="right">
                    <view> <text class="room">审核：</text>
                        <image v-if="PrescDataMainInfo.dispUserStamp.length > 10" style="width:180rpx;height:66rpx"
                            :src="PrescDataMainInfo.dispUserStamp" />
                        <text v-if="PrescDataMainInfo.dispUserStamp.length < 10" class="room">{{
                            PrescDataMainInfo.auditUserName }}</text>
                    </view>
                    <!-- <view> <text class="room">发药：</text> {{PrescDataMainInfo.dispUserName}}</view> -->
                </view>
            </view>
            <view class="last">医师处方仅开具3日内有效（医师注明除外）</view>
        </view>
    </view>
</template>

<script>
import $http from "@/utils/https";
import Util from '@/utils/utils';
import navBar from '@/components/navBar/index'
const app = getApp()
export default {
    components: {
        'nav-bar': navBar
    },
    data() {
        return {
            height: app.globalData.height,
            navbarData: {
                isGoHome: true,
                isGoBack: true,
                title: "我的处方详情"
            },
            prescNo: '',
            userData: {},
            PrescDataDetail: [],       ///药品列表
            PrescDataMainInfo: {}      ///处方信息
        }
    },
    onLoad(options) {
        const userData = this.$cache.get('userData')
        if (userData) this.userData = userData
        if (options && options.hasOwnProperty('id') && options.id) {
            this.setData({ prescNo: options.id })
        }
    },
    onReady: function () {
        this.getPrescDataDetail()
    },
    methods: {
        // 请求电子处方详情列表数据
        getPrescDataDetail: function () {
            let data = {
                params: [{
                    prescNo: this.prescNo,
                    hospCode: this.userData.hisHospID
                }]
            }
            $http.post("urlS", this, {
                code: "03100092",
                data: data,
                namespace: 'Y',
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setData({ PrescDataDetail: res.result[0].detailInfo[0].rows, PrescDataMainInfo: res.result[0].mainInfo[0] });
                    } else {
                        this.setData({ PrescDataDetail: [], PrescDataMainInfo: {} });
                    }
                }
            });
        }
    }
}
</script>

<style>
/* pages/mine//myPrescription/prescriptionDetail/prescriptionDetail.wxss */
.prescriptionDetail {
    margin: 15rpx;
    padding: 10rpx;
    background-color: #fff;
}

.prescriptionDetail .top {
    position: relative;
}

.prescriptionDetail .top .buttom {
    position: absolute;
    right: 18rpx;
    top: 68rpx;
    padding: 3rpx 8rpx;
    border: 2rpx silver solid;
    color: #999;
    border-radius: 14rpx;
}

.prescriptionDetail .top .tit {
    text-align: center;
    font-size: 37rpx;
    font-weight: 700;
    height: 48rpx;
}

.prescriptionDetail .top .tit-small {
    text-align: center;
    font-size: 33rpx;
    font-weight: 700;
    height: 42rpx;
}

.prescriptionDetail .top .NO {
    text-align: right;
    margin-top: 20rpx;
    height: 38rpx;
}

.prescriptionDetail .top .NO .k {
    color: red;
}

.prescriptionDetail .userInfo {
    min-height: 160rpx;
    margin-top: 20rpx;
    padding: 13rpx;
    color: #333;
    height: 186rpx;
    border-bottom: 2rpx silver solid;
}

.prescriptionDetail .room {
    font-size: 24rpx;
    color: #666;
}

.prescriptionDetail .userInfo .left {
    width: 49%;
    float: left;
}

.prescriptionDetail .userInfo .right {
    width: 49%;
    float: left;
}

.prescriptionDetail .RP {
    padding: 10rpx;
    height: 580rpx;
    overflow: auto;
}

.prescriptionDetail .RP .T {
    font-size: 35rpx;
}

.prescriptionDetail .content {
    margin-bottom: 15rpx;
}

.prescriptionDetail .content-tit {
    margin-top: 15rpx;
}

.prescriptionDetail .content-tit .A {
    margin-left: 15%;
}

.prescriptionDetail .content-tit .N {
    float: right;
}

.prescriptionDetail .content-bottom {
    margin-top: 15rpx;
}

.prescriptionDetail .content-bottom text {
    margin-left: 50rpx;
}

.prescriptionDetail .blank {
    border-top: 2rpx dashed #999;
    text-align: center;
    height: 100rpx;
    margin-top: 20rpx;
}

.prescriptionDetail .doctor {
    border-bottom: 0;
    border-top: 2rpx silver solid;
    height: 150rpx;
}

.prescriptionDetail .last {
    text-align: center;
    color: #999999;
    height: 38rpx;
}
</style>