<template>
  <div class="mainBox">
    <div class="mainContent">
      <div class="navigation">
        <div class="goBack newGoBack">
          <span class="back" style="display: flex;align-items: center;" @click="backAction()">
            <span class="iconfont" style="font-size: 1.25rem;">&#xe720;</span><span>返回</span>
          </span>
          <!-- <div style="color:#fff;font-size:.875rem;" v-if="index == 1">{{ patient_name }}</div> -->
          <el-popover placement="bottom" trigger="click" :disabled="true" style="display: flex;align-items: center;">
            <li slot="reference" class="name" @click="show = true" style="display: flex;align-items: center;">{{ patient_name }}<span class="iconfont" style="color:#fff;font-size:1.25rem;">&#xe74a;</span></li>
          </el-popover>
        </div>

        <div class="nav newNav1">
          <ul>
            <li
              v-for="(item, i) in ['今日透析', '电子病历']"
              :key="i"
              :class="index == i ? 'active' : ''"
              @click="ClickTab(i)"
            >{{ item }}</li>
          </ul>
        </div>

        <div>
          <el-image
            style="width: 0px; height: 0px"
            :src="url"
            :preview-src-list="srcList"
            ref="previewImg">
          </el-image>
        </div>

        <div class="previewBox">
          <i class="el-icon-picture printerIcon" style="margin-right: 10px;" @click="printImage"></i>

          <i class="el-icon-printer printerIcon" @click="print"></i>
          <!-- <span class="preview" @click="print">预览</span> -->
          <i class="el-icon-date iconDate" @click="openCalendarShow"></i>
        </div>
        <div class="print" style="float: right; display:none">
          <el-button size="mini" type="primary" @click="print" icon="el-icon-printer">打印</el-button>
        </div>
      </div>

      <div class="Tab">
        <!-- <CaseHistory v-show="index == 0" title="病历"></CaseHistory> -->
        <!--<check-tab v-show="index==1" title="化验单"></check-tab>-->
        <dialysis-tab v-if="index == 1" title="透析" v-on:records="jump(val)" @tabIndex="tabIndex" :tableIndex2="tableIndex2"></dialysis-tab>
        <today-tab ref="today" v-show="index == 0 && !showView" title="今日" @show_patient_list="showPatientList" :index = index @tiaozhuan = 'tiaozhuan_click' :tableIndex = tableIndex @history="history_click"></today-tab>
        <!-- <div v-if="showView" style="text-align:center;font-size:0.6rem;">
          <p style="margin-top:20px;">当前叫号</p>
          <p style="margin-top:20px;">{{ $route.query.patient_name ? $route.query.patient_name : ""}}</p>
          <p style="margin-top:20px;">签到时间：{{ $route.query.curPatientTime ? getDates($route.query.curPatientTime) : '' }}</p>
          <p style="color:red;margin-top:20px;">提示：当前患者无排班，请先排班</p>
        </div> -->
      </div>
    </div>
    <!-- <div class="add" @click="print">
      <p>打印预览</p>
    </div> -->
    <!-- <div class="fixedCalling" v-if="queueConfig.txxqyxs == 1">
      <div class="nowCalling">
        <div class="callingName">{{ fisrtQueueInfo && fisrtQueueInfo.patient_name ? fisrtQueueInfo.patient_name : '暂无叫号' }}</div>
        <p v-if="fisrtQueueInfo != null && fisrtQueueInfo.patient_name">当前叫号</p>
      </div>
      <div class="fixedVolume" @click="call">
        <van-icon name="volume" />
      </div>
      <div class="callingName" @click="next">下一位</div>
    </div> -->
    <!-- <div class="callFamilyBox" @click="callFamily" v-if="queueConfig.txxqyxs == 1">
      <img src="../../assets/images/callFamily.png" alt="">
    </div> -->
    <div class="callFamilyBox" @click="callFamily" ref="callBtn" v-if="queueConfig.txxqyxs == 1" @touchstart="down" @mousedown="down"
      @mousemove="move"
      @touchmove="move"
      @mouseup="end"
      @touchend="end"
      @touchcancel="end">
      <img src="../../assets/images/callFamily.png" alt="">
    </div>
    <!-- <div class="printBox" @click="print">
      <img src="../../assets/images/print.png" alt="">
    </div> -->
    <!-- <side-bar :active_index="0"></side-bar> -->
    <!-- <mt-datetime-picker
            v-model="pickerVisible"
            type="date"
            ref="picker"
            year-format="{value} "
            month-format="{value} "
            date-format="{value} ">
    </mt-datetime-picker>-->

    <div class="showBox">
      <van-popup v-model="show" position="top" :style="{ height: '100%' }">
      <div
        style="padding:10px;font-size:20px;text-align:right"
        @click="show = false"
      >
        <van-icon name="cross" />
      </div>
      <van-search
        class="doctorAdviceSearch"
        v-model="searchValue"
        placeholder="请输入病人名字"
        @search="onSearch"
        @input='onSearch'
      />
        <div style="display:flex;justify-content: space-around;">
          <div class="newToolOne" @click="schedualTypesShow = true">
            <div style="display: flex;align-items: center;">
            {{ schedualTypes }}
            <van-icon name="arrow-down" />
            </div>
          </div>
          <div class="newToolOne" @click="zoneShow = true">
            <div style="display: flex;align-items: center;">
            {{ zoneTypes }}
            <van-icon name="arrow-down" />
            </div>
          </div>
        </div>

        <van-tabs v-model="active">
          <van-tab title="我的病人">
            <van-index-bar class="indexBar" sticky highlight-color="#fb6463"  >
              <div v-for="(subItem, index) in mypatients" :key="index" :index="index" v-if="$store.getters.user.template_info.org_id!=10721 && $store.getters.user.template_info.org_id!=10752">
                <van-index-anchor :index="index">
                </van-index-anchor>
                <van-cell
                  @click="choosePatient(item)"
                  v-for="(item, subIndex) in subItem"
                  :key="subIndex"
                  :title="item.patient.name"
                />
              </div>
              <div  :key="index" :index="index" v-if="$store.getters.user.template_info.org_id==10721 || $store.getters.user.template_info.org_id==10752">
                <van-cell
                  @click="choosePatient(item)"
                  v-for="(item, subIndex) in myPatientsOne"
                  :key="subIndex"
                  :title="item.patient.name+ '' +'('+ item.device_number.number+')'"
                />
              </div>
            </van-index-bar>
          </van-tab>
          <van-tab title="全部病人">
            <van-index-bar class="indexBar" sticky highlight-color="#fb6463">
              <div v-for="(subItem, index) in patients" :key="index" :index="index" v-if="$store.getters.user.template_info.org_id!=10721 && $store.getters.user.template_info.org_id!=10752">
                <van-index-anchor :index="index">
                </van-index-anchor>
                <van-cell
                  @click="choosePatient(item)"
                  v-for="(item, subIndex) in subItem"
                  :key="subIndex"
                  :title="item.patient.name"
                />
              </div>

              <div  v-if="$store.getters.user.template_info.org_id==10721 || $store.getters.user.template_info.org_id==10752">
               
                <van-cell
                  @click="choosePatient(item)"
                  v-for="(item, subIndex) in newPatient"
                  :key="subIndex"
                  :title="item.patient.name+ '' +'('+ item.device_number.number+')'"
                />
              </div>
            </van-index-bar>
          </van-tab>
        </van-tabs>
        <van-popup v-model="schedualTypesShow" class="schedualPopup" position="bottom" :style="{ height: '40%' }">
          <van-picker
          show-toolbar
          :columns="schedualTypesColumns"
          @confirm="chooseSchedual"
          @cancel="schedualTypesShow = false"
          />
        </van-popup>
        <van-popup v-model="zoneShow" class="schedualPopup" position="bottom" :style="{ height: '40%' }">
          <van-picker
          show-toolbar
          :columns="zoneColumns"
          @confirm="chooseZone"
          @cancel="zoneShow = false"
          />
        </van-popup>

    </van-popup>
    </div>
    <!-- :min-date="minDate" :max-date="maxDate" -->
    <van-calendar class="calendarPopup" v-model="calendarShow" @confirm="onCalendar" :min-date="minDate"  :formatter="formatter" :show-confirm='false' />

  </div>
