<template>
  <div id="today_panel" v-loading="loading"
         element-loading-text="拼命加载中"
         element-loading-spinner="el-icon-loading"
         element-loading-background="rgba(0, 0, 0, 0.8)">

    <div>
      <div class="infoContent" v-show="keyBoardShow">
        <div style="display:flex;flex:1;margin-right:20px;">
          <span style="color: #4bb467;margin-right:5px;">{{ todayDate }}</span>
          <span style="margin-right:5px">({{ patientInfo.dialysis_no }})</span>
          <span style="margin-right:5px">| {{ dialysis_mode }}/{{ bedNumber }}</span>
          <span style="flex:1;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;width:40px;">{{blood_access_part_opera_name}}</span>
        </div>
        <div><i class="el-icon-s-unfold" @click="msgtip_visibility = true"></i></div>
      </div>
      <div class="scrollBar" v-show="keyBoardShow" ref="tabContentScroll">
        <div style="display:flex;align-items: center;" id="tab_list">
          <div ref="tab_item" :class="barActive == index ? 'actionOne barActive' : 'actionOne'" @click="clickAction(index)" v-for="(item,index) in stepData" :key="index" style="position: relative;">
            {{item.title}}
            <van-icon v-if="item.value == 1" class="hook" name="passed" />
            <span class="redpoint" v-if="getUnReadNum() && index == 4">{{getUnReadNum()}}</span>
            <span class="redpoint" v-if="getUnReadNumOne() && index == 11">{{getUnReadNumOne()}}</span>
          </div>
        </div>
      </div>

      <div class="grayBorder"></div>
    </div>

    <div class="todayMain">
      <!-- 全部透析 -->
      <div v-show="barActive == 0">
        <van-button type="primary" color="#409eff" block @click="requestDialysisRecord">更新数据</van-button>
        <basic-dialysis-prescription id="prescription" :prescription="prescription" :solution="solution" :admin_map="admin_user_map"  title="透析处方"
                              :device_number_map="device_map" :preparestock="preparestock"></basic-dialysis-prescription>

        <div class="blueBorder"></div>

        <basic-accepts-assessment id="accepts_assessment" :record="receiver_treatment_access" title="接诊评估"></basic-accepts-assessment>

        <div class="blueBorder"></div>

        <basic-assessment-before id="assessment_before" :record="predialysis_evaluation" ref="assessment_before"
                          title="透前评估" :dry_weights="dryWeight"
                          :last_predialysis="last_predialysis_evaluation"></basic-assessment-before>

        <div class="blueBorder"></div>

        <basic-stat-order id="stat_order" ref="stat_order" title="临时医嘱" :doctor_map="admin_user_map"
                    :advice_groups="advice_groups"></basic-stat-order>

        <div class="blueBorder"></div>

        <basic-dialysis-computer id="dialysis_computer" ref="dialysis_computer" title="透析上机 " :record="dialysis_order"
                          :admin_map="admin_user_map" :device_number_map="device_number_map"></basic-dialysis-computer>

        <div class="blueBorder"></div>

        <basic-double-check id="double_check" ref="double_check" title="双人核对 " :record="double_check"  :admin_map="admin_user_map"></basic-double-check>

        <div class="blueBorder"></div>

        <basic-dialysis-monitoring id="monitoring" ref="monitoring" title="透析监测"></basic-dialysis-monitoring>

        <div class="blueBorder"></div>

        <basic-dialysis-off id="dialysis_off" ref="dialysis_off" title="透析下机 " :record="dialysis_order"
                    :admin_map="admin_user_map"></basic-dialysis-off>

        <div class="blueBorder"></div>

        <basic-assessment-after
          id="assessment_after"
          ref="assessment_after"
          title="透后评估"
          :record="assessment_after_dislysis"
          :predialysis="predialysis_evaluation"
          :prescription_prop="prescription"
        ></basic-assessment-after>

        <div class="blueBorder"></div>

        <basic-treatment-of id="treatment_of" ref="treatment_of" title="治疗小结" :record="treatment_summary"></basic-treatment-of>
      </div>
      <!-- 透析处方 -->
      <dialysisPrescription v-if="prescription_dialog_reset == true && barActive == 1" :patient_prop="patient" :solution_prop="solution" :machines_prop="devices" :config="config"
                           :prescription_prop="prescription" :operators="operators"
                           :types="goodTypes" :info="goodInfos" :status="status" :targetAdvices="longAdvices"
                           :waitUploadAdvices="waitUploadAdvices" :is_open="is_open"
                           @prescription="prescriptionFunc"
                           :admin_users_prop="admin_users"
                           :predialysis="predialysis_evaluation"
                           :last_predialysis="last_predialysis_evaluation"
                           :record="assessment_after_dislysis"
                           :last_record="last_assessment_after_dislysis"
                           :last_prescription="last_prescription"
                           :dry_weight="dryWeight"
                           :system_prescription ="system_prescription"
                           :schedual="schedual"
                           :his_is_open="his_is_open"
                           :prescription_open="prescription_open"
                           :is_advice_open="is_advice_open"
                           @longSolution="longSolutionFunc" ref="prescription_dialog"
                           :stockType="stockType"
                           :admin_map="admin_user_map"
                           :admins="admin_users"
                           :lastDialysisPrescription="lastDialysisPrescription"
                           ></dialysisPrescription>
        <!-- 接诊 -->
        <accepts v-if="barActive == 2" ref="accepts" :accepts="receiver_treatment_access" :patient_prop="patient"></accepts>
        <!-- 透前 -->
        <assessmentBefore v-if="barActive == 3" :predialysis="predialysis_evaluation" :last_predialysis="last_predialysis_evaluation"
                         :last_befor="last_befor"
                         :dry_weight_list="dryWeightList"
                         :dry_weight="dryWeight"
                         :patient_prop="patient" @evaluation="update_evaluation" @close="closeAssessmentBefore"
                         :admin_users_prop="admin_users" :lastAssessment="lastAssessment"
                         :predialysis_evaluation_obj="predialysis_evaluation_obj"
                         :first_monitor="first_monitor"
                         :last_record="last_assessment_after_dislysis"
                         ref="assessment_dialog" @weight_update="weightFunc"></assessmentBefore>
        <!-- 医嘱 -->
        <doctorAdvice v-if="barActive == 4" :patient_prop="patient" :predialysis="predialysis_evaluation"
                      :advice_groups="advice_groups"
                      :advice_list_prop="doctor_advices"
                      :admin_users_prop="admin_users"
                      :his_is_open="his_is_open"
                      @orderDialog="closeStatOrder"
                      :dialysis_order="dialysis_order"
                      :is_advice_open="is_advice_open"
                      :prescription_prop="prescription"

                      ref="orders_dialog"></doctorAdvice>
        <!-- 双人核对 -->
        <doubleCheck v-if="barActive == 5" :patient_prop="patient" ref="doubleCheck"
                    @did_update="updateDoubleCheck"
                    :dialysis_order="dialysis_order"
                    :record="double_check"
                    :admin_users_prop="admin_users"
                    :admin_map="admin_user_map"
                    :admins="admin_users"
                    :predialysis="predialysis_evaluation"
                    :prescription_prop="prescription"></doubleCheck>
        <!-- 上机 -->
        <computer v-if="barActive == 6" :schedule="schedual"
                  :patient_prop="patient"
                  :record="dialysis_order"
                  :prescription_prop="prescription"
                  :admins="startArr"
                  :device_numbers="device_numbers"
                  :admin_map="start_user_map"
                  :admin_staff="admin_staff_map"
                  :device_number_map="device_number_map"
                  :last_order="lastOrder"
                  :stockType="stockType"
                  @did_start="closeDialysisComputer"
                   :predialysis="predialysis_evaluation"
                  @did_add_monitor="didAddMonitor"

                  ></computer>
        <monitoring v-if="barActive == 7" :monitor_records="monitor_records"
                    :last_monitor_record="last_monitor_record"
                    :patient="patient"
                    :dry_weight="dryWeight"
                    :order="dialysis_order"
                    :prescription_prop="prescription"
                    :dialysis_order="dialysis_order"
                    :assessment_after_dislysis="assessment_after_dislysis"
                    @did_add_monitor="didAddMonitor"
                    @did_edit_monitor="didEditMonitor"
                    @did_delete_monitor="didDelMonitor"
                    @did_delete_more_monitor="didDelMoreMonitor"
                    @close="closeMonitoring"
                    ref="monit_dialog"></monitoring>
        <plane v-if="barActive == 8" :patient_prop="patient" :record="dialysis_order" :last_monitor_record="last_monitor_record"
                :admins="startArr" :admin_map="start_user_map"
                :last_order="lastOrder"
                :monitor_records="monitor_records"
                :prescription_prop="prescription" @did_off="closeDialysisOff"></plane>
        <assessmentAfter v-if="barActive == 9" :patient_prop="patient"
                        :record="assessment_after_dislysis"
                        :last_record="last_assessment_after_dislysis"
                        :predialysis="predialysis_evaluation"
                        :last_monitor="last_monitor"
                        :prescription_prop="prescription"
                        @did_update="closeAssessmentAfter"
                        @close="closeAssessmentAfter"
                        ref="thoroug_dialog"></assessmentAfter>
        <treatment v-if="barActive == 10" :patient_prop="patient" :record="treatment_summary" @did_update="updateTreatmentOf"
                    @close="closeTreatmentOf" ref="treatment_dialog" :prescription_prop="prescription"  :predialysis_evaluation="predialysis_evaluation"  :advice_groups="advice_groups" :dialysis_order="dialysis_order" :assessment_after_dislysis="assessment_after_dislysis" :monitor_records="monitor_records"></treatment>
        <!-- 耗材 -->
        <consumables v-if="barActive == 11" :patient_id='patient.id' :schedule_date='schedual.schedule_date' :name='patient.name' :is_open='config.is_open' :is_computer='newStage != 0 ? newStage : dialysis_order.stage' @update_good_user="getDialysisGoods"></consumables>
    </div>
    <van-popup v-model="msgtip_visibility" class="msgtipPopup" get-container="#today_panel">
      <msg-tip
        :visibility="msgtip_visibility"
        :predialysis="predialysis_evaluation"
        :last_predialysis="last_predialysis_evaluation"
        :record="assessment_after_dislysis"
        :dry_weight="dryWeight"
        :last_record="last_assessment_after_dislysis"
        :patient_prop="patient"
        :prescription_prop="prescription"
        v-on:menu-msg-tip="menuMsgTip"
      ></msg-tip>
    </van-popup>
    <div class="checkBox2" @click="goBack" v-show="date<todayTime">
      <img src="../../../assets/images/gotoday.png" alt="">
    </div>
    <div class="checkBox1" @click="goCheck" ref="moveBtn" v-if="user_type!=3 || ($store.getters.user.template_info.org_id==10013 || $store.getters.user.template_info.org_id==10014 || $store.getters.user.template_info.org_id==10215  || $store.getters.user.template_info.org_id==10318|| $store.getters.user.template_info.org_id==10471 || $store.getters.user.template_info.org_id==10693)">
      <img src="../../../assets/images/check.png"  v-if="barActive != 4" @mousedown="down" @touchstart="down"
      @mousemove="move"
      @touchmove="move"
      @mouseup="end"
      @touchend="end"
      @touchcancel="end" alt="">
    </div>

    <div class="checkBox4" @click="tiaozhuan" ref="moveBtn2" v-if="$store.getters.user.template_info.org_id==10445 || $store.getters.user.template_info.org_id==9675">
      <img src="../../../assets/images/check2.png" @mousedown="down2" @touchstart="down2"
      @mousemove="move2"
      @touchmove="move2"
      @mouseup="end2"
      @touchend="end2"
      @touchcancel="end2" alt="" v-if="barActive == 4">
    </div>

    <div class="checkBox3"  @click="toExecution" ref="moveBtns" v-if="user_type==3 && ($store.getters.user.template_info.org_id==10340 || $store.getters.user.template_info.org_id==10489)">
        <img src="../../../assets/images/advice.png" @mousedown="downs" @touchstart="downs"
      @mousemove="moves"
      @touchmove="moves"
      @mouseup="ends"
      @touchend="ends"
      @touchcancel="ends" alt/>
        <span class="redpoints" v-if="total>0">
          {{ total }}
        </span>
    </div>

    <van-dialog v-model="dry_visibility"  width="90%"  show-cancel-button>
      <div style="margin:10px;height:100px; overflow-y: scroll;">
        <div style="">
          <table border="1" cellspacing="0" cellpadding="0" width="100%" style="text-align:center;table-layout: fixed;">
            <tr>
              <th>项目名称</th>
              <th>上次检查日期</th>
            </tr>
            <tr v-for="(item, index) in remind_lists">
              <td>{{item.re.project_name}} </td>
              <td>{{getTimeTwo(item.last_remind_date)}}</td>
            </tr>

          </table>
        </div>
      </div>
    </van-dialog>

    <div class="popup">
      <van-popup
        v-model:show="showRight"
        position="right"
        :style="{ width: '60%', height: '100%',right: '-30%' }">

        <div  v-if="drugStockConfig.is_open == 0 || drugStockConfig.is_open == 2">
          <div style="margin: 10px;border-bottom: 1px solid black;">
            <span class="text">姓名</span>
            <span class="text">条数</span>
          </div>
          <div v-for="item in adviceList">
            <div style="margin: 10px;border-bottom: 1px solid black;" @click="toExecutionPatent(item)">
              <span class="text">{{getPaitenName(item.patient_id) }}</span>
              <span class="text">{{item.count }}</span>
            </div>
          </div>
        </div>

        <div  v-if="drugStockConfig.is_open == 1 ">
          <div style="margin: 10px;border-bottom: 1px solid black;">
            <span class="text">姓名</span>
            <span class="text">条数</span>
          </div>
          <div v-for="item in tableData">
            <div style="margin: 10px;border-bottom: 1px solid black;" @click="toExecutionPatent(item)">
              <span class="text">{{getPaitenName(item.patient_id) }}</span>
              <span class="text">{{item.count }}</span>
            </div>
          </div>
        </div>
      </van-popup>
    </div>
  </div>
</template>
<script>
import axios from 'axios'
import basicDetailsInfo from './detailsInfo'
import basicDialysisPrescription from './dialysisPrescription'
import basicPastData from './pastData'
import basicAcceptsAssessment from './acceptsAssessment'
import basicAssessmentBefore from './assessmentBefore'
import basicStatOrder from './statOrder'
import basicDialysisComputer from './dialysisComputer'
import basicDoubleCheck from './doubleCheck'
import basicDialysisMonitoring from './dialysisMonitoring'
import basicDialysisOff from './dialysisOff'
import basicAssessmentAfter from './assessmentAfter'
import basicTreatmentOf from './treatmentOf'
import { Toast } from 'vant'
// new
import dialysisPrescription from '../newActionBar/dialysisPrescription'
import accepts from '../newActionBar/accepts'
import assessmentBefore from '../newActionBar/assessmentBefore'
import doubleCheck from '../newActionBar/doubleCheck'
import computer from '../newActionBar/computer'
import plane from '../newActionBar/plane'
import assessmentAfter from '../newActionBar/assessmentAfter'
import treatment from '../newActionBar/treatment'
import consumables from '../newActionBar/consumables'
import monitoring from '../newActionBar/monitoring'
import doctorAdvice from '../newActionBar/doctorAdvice'
import MsgTip from '../dialog/subMenu/MsgTip'

