<template>
    <nav-bar :navbar-data="navbarData"></nav-bar>
    <view :style="{ marginTop: height +'px' }">
        <writeDeseCon :flag="true" :path="path" />
    </view>
</template>

<script>
import $http from "@/utils/https"
import Util from "@/utils/utils"
import navBar from '@/components/navBar/index'
import writeDeseCon from '../../components/writeDeseCon/writeDeseCon'
const app = getApp();
export default {
    components: {
        'nav-bar': navBar,
        'writeDeseCon': writeDeseCon
    },
    data() {
        return {
            height: app.globalData.height,
            navbarData: {
                isGoHome: true,
                isGoBack: true,
                title: "图文咨询"
            },
            doctorObj: Object,
            path: '../../graphicConsultation/graphicConsulChoosePatient/graphicConsulChoosePatient',
            hospID: this.$cache.get('userData').hospID,
            hisHospID: this.$cache.get('userData').hisHospID,
            locID: String,
            schDate: String,
            schDateKey: String,
            disesTime: "",
            disesNote: "",
            fileList: [],
            patObj: {}
        }
    },
    onLoad: function (options) {
        this.getSchDateKey();
        // uni.setNavigationBarTitle({
        //     title: "图文咨询"
        // });
    },
    onShow: function () {
        this.setData({
            patObj: app.globalData.patObj,
            path: app.globalData.patObj.patID ? '../../graphicConsultation/graphicConsulPay/graphicConsulPay' : '../../graphicConsultation/graphicConsulChoosePatient/graphicConsulChoosePatient'
        }, () => {
            app.globalData.backPage = app.globalData.patObj.patID ? 1 : 2
        })
    },
    methods: {
        ///根据科室，医生，日期查询图文排班ID
        getSchDateKey: Util.debounce(function () {
            let data = {
                params: [{
                    doctorID: app.globalData.docObj.doctorID + "",
                    hospCode: this.$cache.get('userData').hisHospID,
                    locID: app.globalData.locObj.locID,
                    userID: "",
                    imageFlag: "Y",
                    date: app.globalData.schDate

                }]
            }
            uni.showLoading({
                mask: true
            })
            $http.post("urlS", this, {
                namespace: "Y",
                code: "03100040",
                data: data,
                success: function (res) {
                    uni.hideLoading();
                    if (+res.errorCode === 0) {
                        const resDetailID = res.result.length > 0 ? res.result[0].resDetailID : "";
                        this.setData({ schDateKey: resDetailID });
                        app.globalData.writeObj.schDateKey = resDetailID;
                        console.log("schDateKey", resDetailID)
                    } else {
                        this.setData({ schDateKey: "" });
                    }
                }
            });
        }),
    }
}
</script>