</template>

<script>
import axios from 'axios'
import '@/styles/style.scss'
// import '@/styles/media.scss'
import SideBar from '@/pages/layout/SideBar'
import TodayTab from './today/TodayTab'
import DialysisTab from './dialysis/DialysisTab'
import RecordsTab from './records/RecordsTab'
import { Popover } from 'vux'
import CheckTab from './dialysis/CheckTab'
import { parseTime } from '@/utils'
import { GetPatientInfoWithDiseases } from '@/api/patient'
import { Toast } from 'vant'
import CaseHistory from './records/CaseHistory'
import { mediaMatches } from '@/libs/functionPad'
import { getDialysisScheduals, dialysisGlobalConfig, getPatientDialysisRecord,getPatientMap } from '@/api/dialysis'
import {setRem} from '@/libs/functionRem'
import '../../libs/rem.js'
import { uParseTime } from '@/utils/tools'
const moment = require('moment')
let pinyin = require('js-pinyin')

export default {
  name: 'DetailsPage',
  inject: ['reload'],
  components: {
    CaseHistory,
    CheckTab,
    SideBar,
    TodayTab,
    DialysisTab,
    RecordsTab,
    Popover
  },
  data () {
    return {
      // pickerVisible: new Date(),
      patient_id: 0,
      patient_name: '',
      date: 0,
      index: 0,
      tableIndex:0,
      tableIndex2:0,
      patient: null,
      sqls: [
        window.matchMedia('(max-width:418px)'), // 和CSS一样，也要注意顺序！
        window.matchMedia('(max-width:768px)'),
        window.matchMedia('(max-width:992px)'),
        window.matchMedia('(max-width:1200px)')
      ],
      clientHeight: document.body.clientHeight,

      show: false,
      FirstPin: [
        'A',
        'B',
        'C',
        'D',
        'E',
        'F',
        'G',
        'H',
        'I',
        'J',
        'K',
        'L',
        'M',
        'N',
        'O',
        'P',
        'Q',
        'R',
        'S',
        'T',
        'U',
        'V',
        'W',
        'X',
        'Y',
        'Z'
      ],
      patients: {},
      mypatients: {},
      schedualTypes: '全部班次',
      schedualValue: 0,
      schedualTypesShow: false,
      schedualTypesColumns: ['全部班次', '上午', '下午', '晚上'],
      zoneTypes: '全部分区',
      zoneValue: 0,
      zoneShow: false,
      zoneColumns: [],
      myPatientsOne:[],
      newPatient:[],
      //
      users: {
        name: '',
        id: '',
        user_type: ''
      },
      admin_users: {},
      active: 0,
      searchValue: '',
      allSearchArr: [],
      searchArr: [],

      // 叫号
      timers: null,
      fisrtQueueInfo: {},
      showView: false,
      queueConfig: {},

      calendarShow: false,
      minDate: new Date(moment().subtract(2, 'year').format('YYYY-MM-DD')),
      maxDate: new Date(),
      clientHeight: document.body.clientHeight,

      flags: false,
      position: {
        x: 0,
        y: 0
      },
      active: 0,
      callnx: '',
      callny: '',
      calldx: '',
      calldy: '',
      callxPum: '',
      callyPum: '',
      isShow: false,
      callBtn: {},
      url: '',
      srcList: [],
      sitemap:{},
      today:new Date()
    }
  },
  computed: {
    websocket () {
      return this.$store.state.user.websocket
    }
  },
  created () {
    setRem()
    this.initData = {
      cmd: 'queue/join',
      data: {type: 3, page: 0, size: 0}
    }
    //  this.websocketSend(this.initData)
    // mediaMatches()
    // for (var i = 0; i < this.sqls.length; i++) {
    //   this.sqls[i].addListener(this.mediaMatches)
    // }

    var patient_id = this.$route.query.patient_id
    var date = this.$route.query.date
    var patient_name = this.$route.query.patient_name
    this.patient_id = patient_id
    this.date = date
    this.patient_name = patient_name

    this.GetPatientInfoWithDiseases(this.patient_id)
    // this.requestDialysisScheduals()

    this.users.name = this.$store.getters.user.user.user_name
    this.users.id = this.$store.getters.user.admin.id
    this.users.user_type = this.$store.getters.user.user.user_type
    // console.log('this.users', this.users)
    let newScheduals = this.$store.getters.scheduals
    console.log('333333333', newScheduals)
    var zoneMap = {}
    var schedualMap = {}
    for (let index = 0; index < newScheduals.scheduals.length; index++) {
      const schedual = newScheduals.scheduals[index]

      if (schedual.dialysis_order != null) {
        if (schedualMap[schedual.device_number.zone.name] == null) {
          schedualMap[schedual.device_number.zone.name] = []
        }
        schedualMap[schedual.device_number.zone.name].push(schedual)
        if (zoneMap[schedual.device_number.zone.name] == null) {
          zoneMap[schedual.device_number.zone.name] = schedual.device_number.zone
        }
      }
    }

    var zones = []
    zones.push({ id: 0, text: '全部分区' })
    for (var zoneName in zoneMap) {
      zones.push({ id: zoneMap[zoneName].id, text: zoneName })
    }

    zones = zones.sort(function (a, b) {
      return a.value > b.value
    })
    this.zoneColumns = zones

    if (sessionStorage.getItem('schedualType') != null) {
      this.schedualValue = parseInt(sessionStorage.getItem('schedualType'))
      if (parseInt(sessionStorage.getItem('schedualType')) == 1) {
        this.schedualTypes = '上午'
      } else if (parseInt(sessionStorage.getItem('schedualType')) == 2) {
        this.schedualTypes = '下午'
      } else if (parseInt(sessionStorage.getItem('schedualType')) == 3) {
        this.schedualTypes = '晚上'
      } else {
        this.schedualTypes = '全部班次'
      }
    }
    if (sessionStorage.getItem('zoneType') != null) {
      this.zoneValue = parseInt(sessionStorage.getItem('zoneType'))
      this.zoneColumns.map(item => {
        if (parseInt(sessionStorage.getItem('zoneType')) == item.id) {
          this.zoneTypes = item.text
        }
      })
    }
    this.getScheduals(newScheduals.scheduals)
  },
  beforeMount () {
    // this.websocketMess()
  },
  mounted () {
    if (this.$route.query.active1) {
      this.index = parseInt(this.$route.query.active1)
    }
    const that = this
    window.onresize = () => {
      return (() => {
        window.clientHeight = document.body.clientHeight
        that.clientHeight = window.clientHeight
      })()
    }

    // let obj = {
    //   cmd: 'queue/join',
    //   data: {type: 3, page: 0, size: 0}
    // }
    // this.websocketSend(obj)
  },
  updated () {
    this.$nextTick(() => {
      this.callBtn = this.$refs.callBtn
      if (sessionStorage.getItem('callBtnTop')) {
        this.callBtn.style.top = sessionStorage.getItem('callBtnTop')
        this.callBtn.style.bottom = 'initial'
      }
      if (sessionStorage.getItem('callBtnLeft')) {
        this.callBtn.style.left = sessionStorage.getItem('callBtnLeft')
      }
    })
  },
  beforeDestroy () {
    let unObj = {
      cmd: 'queue/unjoin',
      data: {type: 3}
    }
    this.websocketSend(unObj)
  },
  methods: {
    compare (property) {
        return function (a, b) {
          var value1 = a[property]
          var value2 = b[property]
          return value1 - value2
        }
     },
    down (event) {
      this.flags = true
      var touch
      if (event.touches) {
        touch = event.touches[0]
      } else {
        touch = event
      }
      this.position.x = touch.clientX
      this.position.y = touch.clientY
      this.calldx = this.callBtn.offsetLeft
      this.calldy = this.callBtn.offsetTop
    },
    move (event) {
      if (this.flags) {
        var touch
        if (event.touches) {
          touch = event.touches[0]
        } else {
          touch = event
        }
        this.callnx = touch.clientX - this.position.x
        this.callny = touch.clientY - this.position.y
        this.callxPum = this.calldx + this.callnx
        this.callyPum = this.calldy + this.callny
        var clientWidth = document.documentElement.clientWidth
        var clientHeight = document.documentElement.clientHeight
        if (
          this.callxPum > 0 &&
          this.callxPum < clientWidth - this.callBtn.offsetWidth
        ) {
          this.callBtn.style.left = this.callxPum + 'px'
        }
        if (
          this.callyPum > 0 &&
          this.callyPum < clientHeight - this.callBtn.offsetHeight
        ) {
          this.callBtn.style.top = this.callyPum + 'px'
        }

        // 阻止页面的滑动默认事件
        document.addEventListener('touchmove', this.handler, {
          passive: false
        })
      }
    },
    // 鼠标释放时候的函数
    end () {
      this.flags = false
      sessionStorage.setItem('callBtnTop', this.callBtn.style.top)
      sessionStorage.setItem('callBtnLeft', this.callBtn.style.left)
      document.addEventListener('touchmove', this.handler, {
        passive: false
      })
    },
    websocketSend (data) {
      try {
        this.websocket.send(JSON.stringify(data))
      } catch (error) {
        this.showError = true
        this.showIndex = 4
        this.errorInfo = '网络异常，请稍后退出重试！'
      }
    },
    websocketMess () {
      this.websocket.onmessage = e => {
        let res = JSON.parse(e.data)
        // let res = re.data;
        console.log('res3333333333', res)
        if (res.channel == 'queue/join') {
          // res.data.fisrtQueueInfo.create_time = moment(res.data.fisrtQueueInfo.create_time * 1000).format('HH:mm')
          let timeType = null
          if (new Date().getHours() < 10) {
            timeType = 1
          } else if (new Date().getHours() >= 10) {
            timeType = 2
          }
          let fisrtQueueInfo = []
          this.newFisrtQueueInfo = res.data.fisrtQueueInfo
          if (res.data.fisrtQueueInfo != null) {
            if (timeType == 1) {
              fisrtQueueInfo = res.data.fisrtQueueInfo.morning
              if (fisrtQueueInfo != null) {
                if (fisrtQueueInfo.create_time) {
                  fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
                }
              }
            } else if (timeType == 2) {
              fisrtQueueInfo = res.data.fisrtQueueInfo.afternoon
              if (fisrtQueueInfo != null) {
                if (fisrtQueueInfo.create_time) {
                  fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
                }
              }
            }
          }
          this.queueConfig = res.data.queueConfig
          if (this.queueConfig.txxqyxs == 1) {
            this.$nextTick(() => {
              this.callBtn = this.$refs.callBtn
              if (sessionStorage.getItem('callBtnTop')) {
                this.callBtn.style.top = sessionStorage.getItem('callBtnTop')
                this.callBtn.style.bottom = 'initial'
              }
              if (sessionStorage.getItem('callBtnLeft')) {
                this.callBtn.style.left = sessionStorage.getItem('callBtnLeft')
              }
            })
          }

          this.fisrtQueueInfo = fisrtQueueInfo
          let arr = res.data.patientQueueList.data
          let waitingCalledArr = []
          let calledArr = []
          arr.map(item => {
            if (item.status == 1) {
              // item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
              waitingCalledArr.push(item)
            } else if (item.status == 2) {
              // item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
              calledArr.push(item)
            }
          })
          console.log('waitingCalledArr待叫号', waitingCalledArr)
          console.log('waitingCalledArr以较好', calledArr)
          this.waitingCalled = waitingCalledArr
          this.called = calledArr
        } else if (res.channel == 'allQueueList') {
          let arr = res.data.queue_list.data
          let waitingCalledArr = []
          let calledArr = []
          arr.map(item => {
            if (item.status == 1) {
              // item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
              waitingCalledArr.push(item)
            } else if (item.status == 2) {
              // item.create_time = moment(item.create_time * 1000).format('HH:mm:ss')
              calledArr.push(item)
            }
          })
          this.waitingCalled = waitingCalledArr
          this.called = calledArr
        } else if (res.channel == 'patientCallInfo') {
          res.data.patientInfo.create_time = moment(res.data.patientInfo.create_time * 1000).format('HH:mm')
          this.fisrtQueueInfo = res.data.patientInfo
        } else if (res.channel == 'fisrtQueueInfo') {
          let timeType = null

          if (new Date().getHours() < 10) {
            timeType = 1
          } else if (new Date().getHours() >= 10) {
            timeType = 2
          }
          let fisrtQueueInfo = []
          this.newFisrtQueueInfo = res.data.patientInfo
          if (res.data.patientInfo != null) {
            if (timeType == 1) {
              fisrtQueueInfo = res.data.patientInfo.morning
              if (fisrtQueueInfo != null) {
                if (fisrtQueueInfo.create_time) {
                  fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
                }
              }
            } else if (timeType == 2) {
              fisrtQueueInfo = res.data.patientInfo.afternoon
              if (fisrtQueueInfo != null) {
                if (fisrtQueueInfo.create_time) {
                  fisrtQueueInfo.create_time = moment(parseInt(fisrtQueueInfo.create_time) * 1000).format('HH:mm')
                }
              }
            }
          }
          this.fisrtQueueInfo = fisrtQueueInfo
        }
      }
    },
    call () {
      let org_id = parseInt(sessionStorage.getItem('org_id'))
      let admin_user_id = parseInt(sessionStorage.getItem('admin_user_id'))
      axios.get('/api/index/callpatient?org_id=' + org_id + '&patient_id=' + this.patient_id + '&admin_user_id=' + admin_user_id).then(res => {
        console.log(res)
        // let patientArr = res.data.queue_list.data
        // this.patientArr = patientArr
        // this.$emit('child-event',this.patientArr)
        if (res.data.code == 200) {
          Toast.success('叫号成功')
          this.curPatient = res.data.data.patientInfo
          let arr = []
          this.allSearchArr.map(item => {
            arr.push(item.patient_id)
          })
          if (arr.indexOf(parseInt(res.data.data.patientInfo.patient_id)) > -1) {
            this.showView = false
            this.$router.push('/details?patient_id=' + parseInt(res.data.data.patientInfo.patient_id) + '&date=' + this.$route.query.date + '&patient_name=' + res.data.data.patientInfo.patient_name + '&showView=false' + '&curPatientTime=' + res.data.data.patientInfo.create_time)
          } else {
            this.showView = true
            this.$router.push('/details?patient_id=' + parseInt(res.data.data.patientInfo.patient_id) + '&date=' + this.$route.query.date + '&patient_name=' + res.data.data.patientInfo.patient_name + '&showView=true' + '&curPatientTime=' + res.data.data.patientInfo.create_time)
          }
        }
      })
    },
    next () {
      let schedule_type = null
      if (new Date().getHours() < 11) {
        schedule_type = 1
      } else {
        schedule_type = 2
      }
      let org_id = parseInt(sessionStorage.getItem('org_id'))
      let admin_user_id = parseInt(sessionStorage.getItem('admin_user_id'))
      axios.get('/api/index/nextcall?org_id=' + org_id + '&patient_id=' + this.patient_id + '&admin_user_id=' + admin_user_id + '&schedule_type=' + schedule_type).then(res => {
        console.log(res)
        // let patientArr = res.data.queue_list.data
        // this.patientArr = patientArr
        // this.$emit('child-event',this.patientArr)
        if (res.data.data.patientInfo == null) {
          Toast.success('已经是最后一位了')
          return
        }
        if (res.data.code == 200) {
          Toast.success('叫号成功')
          this.curPatient = res.data.data.patientInfo
          this.fisrtQueueInfo = res.data.data.patientInfo
          let arr = []
          this.allSearchArr.map(item => {
            arr.push(item.patient_id)
          })
          if (arr.indexOf(parseInt(res.data.data.patientInfo.patient_id)) > -1) {
            this.showView = false
            this.reload()
            this.$router.replace('/details?patient_id=' + parseInt(res.data.data.patientInfo.patient_id) + '&date=' + this.$route.query.date + '&patient_name=' + res.data.data.patientInfo.patient_name + '&showView=false' + '&curPatientTime=' + res.data.data.patientInfo.create_time)
          } else {
            this.showView = true
            this.reload()
            this.$router.replace('/details?patient_id=' + parseInt(res.data.data.patientInfo.patient_id) + '&date=' + this.$route.query.date + '&patient_name=' + res.data.data.patientInfo.patient_name + '&showView=true' + '&curPatientTime=' + res.data.data.patientInfo.create_time)
          }
        }
      })
    },
    callFamily () {
      let org_id = parseInt(sessionStorage.getItem('org_id'))
      let admin_user_id = parseInt(sessionStorage.getItem('admin_user_id'))
      axios.get('/api/index/callpatientjs?org_id=' + org_id + '&patient_id=' + this.patient_id + '&admin_user_id=' + admin_user_id).then(res => {
        console.log(res)
        if (res.data.code == 200) {
          Toast.success('叫号成功')
        } else {
          Toast.success('叫号失败')
        }
      })
    },
    getDates (time) {
      return moment(time * 1000).format('HH:mm:ss')
    },
    ClickTab: function (tabIndex) {
      this.index = tabIndex
      this.tableIndex = tabIndex
    },
    backAction () {
      // this.$router.back(-1);
      this.$router.push('/main')
    },
    openPicker () {
      this.$refs.picker.open()
    },
    print: function () {
      var xtdate = parseTime(this.date, '{y}-{m}-{d}')
      if (this.patient != null) {
        this.$router.push(
          '/Print?xtdate=' + xtdate + '&xtno=' + this.patient.dialysis_no+"&patient_id="+this.$route.query.patient_id
        )
      }
    },
    GetPatientInfoWithDiseases (id) {

      GetPatientInfoWithDiseases(id).then(response => {
          if (response.data.state == 1) {
            this.patient = response.data.data.patient
          } else {
            Toast.fail(response.data.msg)
            return false
          }
        })
        .catch(() => {
          // on cancel
          Toast.fail('网络异常')
          return false
        })
    },
    jump: function (val) {
      this.index = 2
    },
    toMyPatients () {
      var patient_id = this.$route.query.patient_id
      this.$router.push('/mypatients/' + patient_id)
    },
    getScheduals (patient) {
      // console.log('222222', this.$store.getters.adminUserArr.adminUserArr)
      if (this.$store.getters.adminUserArr.adminUserArr) {
        console.log('上面')
        this.getAdminUser(patient)
      } else {
        console.log('下面')
        this.dialysisGlobalConfig(patient)
      }

      // console.log(222222, patient)
      this.allSearchArr = patient

      let newPatients = []
      if (this.schedualValue == 0) {
        newPatients = patient
      } else {
        patient.map(item => {
          if (item.schedule_type == this.schedualValue) {
            newPatients.push(item)
          }
        })
      }
      let zoneNewPatients = []
      if (this.zoneValue == 0) {
        zoneNewPatients = newPatients
      } else {
        newPatients.map(item => {
          if (item.device_number.zone_id == this.zoneValue) {
            zoneNewPatients.push(item)
          }
        })
      }

     

     


      let cityNameList = []
      for (let p in zoneNewPatients) {
        cityNameList.push(zoneNewPatients[p])
      }

      console.log("全部患者-------------------------",cityNameList)


        // //解决溪康排序问题
       if(cityNameList!=null && cityNameList.length>0){
          for(let i=0;i<cityNameList.length;i++){
            cityNameList[i].sort = 0
            cityNameList[i].sort = cityNameList[i].device_number.sort 
          }
        }
       
        this.newPatient = []
        this.newPatient = cityNameList.sort(this.compare('sort'))




      let firstName = {}
      this.FirstPin.forEach(item => {
        firstName[item] = []
        cityNameList.forEach(el => {
          let first = pinyin.getFullChars(el.patient.name).substring(0, 1)
          if (first == item) {
            firstName[item].push(el)
          }
        })
        this.patients = firstName

      

       
        
        
        // 判断非空
        let newObj = {}
        Object.keys(this.patients).map((item, index) => {
          if (this.patients[item].length != 0) {
            newObj[item] = this.patients[item]
          }
        })
        this.patients = newObj

     
       
        
        // console.log('所有的病人', this.patients)
      })
    },
    // requestDialysisScheduals () {
    //   var type = 0
    //   getDialysisScheduals({ type: type, date: parseTime(this.date, '{y}-{m}-{d}') })
    //     .then(rs => {
    //       var resp = rs.data
    //       if (resp.state == 1) {

    //         var patient = resp.data.scheduals
    //         this.dialysisGlobalConfig(patient)
    //         console.log(222222,patient)
    //         this.allSearchArr = patient
    //         let cityNameList = []
    //         for (let p in patient) {
    //           cityNameList.push(patient[p])
    //         }
    //         let firstName = {}
    //         this.FirstPin.forEach(item => {
    //           firstName[item] = []
    //           cityNameList.forEach(el => {
    //             let first = pinyin.getFullChars(el.patient.name).substring(0, 1)
    //             if (first == item) {
    //               firstName[item].push(el)
    //             }
    //           })
    //           this.patients = firstName
    //           // 判断非空
    //           let newObj = {}
    //           Object.keys(this.patients).map((item, index) => {
    //             if (this.patients[item].length != 0) {
    //               newObj[item] = this.patients[item]
    //             }
    //           })
    //           this.patients = newObj
    //         })
    //         console.log(33333333,this.patients)

    //       } else {
    //         this.$toast({
    //           message: resp.msg
    //         })
    //       }
    //     })
    //     .catch(error => {

    //     })
    // },
    choosePatient (schedual) {
      var patient_id = schedual.patient.id
      var date = schedual.schedule_date
      var name = schedual.patient.name
      this.reload()
      this.$router.replace({
        path: '/details',
        query: {
          patient_id: patient_id,
          date: date,
          patient_name: name
        }
      })
      // sessionStorage.removeItem('newBarIndex')
      this.show = false
    },
    getAdminUser (patient) {
      // console.log("病人列表-----------------------------------",patient)

      // if(patient!=null && patient.length>0){
      //   for(let i=0;i<patient.length;i++){
      //      patient[i].sort= 0
      //      patient[i].sort = patient[i].device_number.sort
      //   }
      //   this.newPatient =  patient.sort(function (a, b) {
      //       return a.sort > b.sort
      //    })
      // }

      console.log('user---', this.users.user_type)
      if (this.users.user_type == 1 || this.users.user_type == 2) {
        // console.log('触发了吗')
        let arr = []
        let zoneArr = []
        patient.map((item, index) => {
          if (item.prescription != null && item.prescription.creater == this.users.id) {
            if (item.schedule_type == this.schedualValue) {
              arr.push(item)
            } else if (this.schedualValue == 0) {
              arr.push(item)
            }
          }
        })
        arr.map(item => {
          if (item.device_number.zone_id == this.zoneValue) {
            zoneArr.push(item)
          } else if (this.zoneValue == 0) {
            zoneArr.push(item)
          }
        })

        if(zoneArr!=null && zoneArr.length>0){
          for(let i=0;i<zoneArr.length;i++){
            zoneArr[i].sort = 0
            zoneArr[i].sort = zoneArr[i].device_number.sort 
          }
        }
       
        this.myPatientsOne = []
        this.myPatientsOne = zoneArr.sort(this.compare('sort'))

       

        this.searchArr = zoneArr



        let cityNameList = []
        for (let p in zoneArr) {
          cityNameList.push(zoneArr[p])
        }
        let firstName = {}
        this.FirstPin.forEach(item => {
          firstName[item] = []
          cityNameList.forEach(el => {
            let first = pinyin.getFullChars(el.patient.name).substring(0, 1)
            if (first == item) {
              firstName[item].push(el)
            }
          })
         

          this.mypatients = firstName
          // 判断非空
          let newObj = {}
          Object.keys(this.mypatients).map((item, index) => {
            if (this.mypatients[item].length != 0) {
              newObj[item] = this.mypatients[item]
            }
          })
          this.mypatients = newObj
        })
        // console.log('我的病人', this.mypatients)
      } else if (this.users.user_type == 3) {
        let arr = []
        let zoneArr = []
       

        if (this.$store.getters.user.template_info.org_id == 10340) {
          patient.map((item, index) => {
            if ((item.dialysis_order != null && item.dialysis_order.start_nurse == this.users.id) || ((item.dobule_check != null && item.dobule_check.creater == this.users.id || item.dobule_check != null && item.dobule_check.modifier == this.users.id))) {
              if (item.schedule_type == this.schedualValue) {
                arr.push(item)
              } else if (this.schedualValue == 0) {
                if (item.patient_id == 19471) {
                  console.log('item.dialysis_order.start_nurse', item.dialysis_order.start_nurse)
                  console.log('this.users.id', this.users.id)
                  console.log('schedule_type', item.schedule_type)
                  console.log('this.schedualValue', this.schedualValue)
                }
                arr.push(item)
              }
            }
          })
          
        } else {
          patient.map((item, index) => {
            if (item.dialysis_order != null && item.dialysis_order.start_nurse == this.users.id) {
              if (item.schedule_type == this.schedualValue) {
                arr.push(item)
              } else if (this.schedualValue == 0) {
                arr.push(item)
              }
            }
          })
        }



        arr.map(item => {
          if (item.device_number.zone_id == this.zoneValue) {
            zoneArr.push(item)
          } else if (this.zoneValue == 0) {
            zoneArr.push(item)
          }
        })

        console.log("zoneArr---------------------",zoneArr)
       

        // //解决溪康排序问题  我的病人列表
        if(zoneArr!=null && zoneArr.length>0){
          for(let i=0;i<zoneArr.length;i++){
            zoneArr[i].sort = 0
            zoneArr[i].sort = zoneArr[i].device_number.sort 
          }
        }
       
        this.myPatientsOne = []
        this.myPatientsOne = zoneArr.sort(this.compare('sort'))
        console.log("我的病人hhhhhhhhhhhhhhhhhhhh",this.myPatientsOne)
      

        let cityNameList = []
        for (let p in zoneArr) {
          cityNameList.push(zoneArr[p])
        }

        

        let firstName = {}
        this.FirstPin.forEach(item => {
          firstName[item] = []
          cityNameList.forEach(el => {
            let first = pinyin.getFullChars(el.patient.name).substring(0, 1)
            if (first == item) {
              firstName[item].push(el)
            }
          })
         
          this.mypatients = firstName
          // 判断非空
          let newObj = {}
          Object.keys(this.mypatients).map((item, index) => {
            if (this.mypatients[item].length != 0) {
              newObj[item] = this.mypatients[item]
            }
          })
          this.mypatients = newObj
        })
        console.log('我的病人', this.mypatients)
        
      
      }
    },
    dialysisGlobalConfig (patient) {
      dialysisGlobalConfig().then(rs => {
        var res = rs.data
        if (res.state == 1) {
          this.admin_users = res.data.admin_users
          this.$store.dispatch('SetAdminUserArr', { adminUserArr: this.admin_users })
          if (this.users.user_type == 2) {
            let arr = []
            let zoneArr = []
            patient.map((item, index) => {
              if (item.prescription != null && item.prescription.creater == this.users.id) {
                if (item.schedule_type == this.schedualValue) {
                  arr.push(item)
                } else if (this.schedualValue == 0) {
                  arr.push(item)
                }
              }
            })
            arr.map(item => {
              if (item.device_number.zone_id == this.zoneValue) {
                zoneArr.push(item)
              } else if (this.zoneValue == 0) {
                zoneArr.push(item)
              }
            })
              // //解决溪康排序问题  我的病人列表
             if(zoneArr!=null && zoneArr.length>0){
                for(let i=0;i<zoneArr.length;i++){
                  zoneArr[i].sort = 0
                  zoneArr[i].sort = zoneArr[i].device_number.sort 
                }
              }
            
              this.myPatientsOne = []
              this.myPatientsOne = zoneArr.sort(this.compare('sort'))

            this.searchArr = zoneArr

            let cityNameList = []
            for (let p in zoneArr) {
              cityNameList.push(zoneArr[p])
            }
            


            let firstName = {}
            this.FirstPin.forEach(item => {
              firstName[item] = []
              cityNameList.forEach(el => {
                let first = pinyin.getFullChars(el.patient.name).substring(0, 1)
                if (first == item) {
                  firstName[item].push(el)
                }
              })
              this.mypatients = firstName
              // 判断非空
              let newObj = {}
              Object.keys(this.mypatients).map((item, index) => {
                if (this.mypatients[item].length != 0) {
                  newObj[item] = this.mypatients[item]
                }
              })
              this.mypatients = newObj
            })
            // console.log('我的病人', this.mypatients)
          } else if (this.users.user_type == 3) {
            let arr = []
            let zoneArr = []
            patient.map((item, index) => {
              if (item.dialysis_order != null && item.dialysis_order.start_nurse == this.users.id) {
                if (item.schedule_type == this.schedualValue) {
                  arr.push(item)
                } else if (this.schedualValue == 0) {
                  arr.push(item)
                }
              }
            })
            arr.map(item => {
              if (item.device_number.zone_id == this.zoneValue) {
                zoneArr.push(item)
              } else if (this.zoneValue == 0) {
                zoneArr.push(item)
              }
            })


              // //解决溪康排序问题  我的病人列表
              if(zoneArr!=null && zoneArr.length>0){
                for(let i=0;i<zoneArr.length;i++){
                  zoneArr[i].sort = 0
                  zoneArr[i].sort = zoneArr[i].device_number.sort 
                }
              }
            
              this.myPatientsOne = []
              this.myPatientsOne = zoneArr.sort(this.compare('sort'))

             this.searchArr = zoneArr

            // console.log('arr', arr)
            let cityNameList = []
            for (let p in zoneArr) {
              cityNameList.push(zoneArr[p])
            }

            console.log("所有患者的数据=========================",cityNameList)


            // if(cityNameList!=null && cityNameList.length>0){
            //   for(let i=0;i<cityNameList.length;i++){
            //     cityNameList[i].sort = 0
            //     cityNameList[i].sort = cityNameList[i].device_number.sort 
            //   }
            // }
       
            // this.newPatient = []
            // this.newPatient = cityNameList.sort(function (a, b) {
            //     return a.sort > b.sort
            // })
              
           
          


            let firstName = {}
            this.FirstPin.forEach(item => {
              firstName[item] = []
              cityNameList.forEach(el => {
                let first = pinyin.getFullChars(el.patient.name).substring(0, 1)
                if (first == item) {
                  firstName[item].push(el)
                }
              })
              this.mypatients = firstName
              // 判断非空
              let newObj = {}
              Object.keys(this.mypatients).map((item, index) => {
                if (this.mypatients[item].length != 0) {
                  newObj[item] = this.mypatients[item]
                }
              })
              this.mypatients = newObj
            })
            // console.log('我的病人', this.mypatients)
          }
        }
      })
    },
    onSearch (val) {
      console.log(val)
      console.log("active=-----------------",this.active)
      console.log("searchArr",this.searchArr)
      if (this.active == 0) {
        let arr = []
        this.searchArr.map(item => {
          if (item.patient.name.indexOf(val) != -1) {
            arr.push(item)
          }
        })
        let cityNameList = []
        for (let p in arr) {
          cityNameList.push(arr[p])
        }

        console.log("cityNameList",cityNameList)

          // //解决溪康排序问题  我的病人列表
          if(cityNameList!=null && cityNameList.length>0){
              for(let i=0;i<cityNameList.length;i++){
                cityNameList[i].sort = 0
                cityNameList[i].sort = cityNameList[i].device_number.sort 
              }
          }
            
          this.myPatientsOne = []
          this.myPatientsOne = cityNameList.sort(this.compare('sort'))
          console.log("myPatientsOne----------------",this.myPatientsOne)


        let firstName = {}
        this.FirstPin.forEach(item => {
          firstName[item] = []
          cityNameList.forEach(el => {
            let first = pinyin.getFullChars(el.patient.name).substring(0, 1)
            if (first == item) {
              firstName[item].push(el)
            }
          })
          this.mypatients = firstName
          // 判断非空
          let newObj = {}
          Object.keys(this.mypatients).map((item, index) => {
            if (this.mypatients[item].length != 0) {
              newObj[item] = this.mypatients[item]
            }
          })
          this.mypatients = newObj
        })
      } else if (this.active == 1) {

        console.log("allSearchArr------------------",this.allSearchArr)
        let arr = []
        this.allSearchArr.map(item => {
          if (item.patient.name.indexOf(val) != -1) {
            arr.push(item)
          }
        })
        let cityNameList = []
        for (let p in arr) {
          cityNameList.push(arr[p])
        }


       // //解决溪康排序问题  我的病人列表
       if(cityNameList!=null && cityNameList.length>0){
          for(let i=0;i<cityNameList.length;i++){
             cityNameList[i].sort = 0
             cityNameList[i].sort = cityNameList[i].device_number.sort 
           }
         }
            
        this.newPatient = []
        this.newPatient = cityNameList.sort(this.compare('sort'))


        let firstName = {}
        this.FirstPin.forEach(item => {
          firstName[item] = []
          cityNameList.forEach(el => {
            let first = pinyin.getFullChars(el.patient.name).substring(0, 1)
            if (first == item) {
              firstName[item].push(el)
            }
          })
          this.patients = firstName
          // 判断非空
          let newObj = {}
          Object.keys(this.patients).map((item, index) => {
            if (this.patients[item].length != 0) {
              newObj[item] = this.patients[item]
            }
          })
          this.patients = newObj
        })
      }
    },
    chooseSchedual (value) {
      this.schedualTypes = value
      if (value == '全部班次') {
        this.schedualValue = 0
      } else if (value == '上午') {
        this.schedualValue = 1
      } else if (value == '下午') {
        this.schedualValue = 2
      } else if (value == '晚上') {
        this.schedualValue = 3
      }
      sessionStorage.setItem('schedualType', this.schedualValue)
      let newScheduals = this.$store.getters.scheduals
      this.getScheduals(newScheduals.scheduals)
      this.schedualTypesShow = false
    },
    chooseZone (value) {
      console.log(value)
      this.zoneTypes = value.text
      this.zoneValue = value.id
      sessionStorage.setItem('zoneType', this.zoneValue)
      let newScheduals = this.$store.getters.scheduals
      this.getScheduals(newScheduals.scheduals)
      this.zoneShow = false
    },
    showPatientList () {
      this.show = true
    },
    getTimeOne (time) {
      return uParseTime(time, '{y}-{m}-{d}')
    },
    switchMsec (time){ // 日期转换成毫秒
      let date = new Date(time);
      // 有三种方式获取
      let time1 = date.getTime(); // 精确到毫秒;
      return (time1/1000)-28800
    },
    formatter (day) {

      this.patientAllDayList.map(item => {
      //  console.log("itemwowowwo",item.scheudle)
       if(this.$store.getters.user.template_info.org_id == 9538 || this.$store.getters.user.template_info.org_id == 10101 || this.$store.getters.user.template_info.org_id == 10353 || this.$store.getters.user.template_info.org_id == 9946){
        if (item.dialysis_date == new Date(day.date).getTime() / 1000) {
          day.bottomInfo = item.schedual_type == 1 ? '上午' : item.schedual_type == 2 ? '下午' : item.schedual_type == 3 ? '晚上' : ''
          day.topInfo = this.GetModeByModeId(item.mode_id)
          if(day.bottomInfo!=undefined){
            if(this.switchMsec(this.getTimeOne(day.date)) < this.switchMsec(this.getTimeOne(this.today))){
              day.className = "custom-date-one"
            }
          }
        }

       }else{
        if (item.schedule_date == new Date(day.date).getTime() / 1000) {
          day.bottomInfo = item.schedule_type == 1 ? '上午' : item.schedule_type == 2 ? '下午' : item.schedule_type == 3 ? '晚上' : ''
          day.topInfo = this.GetModeByModeId(item.mode_id)
          if(day.bottomInfo!=undefined){
            if(this.switchMsec(this.getTimeOne(day.date)) < this.switchMsec(this.getTimeOne(this.today))){
              day.className = "custom-date"
            }
            if(this.switchMsec(this.getTimeOne(day.date)) > this.switchMsec(this.getTimeOne(this.today))){
               day.className = "custom-date-two"
            }
          }
        }
       }

      })


      return day
    },
    getPatientDialysisRecord () {
      let patient_id = this.patient_id
      //某月第一天
      // let startTime = moment().startOf('months').format('YYYY-MM-DD')
      //let startTime =  moment().month(moment().month() - 6).startOf('month').format('YYYY-MM-DD')

      let startTime =moment().subtract(2, 'years').format('YYYY-MM-DD')
        //某月最后一天
      let endTime = moment().month(moment().month() +1).endOf('month').format('YYYY-MM-DD')

      console.log("开始时间",startTime,endTime)
      getPatientDialysisRecord({id: patient_id,start_time:startTime,end_time:endTime}).then((res) => {
        console.log('resres', res)
        let list = res.data.data.list
        this.patientAllDayList = list
        this.calendarShow = true
      })
    },
    GetModeByModeId (val) {
      let treatment_mode_name = ''
      let treatment_mode = this.$store.getters.treatment_mode

      for (let keys in treatment_mode) {
        if (treatment_mode[keys].id == val) {
          treatment_mode_name = treatment_mode[keys].name
        }
      }

      return treatment_mode_name
    },
    onCalendar (val) {
      this.patientAllDayList.map(item => {
         console.log("iemwoowwoow",item)
         if(this.$store.getters.user.template_info.org_id == 9538 || this.$store.getters.user.template_info.org_id == 10101 || this.$store.getters.user.template_info.org_id == 10353 || this.$store.getters.user.template_info.org_id == 9946){
          if (item.dialysis_date == new Date(val).getTime() / 1000) {
              this.reload()
              this.$router.replace({
                path: '/details',
                query: {
                  patient_id: this.$route.query.patient_id,
                  date: new Date(val).getTime() / 1000,
                  patient_name: this.patient_name
                }
              })
              // sessionStorage.removeItem('newBarIndex')
              this.calendarShow = false
         }

         }
         if(this.$store.getters.user.template_info.org_id != 9538 && this.$store.getters.user.template_info.org_id != 10101 && this.$store.getters.user.template_info.org_id != 10353 && this.$store.getters.user.template_info.org_id != 9946){
          if (item.schedule_date == new Date(val).getTime() / 1000) {
              this.reload()
              this.$router.replace({
                path: '/details',
                query: {
                  patient_id: this.$route.query.patient_id,
                  date: new Date(val).getTime() / 1000,
                  patient_name: this.patient_name
                }
              })
              // sessionStorage.removeItem('newBarIndex')
              this.calendarShow = false
         }

        }


      })
    },
    openCalendarShow () {
      this.getPatientDialysisRecord()
    },
    // 图片预览
    printImage(){
      let patient_id = this.patient_id
       getPatientMap(patient_id).then(response=>{
          if(response.data.state ==1){
             var sitemap = response.data.data.sitemap
             console.log("sitemap",sitemap)
             if(sitemap!=null&&sitemap.id>0){
                this.url = sitemap.img_url
                this.srcList.push(sitemap.img_url)
                this.$refs.previewImg.showViewer = true
             }

          }
       })

    },
    tiaozhuan_click(eve){
      console.log('33333333322222',eve);
      this.index = eve
    },
    // 自定义方法
    tabIndex(eve){
      console.log('eve111111',eve);
      this.tableIndex = eve
    },
    history_click(eve){
      console.log('history_click',eve);
      this.tableIndex2 =eve
    }

  },
  watch: {
    clientHeight (val) {
      // 为了避免频繁触发resize函数导致页面卡顿，使用定时器
      if (!this.timer) {
        // 一旦监听到的screenWidth值改变，就将其重新赋给data里的screenWidth
        this.clientHeight = val
        this.timer = true
        let that = this
        setTimeout(function () {
          // 打印screenWidth变化的值
          console.log('zhixing')
          that.timer = false
          setRem()
        }, 400)
      }
    },
    '$route': function (to, from) {
      if (to.query.active1 == '0' && to.active2 == undefined) {
        var patient_id = to.query.patient_id
        var date = to.query.date
        var patient_name = to.query.patient_name
        this.patient_id = patient_id
        this.date = date
        this.patient_name = patient_name
        this.GetPatientInfoWithDiseases(this.patient_id)
        this.index = parseInt(to.query.active1)
      }
      if (to.query.patient_id != from.query.patient_id) {
        var patient_id = this.$route.query.patient_id
        var date = this.$route.query.date
        var patient_name = this.$route.query.patient_name
        this.patient_id = patient_id
        this.date = date
        this.patient_name = patient_name
        this.GetPatientInfoWithDiseases(this.patient_id)
      }
    }
  },
  beforeRouteLeave (to, from, next) {
    // 在渲染该组件的对应路由被 confirm 前调用
    // 不！能！获取组件实例 `this`
    // 因为当钩子执行前，组件实例还没被创建
    console.log('to', to)
    console.log('from', from)
    if (to.path == '/main') {
      sessionStorage.removeItem('newBarIndex')
    }
    next()
  }
  // beforeRouteUpdate(to, from){
  //   console.log(to)
  //   if(to.query.active1 == "2" && to.active2 == undefined){
  //     console.log(123)

  //     var patient_id = to.query.patient_id;
  //     var date = to.query.date;
  //     var patient_name = to.query.patient_name;
  //     this.patient_id = patient_id;
  //     this.date = date;
  //     this.patient_name = patient_name;
  //     console.log(this.date)
  //     this.GetPatientInfoWithDiseases(this.patient_id);
  //     // this.index = parseInt(to.query.active1)
  //   }
  //   console.log(from)
  // }
}
</script>