import {
  CreateGroupAdvice,
  dialysisGlobalConfig,
  getDialysisRecord,
  getPatientId,
  getDialysisGoods,
  getAdviceListNoExecution
} from '@/api/dialysis'
import { GetRemindLongAdviceOne } from '@/api/advice'

import {uParseTime} from '@/utils/tools'
import { parseTime } from '@/utils'
import request from '@/utils/request'
import { getDataConfig } from '@/utils/data'
import {Dialog} from 'vant'
const moment = require('moment')
export default {
  name: 'TodayTab',
  components: {
    dialysisPrescription,
    accepts,
    assessmentBefore,
    doubleCheck,
    computer,
    plane,
    assessmentAfter,
    treatment,
    consumables,
    monitoring,
    doctorAdvice,
    MsgTip,
    basicDetailsInfo,
    basicDialysisPrescription,
    basicPastData,
    basicAcceptsAssessment,
    basicAssessmentBefore,
    basicStatOrder,
    basicDialysisComputer,
    basicDoubleCheck,
    basicDialysisMonitoring,
    basicDialysisOff,
    basicAssessmentAfter,
    basicTreatmentOf

  },
  props:{
    index:Number,
    tableIndex:Number
  },
  inject: ['reload'],
  data () {
    return {
      loading: true,
      index: 0,
      dry_visibility:false,
      remind_lists:[],
      showRight:false,
      // show_fixed_nav: false,
      patient_id: 0,
      date: 0,
      menuList: [
        { value: '2', label: ' 透析处方', showPopup: false },
        { value: '3', label: ' 接诊评估', showPopup: false },
        { value: '4', label: ' 透前评估', showPopup: false },
        { value: '5', label: ' 临时医嘱', showPopup: false },
        { value: '6', label: ' 透析上机', showPopup: false },
        { value: '1', label: ' 双人核对', showPopup: false },
        { value: '7', label: ' 透析监测', showPopup: false },
        { value: '8', label: ' 透析下机', showPopup: false },
        { value: '9', label: ' 透后评估', showPopup: false },
        { value: '10', label: ' 治疗小结', showPopup: false }
      ],
      isPullData: 1,
      config: {}, // 库存自动扣减
      operators: [], // 操作人
      patient: {}, // 患者信息
      schedual: {}, // 患者排班信息
      prescription: {}, // 透析处方
      solution: {}, // 透析方案
      his_is_open: 0,
      his_project_is_open: 0,
      last_prescription: {},
      lastDialysisPrescription:{},
      system_prescription: {}, // 系统透析模版
      thoroug_dialog_reset: true,
      prescription_dialog_reset: true,
      monit_dialog_reset: true,
      receiver_treatment_access: {}, // 接诊评估
      predialysis_evaluation: {}, // 透前评估
      predialysis_evaluation_obj:{},
      last_predialysis_evaluation: {}, // 上次透前评估
      last_befor:{},
      doctor_advices: [], // 临时医嘱
      project: [], // 项目
      advice_groups: [], // 对 doctor_advices 进行分组后的组列表，元素为 { group_no, start_time, advices:[advice object] }
      double_check: {}, // 双人核对
      assessment_after_dislysis: {}, // 透后评估
      last_assessment_after_dislysis: {}, // 上次透后评估
      treatment_summary: {}, // 治疗小结
      monitor_records: [], // 透析监测
      last_monitor_record: {
        id: 0,
        operate_time: new Date().getTime(),
        sodium_concentration: '',
        dialysate_temperature: ''
      }, // 上一次透析的监测记录
      dialysis_order: {}, // 透析记录
      admin_users: [], // 系统用户列表
      devices: [], // 设备
      device_numbers: [], // 床位号
      admin_user_map: {}, // {user_id: admin_user object}
      start_user_map: {},
      startArr: [],
      device_map: {}, // {device_id: device}
      device_number_map: {}, // {device_number_id: device_number}
      scrollTop: '',
      goTopShow: false,
      goodTypes: [],
      goodInfos: [],
      dryWeight: {},
      lastAssessment: {},
      longAdvices: [],
      waitUploadAdvices: [],
      is_open: 0,
      targetAdvices: [],
      status: '',
      patientid: 0,
      dialyzerPerfusionApparatus: [],

      patient_name: '',
      todayTime: 0,
      showTime: false,
      admin_roles: [{id: 0, name: '请选择'}],
      admin_staff_map: {},
      find_prescription: {},
      prescribeOne: {},
      stockType: [],
      preparestock: [],
      anticoagulantsConfit: {},

      // new
      patientInfo: {},
      barActive: 1,
      newStage: 0,
      contagion: '',
      good_user: [],
      todayDate: '',
      blood_access_part_opera_name: '',
      bedNumber: '',
      msgtip_visibility: false,
      keyBoardShow: true,
      appSourceState: '',

      flags: false,
      position: {
        x: 0,
        y: 0
      },
      positions: {
        x: 0,
        y: 0
      },
      position2:{
        x: 0,
        y: 0
      },

      active: 0,
      nx: '',
      ny: '',
      dx: '',
      dy: '',
      xPum: '',
      yPum: '',

      nsx: '',
      nsy: '',
      dsx: '',
      dsy: '',
      xsPum: '',
      ysPum: '',

      nx2: '',
      ny2: '',
      dx2: '',
      dy2: '',
      xPum2: '',
      yPum2: '',

      isShow: false,
      moveBtn: {},
      moveBtns: {},
      moveBtn2:{},
      is_project_open: 0,
      new_dialysis_goods: [],
      list: [],
      is_advice_open: 0,
      prescription_open: 0,
      warehouseOutList: [],
      his_config: {},
      lastOrder: {},
      drugStockConfig:{},
      adviceList:[],
      projectList:[],
      patientList:[],
      total:0,
      dialogVisible:false,
      tableData:[],
      user_type:0,
      dryWeightList:[],
      first_monitor:{},
      last_monitor:{},
      // blood_id:0,
    }
  },
  computed: {
    stepData: function () {
      var steps = [
        { title: '透析全部', name: 'basicInfo', value: 0, is_show: 0},
        { title: '透析处方', name: 'prescription', value: 0, is_show: 1 },
        { title: '接诊评估', name: 'accepts_assessment', value: 0, is_show: 1 },
        { title: '透前评估', name: 'assessment_before', value: 0, is_show: 1 },
        { title: '临时医嘱', name: 'stat_order', value: 0, is_show: 0},

        { title: '双人核对', name: 'double_check', value: 0, is_show: 2 },
        { title: '透析上机', name: 'dialysis_computer', value: 0, is_show: 2},
        { title: '透析监测', name: 'dialysis_monitoring', value: 0, is_show: 2 },
        { title: '透析下机', name: 'dialysis_off', value: 0, is_show: 2},
        { title: '透后评估', name: 'assessment_after', value: 0, is_show: 1},
        { title: '治疗小结', name: 'treatment_of', value: 0, is_show: 1},
        { title: '耗材出库', name: 'dialysis_consumables', value: 0, is_show: 0},


      ]
      if (!isNaN(this.prescribeOne.id) && this.prescribeOne.id > 0 && this.prescribeOne.creater > 0) {
        steps[1].value = 1
      }

      if (
        !isNaN(this.receiver_treatment_access.id) &&
        this.receiver_treatment_access.id > 0
      ) {
        steps[2].value = 1
      }
      var datenow = this.$route.query.date

      if (typeof this.predialysis_evaluation.id !== 'undefined' && !isNaN(this.predialysis_evaluation.id) && this.predialysis_evaluation.id > 0 && this.predialysis_evaluation.assessment_date >= datenow) {
        steps[3].value = 1
      }

      if (this.doctor_advices.length > 0) {
        steps[4].value = 1
      }

      if (!isNaN(this.dialysis_order.id) && this.dialysis_order.id > 0) {
        steps[6].value = 1
        if (this.dialysis_order.stage == 2) {
          steps[8].value = 1
        }
      }
      if (
        !isNaN(this.double_check.id) &&
        this.double_check.creater > 0 && this.double_check.modifier > 0
      ) {
        steps[5].value = 1
      }
      if (this.monitor_records.length > 0) {
        steps[7].value = 1
      }
      if (!isNaN(this.assessment_after_dislysis.id) && this.assessment_after_dislysis.id > 0) {
        steps[9].value = 1
      }
      if (!isNaN(this.treatment_summary.id) && this.treatment_summary.id > 0) {
        steps[10].value = 1
      }
      if (this.good_user.length > 0) {
        steps[11].value = 1
      }

      return steps
    },
    dialysis_mode: function () {
      var mode = this.getValueStr('mode_id', 'mode_id')
      if (mode.length == 0) {
        return ''
      }
      if (this.$store.getters.treatment_mode[mode] != undefined) {
        return this.$store.getters.treatment_mode[mode].name
      }
      return ''
    },

  },
  created () {
    if (this.$store.getters.user.user.user_type == 3) {
      this.barActive = 0
    } else {
      this.barActive = 1
    }
    var patient_id = this.$route.query.patient_id
    var date = this.$route.query.date
    this.patient_id = patient_id
    this.date = date
    var patient_name = this.$route.query.patient_name
    this.patient_name = patient_name
    this.contagionList = this.$store.getters.contagions

    this.todayDate = moment(new Date(this.$route.query.date * 1000)).format('YYYY-MM-DD')

    var start = moment(new Date()).format('YYYY-MM-DD')
    var today = this.getTimestamp(start) - 28800
    this.todayTime = today
    this.requestDialysisRecord()
    this.requestLongAdvice()
    this.goTop()
    this.getPatientId(patient_id)

    this.getDialysisGoods()

    var user_type =  this.$store.getters.user.user.user_type
    this.user_type = user_type
    if(user_type == 3){
       var admin_user_id =  this.$store.getters.user.admin.id

      //获取未执行的医嘱
     this.getAdviceListNoExecution(admin_user_id)
    }
  },

  mounted () {
    this.moveBtn2 = this.$refs.moveBtn2
    if (sessionStorage.getItem('checkBtnTop2')) {
      this.moveBtn2.style.top = sessionStorage.getItem('checkBtnTop2')
      this.moveBtn2.style.bottom = 'initial'
    }
    if (sessionStorage.getItem('checkBtnLeft2')) {
      this.moveBtn2.style.left = sessionStorage.getItem('checkBtnLeft2')
    }

    this.moveBtn = this.$refs.moveBtn
    if (sessionStorage.getItem('checkBtnTop')) {
      this.moveBtn.style.top = sessionStorage.getItem('checkBtnTop')
      this.moveBtn.style.bottom = 'initial'
    }
    if (sessionStorage.getItem('checkBtnLeft')) {
      this.moveBtn.style.left = sessionStorage.getItem('checkBtnLeft')
    }
    this.moveBtns =this.$refs.moveBtns
    if (sessionStorage.getItem('checkBtnsTop')) {
      this.moveBtns.style.top = sessionStorage.getItem('checkBtnTop')
      this.moveBtns.style.bottom = 'initial'
    }
    if (sessionStorage.getItem('checkBtnsLeft')) {
      this.moveBtns.style.left = sessionStorage.getItem('checkBtnLeft')
    }
    window.addEventListener('scroll', this.handleScroll)
    this.appSource()
    const originHeight = document.documentElement.clientHeight || document.body.clientHeight
    window.addEventListener('resize', () => {
      const resizeHeight = document.documentElement.clientHeight || document.body.clientHeight
      if (resizeHeight < originHeight) {
        this.keyBoardShow = false
      } else {
        this.keyBoardShow = true
      }
    }, false)
    this.setTabList()
    var user_type =  this.$store.getters.user.user.user_type
    var admin_user_id = 0
    if(user_type == 3){
      admin_user_id =  this.$store.getters.user.admin.id
     //获取未执行的医嘱
     this.getAdviceListNoExecution(admin_user_id)
    }
    this.timerDia = window.setInterval(() => {
      setTimeout(this.getAdviceListNoExecution(admin_user_id), 0)
    }, 1000*300)

  },

  watch: {
    // doctor_advices: function () {
    //   this.$refs.stat_order.setAdvices(this.doctor_advices)
    // },
    monitor_records: function () {
      this.$refs.monitoring.setRecords(this.monitor_records)
    },
    '$route': function (to, from) {
      if (to.query.active1 == '2' && to.active2 == undefined) {
        this.date = this.$route.query.date
        this.requestLongAdvice()
        this.requestDialysisRecord()
      }
      if (to.query.patient_id != from.query.patient_id) {
        var patient_id = this.$route.query.patient_id
        var date = this.$route.query.date
        this.patient_id = patient_id
        this.date = date
        this.requestDialysisRecord()
        this.getPatientId(patient_id)
      }
    }

    // $route: 'requestDialysisRecord'
  },
  methods: {
    tiaozhuan(){
      this.index = 1
      this.tableIndex = 4
      this.$emit('tiaozhuan',this.index)
      this.$emit('history',this.tableIndex)
      console.log('this.index',this.index);
    },
    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.dx = this.moveBtn.offsetLeft
      this.dy = this.moveBtn.offsetTop
      console.log('this.moveBtn.offsetLeft',this.moveBtn.offsetLeft);

    },
    move (event) {
      if (this.flags) {
        var touch
        if (event.touches) {
          touch = event.touches[0]
        } else {
          touch = event
        }
        this.nx = touch.clientX - this.position.x
        this.ny = touch.clientY - this.position.y
        this.xPum = this.dx + this.nx
        this.yPum = this.dy + this.ny
        var clientWidth = document.documentElement.clientWidth
        var clientHeight = document.documentElement.clientHeight
        if (
          this.xPum > 0 &&
          this.xPum < clientWidth - this.moveBtn.offsetWidth
        ) {
          this.moveBtn.style.left = this.xPum + 'px'
        }
        if (
          this.yPum > 0 &&
          this.yPum < clientHeight - this.moveBtn.offsetHeight
        ) {
          this.moveBtn.style.top = this.yPum + 'px'
        }

        // 阻止页面的滑动默认事件
        document.addEventListener('touchmove', this.handler, {
          passive: false
        })
      }
    },
    // 鼠标释放时候的函数
    end () {
      this.flags = false
      sessionStorage.setItem('checkBtnTop', this.moveBtn.style.top)
      sessionStorage.setItem('checkBtnLeft', this.moveBtn.style.left)
      document.addEventListener('touchmove', this.handler, {
        passive: false
      })
    },

    downs (event) {
      this.flags = true
      var touch
      if (event.touches) {
        touch = event.touches[0]
      } else {
        touch = event
      }
      this.positions.x = touch.clientX
      this.positions.y = touch.clientY
      this.dsx = this.moveBtns.offsetLeft
      this.dsy = this.moveBtns.offsetTop
    },
    moves (event) {
      if (this.flags) {
        var touch
        if (event.touches) {
          touch = event.touches[0]
        } else {
          touch = event
        }
        this.nsx = touch.clientX - this.positions.x
        this.nsy = touch.clientY - this.positions.y
        this.xsPum = this.dsx + this.nsx
        this.ysPum = this.dsy + this.nsy
        var clientWidth = document.documentElement.clientWidth
        var clientHeight = document.documentElement.clientHeight
        if (
          this.xsPum > 0 &&
          this.xsPum < clientWidth - this.moveBtns.offsetWidth
        ) {
          this.moveBtns.style.left = this.xsPum + 'px'
        }
        if (
          this.ysPum > 0 &&
          this.ysPum < clientHeight - this.moveBtns.offsetHeight
        ) {
          this.moveBtns.style.top = this.ysPum + 'px'
        }

        // 阻止页面的滑动默认事件
        document.addEventListener('touchmove', this.handler, {
          passive: false
        })
      }
    },
    // 鼠标释放时候的函数
    ends () {
      this.flags = false
      sessionStorage.setItem('checkBtnTop', this.moveBtns.style.top)
      sessionStorage.setItem('checkBtnLeft', this.moveBtns.style.left)
      document.addEventListener('touchmove', this.handler, {
        passive: false
      })
    },

    // 长期医嘱
    down2 (event) {
      console.log('this.moveBtn2',this.moveBtn2);
      this.flags = true
      var touch
      if (event.touches) {
        touch = event.touches[0]
      } else {
        touch = event
      }
      this.position2.x = touch.clientX
      this.position2.y = touch.clientY
      this.dx2 = this.moveBtn2.offsetLeft
      this.dy2 = this.moveBtn2.offsetTop
    },
    move2 (event) {
      if (this.flags) {
        var touch
        if (event.touches) {
          touch = event.touches[0]
        } else {
          touch = event
        }
        this.nx2 = touch.clientX - this.position2.x
        this.ny2 = touch.clientY - this.position2.y
        this.xPum2 = this.dx2 + this.nx2
        this.yPum2 = this.dy2 + this.ny2
        var clientWidth = document.documentElement.clientWidth
        var clientHeight = document.documentElement.clientHeight
        if (
          this.xPum2 > 0 &&
          this.xPum2 < clientWidth - this.moveBtn2.offsetWidth
        ) {
          this.moveBtn2.style.left = this.xPum2 + 'px'
        }
        if (
          this.yPum2 > 0 &&
          this.yPum2 < clientHeight - this.moveBtn2.offsetHeight
        ) {
          this.moveBtn2.style.top = this.yPum2 + 'px'
        }

        // 阻止页面的滑动默认事件
        document.addEventListener('touchmove', this.handler, {
          passive: false
        })
      }
    },
    // 鼠标释放时候的函数
    end2 () {
      this.flags = false
      sessionStorage.setItem('checkBtnTop2', this.moveBtn2.style.top)
      sessionStorage.setItem('checkBtnLeft2', this.moveBtn2.style.left)
      document.addEventListener('touchmove', this.handler, {
        passive: false
      })
    },

    handler () {
      if (this.flags) {
        event.preventDefault()
      } else {
        return true
      }
    },
    // handleScroll: function() {
    //   var scrollTop =
    //     window.pageYOffset ||
    //     document.documentElement.scrollTop ||
    //     document.body.scrollTop;
    //   this.show_fixed_nav = scrollTop > 160;
    // },
    setTabList () {
      this.$nextTick(() => {
        if (this.stepData.length > 0) {
          // this.setLine()
          this.scrollIntodiv()
        }
      })
    },
    scroll () {
      this.scrollLeft = this.$refs.tabContentScroll.scrollLeft
    },
    getElementData (el, callback) {
      const domArr = this.$refs.tab_item
      const arr = []
      domArr.forEach(e => {
        arr.push({ id: 'tab_item', left: e.offsetLeft, width: e.offsetWidth })
      })
      callback(arr)
    },
    scrollIntodiv () {
      this.getElementData('#tab_list', data => {
        // const list = data[0]
        this.getElementData('#tab_item', data => {
          const item = data[this.barActive]
          // 滚动父级元素宽度
          // const tabContentWidth = this.$refs.tabContentScroll.scrollWidth
          // 父级元素可视区域宽度
          const screenWdith = this.$refs.tabContentScroll.offsetWidth
          // item的宽度
          const itemWidth = item.width
          // item距离最左侧的距离
          const itemOffsetLeft = item.left
          // item中间值 = (父级可视区域宽度 - item的宽度) / 2
          const itemCenter = (screenWdith - itemWidth) / 2
          // item目标值 = 当前item左移值 - 中间值
          const itemTarget = itemOffsetLeft - itemCenter
          // 屏幕宽度
          const winWidth = window.innerWidth

          // 目标值小于0时，滚动值设置为0
          if (itemTarget < 0) {
            this.$refs.tabContentScroll.scrollLeft = 0
            return
          }
          // 目标值小于屏幕宽减去父级可是区域宽时，滚动值设置为 父级可是区域宽-屏幕宽+元素宽
          if (itemTarget < winWidth - screenWdith) {
            this.$refs.tabContentScroll.scrollLeft = screenWdith - winWidth + itemWidth
            return
          }
          this.$refs.tabContentScroll.scrollLeft = itemTarget
        })
      })
    },
    appSource () {
      const u = navigator.userAgent
      const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
      if (isiOS) {
        this.appSourceState = 'ios'
      } else {
        this.appSourceState = 'andriod'
      }
    },
    menuMsgTip: function () {
      this.msgtip_visibility = false
    },
    getPatientId (id) {
      getPatientId(id).then(response => {
        if (response.data.state == 1) {
          var patient = response.data.data.patient

          this.patientid = patient.id
          this.patientInfo = patient
          let infectioulist = response.data.data.infectioulist

          let arr = []
          infectioulist.map(item => {
            arr.push(item.disease_id)
          })
          let contagion = []
          this.contagionList.map(it => {
            if (arr.indexOf(it.id) > -1) {
              contagion.push(it.name)
            }
          })
          this.contagion = contagion.join(',')
        }
      })
    },
    goCheck () {
      this.$router.push(
        {path:'/patientdetail?' +
          'patientid=' +
          this.patientid +
          '&active=' +
          4 +
          '&restatus=' +
          1,query:{id:this.patient_id,date:this.date,name:this.patient_name,patientid:this.patientid}}
      )
    },

    didAddMonitor (monitor) {
      this.monitor_records.push(monitor)
      this.monitor_records.sort((a, b) => b.operate_time - a.operate_time)
      this.monitor_records.reverse()
      // this.$refs.monit_dialog.setRecords(this.monitor_records)
      this.last_monitor_record = monitor
    },

    didEditMonitor (monitor) {
      var mrl = this.monitor_records.length
      var monitor_index = -1
      for (let index = 0; index < mrl; index++) {
        if (this.monitor_records[index].id == monitor.id) {
          monitor_index = index
          break
        }
      }

      this.monitor_records[monitor_index].arterial_pressure = monitor.arterial_pressure
      this.monitor_records[monitor_index].arterial_pressure_type = monitor.arterial_pressure_type
      this.monitor_records[monitor_index].blood_flow_volume = monitor.blood_flow_volume
      this.monitor_records[monitor_index].breathing_rate = monitor.breathing_rate
      this.monitor_records[monitor_index].dialysate_temperature = monitor.dialysate_temperature
      this.monitor_records[monitor_index].temperature = monitor.temperature
      this.monitor_records[monitor_index].diastolic_bp = monitor.diastolic_bp
      this.monitor_records[monitor_index].displacement_quantity = monitor.displacement_quantity
      this.monitor_records[monitor_index].dispose = monitor.dispose
      this.monitor_records[monitor_index].ktv = monitor.ktv
      this.monitor_records[monitor_index].monitor_date = monitor.monitor_date
      this.monitor_records[monitor_index].monitoring_nurse = monitor.monitoring_nurse
      this.monitor_records[monitor_index].operate_time = monitor.operate_time
      this.monitor_records[monitor_index].pulse_frequency = monitor.pulse_frequency
      this.monitor_records[monitor_index].replacement_rate = monitor.replacement_rate
      this.monitor_records[monitor_index].result = monitor.result
      this.monitor_records[monitor_index].sodium_concentration = monitor.sodium_concentration
      this.monitor_records[monitor_index].symptom = monitor.symptom
      this.monitor_records[monitor_index].systolic_bp = monitor.systolic_bp
      this.monitor_records[monitor_index].transmembrane_pressure = monitor.transmembrane_pressure
      this.monitor_records[monitor_index].transmembrane_pressure_type = monitor.transmembrane_pressure_type
      this.monitor_records[monitor_index].ultrafiltration_rate = monitor.ultrafiltration_rate
      this.monitor_records[monitor_index].ultrafiltration_volume = monitor.ultrafiltration_volume
      this.monitor_records[monitor_index].venous_pressure = monitor.venous_pressure
      this.monitor_records[monitor_index].venous_pressure_type = monitor.venous_pressure_type
      this.monitor_records[monitor_index].diastolic_blood_pressure = monitor.diastolic_blood_pressure
      this.monitor_records[monitor_index].systolic_blood_pressure = monitor.systolic_blood_pressure
      this.monitor_records[monitor_index].conductivity = monitor.conductivity
      this.monitor_records[monitor_index].displacement_flow_quantity = monitor.displacement_flow_quantity
      this.monitor_records[monitor_index].heparin = monitor.heparin
      this.monitor_records[monitor_index].dialysate_flow = monitor.dialysate_flow
      this.monitor_records[monitor_index].filter_pressure = monitor.filter_pressure

      this.monitor_records[monitor_index].monitor_anticoagulant_value = monitor.monitor_anticoagulant_value
      this.monitor_records[monitor_index].monitor_anticoagulant = monitor.monitor_anticoagulant
      this.monitor_records[monitor_index].blood_pressure_monitoring_site = monitor.blood_pressure_monitoring_site
      this.monitor_records[monitor_index].complication = monitor.complication
      this.monitor_records[monitor_index].accumulated_blood_volume = monitor.accumulated_blood_volume
      this.monitor_records[monitor_index].blood_temperature = monitor.blood_temperature
      this.monitor_records[monitor_index].urea_monitoring = monitor.urea_monitoring
      this.monitor_records[monitor_index].blood_thickness = monitor.blood_thickness
      this.monitor_records[monitor_index].blood_monitor = monitor.blood_monitor
      this.monitor_records[monitor_index].blood_oxygen_saturation = monitor.blood_oxygen_saturation
      this.monitor_records[monitor_index].dehydration = monitor.dehydration
      this.monitor_records[monitor_index].heparin_amount = monitor.heparin_amount
      this.monitor_records[monitor_index].replacement_speed = monitor.replacement_speed
      this.monitor_records[monitor_index].dicarbonate= monitor.dicarbonate
      this.monitor_records[monitor_index].is_pressure = monitor.is_pressure
      this.monitor_records[monitor_index].ultrafiltration_rate_one = monitor.ultrafiltration_rate_one
      this.monitor_records[monitor_index].heparin_one = monitor.heparin_one

      this.monitor_records[monitor_index].monitor_systolic_blood_pressure_one =monitor.monitor_systolic_blood_pressure_one
      this.monitor_records[monitor_index].monitor_diastolic_blood_pressure_one =monitor.monitor_diastolic_blood_pressure_one
      this.monitor_records[monitor_index].monitor_pulse_frequency_one = monitor.monitor_pulse_frequency_one
      this.monitor_records[monitor_index].blood_flow_volume_one =  monitor.blood_flow_volume_one
      this.monitor_records[monitor_index].venous_pressure_one = monitor.venous_pressure_one
      this.monitor_records[monitor_index].arterial_pressure_one = monitor.arterial_pressure_one
      this.monitor_records[monitor_index].transmembrane_pressure_one = monitor.transmembrane_pressure_one
      this.monitor_records[monitor_index].ultrafiltration_volume_one = monitor.ultrafiltration_volume_one
      this.monitor_records[monitor_index].sodium_concentration_one = monitor.sodium_concentration_one
      this.monitor_records[monitor_index].dialysate_temperature_one = monitor.dialysate_temperature_one
      this.monitor_records[monitor_index].replacement_rate_one = monitor.replacement_rate_one
      this.monitor_records[monitor_index].displacement_quantity_one = monitor.displacement_quantity_one
      this.monitor_records[monitor_index].ktv_one = monitor.ktv_one
      this.monitor_records[monitor_index].urr_one = monitor.urr_one
      this.monitor_records[monitor_index].conductivity_one = monitor.conductivity_one
      this.monitor_records[monitor_index].displacement_flow_quantity_one = monitor.displacement_flow_quantity_one
      this.monitor_records[monitor_index].blood_oxygen_saturation_one = monitor.blood_oxygen_saturation_one
      this.monitor_records[monitor_index].dialysate_flow_one = monitor.dialysate_flow_one
      this.monitor_records[monitor_index].blood_sugar_one = monitor.blood_sugar_one
      this.monitor_records[monitor_index].monitor_temperature_one = monitor.monitor_temperature_one
      this.monitor_records[monitor_index].pulse_frequency_one= monitor.pulse_frequency_one
      this.monitor_records[monitor_index].blood_temperature_one = monitor.blood_temperature_one
      this.monitor_records[monitor_index].urea_monitoring_one =monitor.urea_monitoring_one
      this.monitor_records[monitor_index].blood_thickness_one = monitor.blood_thickness_one
      this.monitor_records[monitor_index].blood_monitor_one = monitor.blood_monitor_one
      this.monitor_records[monitor_index].replacement_speed_one = monitor.replacement_speed_one
      this.monitor_records[monitor_index].dicarbonate_one = monitor.dicarbonate_one
      this.monitor_records[monitor_index].accumulated_blood_volume_one = monitor.accumulated_blood_volume_one


      this.monitor_records.sort((a, b) => a.operate_time - b.operate_time)

    },
    didDelMonitor (record_id) {
      var mrl = this.monitor_records.length
      for (let index = 0; index < mrl; index++) {
        if (this.monitor_records[index].id == record_id) {
          this.monitor_records.splice(index, 1)
          break
        }
      }
    },
    didDelMoreMonitor (str) {
      let arr = str.split(',')
      for (let index = 0; index < this.monitor_records.length; index++) {
        arr.map(it => {
          if (this.monitor_records[index].id == it) {
            this.monitor_records.splice(index, 1)
          }
        })
      }
    },

    menuClick: function (popupIndex) {
      this.index = popupIndex
      if (popupIndex >= 0) {
        if (popupIndex == 4) {
          if (this.his_is_open == 1) {
            if(this.$store.getters.user.template_info.org_id!=10721){
              if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
              this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
              } else {
                this.menuList[popupIndex].showPopup = true
              }
            }else {
              this.menuList[popupIndex].showPopup = true
            }
           
          } else {
            this.menuList[popupIndex].showPopup = true
          }
        } else {
          this.menuList[popupIndex].showPopup = true
        }
      }
      if (
        popupIndex == 1 &&
        typeof this.$refs.prescription_dialog !== 'undefined'
      ) {
        this.$refs.prescription_dialog.open(this.prescription, this.last_prescription)
      } else if (
        popupIndex == 3 &&
        typeof this.$refs.assessment_dialog !== 'undefined'
      ) {
        this.$refs.assessment_dialog.open()
      } else if (
        popupIndex == 4 &&
        typeof this.$refs.orders_dialog !== 'undefined'
      ) {
        // this.$refs.orders_dialog.open();
      } else if (
        popupIndex == 0 &&
        typeof this.$refs.computer_dialog !== 'undefined'
      ) {
        this.$refs.computer_dialog.open()
      } else if (
        popupIndex == 6 &&
        typeof this.$refs.monit_dialog !== 'undefined'
      ) {
        this.$refs.monit_dialog.open()
      } else if (
        popupIndex == 7 &&
        typeof this.$refs.plane_dialog !== 'undefined'
      ) {
        this.$refs.plane_dialog.open()
      } else if (
        popupIndex == 8 &&
        typeof this.$refs.thoroug_dialog !== 'undefined'
      ) {
        this.$refs.thoroug_dialog.open()
      } else if (
        popupIndex == 9 &&
        typeof this.$refs.treatment_dialog !== 'undefined'
      ) {
        this.$refs.treatment_dialog.open()
      }
    },
    popupDidHide: function (popupIndex) {
      this.index = -1
    },
    closeDialog (index) {
      this.index = -1
      this.menuList[index].showPopup = false
    },
    weightFunc (val) {
      this.dryWeight = val
    },

    // 接口开始的时间
    requestDialysisRecord () {
      console.log("金hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")
      if (this.$route.query.showView == true) {
        return
      }
      var dateStr = parseTime(this.date, '{y}-{m}-{d}')
      var params = {
        patient_id: this.patient_id,
        date: dateStr
      }
      this.advice_groups = []
      this.doctor_advices = []
      this.loading = true
      getDialysisRecord(params).then(rs => {
        var resp = rs.data

        if (resp.state == 1) {
          this.stockType = resp.data.stockType
          var lastOrder = resp.data.lastOrder
          this.lastOrder = lastOrder
          var prepare = resp.data.prepare
          if (prepare != null) {
            this.preparestock = prepare
          } else {
            this.preparestock = []
          }
          var waitstoredata = this.$store.getters.waitscheduals
          var waitscheduals = waitstoredata.waitscheduals
          var storedata = this.$store.getters.scheduals
          var scheduals = storedata.scheduals

          var patient = resp.data.patient // 患者信息
          var schedual = resp.data.schedual // 患者排班信息
          var prescription = resp.data.prescription // 透析处方

          this.patientInfo.name = patient.name

          var solution = resp.data.solution // 透析方案
          if (solution && solution.target_ultrafiltration > 0) {
            solution.target_ultrafiltration = 0
          }
          var receiver_treatment_access = resp.data.receiver_treatment_access // 接诊评估
          var predialysis_evaluation = resp.data.predialysis_evaluation // 透前评估
          console.log("哈得很发哈好地方",predialysis_evaluation)
          this.predialysis_evaluation_obj = predialysis_evaluation
          var doctor_advices = resp.data.doctor_advices // 临时医嘱

          var all_projcet = []



          if (this.$store.getters.user.template_info.org_id == 10318) {
            var project = resp.data.project // 项目
            if(project!=null && project.length > 0){
              for (let i = 0; i < project.length; i++) {
                if (project[i].type == 2) {
                  all_projcet.push(project[i])
                }
              }
              this.project = all_projcet
            }

          }

          if (this.$store.getters.user.template_info.org_id == 10635) {
            var project = resp.data.project // 项目
            // console.log("project=----------------",project)
            if(project!=null && project.length > 0){
              for (let i = 0; i < project.length; i++) {
                if (project[i].project_id == 14186 || project[i].project_id == 13292 || project[i].project_id == 13289) {
                    all_projcet.push(project[i])
                }
              }
              this.project = all_projcet
            }

          }
          var new_all_project = []

          var new_all_group = []

          var good_list_group = []

          //针对 10726 江西乐安祥康血液透析中心
          if(this.$store.getters.user.template_info.org_id == 10726 || this.$store.getters.user.template_info.org_id == 10164){
            var project = resp.data.project // 项目
            if(project!=null && project.length > 0){
              for (let i = 0; i < project.length; i++) {

                if(project[i].type == 3){
                  good_list_group.push(project[i])
                }

                if (project[i].type == 2 && project[i].team_id ==0) {
                     new_all_project.push(project[i])
                }

                if (project[i].type == 2 && project[i].team_id > 0) {
                     new_all_group.push(project[i])
                }

              }
              if(good_list_group!=null && good_list_group.length>0){
                this.project.push(...good_list_group)
              }
              if(new_all_project!=null && new_all_project.length>0){
                this.project.push(...new_all_project)
              }
              console.log("项目组套名称----------------",new_all_group)
              if(new_all_group!=null && new_all_group.length>0){
                  let dataInfo = {}
                  new_all_group.forEach((item, index) => {
                  let { team_id } = item
                  if (!dataInfo[team_id]) {
                    dataInfo[team_id] = {
                      team_id:item.team_id,
                      id:item.team_id,
                      advice_name:item.team.project_team,
                      project_team:item.team.project_team,
                      doctor:item.doctor,
                      start_time:item.start_time,
                      execution_time:item.execution_time,
                      execution_state:item.execution_state,
                      execution_staff:item.execution_staff,
                      check_time:item.check_time,
                      check_state:item.check_state,
                      checker:item.checker,
                      remark:'',
                      parent_id:0,
                      is_check_team:1,
                      team:item.team,
                      project:item.project,
                      good_info:item.good_info,
                      type:item.type,
                      count:item.count,
                      remark:item.remark,

                    }
                  }
                })
                let arr = Object.values(dataInfo)
                if(arr!=null && arr.length>0){
                  console.log("arr----------------",arr)
                  this.project.push(...arr)
                }

              }

            }

          }

          if (this.$store.getters.user.template_info.org_id != 10318 && this.$store.getters.user.template_info.org_id != 10635 && this.$store.getters.user.template_info.org_id != 10726) {
            var project = resp.data.project

            if(project!=null && project.length>0){
              this.project = project
              let tempProject = resp.data.team_projects
              // console.log("项目嘱托=====================",tempProject)
              // 加个新字段用来区分是否为检验费组套, is_check_team: 1是 2不是
              if (project != null) {
                for (let i = 0; i < project.length; i++) {
                  project[i]['is_check_team'] = 2
                }
              }
              if (tempProject != undefined) {
                for (let i = 0; i < tempProject.length; i++) {
                  tempProject[i]['is_check_team'] = 1
                }
                project = project.concat(tempProject)
              }
              this.project = project
            }

          }

          var his_doctor_advices = resp.data.his_advices

          this.his_is_open = resp.data.is_open_config.is_open

          this.his_project_is_open = resp.data.is_project_open_config.is_open

          var is_advice_open = resp.data.is_advice_open.is_advice_open

          this.is_advice_open = is_advice_open
          if (is_advice_open != 1) {
            if (this.his_project_is_open != 1) {
              project = []
            }
            if (doctor_advices != null) {
              for (let i = 0; i < doctor_advices.length; i++) {
                doctor_advices[i]['origin'] = 1
              }
            }

            if (this.his_is_open == 1) {
              doctor_advices = []
            }
          }
           console.log("医嘱his_doctor_advices--------------",his_doctor_advices)
          if (his_doctor_advices != null) {
            for (let i = 0; i < his_doctor_advices.length; i++) {
              his_doctor_advices[i]['origin'] = 2
              his_doctor_advices[i]['way'] = 1
              if (doctor_advices != null) {

                //针对 濉溪杏康血液透析中心
                if(this.$store.getters.user.template_info.org_id == 10721){
                  if(his_doctor_advices[i].execution_frequency.indexOf("上机前") == -1 && his_doctor_advices[i].delivery_way.indexOf("口服")==-1 && his_doctor_advices[i].advice_name.indexOf("胰岛素")==-1){
                    doctor_advices.push(his_doctor_advices[i])
                  }
                }else{
                  doctor_advices.push(his_doctor_advices[i])
                }


              } else {
                  doctor_advices = []
                  //针对 濉溪杏康血液透析中心
                  if(this.$store.getters.user.template_info.org_id == 10721){
                    if(his_doctor_advices[i].execution_frequency.indexOf("上机前") == -1 && his_doctor_advices[i].delivery_way.indexOf("口服")==-1 && his_doctor_advices[i].advice_name.indexOf("胰岛素")==-1){
                      doctor_advices.push(his_doctor_advices[i])
                    }
                  }else{
                       doctor_advices.push(his_doctor_advices[i])
                  }
              }
            }
          }

          this.prescription_open = resp.data.prescription_open

          var last_prescription = resp.data.last_prescription
         //不按透析模式
         this.lastDialysisPrescription =  resp.data.lastDialysisPrescription
         console.log("不按透析模式wowowowo",this.lastDialysisPrescription)
          var system_prescription = resp.data.system_prescription

          this.dryWeight = resp.data.dry_weight

          if (prescription == null || prescription.creater == 0) {
            this.isPullData = 1
          } else {
            this.isPullData = 2
          }

          this.goodInfos = resp.data.goodInfos

          if (doctor_advices != null) {
            for (let i = 0; i < doctor_advices.length; i++) {
              doctor_advices[i]['is_selected'] = 0
            }
          }

          var double_check = resp.data.double_check // 双人核对
          var assessment_after_dislysis = resp.data.assessment_after_dislysis // 透后评估

          var treatment_summary = resp.data.treatment_summary // 治疗小结

          var monitor_records = resp.data.monitor_records // 透析监测
          var dialysis_order = resp.data.dialysis_order // 透析记录

          var operators = resp.data.operators // 操作人
          var config = resp.data.config // 库存自动扣减配置

          var types = resp.data.types // 所有系统库存商品类型
          var last_predialysis_evaluation = resp.data.last_predialysis_evaluation // 上一次透前评估

          if(this.$store.getters.user.template_info.org_id == 10340){

            if(last_predialysis_evaluation!=null){
              last_predialysis_evaluation.symptom_before_dialysis = ""
              last_predialysis_evaluation.weight_befor_remake = ""
            }

          }

          var last_assessment_after_dislysis = resp.data.last_assessment_after_dislysis // 上一次透前评估

          var last_monitor_record = resp.data.last_monitor_record
          // 最后一次血管通
          this.lastAssessment = resp.data.lastAssessment

          var prescribeOne = resp.data.prescribeOne

          this.prescribeOne = prescribeOne == null ? { id: '' } : prescribeOne
          if (Object.keys(waitstoredata).length > 0) {
            for (let index = 0; index < waitscheduals.length; index++) {
              if (waitscheduals[index].patient_id == patient.id) {
                waitscheduals[index].patient = patient
                waitscheduals[index].assessment_before_dislysis = predialysis_evaluation
                waitscheduals[index].prescription = prescription
                waitscheduals[index].doctor_advice = doctor_advices
                waitscheduals[index].dialysis_order = dialysis_order
                waitscheduals[index].project = project
              }
            }

            this.$store.dispatch('SetWaitScheduals', {
              waitscheduals: waitscheduals
            })
          }

          if (Object.keys(storedata).length > 0) {
            for (let index = 0; index < scheduals.length; index++) {
              if (scheduals[index].patient_id == patient.id) {
                scheduals[index].patient = patient
                scheduals[index].assessment_before_dislysis = predialysis_evaluation
                scheduals[index].prescription = prescription
                scheduals[index].doctor_advice = doctor_advices
                scheduals[index].project = project
                scheduals[index].dialysis_order = dialysis_order
              }
            }
            this.$store.dispatch('SetScheduals', { scheduals: scheduals })
          }
          this.system_prescription = system_prescription == null ? { id: '' } : system_prescription

          this.patient = patient
          this.schedual = schedual == null ? {} : schedual
          this.prescription = prescription == null ? { id: '' } : prescription
          this.find_prescription = prescription == null ? {id: ''} : prescription

          this.solution = solution == null ? { id: '' } : solution

          this.last_prescription = last_prescription == null ? { id: '' } : last_prescription
          this.receiver_treatment_access = receiver_treatment_access == null ? { id: '' } : receiver_treatment_access

          this.predialysis_evaluation = predialysis_evaluation == null ? {} : predialysis_evaluation

          this.last_predialysis_evaluation = last_predialysis_evaluation == null ? {} : last_predialysis_evaluation
          this.doctor_advices = doctor_advices == null ? [] : doctor_advices

          this.last_befor = resp.data.lastAssesmentBeforDialysis
          this.first_monitor = resp.data.firstMonitor
          this.last_monitor = resp.data.lastMonitor
          this.dryWeightList = resp.data.dryWeightList

          this.config = config
          this.goodTypes = types
          if(this.$store.getters.user.template_info.org_id !=10579){
            if (predialysis_evaluation != null) {
            this.blood_access_part_opera_name = this.getBloodAccessOpera(this.predialysis_evaluation.blood_access_part_opera_id)
          } else {
            this.blood_access_part_opera_name = this.getBloodAccessOpera(this.last_predialysis_evaluation.blood_access_part_opera_id)
          }
          }
          if(this.$store.getters.user.template_info.org_id ==10579){
            console.log("处方----------------",this.prescription)
            if (this.prescription != null) {
            this.blood_access_part_opera_name = this.getBloodAccessOpera(this.prescription.blood_access)
          } else {
            this.blood_access_part_opera_name = this.getBloodAccessOpera(this.prescription.blood_access)
          }
          }


          if (this.his_is_open != 1) {
            if (this.doctor_advices.length > 0) {
              var group = this.newAdviceGroupObject()
              var initGroupBlock = function (group, advice) {
                group.group_no = advice.groupno
                group.prescription_id = advice.prescription_id
                // group.start_time = advice.start_time
                // group.advice_doctor = advice.advice_doctor
                // group.exec_staff = advice.execution_staff
                // group.exec_time = advice.execution_time
                // group.checker = advice.checker
              }
              for (let index = 0; index < this.doctor_advices.length; index++) {
                const advice = this.doctor_advices[index]
                if (advice.groupno == 0) {
                  // 老版本的医嘱没有分组的概念，所以这一个 if 是解决这个问题的，将每个无分组的医嘱各自归为一组
                  if (advice.parent_id > 0) {
                    if (this.advice_groups.length > 0) {
                      var parent_group = this.advice_groups[
                        this.advice_groups.length - 1
                      ]
                      if (parent_group.advices.length > 0) {
                        if (parent_group.advices[0].id == advice.parent_id) {
                          parent_group.advices.push(advice)
                        }
                      }
                    }
                    continue
                  } else {
                    if (group.group_no > 0) {
                      this.advice_groups.push(group)
                      group = this.newAdviceGroupObject()
                    }

                    initGroupBlock(group, advice)
                    group.advices.push(advice)
                    this.advice_groups.push(group)
                    group = this.newAdviceGroupObject()
                    continue
                  }
                }

                if (group.group_no > 0 && group.group_no != advice.groupno) {
                  this.advice_groups.push(group)
                  group = this.newAdviceGroupObject()
                }
                if (group.group_no == 0) {
                  initGroupBlock(group, advice)
                }
                if (group.group_no == advice.groupno) {
                  group.advices.push(advice)
                }
              }

              if (group.group_no > 0) {
                // 上述的算法会导致最后一组没有加到advice_groups，这里要手动加上
                this.advice_groups.push(group)
              }
            }
          } else {
            let new_doctor_advice = this.doctor_advices
            let arr = this.newUnique(new_doctor_advice, 'prescription_id')
            let lastData = []
            let newArr = []
            arr.map(item => {
              if (item.advices.length > 0) {
                item.advices.map(it => {
                  let status = lastData.some(group_no => (group_no['group_no'] == it['groupno'] && group_no['prescription_id'] == it['prescription_id']))
                  if (!status) {
                    let obj = {
                      group_no: '',
                      prescription_id: '',
                      advices: []
                    }
                    obj.group_no = it.groupno
                    obj.prescription_id = it.prescription_id
                    obj.advices.push(it)
                    lastData.push(obj)
                  } else {
                    lastData.forEach((project_name, index) => {
                      if (project_name['group_no'] === it['groupno']) {
                        if (project_name['prescription_id'] === it['prescription_id']) {
                          project_name.advices.push(it)
                        }
                      }
                    })
                  }
                })
              }
            })
            lastData.push(...newArr)
            this.advice_groups = lastData
          }

          this.is_project_open = resp.data.is_project_open_config.is_open

          console.log("项目姐夫------------------------",this.project)

          console.log("项目开关-----------------",this.is_project_open)

          //针对濉溪杏康
          if(this.$store.getters.user.template_info.org_id == 10721){
            this.is_project_open = 2
          }
             
          if (this.project != null && this.is_project_open == 1) {
            this.project.map(item => {
              let obj = {
                advice_doctor: item.doctor,
                start_time: item.start_time,
                advice_name: item.team_id > 0 && item.is_check_team == 1 ? item.team.project_team : item.type == 2 ? item.project.project_name + ' ' + item.count + item.project.unit : item.good_info.good_name + ' ' + item.good_info.specification_name + ' ' + item.count + item.good_info.packing_unit,
                execution_time: item.execution_time,
                execution_state: item.execution_state,
                execution_staff: item.execution_staff,
                check_time: item.check_time,
                check_state: item.check_state,
                checker: item.checker,
                remark: '',
                id: item.id,
                parent_id: 0,
                projectType: 2,
                team_id: item.team_id,
                is_check_team: item.is_check_team,
                remark:item.remark,
              }
              let advice = []
              advice.push(obj)
              console.log("avice==================================",advice)
              let advices = {
                advices: advice,
                group_no: 0
              }
              this.advice_groups.push(advices)
            })
          }
          // new doctor
          let doctorAdviceArr = []
          this.doctor_advices.map(item => {
            item.children = []
            this.doctor_advices.map(it => {
              if (item.id == it.parent_id) {
                item.children.push(it)
              }
            })
            if (item.parent_id == 0) {
              doctorAdviceArr.push(item)
            }
          })
          this.doctor_advices = doctorAdviceArr

          this.double_check = double_check == null ? { id: '' } : double_check
          this.assessment_after_dislysis =
            assessment_after_dislysis == null
              ? { id: '' }
              : assessment_after_dislysis
          this.last_assessment_after_dislysis =
            last_assessment_after_dislysis == null
              ? { id: '' }
              : last_assessment_after_dislysis
          this.treatment_summary =
            treatment_summary == null ? { id: '' } : treatment_summary
          this.monitor_records = monitor_records == null ? [] : monitor_records
          this.last_monitor_record =
            last_monitor_record == null
              ? this.last_monitor_record
              : last_monitor_record
          this.dialysis_order =
            dialysis_order == null ? { id: '' } : dialysis_order
          this.operators = operators
          // this.$refs.stat_order.setAdvices(this.doctor_advices)
          this.$refs.monitoring.setRecords(this.monitor_records)

          // 强制刷新子组件
          this.thoroug_dialog_reset = false
          this.$nextTick(() => {
            this.thoroug_dialog_reset = true
          })

          this.prescription_dialog_reset = false

          this.$nextTick(() => {
            this.prescription_dialog_reset = true
          })
          this.monit_dialog_reset = false
          this.$nextTick(() => {
            this.monit_dialog_reset = true
          })

          this.$nextTick(() => {
            setTimeout(() => {
              if (sessionStorage.getItem('newBarIndex') != null) {
                this.barActive = parseInt(sessionStorage.getItem('newBarIndex'))
              }
            }, 300)
          })

          this.title = patient.name

          if (this.$store.getters.globalConfig && Object.keys(this.$store.getters.globalConfig).length > 0) {
            this.admin_users = JSON.parse(JSON.stringify(this.$store.getters.globalConfig.globalConfig.admin_users))

            var roles = JSON.parse(JSON.stringify(this.$store.getters.globalConfig.globalConfig.admin_users))

            if (roles.length > 0) {
              for (let i = 0; i < roles.length; i++) {
                this.admin_roles.push(roles[i])
              }
            }

            this.devices = JSON.parse(JSON.stringify(this.$store.getters.globalConfig.globalConfig.devices))
            this.device_numbers = JSON.parse(JSON.stringify(this.$store.getters.globalConfig.globalConfig.device_numbers))

            var device_map = {}
            for (let index = 0; index < this.devices.length; index++) {
              const device = this.devices[index]
              device_map[device.id] = device
            }
            this.device_map = device_map

            var admin_map = {}
            for (let index = 0; index < this.admin_users.length; index++) {
              const admin = this.admin_users[index]
              admin_map[admin.id] = admin
            }
            this.admin_user_map = admin_map

            var start_map = {}
            this.startArr = []
            for (let i = 0; i < this.admin_users.length; i++) {
              if (this.admin_users[i].user_type == 3) {
                this.startArr.push(this.admin_users[i])
              }
            }
            for (let index = 0; index < this.startArr.length; index++) {
              const admin = this.startArr[index]
              start_map[admin.id] = admin
            }

            this.start_user_map = start_map

            var admin_staff = {}
            for (let index = 0; index < this.admin_roles.length; index++) {
              const admin = this.admin_roles[index]
              admin_staff[admin.id] = admin
            }

            this.admin_staff_map = admin_staff

            var device_number_map = {}
            for (let index = 0; index < this.device_numbers.length; index++) {
              const device_number = this.device_numbers[index]

              device_number_map[device_number.id] = device_number
            }
            this.device_number_map = device_number_map
            this.loading = false
          } else {
            dialysisGlobalConfig().then(rs => {
              var res = rs.data
              if (res.state == 1) {
                this.$store.dispatch('SetGlobalConfig', { globalConfig: JSON.parse(JSON.stringify(res.data)) })
                // sessionStorage.setItem("admin_users", [JSON.stringify(res.data.admin_users)]);
                // sessionStorage.setItem("devices", [JSON.stringify(res.data.devices)]);
                // sessionStorage.setItem("device_numbers", [JSON.stringify(res.data.device_numbers)]);
                this.admin_users = res.data.admin_users
                this.devices = res.data.devices
                this.device_numbers = res.data.device_numbers

                if (
                  this.dialysis_order.id &&
                  this.dialysis_order.DeviceNumber &&
                  this.dialysis_order.DeviceNumber.number.length > 0
                ) {
                  let str = ''
                  this.device_numbers.map(item => {
                    if (item.zone_id == this.dialysis_order.DeviceNumber.zone_id && item.id == this.dialysis_order.DeviceNumber.id) {
                      str = item.zone_name + '-' + this.dialysis_order.DeviceNumber.number
                      this.bedNumber = str
                    }
                  })
                } else {
                  let str = ''
                  if (this.schedual.device_number == null) {
                    return ''
                  } else {
                    this.device_numbers.map(item => {
                      if (item.zone_id == this.schedual.device_number.zone_id && item.id == this.schedual.device_number.id) {
                        str = item.zone_name + '-' + this.schedual.device_number.number
                        this.bedNumber = str
                      }
                    })
                  }
                }

                var device_map = {}
                for (let index = 0; index < this.devices.length; index++) {
                  const device = this.devices[index]
                  device_map[device.id] = device
                }
                this.device_map = device_map

                var admin_map = {}
                for (let index = 0; index < this.admin_users.length; index++) {
                  const admin = this.admin_users[index]
                  admin_map[admin.id] = admin
                }
                this.admin_user_map = admin_map

                var start_map = {}
                for (let i = 0; i < this.admin_users.length; i++) {
                  if (this.admin_users[i].user_type == 3) {
                    this.startArr.push(this.admin_users[i])
                  }
                }
                for (let index = 0; index < this.startArr.length; index++) {
                  const admin = this.startArr[index]
                  start_map[admin.id] = admin
                }

                this.start_user_map = start_map

                var device_number_map = {}
                for (let index = 0; index < this.device_numbers.length; index++) {
                  const device_number = this.device_numbers[index]
                  device_number_map[device_number.id] = device_number
                }
                this.device_number_map = device_number_map
              }

              this.requestLongAdvice()

              this.loading = false
            })
          }

          if (
            this.dialysis_order.id &&
            this.dialysis_order.DeviceNumber &&
            this.dialysis_order.DeviceNumber.number.length > 0
          ) {
            let str = ''
            this.device_numbers.map(item => {
              if (item.zone_id == this.dialysis_order.DeviceNumber.zone_id && item.id == this.dialysis_order.DeviceNumber.id) {
                str = item.zone_name + '-' + this.dialysis_order.DeviceNumber.number
                this.bedNumber = str
              }
            })
          } else {
            let str = ''
            if (this.schedual.device_number == null) {
              return ''
            } else {
              this.device_numbers.map(item => {
                if (item.zone_id == this.schedual.device_number.zone_id && item.id == this.schedual.device_number.id) {
                  str = item.zone_name + '-' + this.schedual.device_number.number
                  this.bedNumber = str
                }
              })
            }
          }
          if (this.barActive == 1) {
            this.$refs.prescription_dialog.getPermission()
          }

          if(resp.data.remind_lists!=null&&resp.data.remind_lists.length > 0){
              this.dry_visibility = true
            this.remind_lists = resp.data.remind_lists
          }



        } else {
          this.$toast({
            message: resp.msg
          })
          this.loading = false
        }
      })
    },
    requestLongAdvice () {
      var dateStr = parseTime(this.date, '{y}-{m}-{d}')

      var params = {
        id: this.patient_id,
        schedule_date: dateStr
      }
      GetRemindLongAdviceOne(params).then(rs => {
        var resp = rs.data
        if (resp.state == 1) {
          var status = parseInt(resp.data.status)
          this.status = status

          switch (status) {
            case 2:
              var totalAdvice = resp.data.advices
              console.log("totalAdvice-------------------",totalAdvice)
              var longAdvicesTwo = resp.data.advices_two
              console.log("longAdvicesTwo=-=-----------------------",longAdvicesTwo)
              var waitUploadAdvices = []
              if (totalAdvice != null && totalAdvice.length != 0) {
                for (let i = 0; i < totalAdvice.length; i++) {
                  totalAdvice[i]['isCheck'] = 1
                }

                for (let i = 0; i < totalAdvice.length; i++) {
                  for (let a = 0; a < longAdvicesTwo.length; a++) {
                    if (totalAdvice[i].template_id ==longAdvicesTwo[a].template_id && totalAdvice[i].week_day ==longAdvicesTwo[a].week_day && totalAdvice[i].frequency_type ==longAdvicesTwo[a].frequency_type) {
                      totalAdvice[i]['isCheck'] = 0
                    }
                  }
                }

                for (let i = 0; i < totalAdvice.length; i++) {
                  if (totalAdvice[i].isCheck == 1) {
                    waitUploadAdvices.push(totalAdvice[i])
                  }
                }

                console.log("waitUploadAdvices------------------",waitUploadAdvices)
              }

              this.is_open = resp.data.is_open_remind

              if (this.his_is_open == 1) {
                this.is_open = 0
              }
              this.longAdvices = totalAdvice
              this.waitUploadAdvices = waitUploadAdvices
              // eslint-disable-next-line camelcase
              var prescription_open = resp.data.prescription_open

              this.prescription_open = prescription_open
              break
          }
        } else {
        }
      })
    },
    getNowFormatDate () {
      var date = new Date()
      var seperator1 = '-'
      var year = date.getFullYear()
      var month = date.getMonth() + 1
      var strDate = date.getDate()
      if (month >= 1 && month <= 9) {
        month = '0' + month
      }
      if (strDate >= 0 && strDate <= 9) {
        strDate = '0' + strDate
      }
      var currentdate = year + seperator1 + month + seperator1 + strDate
      return currentdate
    },
    newAdviceGroupObject: function () {
      return Object.assign(
        {},
        {
          prescription_id: 0,
          group_no: 0,
          // advice_doctor: 0,
          // start_time: 0,
          advices: []
          // exec_staff: 0,
          // exec_time: 0,
          // checker: 0,
        }
      )
    },
    adviceFunc: function () {},
    prescriptionFunc: function (val, advices) {
      this.prescription = val
      this.prescribeOne = val
      this.newRequestDialysisRecord()
    },

    longSolutionFunc: function (val) {
      this.solution = val
    },

    closePrescriptionDialog: function () {
      this.closeDialog(1)
      // this.scrollToView('prescription')
    },

    closeAcceptsAssessment: function () {
      this.closeDialog(2)
      // this.scrollToView('accepts_assessment')
    },

    closeAssessmentBefore: function () {
      this.closeDialog(3)
      // this.scrollToView('assessment_before')
    },

    update_evaluation: function (evaluation) {
      this.predialysis_evaluation = evaluation
      this.closeAssessmentBefore()
      this.newRequestDialysisRecord()
    },

    closeStatOrder: function () {
      this.closeDialog(4)
      // this.scrollToView('stat_order')
    },

    closeDialysisComputer: function (dialysis_order) {
      this.closeDialog(0)
      this.dialysis_order = dialysis_order
      this.newRequestDialysisRecord()
    },
    closeDialysisComputerclose: function (dialysis_order) {
      this.closeDialog(0)
    },

    closeDoubleCheck: function (val) {
      this.double_check = Object.assign({}, val)
      this.closeDialog(5)
    },

    closeMonitoring: function () {
      this.closeDialog(6)
      // this.scrollToView('monitoring')
    },

    closeDialysisOff: function (assessment_after_dislysis) {
      this.closeDialog(7)
      if (assessment_after_dislysis != undefined) {
        this.assessment_after_dislysis = assessment_after_dislysis
      }
      this.requestDialysisRecord()
    },
    closeDialysisOffclose: function () {
      this.closeDialog(7)
      // this.scrollToView('dialysis_off')
    },

    closeAssessmentAfter: function (assessment_after_dislysis) {
      this.closeDialog(8)
      // this.scrollToView('assessment_after')
      if (assessment_after_dislysis != undefined) {
        this.assessment_after_dislysis = assessment_after_dislysis
      }
      this.requestDialysisRecord()
    },
    updateTreatmentOf: function (val) {
      this.closeDialog(9)
      this.treatment_summary = val
    },

    closeTreatmentOf: function () {
      this.closeDialog(9)
      // this.scrollToView('treatment_of')
    },

    scrollToView: function (id) {
      document.body.scrollTop =
        document.querySelector('#' + id).offsetTop - 100
      document.documentElement.scrollTop =
        document.querySelector('#' + id).offsetTop - 100
    },

    handleScroll () {
      this.scrollTop =
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop
      if (this.scrollTop > 50) {
        this.goTopShow = true
      } else {
        this.goTopShow = false
      }
    },

    goTop () {
      let timer = null,
        _that = this
      cancelAnimationFrame(timer)
      timer = requestAnimationFrame(function fn () {
        if (_that.scrollTop > 0) {
          _that.scrollTop -= 50
          document.body.scrollTop = document.documentElement.scrollTop =
            _that.scrollTop
          timer = requestAnimationFrame(fn)
        } else {
          cancelAnimationFrame(timer)
          _that.goTopShow = false
        }
      })
    },

    destroyed () {
      window.removeEventListener('scroll', this.handleScroll)
    },

    getUnReadNum () {
      if (this.his_is_open == 1) {
        let doctorAdvice = []
        for (let y = 0; y < this.doctor_advices.length; y++) {
          if (this.doctor_advices[y].execution_state != 1) {
            doctorAdvice.push(this.doctor_advices[y])
          }
        }
        return doctorAdvice.length
      } else {
        let doctorAdvice = []
        for (let y = 0; y < this.doctor_advices.length; y++) {
          if (this.doctor_advices[y].execution_state != 1) {
            doctorAdvice.push(this.doctor_advices[y])
          }
        }
        return doctorAdvice.length
      }
    },

    groupBy (array, f) {
      const groups = {}
      array.forEach(function (o) {
        const group = JSON.stringify(f(o))
        groups[group] = groups[group] || []
        groups[group].push(o)
      })
      return Object.keys(groups).map(function (group) {
        return groups[group]
      })
    },

    getDeviceNumber () {
      if (
        this.dialysis_order.id &&
        this.dialysis_order.DeviceNumber &&
        this.dialysis_order.DeviceNumber.number.length > 0
      ) {
        let str = ''
        this.device_numbers.map(item => {
          if (item.zone_id == this.dialysis_order.DeviceNumber.zone_id && item.id == this.dialysis_order.DeviceNumber.id) {
            str = item.zone_name + '-' + this.dialysis_order.DeviceNumber.number
          }
        })
        return str
        // return this.dialysis_order.DeviceNumber.number
      } else {
        if (this.schedual.device_number == null) {
          return ''
        } else {
          let str = ''
          this.device_numbers.map(item => {
            if (item.zone_id == this.schedual.device_number.zone_id && item.id == this.schedual.device_number.id) {
              str = item.zone_name + '-' + this.schedual.device_number.number
            }
          })
          return str
        }
      }
    },

    dateDiff (firstDate, secondDate) {
      var firstDate = new Date(firstDate)
      var secondDate = new Date(secondDate)
      var diff = Math.abs(firstDate.getTime() - secondDate.getTime())
      var result = parseInt(diff / (1000 * 60 * 60 * 24))
      return result
    },
    newRequestDialysisRecord () {
      if (this.$route.query.showView == true) {
        return
      }
      var dateStr = parseTime(this.date, '{y}-{m}-{d}')
      var params = {
        patient_id: this.patient_id,
        date: dateStr
      }

      this.advice_groups = []
      this.doctor_advices = []

      getDialysisRecord(params)
        .then(rs => {
          var resp = rs.data
          if (resp.state == 1) {
            var waitstoredata = this.$store.getters.waitscheduals

            var waitscheduals = waitstoredata.waitscheduals
            var storedata = this.$store.getters.scheduals
            var scheduals = storedata.scheduals

            var patient = resp.data.patient // 患者信息
            var schedual = resp.data.schedual // 患者排班信息
            var prescription = resp.data.prescription // 透析处方

            var solution = resp.data.solution // 透析方案
            var receiver_treatment_access = resp.data.receiver_treatment_access // 接诊评估
            var predialysis_evaluation = resp.data.predialysis_evaluation // 透前评估
            console.log("透前评估我哦我我",predialysis_evaluation)
            var doctor_advices = resp.data.doctor_advices // 临时医嘱
            var last_prescription = resp.data.last_prescription

            var system_prescription = resp.data.system_prescription

            this.dryWeight = resp.data.dry_weight

            var lastOrder = resp.data.lastOrder
            this.lastOrder = lastOrder
            if (prescription == null || prescription.creater == 0) {
              this.isPullData = 1
            } else {
              this.isPullData = 2
            }

            // this.goodInfos = resp.data.goodInfos

            if (doctor_advices != null) {
              for (let i = 0; i < doctor_advices.length; i++) {
                doctor_advices[i]['is_selected'] = 0
              }
            }

            var double_check = resp.data.double_check // 双人核对
            var assessment_after_dislysis = resp.data.assessment_after_dislysis // 透后评估
            var treatment_summary = resp.data.treatment_summary // 治疗小结
            var monitor_records = resp.data.monitor_records // 透析监测
            var dialysis_order = resp.data.dialysis_order // 透析记录
            var operators = resp.data.operators // 操作人

            var config = resp.data.config // 库存自动扣减配置

            var types = resp.data.types // 所有系统库存商品类型

            var project = resp.data.project // 项目

            var all_projcet = []

            if (this.$store.getters.user.template_info.org_id == 10318) {

              var project = resp.data.project // 项目
              if(project!=null && project.length>0){
                for (let i = 0; i < project.length; i++) {
                if (project[i].type == 2) {
                  all_projcet.push(project[i])
                }
               }
               this.project = all_projcet
              }

            }

            if (this.$store.getters.user.template_info.org_id != 10318) {
              var project = resp.data.project
              if(project!=null && project.length>0){
                this.project = project
              }

            }
            var his_doctor_advices = resp.data.his_advices



            this.his_is_open = resp.data.is_open_config.is_open

            var is_advice_open = resp.data.is_advice_open.is_advice_open

            if (is_advice_open == 1) {
              this.is_open = 1
            }
            if (is_advice_open != 1) {
              if (this.his_is_open == 1) {
                doctor_advices = []
              }
              this.his_project_is_open = resp.data.is_project_open_config.is_open
              if (this.his_project_is_open != 1) {
                project = []
              }
              if (this.his_is_open == 1) {
                doctor_advices = []
                this.is_open = 0
              }
            }

            if (doctor_advices != null) {
              for (let i = 0; i < doctor_advices.length; i++) {
                doctor_advices[i]['origin'] = 1
              }
            }
            // if (his_doctor_advices != null) {
            //   for (let i = 0; i < his_doctor_advices.length; i++) {
            //     his_doctor_advices[i]['origin'] = 2
            //     his_doctor_advices[i]['way'] = 1
            //     if (doctor_advices != null) {
            //       doctor_advices.push(his_doctor_advices[i])
            //     }
            //     if (doctor_advices == null) {
            //       doctor_advices = []
            //       doctor_advices.push(his_doctor_advices[i])
            //     }
            //   }
            // }
            if (his_doctor_advices != null) {
            for (let i = 0; i < his_doctor_advices.length; i++) {
              his_doctor_advices[i]['origin'] = 2
              his_doctor_advices[i]['way'] = 1
              if (doctor_advices != null) {

                //针对 濉溪杏康血液透析中心
                if(this.$store.getters.user.template_info.org_id == 10721){
                  if(his_doctor_advices[i].execution_frequency.indexOf("上机前") == -1 && his_doctor_advices[i].delivery_way.indexOf("口服")==-1 && his_doctor_advices[i].advice_name.indexOf("胰岛素")==-1){
                    doctor_advices.push(his_doctor_advices[i])
                  }
                }else{
                  doctor_advices.push(his_doctor_advices[i])
                }


              } else {
                  doctor_advices = []
                  //针对 濉溪杏康血液透析中心
                  if(this.$store.getters.user.template_info.org_id == 10721){
                    if(his_doctor_advices[i].execution_frequency.indexOf("上机前") == -1 && his_doctor_advices[i].delivery_way.indexOf("口服")==-1 && his_doctor_advices[i].advice_name.indexOf("胰岛素")==-1){
                      doctor_advices.push(his_doctor_advices[i])
                    }
                  }else{
                       doctor_advices.push(his_doctor_advices[i])
                  }
              }
            }
          }
            var last_predialysis_evaluation = resp.data.last_predialysis_evaluation // 上一次透前评估
            var last_assessment_after_dislysis = resp.data.last_assessment_after_dislysis // 上一次透前评估
            var last_monitor_record = resp.data.last_monitor_record
            if (Object.keys(waitstoredata).length > 0) {
              for (let index = 0; index < waitscheduals.length; index++) {
                if (waitscheduals[index].patient_id == patient.id) {
                  waitscheduals[index].patient = patient
                  waitscheduals[
                    index
                  ].assessment_before_dislysis = predialysis_evaluation
                  waitscheduals[index].prescription = prescription
                  waitscheduals[index].doctor_advice = doctor_advices
                  waitscheduals[index].dialysis_order = dialysis_order
                  waitscheduals[index].project = project
                }
              }

              this.$store.dispatch('SetWaitScheduals', {
                waitscheduals: waitscheduals
              })
            }

            if (Object.keys(storedata).length > 0) {
              for (let index = 0; index < scheduals.length; index++) {
                if (scheduals[index].patient_id == patient.id) {
                  scheduals[index].patient = patient
                  scheduals[index].assessment_before_dislysis = predialysis_evaluation
                  scheduals[index].prescription = prescription
                  scheduals[index].doctor_advice = doctor_advices
                  scheduals[index].dialysis_order = dialysis_order
                  scheduals[index].project = project
                }
              }
              this.$store.dispatch('SetScheduals', { scheduals: scheduals })
            }

            this.patient = patient
            this.schedual = schedual == null ? {} : schedual
            this.prescription = prescription == null ? { id: '' } : prescription

            this.solution = solution == null ? { id: '' } : solution
            this.last_prescription = last_prescription == null ? { id: '' } : last_prescription

            this.system_prescription = system_prescription == null ? { id: '' } : system_prescription

            this.receiver_treatment_access = receiver_treatment_access == null ? { id: '' } : receiver_treatment_access
            this.predialysis_evaluation = predialysis_evaluation == null ? {} : predialysis_evaluation
            this.last_predialysis_evaluation = last_predialysis_evaluation == null ? {} : last_predialysis_evaluation
            this.doctor_advices = doctor_advices == null ? [] : doctor_advices
            this.config = config
            this.goodTypes = types

            if (predialysis_evaluation != null) {
              this.blood_access_part_opera_name = this.getBloodAccessOpera(this.predialysis_evaluation.blood_access_part_opera_id)
            } else {
              this.blood_access_part_opera_name = this.getBloodAccessOpera(this.last_predialysis_evaluation.blood_access_part_opera_id)
            }

            if (this.doctor_advices.length > 0) {
              var group = this.newAdviceGroupObject()
              var initGroupBlock = function (group, advice) {
                group.group_no = advice.groupno
              }
              for (let index = 0; index < this.doctor_advices.length; index++) {
                const advice = this.doctor_advices[index]
                if (advice.groupno == 0) {
                  // 老版本的医嘱没有分组的概念，所以这一个 if 是解决这个问题的，将每个无分组的医嘱各自归为一组
                  if (advice.parent_id > 0) {
                    if (this.advice_groups.length > 0) {
                      var parent_group = this.advice_groups[
                        this.advice_groups.length - 1
                      ]
                      if (parent_group.advices.length > 0) {
                        if (parent_group.advices[0].id == advice.parent_id) {
                          parent_group.advices.push(advice)
                        }
                      }
                    }
                    continue
                  } else {
                    if (group.group_no > 0) {
                      this.advice_groups.push(group)
                      group = this.newAdviceGroupObject()
                    }

                    initGroupBlock(group, advice)
                    group.advices.push(advice)
                    this.advice_groups.push(group)
                    group = this.newAdviceGroupObject()
                    continue
                  }
                }

                if (group.group_no > 0 && group.group_no != advice.groupno) {
                  this.advice_groups.push(group)
                  group = this.newAdviceGroupObject()
                }
                if (group.group_no == 0) {
                  initGroupBlock(group, advice)
                }
                if (group.group_no == advice.groupno) {
                  group.advices.push(advice)
                }
              }
              if (group.group_no > 0) {
                // 上述的算法会导致最后一组没有加到advice_groups，这里要手动加上
                this.advice_groups.push(group)
              }
            }


            this.is_project_open = resp.data.is_project_open_config.is_open

            // console.log("第二项目姐夫------------------------",this.project)

            // console.log("第二项目开关-----------------",this.is_project_open)

          //针对濉溪杏康
          if(this.$store.getters.user.template_info.org_id == 10721){
            this.is_project_open = 2
          }

          if (this.project != null && this.is_project_open == 1) {
            this.project.map(item => {
              let obj = {
                advice_doctor: item.doctor,
                start_time: item.start_time,
                advice_name: item.team_id > 0 && item.is_check_team == 1 ? item.team.project_team : item.type == 2 ? item.project.project_name + ' ' + item.count + item.project.unit : item.good_info.good_name + ' ' + item.good_info.specification_name + ' ' + item.count + item.good_info.packing_unit,
                execution_time: item.execution_time,
                execution_state: item.execution_state,
                execution_staff: item.execution_staff,
                check_time: item.check_time,
                check_state: item.check_state,
                checker: item.checker,
                remark: '',
                id: item.id,
                parent_id: 0,
                projectType: 2,
                team_id: item.team_id,
                is_check_team: item.is_check_team
              }
              let advice = []
              advice.push(obj)
              let advices = {
                advices: advice,
                group_no: 0
              }
              this.advice_groups.push(advices)
            })
          }

            // this.project.map(item => {
            //   let obj = {
            //     advice_doctor: item.doctor,
            //     start_time: item.start_time,
            //     advice_name: item.type == 2 ? item.project.project_name : item.good_info.good_name,
            //     execution_time: item.execution_time,
            //     execution_state: item.execution_state,
            //     execution_staff: item.execution_staff,
            //     check_time: item.check_time,
            //     check_state: item.check_state,
            //     checker: item.checker,
            //     remark: '',
            //     id: item.id,
            //     parent_id: 0,
            //     projectType: 2
            //   }
            //   let advice = []
            //   advice.push(obj)
            //   let advices = {
            //     advices: advice,
            //     group_no: 0
            //   }
            //   this.advice_groups.push(advices)
            // })

            let doctorAdviceArr = []
            this.doctor_advices.map(item => {
              item.children = []
              this.doctor_advices.map(it => {
                if (item.id == it.parent_id) {
                  item.children.push(it)
                }
              })
              if (item.parent_id == 0) {
                doctorAdviceArr.push(item)
              }
            })
            this.doctor_advices = doctorAdviceArr

            this.double_check = double_check == null ? { id: '' } : double_check
            this.assessment_after_dislysis =
            assessment_after_dislysis == null ? { id: '' } : assessment_after_dislysis
            this.last_assessment_after_dislysis =
            last_assessment_after_dislysis == null ? { id: '' } : last_assessment_after_dislysis
            this.treatment_summary = treatment_summary == null ? { id: '' } : treatment_summary
            this.monitor_records = monitor_records == null ? [] : monitor_records
            this.last_monitor_record = last_monitor_record == null ? this.last_monitor_record : last_monitor_record
            this.dialysis_order = dialysis_order == null ? { id: '' } : dialysis_order
            this.operators = operators

            this.$refs.monitoring.setRecords(this.monitor_records)

            this.title = patient.name
            // 强制刷新子组件

            this.thoroug_dialog_reset = false
            this.$nextTick(() => {
              this.thoroug_dialog_reset = true
            })
            this.prescription_dialog_reset = false
            this.$nextTick(() => {
              this.prescription_dialog_reset = true
            })
            this.monit_dialog_reset = false
            this.$nextTick(() => {
              this.monit_dialog_reset = true
            })

            this.$nextTick(() => {
              if (sessionStorage.getItem('newBarIndex') != null) {
                this.barActive = parseInt(sessionStorage.getItem('newBarIndex'))
              }
            })
          } else {
            this.$toast({
              message: resp.msg
            })
            this.loading = false
          }
        }).catch(error => {
          this.loading = false
          this.$toast({
            message: '请求超时'
          })
        })
    },
    getPermission (url, num) {
      request.get('/m/api/permission/get', {
        params: {
          create_url: url,
          module: num
        }
      })
        .then(res => {
          if (res.data.state == 0) {
            this.$toast({
              message: '您没有权限查看'
            })
          } else if (res.data.state == 1) {
            if (res.data.data.is_has_create == true) {
              this.menuList[num].showPopup = true
            } else {
              this.$toast({
                message: '您没有权限查看'
              })
            }
          }
        })
    },
    newMenuClick () {
      var stage = 0
      if (this.dialysis_order && this.dialysis_order.id > 0) {
        stage = this.dialysis_order.stage
      }
      this.$router.push('/dialysisConsumables?patient_id=' + this.patient.id + '&schedule_date=' + this.schedual.schedule_date + '&name=' + this.patient.name + '&is_open=' + this.config.is_open + '&is_computer=' + stage)
    },
    getTimestamp (time) { // 把时间日期转成时间戳
      return (new Date(time)).getTime() / 1000
    },
    goBack () {
      var start = moment(new Date()).format('YYYY-MM-DD')
      var today = this.getTimestamp(start) - 28800
      this.reload()
      this.$router.replace('/details?patient_id=' + this.patient_id + '&date=' + today + '&patient_name=' + this.patient_name)
      this.date = today
      this.requestDialysisRecord()
    },

    // new
    getValueStr (pkey, skey) {
      if (
        (this.prescription == null || this.prescription.id == '') &&
        (this.solution == null || this.solution.id == '')
      ) {
        return ''
      } else if (this.prescription != null && this.prescription.id != '') {
        if (
          this.prescription[pkey] == null ||
          this.prescription[pkey] == undefined
        ) {
          return ''
        }
        return this.prescription[pkey] + ''
      } else {
        if (this.solution[skey] == null || this.solution[skey] == undefined) {
          return ''
        }
        return this.solution[skey] + ''
      }
    },
    getBloodAccessOpera: function (id) {
      var BloodAccessOpera = getDataConfig(
        'hemodialysis',
        'vascular_access_desc'
      )
      var BloodAccessOperaName = ''
      for (let i = 0; i < BloodAccessOpera.length; i++) {
        if (BloodAccessOpera[i].id == id) {
          BloodAccessOperaName = BloodAccessOpera[i].name
        }
      }
      return BloodAccessOperaName
    },
    clickAction (index) {
      if (this.barActive == 1) {
        if (this.$refs.prescription_dialog.changePrescription > 3) {
          Dialog.confirm({
            title: '处方数据尚未保存,是否要保存'
          }).then(() => {
            this.$nextTick(() => {
              this.$refs.prescription_dialog.commitInfo()
              setTimeout(() => {
                if (index == 4) {
                  if (this.his_is_open == 1) {
                    if(this.$store.getters.user.template_info.org_id!=10721){
                      if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                      this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                    } else {
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                    }else{
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                  
                  } else {
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
              }, 500)
            })
          }).catch(() => {
            this.requestDialysisRecord()
            if (index == 4) {
              if (this.his_is_open == 1) {
                if(this.$store.getters.user.template_info.org_id!=10721){
                  if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                  this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
                }else{
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
               
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
            } else {
              this.$nextTick(() => {
                this.barActive = index
              })
            }
          })
        } else {
          if (index == 4) {
            if (this.his_is_open == 1) {
              if(this.$store.getters.user.template_info.org_id!=10721){
                if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
              }else{
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
             
            } else {
              this.$nextTick(() => {
                this.barActive = index
              })
            }
          } else {
            this.$nextTick(() => {
              this.barActive = index
            })
          }
        }
      } else if (this.barActive == 2) {
        if (this.$refs.accepts.changeReceiveTreatmentAsses > 1) {
          Dialog.confirm({
            title: '接诊评估数据尚未保存,是否要保存'
          }).then(() => {
            this.$nextTick(() => {
              this.$refs.accepts.commitInfo()
              setTimeout(() => {
                // this.requestDialysisRecord()
                if (index == 4) {
                  if (this.his_is_open == 1) {
                    if(this.$store.getters.user.template_info.org_id!=10721){
                      if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                      this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                    } else {
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                    }else{
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                   
                  } else {
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
              }, 500)
            })
          })
            .catch(() => {
              this.requestDialysisRecord()
              if (index == 4) {
                if (this.his_is_open == 1) {
                  if(this.$store.getters.user.template_info.org_id!=10721){
                    if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                    this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                  } else {
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                  }else{
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
            })
        } else {
          if (index == 4) {
            if (this.his_is_open == 1) {
              if(this.$store.getters.user.template_info.org_id!=10721){
                if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
              }else{
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
           
            } else {
              this.$nextTick(() => {
                this.barActive = index
              })
            }
          } else {
            this.$nextTick(() => {
              this.barActive = index
            })
          }
        }
      } else if (this.barActive == 3) {
        if (this.$refs.assessment_dialog.changeAssessmentBefore > 1) {
          Dialog.confirm({
            title: '透前评估数据尚未保存,是否要保存'
          }).then(() => {
            this.$nextTick(() => {
              this.$refs.assessment_dialog.commitInfo()
              setTimeout(() => {
              // this.requestDialysisRecord()
                if (index == 4) {
                  if (this.his_is_open == 1) {
                    if(this.$store.getters.user.template_info.org_id!=10721){
                      if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                      this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                    } else {
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                    }else{
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                   
                  } else {
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
              }, 500)
            })
          })
            .catch(() => {
              this.requestDialysisRecord()
              if (index == 4) {
                if (this.his_is_open == 1) {
                  if(this.$store.getters.user.template_info.org_id!=10721){
                    if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                    this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                  } else {
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                  }else{
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                 
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
            })
        } else {
          if (index == 4) {
            if (this.his_is_open == 1) {
              if(this.$store.getters.user.template_info.org_id!=10721){
                if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
              }else{
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
            
            } else {
              this.$nextTick(() => {
                this.barActive = index
              })
            }
          } else {
            this.$nextTick(() => {
              this.barActive = index
            })
          }
        }
      } else if (this.barActive == 5) {
        if (this.$refs.doubleCheck.changeDoubleReview > 1) {
          Dialog.confirm({
            title: '双人核对数据尚未保存,是否要保存'
          }).then(() => {
            this.$nextTick(() => {
              this.$refs.doubleCheck.commitInfo()
              setTimeout(() => {
                // this.requestDialysisRecord()
                if (index == 4) {
                  if (this.his_is_open == 1) {
                    if(this.$store.getters.user.template_info.org_id!=10721){
                      if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                      this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                    } else {
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                    }else{
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                   
                  } else {
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
              }, 500)
            })
          })
            .catch(() => {
              this.requestDialysisRecord()
              if (index == 4) {
                if (this.his_is_open == 1) {
                  if(this.$store.getters.user.template_info.org_id!=10721){
                    if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                    this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                  } else {
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                  }else{
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                 
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
            })
        } else {
          if (index == 4) {
            if (this.his_is_open == 1) {
              if(this.$store.getters.user.template_info.org_id!=10721){
                if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
              }else{
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
            
            } else {
              this.$nextTick(() => {
                this.barActive = index
              })
            }
          } else {
            this.$nextTick(() => {
              this.barActive = index
            })
          }
        }
      } else if (this.barActive == 9) {
        if (this.$refs.thoroug_dialog.changeAssessmentAfter > 1) {
          Dialog.confirm({
            title: '透后评估数据尚未保存,是否要保存'
          }).then(() => {
            this.$nextTick(() => {
              this.$refs.thoroug_dialog.commitInfo()
              setTimeout(() => {
                // this.requestDialysisRecord()
                if (index == 4) {
                  if (this.his_is_open == 1) {
                    if(this.$store.getters.user.template_info.org_id!=10721){
                      if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                      this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                    } else {
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                    }else{
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                   
                  } else {
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
              }, 500)
            })
          })
            .catch(() => {
              this.requestDialysisRecord()
              if (index == 4) {
                if (this.his_is_open == 1) {
                  if(this.$store.getters.user.template_info.org_id!=10721){
                    if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                    this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                  } else {
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                  }else{
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                 
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
            })
        } else {
          if (index == 4) {
            if (this.his_is_open == 1) {
              if(this.$store.getters.user.template_info.org_id!=10721){
                if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
              }else{
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
             
            } else {
              this.$nextTick(() => {
                this.barActive = index
              })
            }
          } else {
            this.$nextTick(() => {
              this.barActive = index
            })
          }
        }
      } else if (this.barActive == 10) {
        if (this.$refs.treatment_dialog.changeDialysisSummary > 1) {
          Dialog.confirm({
            title: '透析小结数据尚未保存,是否要保存'
          }).then(() => {
            this.$nextTick(() => {
              this.$refs.treatment_dialog.commitInfo()
              setTimeout(() => {
                // this.requestDialysisRecord()
                if (index == 4) {
                  if (this.his_is_open == 1) {
                    if(this.$store.getters.user.template_info.org_id!=10721){
                      if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                      this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                    } else {
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                    }else{
                      this.$nextTick(() => {
                        this.barActive = index
                      })
                    }
                   
                  } else {
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
              }, 500)
            })
          })
            .catch(() => {
              this.requestDialysisRecord()
              if (index == 4) {
                if (this.his_is_open == 1) {
                  if(this.$store.getters.user.template_info.org_id!=10721){
                    if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                    this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
                  } else {
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                  }else{
                    this.$nextTick(() => {
                      this.barActive = index
                    })
                  }
                 
                } else {
                  this.$nextTick(() => {
                    this.barActive = index
                  })
                }
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
            })
        } else {
          if (index == 4) {
            if (this.his_is_open == 1) {
              if(this.$store.getters.user.template_info.org_id!=10721){
                if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
                this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
              } else {
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
              }else{
                this.$nextTick(() => {
                  this.barActive = index
                })
              }
             
            } else {
              this.$nextTick(() => {
                this.barActive = index
              })
            }
          } else {
            this.$nextTick(() => {
              this.barActive = index
            })
          }
        }
      } else {
        // this.requestDialysisRecord()
        if (index == 4) {
          if (this.his_is_open == 1) {
            if(this.$store.getters.user.template_info.org_id!=10721){
              if (this.$store.getters.user.user.user_type == 1 || this.$store.getters.user.user.user_type == 2) {
              this.$router.push('/dialysis/hisOrder?id=' + this.$route.query.patient_id + '&record_date=' + parseTime(this.$route.query.date, '{y}-{m}-{d}'))
            } else {
              this.$nextTick(() => {
                this.barActive = index
              })
            }
            }else{
              this.$nextTick(() => {
                this.barActive = index
              })
            }
          
          } else {
            this.$nextTick(() => {
              this.barActive = index
            })
          }
        } else {
          this.$nextTick(() => {
            this.barActive = index
          })
        }
      }

      sessionStorage.setItem('newBarIndex', index)
      var stage = 0
      if (this.dialysis_order && this.dialysis_order.id > 0) {
        stage = this.dialysis_order.stage
      }
      this.newStage = stage
      this.scroll()
      this.setTabList()
    },
    updateDoubleCheck: function (val) {
      this.double_check = Object.assign({}, val)
    },
    choosePatient () {
      this.$emit('show_patient_list')
    },
    getDialysisGoods () {
      let query = {
        schedule_date: parseTime(this.schedule_date ? this.schedule_date : this.$route.query.date, '{y}-{m}-{d}'),
        schedule_type: 0,
        partition_id: 0,
        page: 1,
        patient_id: this.patient_id ? this.patient_id : this.$route.query.patient_id
      }
      getDialysisGoods(query).then(rs => {
        var res = rs.data
        this.good_user = res.data.dialysis_goods[0].good_user

        // 后加的
        this.new_dialysis_goods = res.data.dialysis_goods

        this.warehouseOutList = res.data.warehouseOutList
        this.list = []

        this.his_config = res.data.config
        for (let i = 0; i < res.data.dialysis_goods.length; i++) {
          if (res.data.dialysis_goods[i].good_user.length > 0) {
            for (let b = 0; b < res.data.dialysis_goods[i].good_user.length; b++) {
              if (res.data.dialysis_goods[i].good_user[b].info.id > 0) {
                let obj = {
                  good_id: res.data.dialysis_goods[i].good_user[b].info.id,
                  type_name: res.data.dialysis_goods[i].good_user[b].type.type_name,
                  specification_name: res.data.dialysis_goods[i].good_user[b].info.specification_name,
                  count: res.data.dialysis_goods[i].good_user[b].count
                }
                this.list.push(obj)
              }
            }
          } else {

            if (res.data.dialysis_goods[i].good_user_detail.length > 0) {
              for (let b = 0; b < res.data.dialysis_goods[i].good_user_detail.length; b++) {
                if (res.data.dialysis_goods[i].good_user_detail[b].info.id > 0) {
                  let obj = {
                    good_id: res.data.dialysis_goods[i].good_user_detail[b].info.id,
                    type_name: res.data.dialysis_goods[i].good_user_detail[b].type.type_name,
                    specification_name: res.data.dialysis_goods[i].good_user_detail[b].info.specification_name,
                    count: res.data.dialysis_goods[i].good_user_detail[b].count
                  }
                  this.list.push(obj)
                }
              }
            } else {
              if (res.data.dialysis_goods[i].project.length > 0) {
                for (let b = 0; b < res.data.dialysis_goods[i].project.length; b++) {
                  if (res.data.dialysis_goods[i].project[b].good_info.type.out_stock == 1) {
                    if (res.data.dialysis_goods[i].project[b].good_info.id > 0) {
                      let obj = {
                        good_type_id: res.data.dialysis_goods[i].project[b].good_info.good_type_id,
                        good_id: res.data.dialysis_goods[i].project[b].good_info.id,
                        type_name: res.data.dialysis_goods[i].project[b].good_info.type.type_name,
                        specification_name: res.data.dialysis_goods[i].project[b].good_info.specification_name,
                        count: res.data.dialysis_goods[i].project[b].count.toString()
                      }
                      this.list.push(obj)
                    }
                  }
                }
              } else {
                if (res.data.dialysis_goods[i].last_good_user != null) {
                  for (let b = 0; b < res.data.dialysis_goods[i].last_good_user.length; b++) {
                    if (res.data.dialysis_goods[i].last_good_user[b].info.id > 0) {
                      let obj = {
                        good_type_id: res.data.dialysis_goods[i].last_good_user[b].type.id,
                        good_id: res.data.dialysis_goods[i].last_good_user[b].info.id,
                        type_name: res.data.dialysis_goods[i].last_good_user[b].type.type_name,
                        specification_name: res.data.dialysis_goods[i].last_good_user[b].info.specification_name,
                        count: res.data.dialysis_goods[i].last_good_user[b].count.toString()
                      }
                      this.list.push(obj)
                    }
                  }
                }
              }
            }
          }
        }

        var prescription = res.data.prescribe
        var goodInfo = res.data.good_info
        var dialyszerArr = []
        var irrigationArr = []
        if (prescription != null && res.data.dialysis_goods[0].good_user_detail.length == 0) {
          var dialysisDialyszers = prescription.dialysis_dialyszers
          var arr = dialysisDialyszers.split(',')
          var dialysisIrrigation = prescription.dialysis_irrigation
          var arrOne = dialysisIrrigation.split(',')
          for (let i = 0; i < goodInfo.length; i++) {
            for (let j = 0; j < arr.length; j++) {
              if (goodInfo[i].specification_name == arr[j]) {
                dialyszerArr.push(goodInfo[i])
              }
            }
          }
          for (let i = 0; i < goodInfo.length; i++) {
            for (let j = 0; j < arrOne.length; j++) {
              if (goodInfo[i].specification_name == arrOne[j]) {
                irrigationArr.push(goodInfo[i])
              }
            }
          }
          for (let i = 0; i < dialyszerArr.length; i++) {
            dialyszerArr[i].count = 1
            dialyszerArr[i].type_name = '透析器'
          }
          for (let j = 0; j < irrigationArr.length; j++) {
            irrigationArr[j].count = 1
            irrigationArr[j].type_name = '灌流器'
          }

          for (let i = 0; i < dialyszerArr.length; i++) {
            irrigationArr.push(dialyszerArr[i])
          }

          for (let j = 0; j < irrigationArr.length; j++) {
            irrigationArr[j].good_id = irrigationArr[j].id
          }

          let list = irrigationArr.reduce((pre, cur) => {
            let target = pre.find(ee => ee.good_id == cur.good_id)
            if (target) {
              Object.assign(target, cur)
            } else {
              pre.push(cur)
            }
            return pre
          }, this.list)

          for (let i = 0; i < this.list.length; i++) {
            this.list[i].count = this.list[i].count.toString()
          }
          this.list = list
          if (this.list.length > 0) {
            this.color = 1
            this.uploadMethod = 1
          } else {
            this.color = 0
          }
        }

        var newArr = this.newUnique(this.list)
        this.list = newArr
      })
    },
    newUniqueThree (arr) {
      const res = new Map()
      return arr.filter((arr) => !res.has(arr.good_id) && res.set(arr.good_id, 1))
    },
    getUnReadNumOne () {

      var num = 0
      var sum = 0
      var count = 0
      var sum_count = 0
      if (this.new_dialysis_goods != undefined && this.new_dialysis_goods.length > 0) {
        for (let i = 0; i < this.new_dialysis_goods.length; i++) {
          for (let j = 0; j < this.new_dialysis_goods[i].project.length; j++) {
            count += parseInt(this.new_dialysis_goods[i].project[j].count)
          }
          if (this.his_config != undefined && this.his_config.is_open != 1) {
            if (this.new_dialysis_goods[i].project.length == 0) {
              if (this.new_dialysis_goods[i].last_good_user_detail != null && this.new_dialysis_goods[i].last_good_user_detail.length > 0) {
                for (let z = 0; z < this.new_dialysis_goods[i].last_good_user_detail.length; z++) {
                  sum += parseInt(this.new_dialysis_goods[i].last_good_user_detail[z].count)
                }
              }
              if (this.new_dialysis_goods[i].good_user != null && this.new_dialysis_goods[i].good_user.length > 0) {
                sum_count = 1
              }
            }
          }
        }
      }
      if (this.warehouseOutList != undefined && this.warehouseOutList != null && this.warehouseOutList.length > 0) {
        for (let i = 0; i < this.warehouseOutList.length; i++) {
          num += this.warehouseOutList[i].count
        }
      }

      if (count > 0) {
        if ((count - num) > 0) {
          return count - num
        } else {
          return ''
        }
      }
      if (sum > 0) {
        // eslint-disable-next-line camelcase
        if (sum_count == 0) {
          if ((sum - num) > 0) {
            return sum - num
          } else {
            return ''
          }
        }
        // eslint-disable-next-line camelcase
        if (sum_count == 1) {
          return ''
        }
      }

      // }
    },
    unique (data, key) {
      let lastData = []
      data.forEach(item => {
        let status = lastData.some(group_no => group_no[key] == item[key])

        if (!status) {
          // item.value0 = item.value;
          let obj = {
            group_no: '',
            prescription_id: '',
            advices: []
          }
          obj.group_no = item.group_no
          obj.prescription_id = item.prescription_id
          obj.advices.push(...(item.advices))
          lastData.push(obj)
        } else {
          lastData.forEach((project_name, index) => {
            if (project_name[key] === item[key]) {
              project_name.advices.push(...(item.advices))
            }
          })
        }
      })
      return lastData
    },
    newUnique (data, key) {
      let lastData = []
      data.forEach(item => {
        let status = lastData.some(group_no => group_no[key] == item[key])

        if (!status) {
          // item.value0 = item.value;
          let obj = {
            prescription_id: '',
            advices: []
          }
          obj.prescription_id = item.prescription_id
          obj.advices.push(item)
          lastData.push(obj)
        } else {
          lastData.forEach((project_name, index) => {
            if (project_name[key] === item[key]) {
              project_name.advices.push(item)
            }
          })
        }
      })
      return lastData
    }, getTimeTwo (time) {
      return uParseTime(time, '{y}-{m}-{d}')
    },
    newUnique2 (data, key) {
      let lastData = []
      data.forEach(item => {
        let status = lastData.some(group_no => group_no[key] == item[key])

        if (!status) {
          // item.value0 = item.value;
          let obj = {
            group_no: '',
            prescription_id: '',
            advices: []
          }
          obj.group_no = item.groupno
          obj.prescription_id = item.prescription_id
          obj.advices.push(item)
          lastData.push(obj)

        } else {
          lastData.forEach((project_name, index) => {
            if (project_name[key] === item[key] && project_name[prescription_id] === item[prescription_id]) {
              project_name.advices.push(item)
            }
          })
        }
      })
      return lastData
    },
    getAdviceListNoExecution(admin_user_id){

     getAdviceListNoExecution(admin_user_id).then(response=>{
      if(response.data.state == 1){
        this.drugStockConfig = response.data.data.drugStockConfig

        // 血透客户
        if( this.drugStockConfig.is_open == 2 || this.drugStockConfig.is_open == 0){
          this.adviceList = response.data.data.adviceList

          this.total= 0
          if(this.adviceList!=null && this.adviceList.length>0){
            for(let i=0;i<this.adviceList.length;i++){
              this.total += this.adviceList[i].count
            }

          }
        }

        // his客户
        if(this.drugStockConfig.is_open == 1){
          this.hisAdviceList = response.data.data.hisAdviceList
          var total_one =0
          var total_two = 0
          if(this.hisAdviceList!=null && this.hisAdviceList.length>0){
            for(let i=0;i<this.hisAdviceList.length;i++){
              total_one += this.hisAdviceList[i].count
            }

          }
          if(response.data.data.projectConfig!=undefined && response.data.data.projectConfig.is_open == 1){
            this.projectList = response.data.data.projectList
          if(this.projectList!=null && this.projectList.length>0){
            for(let i=0;i<this.projectList.length;i++){
              total_two += this.projectList[i].count
            }

          }
          }

          this.total= 0
          this.total = total_one + total_two
        }

        this.patientList =  response.data.data.patientList

         this.tableData = []
        if(this.adviceList!=null && this.adviceList.length >0){
          for(let i=0;i<this.adviceList.length;i++){
              this.tableData.push(this.adviceList[i])
          }
        }
        if(this.hisAdviceList!=null && this.hisAdviceList.length>0){
          for(let i=0;i<this.hisAdviceList.length;i++){
              this.tableData.push(this.hisAdviceList[i])
          }
        }
        if(this.projectList!=null && this.projectList.length>0){
         if(response.data.data.projectConfig!=undefined && response.data.data.projectConfig.is_open == 1){
           for(let i=0;i<this.projectList.length;i++){
              this.tableData.push(this.projectList[i])
            }
          }

        }
        if(this.tableData!=null && this.tableData.length>0){
            let objinfo = {}
            this.tableData.forEach((item, index) => {
                let { patient_id } = item
                if (!objinfo[patient_id]) {
                  objinfo[patient_id] = {
                    patient_id:item.patient_id,
                    child: [],
                    total:0,
                    count: item.count,
                    advice_date:item.advice_date,
                  }
                }
              })
            let newlist = Object.values(objinfo)

            if(newlist!=null && newlist.length>0){
              for(let i=0;i<newlist.length;i++){
                for(let j=0;j<this.tableData.length;j++){
                  if(newlist[i].patient_id == this.tableData[j].patient_id){
                      newlist[i].child.push(this.tableData[j])
                  }
                }
              }
              for(let i=0;i<newlist.length;i++){
                for(let j=0;j<newlist[i].child.length;j++){
                    newlist[i].total += parseInt(newlist[i].child[j].count)
                }
              }
              this.tableData = []
              this.tableData = newlist
            }
        }
      }
    })
  },
    toExecution(){
      this.showRight = true
    },
    toExecutionPatent(row){

     var patient_name = ""
     patient_name = this.getPaitenName(row.patient_id)

     this.$router.push('/details?patient_id='+row.patient_id+"&date="+row.advice_date+"&patient_name="+patient_name)
     this.showRight =false
    },
    getPaitenName(patient_id){
      var name = ""
      for(let i=0;i<this.patientList.length;i++){
         if(patient_id == this.patientList[i].id){
            name = this.patientList[i].name
         }
      }
      return name
    }
  }
}
</script>

<style lang="scss" scoped>
.infoContent{
  padding: 0 .625rem;
  display: flex;
  color: #409eff;
  height:1.875rem;
  align-items:center;
  font-size: .75rem;
  .el-icon-s-unfold{
    font-size:1.25rem;
  }
}
.patientInfo{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
}
.patientInfoBox{
  display: flex;
  align-items: center;
  font-size: .75rem;
  color:#34495e;
  padding: .625rem 0;
  img{
    width: 2.5rem;
    height: 2.5rem;
    margin-right: .625rem;
  }
  .patientFontWeight{
    font-size: .875rem;
    font-weight: bold;
    color: #000;
  }
}
.changePatient{
  color:#409eff;
  font-size: .875rem;
  width: 4.375rem;
  text-align: right;
}
.scrollBar{
  width:100%;
  overflow-x:auto;
  display: flex;
  margin-bottom:10px;
  .actionOne{
    width: 3.125rem;
    padding:.3125rem;
    font-size: .875rem;
    text-align: center;
    position: relative;
    // font-weight: bold;
    border-radius: 4px;
    margin-left: .3125rem;
    background: #f8f8f8;
  }
  .hook{
    position: absolute;
    right: 0;
    top: 0;
    color:#409eff;
    font-size: .75rem;
  }
  .barActive{
    background: #409eff;
    color:#fff;
    .hook{
      color:#fff;
    }
  }
}
.actionBar{
  display: flex;
  flex-wrap: wrap;
  border-top:1px solid #e5e5e5;
  border-left:1px solid #e5e5e5;
  color: #323233;
  .actionOne{
    width: 25%;
    height: 2.25rem;
    line-height: 2.25rem;
    font-size: .875rem;
    text-align: center;
    border-right: 1px solid #e5e5e5;
    border-bottom: 1px solid #e5e5e5;
    position: relative;
    font-weight: bold;
  }
  .hook{
    position: absolute;
    right: .125rem;
    top: .625rem;
    color:#409eff;
    font-size: 1rem;
  }
  .barActive{
    background: #409eff;
    color:#fff;
    .hook{
      color:#fff;
    }
  }
}
.grayBorder{
  height: 5px;
  background: #f6f6f6;
  width: 100%;
}
.popup{
  .text{
    display: inline-block;
    width: 40%;
    height: 30px;
    font-size: 16px;
  }
  .mainBox .van-popup {
    top: 0%;
    right: -176px;
    -webkit-transform: translate3d(-50%, 0, 0);
    transform: translate3d(-50%, 0, 0);
    border-radius: 10px;
  }
}
</style>
<style style="stylesheet/scss" lang="scss" scoped>
#today_panel {
  overflow-x: hidden;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  .todayMain{
    flex: 1;
    overflow-y: auto;
  }
}
.today_panel {
  height: calc(100% - 63px);
}

.mainContent {
  position: relative;
  .grid {
    padding: 0.2rem 0 0.3rem 0;
    // margin: 0.2rem 0 0 0;
    background: #fff;
    @media only screen and (min-width: 768px) {
      margin: 0.5rem 0 0 0;
      padding: 0.1rem 0 0.45rem 0;
    }
    .list {
      ul {
        @include display-flex;
        @include align-items-center;
        @include text-align;
        @include justify-content-around;
        li {
          font-size: 0.24rem;
          color: #5d6b7a;
          margin-top: 0.35rem;
          p {
            line-height: 0.6rem;
            color: #34495e;
            font-size: 0.4rem;
          }
          img {
            width: 1.2rem;
            height: 1.2rem;
          }
        }
      }
    }
  }
}
.el-button.is-circle {
  padding: 18px !important;
  .el-icon-arrow-up {
    font-size: 20px !important;
  }
}
.redpoint {
  display: inline-block;
  height: 20px;
  width: 20px;
  line-height: 18px;
  text-align: center;
  font-size: .875rem;
  border-radius: 20px;
  color: #fff;
  background: #f56c6c;
  position: absolute;
  border: 1px solid #fff;
  top: 0px;
  // right: -8px;
  left: 0px;
  @media only screen and (min-width: 768px) {
    height: 30px;
    width: 30px;
    line-height: 28px;
  }
}
.redpoints{
  display: inline-block;
  height: 20px;
  width: 20px;
  line-height: 18px;
  text-align: center;
  font-size: .875rem;
  border-radius: 20px;
  color: #fff;
  background: #f56c6c;
  position: relative;
  border: 1px solid #fff;
  top: -46px;
  // right: -8px;
  left: -18px;
  @media only screen and (min-width: 768px) {
    height: 30px;
    width: 30px;
    line-height: 28px;
  }
}
.goTop {
  z-index: 999;
}
.checkBox1 {
  position: fixed;
  left: 0.6rem;
  bottom: 3.25rem;
  z-index:5000;
  img {
    width: 3.5rem;
    height: 3.5rem;
  }
}

.checkBox2 {
  position: fixed;
  left: 0.6rem;
  bottom: 7.5rem;
  img {
    width: 3.5rem;
    height: 3.5rem;
  }
}
.checkBox3 {
  position: fixed;
  right: 0.6rem;
  bottom: 7.5rem;
  width: 100px;
  height: 100px;
  img {
    width: 3.5rem;
    height: 3.5rem;
  }
}
.checkBox4 {
  position: fixed;
  left: 0.6rem;
  bottom: 11rem;
  z-index:5000;
  img {
    width: 3.5rem;
    height: 3.5rem;
  }
}
.contagionImg{
  width: 1rem !important;
  height: 1rem !important;
  margin-right: .3125rem !important;
}

</style>
<style lang="scss">
.el-table::before {
  z-index: 0;
}
.el-loading-spinner {
  top: 10%;
}
.van-cell__value{
  color: #323233;
}
.van-field__label{
  color: #323233;
}
.van-field__control--right{
  padding-right: 1.375rem;
}
.van-calendar__popup.van-popup--bottom, .van-calendar__popup.van-popup--top{
  height: 70% !important;
}
.van-calendar__selected-day{
  background: #409eff;
}
// .van-calendar__top-info{
//   background: #ed7982;
//   color: #fff;
//   border-radius: 2px;
// }
.van-calendar__header-title{
  color: #409eff;
}
.van-checkbox__label{
  font-size: .9375rem;
}
.van-cell{
  font-size: .9375rem;
}
.van-toast{
  z-index: 6000 !important;
}
#today_panel{
  .van-collapse-item__content{
    max-height: 200px;
    overflow-y: auto;
  }
  .msgtipPopup{
    width: 90% !important;
    font-size: .875rem !important;
    z-index: 6000 !important;
    top: 10% !important;
    .Dialog{
        width: 100% !important;
    }
    .DialogTit{
        padding: .625rem !important;
    }
    .Dialog .DialogTit .back{
      font-size: .875rem !important;
    }
    .Dialog .DialogTit .name{
      font-size: .875rem !important;
    }
    .Dialog .DialogContent{
      height: 24.8rem !important;
    }
    .DialogContent .item{
      padding: 0 .625rem;
      font-size: 1rem;
    }
    .DialogContent .item .name{
      height: 2.625rem;
      line-height: 2.625rem !important;
      font-size: 1.375rem !important;
    }
    .DialogContent .item .content .text{
      font-size: .875rem;
      height: 1.875rem;
    }
  }
}
.plate-box .plate ul li {
    font-size: .875rem;
    line-height: 1.375rem;
    float: left;
    width: 50%;
}
.plate-box .title{
  font-size: .875rem;
  line-height: 2rem;
}
.table tr{
  padding: 0.5rem 0 !important;
}

.newDiv{
  .table{
    width: 1000px !important;
    font-size: .875rem !important;
  }
  .table tr th{
    height: 2.25rem !important;
    // line-height: 2.25rem;
    font-size: .875rem;
  }
}
.dialsisTable{
  font-size: .875rem;
}
.plate-box .plate ul li .content{
  font-size: .875rem !important;
}
.plate-box .note{
  font-size: .875rem !important;
}
</style>