<style style="stylesheet/scss" lang="scss" scoped>
.mainBox {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  > :first-child {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
}
.mainContent {
  // position: relative;
  .navigation {
    // @include display-flex;
    // @include align-items-center;
    // @include text-align;
    // @include box-sizing;
    // @include justify-content-between;
    // padding: 0.3rem 0.36rem;
    // border-bottom: 1px #e5e5e5 solid;
    padding: 0 .625rem;
    height: 3.125rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: #258ffc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
    .newGoBack {
      float: left;
      font-size: .875rem;
      display: flex;
      align-items: center;
    }
    .newNav1 {
      float: left;
      margin-right: 1rem;
    }
    .name {
      color: #fff;
    }
    .nav {
      // margin-left: 0.4rem;
      // @media only screen and (min-width: 376px) and (max-width: 415px) {
      //   margin-left: 1rem;
      // }
      // @media only screen and (min-width: 415px) and (max-width: 767px) {
      //   margin-left: 1.6rem;
      // }
      // @media only screen and (min-width: 768px) {
      //   margin-left: 2rem;
      // }
      ul {

        li {
          float: left;
          font-size: .9375rem;
          // margin: 0 .375rem;
          height: 1.875rem;
          line-height: 1.875rem;
          padding: 0 .3125rem;
          cursor: pointer;
          color: #fff;
          border: 1px solid #fff;
          border-radius: 4px;
          &.active {
            // background: $main-color;
            background: #fff;
            color: #258ffc;
            // color: #fff;
            border-radius: 4px;
          }
        }
        >li:first-child{
          border-radius: 4px 0 0 4px;
        }
        >li:last-child{
          border-radius: 0 4px 4px 0;
        }
      }
    }
    .time {
      cursor: pointer;
      .iconfont {
        margin-left: 0.1rem;
      }
    }
  }
  .Tab {
    padding-top: 63px;
    flex: 1;
    overflow-y: auto;
    // padding-bottom: 0.25rem;
    @media only screen and (max-width: 812px) {
      padding-top: 3.125rem !important;
    }
  }
}
.add {
  width: 1.6rem;
  height: 1.6rem;
  background: #f18f68;
  // box-shadow: 0px 3px 9px 0px rgba(7, 30, 102, 0.15);
  border-radius: 50%;
  position: fixed;
  right: 0.6rem;
  bottom: 2.25rem;
  font-size: 0.34rem;
  text-align: center;
  // @media only screen and (max-width: 767px) {
  //   display: none;
  // }
  p {
    width: 26px;
    text-align: center;
    margin: 9px auto 0;
    color: #fff;
    // @media only screen and (min-width: 768px) {
    //   width: 40px !important;
    //   margin: 11px auto 0;
    // }
    @media only screen and (min-width: 768px) {
      width: 50px;
      margin: 17px auto 0;
    }
    @media only screen and (min-width: 415px) and (max-width: 767px) {
      margin: 12px auto 0;
      width: 30px;
    }
  }
}
.printBox {
  position: fixed;
  right: 0.6rem;
  bottom: 1rem;
  img {
    width: 1.875rem;
    height: 1.875rem;
  }
}
.callFamilyBox{
  position: fixed;
  left: 0.6rem;
  bottom: 8rem;
  z-index: 5000;
  img {
    width: 3.5rem;
    height: 3.5rem;
  }
}
.fixedCalling{
  height: 2.1rem;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #fff;
  display: flex;
  justify-content: space-around;
  .nowCalling{
    p{
      font-size: 0.4rem;
      text-align: center;
    }
  }
  .callingName{
    width: 3rem;
    height: 1rem;
    background: #DBDFE7;
    opacity: 0.9;
    border-radius: 0.53rem;
    color:#3389FB;
    text-align: center;
    font-size: 0.53rem;
    line-height: 1rem;
    margin-top: 0.5rem;
  }
  .fixedVolume{
    width: 2rem;
    height: 2rem;
    background: linear-gradient(0deg, #1965E5 0%, #33ACF9 100%);
    box-shadow: 0px 4px 10px 0px rgba(69, 143, 243, 0.27);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: absolute;
    top: -0.33rem;
    .van-icon-volume{
      color: #fff;
      font-size: 1rem;
      margin: 0 auto;
    }
  }
}
.newToolOne{
  width: 6.75rem;
  height: 1.875rem;
  background: #f6f6f6;
  border-radius: 5px;
  text-align: center;
  font-size: .875rem;
  color: #8d8d8d;
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-bottom: 10px;
}
.previewBox{
  display: flex;
  align-items: center;
}
.preview{
  font-size: 1rem;
  color: #fff;
}
.iconDate{
  font-size: 1.5rem;
  margin-left: 1.25rem;
  color: #fff;
}
.calendarPopup{
  top: initial;
  transform: translate3d(0, 0, 0);
  border-radius: 0;
}
.printerIcon{
  font-size: 1.5rem;
  color: #fff;
}

</style>
<style lang="scss">
.custom-date {
  .van-calendar__top-info{
    background: #f44; /* 红色背景 */
  }

}
.custom-date-one{
  .van-calendar__top-info{
    background: #f44; /* 红色背景 */
  }
}

.custom-date-two{
  .van-calendar__top-info{
    background: #409eff; /* 红色背景 */
  }
}
.van-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  box-sizing: content-box;
  width: 90px;
  max-width: 70%;
  min-height: 90px;
  padding: 16px;
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  white-space: pre-wrap;
  text-align: center;
  word-wrap: break-word;
  background-color: rgba(50, 50, 51, 0.88);
  border-radius: 4px;
  -webkit-transform: translate3d(-50%, -50%, 0);
  transform: translate3d(-50%, -50%, 0);
}

.van-dialog {
  position: fixed;
  top: 45%;
  left: 50%;
  width: 320px;
  overflow: hidden;
  font-size: 16px;
  background-color: #fff;
  border-radius: 16px;
  -webkit-transform: translate3d(-50%, -50%, 0);
  transform: translate3d(-50%, -50%, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transition: 0.3s;
  transition: 0.3s;
  -webkit-transition-property: opacity, -webkit-transform;
  transition-property: opacity, -webkit-transform;
  transition-property: transform, opacity;
  transition-property: transform, opacity, -webkit-transform;
}

.van-dialog__message {
  max-height: 60vh;
  padding: 24px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 20px;
  white-space: pre-wrap;
  text-align: center;
  word-wrap: break-word;
  -webkit-overflow-scrolling: touch;
}

.van-button {
  position: relative;
  display: inline-block;
  box-sizing: border-box;
  height: 44px;
  margin: 0;
  padding: 0;
  font-size: 16px;
  line-height: 42px;
  text-align: center;
  border-radius: 2px;
  cursor: pointer;
  -webkit-transition: opacity 0.2s;
  transition: opacity 0.2s;
  -webkit-appearance: none;
  -webkit-text-size-adjust: 100%;
}

.van-button--large {
  width: 100%;
  height: 50px;
  line-height: 48px;
}

.van-dialog__header {
  padding-top: 24px;
  font-weight: 500;
  line-height: 24px;
  text-align: center;
}

.showBox{
  .van-popup{
    top:0;
    transform: none;
    border-radius: 0;
    left: 28%;
    width:72%;
  }
  .van-cell {
    position: relative;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    box-sizing: border-box;
    width: 100%;
    padding: 10px 16px;
    overflow: hidden;
    color: #323233;
    font-size: 14px;
    line-height: 24px;
    background-color: #fff;
  }
  .van-index-bar__index {
    padding: 0 4px 0 16px;
    font-weight: 500;
    font-size: 10px;
    line-height: 14px;
  }
  .van-index-anchor {
    z-index: 1;
    box-sizing: border-box;
    padding: 0 16px;
    color: #323233;
    font-weight: 500;
    font-size: 14px;
    line-height: 32px;
    // background-color: transparent;
  }
  .van-tab {
    position: relative;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0 4px;
    color: #646566;
    font-size: 14px;
    cursor: pointer;
  }
  .van-tabs--line .van-tabs__wrap{
    height: 44px;
  }
  .van-tabs__line {
    position: absolute;
    bottom: 15px;
    left: 0;
    z-index: 1;
    height: 3px;
    background-color: #258ffc;
    border-radius: 3px;
  }
  .van-tabs__nav--line {
    box-sizing: content-box;
    height: 100%;
    padding-bottom: 15px;
  }
  .van-cell::after {
    position: absolute;
    box-sizing: border-box;
    content: ' ';
    pointer-events: none;
    right: 16px;
    bottom: 0;
    left: 16px;
    border-bottom: 1px solid #ebedf0;
    -webkit-transform: scaleY(0.5);
    transform: scaleY(0.5);
  }
  .van-search{
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    box-sizing: border-box;
    padding: 10px 12px;
    background-color: #fff;
  }
  .van-search__content {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    padding-left: 8px;
    background-color: #f7f8fa;
    border-radius: 2px;
  }
  .van-search .van-cell {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    padding: 5px 8px 5px 0;
    background-color: transparent;
  }
  .van-field__left-icon {
    margin-right: 5px;
  }
  .van-field__left-icon .van-icon, .van-field__right-icon .van-icon {
    display: block;
    min-width: 1em;
    font-size: 16px;
    line-height: inherit;
  }
  .van-icon-clear{
    font-size: 16px;
  }
  .schedualPopup{
    top:initial !important;
  }

  // .schedualPopup{
  //   top:initial !important;
  //   .van-picker__toolbar{
  //     height: 1.46rem;
  //     line-height: 1.46rem;
  //   }
  //   .van-picker__cancel, .van-picker__confirm{
  //     padding: 0 0.53rem;
  //     font-size: 0.46rem;
  //   }
  //   .van-picker-column{
  //     font-size: 0.53rem;
  //   }
  //   .van-picker-column__item{
  //     padding: 0 0.14rem;
  //   }
  // }
}

</style>
