<template>
  <div>
    <div v-if="isShowDialog" class="Dialog">
      <div class="DialogTit">
        <span @click="close()" class="iconfont">&#xe6e9;</span>
        <h1 class="name newName">透析处方</h1>
        <button class="newButton" @click="showmsgtip">{{patient.name}}</button>
        <span @click="commitInfo" class="success" v-if="hasPermission">保存</span>
        <span @click="commitInfo" class="success" v-if="!hasPermission"></span>
      </div>
      <div class="warnTxt" v-if="showTxt != ''">
        {{ showTxt }}
      </div>

      <div class="DialogContent newDialogContent" id="dialogTop">
        <div>
          <div @click="showSubMenu('mode')" class="item" ref="mode" v-if="isShow('透析模式')">
            <label class="name" for="txms">透析模式</label>
            <div class="content">
              <span class="text" id="txms">{{GetModeByModeId(dialysisPrescription.mode_id)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>
          <div class="item" @click="openPicker" v-if="isShow('透析时长')">
            <label class="name" for="txsc">透析时长</label>
            <div class="content">
              <span class="text" style="width: 100px">{{timeValue}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div class="item" v-if="isShow('血流量')">
            <label class="name" for="xll">血流量(ml/min)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="xll"
                v-model="dialysisPrescription.blood_flow_volume"
              />
            </div>
          </div>

          <div class="item" v-if="isShow('置换流量')&& $store.getters.user.template_info.org_id==10340">
            <label class="name" for="xll">置换流量(ml/min)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="xll"
                v-model="dialysisPrescription.replacement_flow"
              />
            </div>
          </div>

        <div class="item" v-if="isShow('置换流量')&& $store.getters.user.template_info.org_id!=10340">
            <label class="name" for="xll">置换流量(L/h)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="xll"
                v-model="dialysisPrescription.replacement_flow"
              />
            </div>
          </div>

          <div class="item" v-if="isShow('预冲量')">
            <label class="name"
                   v-if="this.$store.getters.user.template_info.template_id != 9 && this.$store.getters.user.template_info.template_id != 17 && this.$store.getters.user.template_info.template_id != 20 && this.$store.getters.user.template_info.template_id != 21 && this.$store.getters.user.template_info.template_id != 22 && this.$store.getters.user.template_info.template_id != 23"
                   for="mbcll">预冲量(L)</label>
            <label class="name"
                   v-if="this.$store.getters.user.template_info.template_id == 9 || this.$store.getters.user.template_info.template_id == 17 || this.$store.getters.user.template_info.template_id == 20 || this.$store.getters.user.template_info.template_id == 21 || this.$store.getters.user.template_info.template_id == 22 || this.$store.getters.user.template_info.template_id == 23"
                   for="mbcll">预冲量(ml)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="mbcll"
                v-model="dialysisPrescription.pre_impulse"
              />
            </div>
          </div>

          <div class="item" v-if="isShow('目标超滤量')">
            <label class="name"
                   v-if="this.$store.getters.user.template_info.template_id != 9 && this.$store.getters.user.template_info.template_id != 17 && this.$store.getters.user.template_info.template_id != 20 && this.$store.getters.user.template_info.template_id != 21 && this.$store.getters.user.template_info.template_id != 22  && this.$store.getters.user.template_info.template_id != 23 && this.$store.getters.user.template_info.template_id != 24 && this.$store.getters.user.template_info.template_id != 26 && this.$store.getters.user.template_info.template_id != 28 && this.$store.getters.user.template_info.template_id != 27 && this.$store.getters.user.template_info.template_id != 29 && this.$store.getters.user.template_info.template_id != 30 && this.$store.getters.user.template_info.template_id != 32 && this.$store.getters.user.template_info.org_id!=9555  && this.$store.getters.user.template_info.org_id!=10340 && this.$store.getters.user.template_info.org_id!=10441 && this.$store.getters.user.template_info.org_id!=10445 && this.$store.getters.user.template_info.org_id!=10440 && this.$store.getters.user.template_info.org_id!=10469 && this.$store.getters.user.template_info.org_id!=10460"
                   for="mbcll">目标超滤量(L)</label>
            <label class="name"
                   v-if="this.$store.getters.user.template_info.template_id == 9 || this.$store.getters.user.template_info.template_id == 17 || this.$store.getters.user.template_info.template_id == 20 || this.$store.getters.user.template_info.template_id == 21 || this.$store.getters.user.template_info.template_id == 22 || this.$store.getters.user.template_info.template_id == 23 || this.$store.getters.user.template_info.template_id == 24 || this.$store.getters.user.template_info.template_id == 26 || this.$store.getters.user.template_info.template_id == 28 || this.$store.getters.user.template_info.template_id == 27 || this.$store.getters.user.template_info.template_id == 29 || this.$store.getters.user.template_info.template_id == 30 || this.$store.getters.user.template_info.template_id == 32  || this.$store.getters.user.template_info.org_id==9555 || this.$store.getters.user.template_info.org_id==10340  || this.$store.getters.user.template_info.org_id==10441 || this.$store.getters.user.template_info.org_id==10445 || this.$store.getters.user.template_info.org_id==10440 || this.$store.getters.user.template_info.org_id==10469 || this.$store.getters.user.template_info.org_id==10460"
                   for="mbcll">目标超滤量(ml)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="mbcll"
                v-model="dialysisPrescription.target_ultrafiltration"
              />
            </div>
          </div>

           <div class="item" v-if="isShow('处方脱水量')">

            <label class="name" for="mbcll">处方脱水量(ml)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="mbcll"
                v-model="dialysisPrescription.prescription_water"
              />
            </div>
          </div>
          <div
            @click="showSubMenu('dialysate_formulation')"
            class="item"
            ref="dialysate_formulation"
            v-if="isShow('透析液配方')"
          >
            <label class="name" for="txypf">透析液配方</label>
            <div class="content">
              <span
                class="text"
                id="txypf"
              >{{GetDialysateFormulationById(dialysisPrescription.dialysate_formulation)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div @click="showSubMenu('anticoagulant')" class="item" ref="anticoagulant" v-if="isShow('抗凝剂')">
            <label class="name" for="knj">抗凝剂</label>
            <div class="content">
              <span class="text" id="knj">{{GetAnticoagulantById(dialysisPrescription.anticoagulant)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

         <div class="item" v-if="isShow('抗凝剂商品名称')">
            <label class="name" for="knj">抗凝剂商品名称</label>
            <div class="content">
              <input @focus="inputFocus" id="dt" v-model="dialysisPrescription.antioxidant_commodity_name"/>
            </div>
          </div>

           <div class="item" v-if="isShow('无肝素备注') && dialysisPrescription.anticoagulant == 1">
            <label class="name" for="dtl">无肝素备注</label>
            <div class="content">
              <input
                @click="newClick($event)"
                @focus="inputFocus"
                id="dtl"
                v-model="dialysisPrescription.no_heparin_remarks"
              />
            </div>
          </div>

           <div class="item" v-if="isShow('肝素钠') && dialysisPrescription.anticoagulant == 10">
            <label class="name" for="dtl">肝素钠(mg/h)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="dtl"
                v-model="dialysisPrescription.heparin_sodium"
              />
            </div>
          </div>

           <div class="item" v-if="isShow('鱼精蛋白') && dialysisPrescription.anticoagulant == 10">
            <label class="name" for="dtl">鱼精蛋白(mg/h)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="dtl"
                v-model="dialysisPrescription.nucleoprotamine"
              />
             </div>
           </div>

            <div class="item" v-if="isShow('下机前推注鱼精蛋白')&& dialysisPrescription.anticoagulant == 10">
            <label class="name" for="dtl">下机前推注鱼精蛋白(mg)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="dtl"
                v-model="dialysisPrescription.push_the_protamine"
              />
             </div>
           </div>

          <div class="item" v-if="dialysisPrescription.anticoagulant != 5&&isShow('首剂')">
            <label
              class="name"
              for="zl"
              v-if="dialysisPrescription.anticoagulant == 0 ||dialysisPrescription.anticoagulant == -2"
            >首剂(mg)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 2 && this.$store.getters.user.template_info.template_id != 13 && this.$store.getters.user.template_info.template_id != 21 && this.$store.getters.user.template_info.template_id != 23 && this.$store.getters.user.template_info.org_id!=10340 && this.$store.getters.user.template_info.org_id!=10441 && this.$store.getters.user.template_info.org_id!=10445 && this.$store.getters.user.template_info.org_id!=3877 && this.$store.getters.user.template_info.org_id!=10469 && this.$store.getters.user.template_info.org_id!=10471">首剂(iu)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 2 && (this.$store.getters.user.template_info.template_id == 13 || this.$store.getters.user.template_info.template_id == 21 || this.$store.getters.user.template_info.template_id == 23 ||  this.$store.getters.user.template_info.org_id==10340 ||  this.$store.getters.user.template_info.org_id ==10441 ||  this.$store.getters.user.template_info.org_id ==10445 ||  this.$store.getters.user.template_info.org_id==3877 ||  this.$store.getters.user.template_info.org_id==10469 ||  this.$store.getters.user.template_info.org_id==10471)">首剂(mg)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 3 || dialysisPrescription.anticoagulant == 8 || dialysisPrescription.anticoagulant == 9 || dialysisPrescription.anticoagulant ==10">首剂(iu)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 4">首剂(ml)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 1">首剂(mg)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 6">首剂(iu)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 7">首剂(iu)</label>
            <div class="content">
              <input
                v-if="dialysisPrescription.anticoagulant != 1"
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="sj"
                v-model="dialysisPrescription.anticoagulant_shouji"
                :disabled="anticoagulant.shouji==1?false:true"
              />

              <input
                v-if="dialysisPrescription.anticoagulant == 1"
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="sj"
                v-model="dialysisPrescription.no_anticoagulant_shouji"
                disabled="true"
              />
            </div>
          </div>
          <div class="item" v-if="anticoagulant.weichi != -1&&isShow('维持')">
            <label
              class="name"
              for="zl"
              v-if="dialysisPrescription.anticoagulant == 0 ||dialysisPrescription.anticoagulant == -2"
            >维持(mg/h)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 2 && this.$store.getters.user.template_info.template_id != 13 && this.$store.getters.user.template_info.template_id != 21 && this.$store.getters.user.template_info.template_id != 23 && this.$store.getters.user.template_info.org_id!=10340 && this.$store.getters.user.template_info.org_id!=10441  && this.$store.getters.user.template_info.org_id!=10445 && this.$store.getters.user.template_info.org_id!=3877 && this.$store.getters.user.template_info.org_id!=10469 && this.$store.getters.user.template_info.org_id!=10471">维持(iu/h)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 2 && (this.$store.getters.user.template_info.template_id == 13 || this.$store.getters.user.template_info.template_id == 21 || this.$store.getters.user.template_info.template_id == 23 || this.$store.getters.user.template_info.org_id==10340 || this.$store.getters.user.template_info.org_id==10441 || this.$store.getters.user.template_info.org_id==10445 || this.$store.getters.user.template_info.org_id==3877 || this.$store.getters.user.template_info.org_id==10469 || this.$store.getters.user.template_info.org_id==10471)">维持(mg/h)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 3 || dialysisPrescription.anticoagulant == 8 || dialysisPrescription.anticoagulant == 9 || dialysisPrescription.anticoagulant ==10">维持(iu/h)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 4">维持(ml)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 5">维持(ml/h)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 1">维持(mg/h)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 6">维持(iu/h)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 7">维持(iu/h)</label>
            <div class="content">
              <input
                v-if="dialysisPrescription.anticoagulant != 1"
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="wz"
                class="inputBox"
                v-model="dialysisPrescription.anticoagulant_weichi"
                :disabled="anticoagulant.weichi==1?false:true"
              />

              <input
                v-if="dialysisPrescription.anticoagulant == 1"
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="sj"
                v-model="dialysisPrescription.no_anticoagulant_weichi"
                disabled="true"
              />
            </div>
          </div>
          <div class="item" v-if="dialysisPrescription.anticoagulant != 5&& isShow('总量')">
            <label
              class="name"
              for="zl"
              v-if="dialysisPrescription.anticoagulant == 0 ||dialysisPrescription.anticoagulant == -2"
            >总量(mg)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 2 && this.$store.getters.user.template_info.template_id != 13 && this.$store.getters.user.template_info.template_id != 21 && this.$store.getters.user.template_info.template_id != 23  && this.$store.getters.user.template_info.org_id!=10340  && this.$store.getters.user.template_info.org_id!=10441  && this.$store.getters.user.template_info.org_id!=10445 && this.$store.getters.user.template_info.org_id!=3877 && this.$store.getters.user.template_info.org_id!=10469 && this.$store.getters.user.template_info.org_id!=10471">总量(iu)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 2 && (this.$store.getters.user.template_info.template_id == 13 || this.$store.getters.user.template_info.template_id == 21 || this.$store.getters.user.template_info.template_id == 23  || this.$store.getters.user.template_info.org_id==10340  || this.$store.getters.user.template_info.org_id==10441  || this.$store.getters.user.template_info.org_id==10445 || this.$store.getters.user.template_info.org_id==3877 || this.$store.getters.user.template_info.org_id == 10469 || this.$store.getters.user.template_info.org_id == 10471)">总量(mg)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 3 || dialysisPrescription.anticoagulant == 8 || dialysisPrescription.anticoagulant == 9 || dialysisPrescription.anticoagulant ==10">总量(iu)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 4">总量(ml)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 1">总量(mg)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 6">总量(iu)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 7">总量(iu)</label>

            <div class="content">
              <input
                v-if="dialysisPrescription.anticoagulant != 1"
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="zl"
                class="inputBox"
                v-model="dialysisPrescription.anticoagulant_zongliang"
                :disabled="anticoagulant.zongliang==1?false:true"
              />

              <input
                v-if="dialysisPrescription.anticoagulant == 1"
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="sj"
                v-model="dialysisPrescription.no_anticoagulant_zongliang"
                disabled="true"
              />
            </div>
          </div>

          <div class="item" v-if="isShow('开药数量')">
            <label class="name" for="g">开药数量(支)</label>
            <div class="content">
              <input
                type="text"
                id="g"
                class="inputBox"
                v-model="dialysisPrescription.prescribing_number"
              />
            </div>
          </div>

          <div class="item" v-if="isShow('追加肝素量')">
            <label
              class="name"
              for="zl"
              v-if="dialysisPrescription.anticoagulant == 0 ||dialysisPrescription.anticoagulant == -2"
            >追加肝素量(mg)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 2 && this.$store.getters.user.template_info.template_id != 13 && this.$store.getters.user.template_info.template_id != 21 && this.$store.getters.user.template_info.template_id != 23 && this.$store.getters.user.template_info.org_id!=10340 && this.$store.getters.user.template_info.org_id!=3877">追加肝素量(iu)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 2 && (this.$store.getters.user.template_info.template_id == 13 || this.$store.getters.user.template_info.template_id == 21 || this.$store.getters.user.template_info.template_id == 23 ||  this.$store.getters.user.template_info.org_id==10340 ||  this.$store.getters.user.template_info.org_id==3877)">追加肝素量(mg)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 3 || dialysisPrescription.anticoagulant == 8 || dialysisPrescription.anticoagulant == 9 || dialysisPrescription.anticoagulant ==10">追加肝素量(iu)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 4">追加肝素量(ml)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 1">追加肝素量(mg)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 6">追加肝素量(iu)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 7">追加肝素量(iu)</label>
            <div class="content">
              <input
                v-if="dialysisPrescription.anticoagulant != 1"
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="sj"
                v-model="dialysisPrescription.add_amount"
                :disabled="anticoagulant.shouji==1?false:true"
              />

              <input
                v-if="dialysisPrescription.anticoagulant == 1"
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="sj"
                v-model="dialysisPrescription.add_amount"
                disabled="true"
              />
            </div>
          </div>

          <div class="item" v-if="isShow('减肝素量')">
            <label
              class="name"
              for="zl"
              v-if="dialysisPrescription.anticoagulant == 0 ||dialysisPrescription.anticoagulant == -2"
            >减肝素量(mg)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 2 && this.$store.getters.user.template_info.template_id != 13 && this.$store.getters.user.template_info.template_id != 21 && this.$store.getters.user.template_info.template_id != 23 && this.$store.getters.user.template_info.org_id!=10340 && this.$store.getters.user.template_info.org_id!=3877">减肝素量(iu)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 2 && (this.$store.getters.user.template_info.template_id == 13 || this.$store.getters.user.template_info.template_id == 21 || this.$store.getters.user.template_info.template_id == 23 ||  this.$store.getters.user.template_info.org_id==10340 ||  this.$store.getters.user.template_info.org_id==3877)">减肝素量(mg)</label>
            <label class="name" for="zl"
                   v-if="dialysisPrescription.anticoagulant == 3 || dialysisPrescription.anticoagulant == 8 || dialysisPrescription.anticoagulant == 9 || dialysisPrescription.anticoagulant ==10">追加肝素量(iu)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 4">减肝素量(ml)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 1">减肝素量(mg)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 6">减肝素量(iu)</label>
            <label class="name" for="zl" v-if="dialysisPrescription.anticoagulant == 7">减肝素量(iu)</label>
            <div class="content">
              <input
                v-if="dialysisPrescription.anticoagulant != 1"
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="sj"
                v-model="dialysisPrescription.reduce_amount"
                :disabled="anticoagulant.shouji==1?false:true"
              />

              <input
                v-if="dialysisPrescription.anticoagulant == 1"
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="sj"
                v-model="dialysisPrescription.reduce_amount"
                disabled="true"
              />
            </div>
          </div>

          <div class="item" v-if="dialysisPrescription.anticoagulant == 5&& isShow('钙名称')">
            <label class="name" for="g">钙名称</label>
            <div class="content">
              <input
                type="text"
                id="g"
                class="inputBox"
                v-model="dialysisPrescription.anticoagulant_gaimingcheng"
              />
            </div>
          </div>

          <div class="item" v-if="dialysisPrescription.anticoagulant == 5&& isShow('钙剂量')">
            <label class="name" for="gjl">钙剂量(ml)</label>
            <div class="content">
              <input
                type="text"
                id="gjl"
                class="inputBox"
                v-model="dialysisPrescription.anticoagulant_gaijiliang"
              />
            </div>
          </div>
          <!-- <div class="item">
          <label class="name" for="gtz">干体重(kg)</label>
          <div class="content">
            <input type="tel" @focus="inputFocus" id="gtz" v-model="dialysisPrescription.dry_weight"/>
          </div>
          </div>-->

          <div class="line"></div>
          <div class="item" v-if="isShow('置换量')" v-show="zhiShow">
            <label v-if="this.$store.getters.user.template_info.template_id != 20 && this.$store.getters.user.template_info.template_id != 28 && this.$store.getters.user.template_info.template_id != 29" class="name" for="zhy">置换量(L)</label>
            <label v-if="this.$store.getters.user.template_info.template_id == 20 || this.$store.getters.user.template_info.template_id == 28 || this.$store.getters.user.template_info.template_id == 29" class="name"
                   for="zhy">置换量(ml)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="zhy"
                v-model="dialysisPrescription.replacement_total"
              />
            </div>
          </div>

          <!-- <div class="line"></div> -->
          <div class="item" v-if="isShow('钾')">
            <label class="name" for="j">钾(mmol/L)</label>
            <div class="content">
              <input type="number" @click="newClick($event)" @focus="inputFocus" id="j"
                     v-model="dialysisPrescription.kalium"/>
            </div>
          </div>
          <div class="item" v-if="isShow('钠')">
            <label class="name" for="n">钠(mmol/L):</label>
            <div class="content">
              <input type="number" @click="newClick($event)" @focus="inputFocus" id="n"
                     v-model="dialysisPrescription.sodium"/>
            </div>
          </div>
          <div class="item" v-if="isShow('钙')">
            <label class="name" for="gg">钙(mmol/L)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="gg"
                v-model="dialysisPrescription.calcium"
              />
            </div>
          </div>

          <div class="item" v-if="isShow('碳酸氢盐')">
            <label class="name" for="tsqy">碳酸氢盐(mmol/L)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="tsqy"
                v-model="dialysisPrescription.bicarbonate"
              />
            </div>
          </div>
          <div class="item" v-if="isShow('葡萄糖')">
            <label class="name" for="ptt">葡萄糖(mmol/L)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="ptt"
                v-model="dialysisPrescription.glucose"
              />
            </div>
          </div>

          <div class="line"></div>

          <div class="item" v-if="isShow('透析液流量')">
            <label class="name" for="txyll">透析液流量(ml/min)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="txyll"
                v-model="dialysisPrescription.dialysate_flow"
              />
            </div>
          </div>
          <div class="item" v-if="isShow('透析液温度')">
            <label class="name" for="txywd">透析液温度(℃)</label>
            <div class="content">
              <!--<span class="text">HD</span>-->
              <!--<span class="iconfont">&#xe6f9;</span>-->
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="txywd"
                v-model="dialysisPrescription.dialysate_temperature"
              />
            </div>
          </div>
          <div class="item" v-if="isShow('电导率')">
            <label class="name" for="dtl">电导率(mS/cm)</label>
            <div class="content">
              <input
                type="number"
                @click="newClick($event)"
                @focus="inputFocus"
                id="dtl"
                v-model="dialysisPrescription.conductivity"
              />
            </div>
          </div>

          <div @click="showSubMenu('dialyzer_perfusion_apparatus')" class="item" ref="mode" v-if="isShow('透析器/灌流器')">
            <label class="name" for="txms">透析器/灌流器</label>
            <div class="content">
              <span class="text" id="txms">{{dialysisPrescription.dialyzer_perfusion_apparatus}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

           <div @click="showSubMenu('dialysis_dialyszers')" class="item" ref="mode" v-if="isShow('透析器')">
            <label class="name" for="txms">透析器</label>
            <div class="content">
              <span class="text" id="txms">{{dialysisPrescription.dialysis_dialyszers}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

         <div @click="showSubMenu('dialysis_irrigation')" class="item" ref="mode" v-if="isShow('灌流器')">
            <label class="name" for="txms">灌流器</label>
            <div class="content">
              <span class="text" id="txms">{{dialysisPrescription.dialysis_irrigation}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

        <div @click="showSubMenu('dialysis_strainer')" class="item" ref="mode" v-if="isShow('滤过器')">
            <label class="name" for="txms">滤过器</label>
            <div class="content">
              <span class="text" id="txms">{{dialysisPrescription.dialysis_strainer}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div class="line"></div>

          <div
            @click="showSubMenu('body_fluid')"
            class="item"
            ref="body_fluid"
            v-if="isShow('体液过多症状')"
          >
            <label class="name" for="knj">体液过多症状</label>
            <div class="content">
              <span class="text" id="knja">{{getBodyFluid(dialysisPrescription.body_fluid)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div class="item" v-if="isShow('体液过多其他症状')">
            <label class="name" for="knj">体液过多其他症状</label>
            <div class="content">
              <input @focus="inputFocus" id="dt" v-model="dialysisPrescription.body_fluid_other"/>
            </div>
          </div>

          <div
            @click="showSubMenu('special_medicine')"
            class="item"
            ref="special_medicine"
            v-if="isShow('透析前使用特殊药物')"
          >
            <label class="name" for="knj">透析前使用特殊药物</label>
            <div class="content">
              <span
                class="text"
                id="knjaa"
              >{{getSpecialMedicine(dialysisPrescription.special_medicine)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div class="item" v-if="isShow('透析前使用其他特殊药物')">
            <label class="name" for="knj">透析前使用其他特殊药物</label>
            <div class="content">
              <input
                @focus="inputFocus"
                id="dt"
                v-model="dialysisPrescription.special_medicine_other"
              />
            </div>
          </div>

          <div
            @click="showSubMenu('displace_liqui_part')"
            class="item"
            ref="displace_liqui_part"
            v-if="isShow('置换液')"
            v-show="huShow"
          >
            <label class="name" for="knj" v-if="this.$store.getters.user.template_info.template_id != 6">置换液</label>
            <label class="name" for="knj" v-if="this.$store.getters.user.template_info.template_id == 6">置换方式</label>

            <div class="content">
              <span
                class="text"
                id="knjaa"
              >{{getDisplaceLiquiPart(dialysisPrescription.displace_liqui_part)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div class="item" v-if="isShow('置换液总量')" v-show="totalShow">
            <label class="name" for="knj"
                   v-if="this.$store.getters.user.template_info.template_id == 21 || this.$store.getters.user.template_info.template_id == 29">置换液总量(ml)</label>
            <label class="name" for="knj"
                   v-if="this.$store.getters.user.template_info.template_id != 21 && this.$store.getters.user.template_info.template_id != 29">置换液总量(L)</label>
            <div class="content">
              <input
                @focus="inputFocus"
                id="dt"
                v-model="dialysisPrescription.displace_liqui_value"
              />
            </div>
          </div>

         <div class="item" v-if="isShow('置换速度')" v-show="totalShow">
            <label class="name" for="dtl">置换速度(ml/h)</label>
            <div class="content">
              <input
                @click="newClick($event)"
                @focus="inputFocus"
                id="dtl"
                v-model="dialysisPrescription.displace_speed"
              />
            </div>
          </div>

          <div class="item" v-if="isShow('目标KT/V')">
            <label class="name" for="knj">目标KT/V</label>
            <div class="content">
              <input @focus="inputFocus" id="dt" v-model="dialysisPrescription.target_ktv"/>
            </div>
          </div>

          <!--          <div-->
          <!--            @click="showSubMenu('blood_access')"-->
          <!--            class="item"-->
          <!--            ref="blood_access"-->
          <!--            v-if="isShow('血管通路')"-->
          <!--          >-->
          <!--            <label class="name" for="knj">血管通路</label>-->
          <!--            <div class="content">-->
          <!--              <span class="text" id="knjaa">{{getBloodAccess(dialysisPrescription.blood_access)}}</span>-->
          <!--              <span class="iconfont">&#xe6f9;</span>-->
          <!--            </div>-->
          <!--          </div>-->

          <div
            @click="showSubMenu('vascular_access_desc')"
            class="item"
            ref="vascular_access_desc"
            v-if="isShow('血管通路')"
          >
            <h2 class="name">血管通路</h2>
            <div class="content">
              <span class="text">{{getBloodAccessTwo(dialysisPrescription.blood_access)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div class="item" @click="openAnticoagulantPicker" v-if="isShow('抗凝提前停止')">
            <label class="name" for="txsc">抗凝提前停止</label>
            <div class="content">
              <span class="text" style="width: 100px">{{anticoagulantTimeValue}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <!--          <div class="item" v-if="isShow('实际超滤量')">-->
          <!--            <label class="name" for="knj">实际超滤量(L)</label>-->
          <!--            <div class="content">-->
          <!--              <input @focus="inputFocus" id="dt" v-model="dialysisPrescription.ultrafiltration" />-->
          <!--            </div>-->
          <!--          </div>-->

          <!--<div-->
            <!--@click="dialysisGoodsClick()"-->
            <!--class="item"-->
            <!--ref="consumable_material"-->
            <!--v-if="config.is_open == 1"-->
          <!--&gt;-->
            <!--<label class="name" for="knj">透析耗材</label>-->
            <!--<div class="content">-->
              <!--<span class="text" id="knjaa"></span>-->
              <!--<span class="iconfont">&#xe6f9;</span>-->
            <!--</div>-->
          <!--</div>-->

          <div @click="showSubMenu('blood')" class="item" ref="mode" v-if="isShow('抽血')">
            <label class="name" for="txms">抽血</label>
            <div class="content">
              <span class="text" id="txms">{{dialysisPrescription.blood}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div
            @click="showSubMenu('hemodialysis_pipelines')"
            class="item"
            ref="hemodialysis_pipelines"
            v-if="isShow('透析管路')"
          >
            <label class="name" for="knj">透析管路</label>
            <div class="content">
              <span
                class="text"
                id="knjaa"
              >{{getHemodialysisPipelines(dialysisPrescription.hemodialysis_pipelines)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div class="item" v-if="isShow('透析管路支数')">
            <label class="name" for="knj">透析管路支数</label>
            <div class="content">
              <input
                @focus="inputFocus"
                id="dt"
                type="number"
                v-model="dialysisPrescription.hemodialysis_pipelines_count"
                onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)"

              />
            </div>
          </div>

          <div
            @click="showSubMenu('puncture_needle')"
            class="item"
            ref="puncture_needle"
            v-if="isShow('穿刺针')"
          >
            <label class="name" for="knj">穿刺针</label>
            <div class="content">
              <span
                class="text"
                id="knjaa"
              >{{getPunctureNeedle(dialysisPrescription.puncture_needle)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div class="item" v-if="isShow('穿刺针支数')">
            <label class="name" for="knj">穿刺针支数</label>
            <div class="content">
              <input
                @focus="inputFocus"
                id="dt"
                type="number"

                v-model="dialysisPrescription.puncture_needle_count"
                onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)"

              />
            </div>
          </div>

          <div
            @click="showSubMenu('epo')"
            class="item"
            ref="special_medicine"
            v-if="isShow('促红素')"
          >
            <label class="name" for="knj">促红素</label>
            <div class="content">
              <span
                class="text"
                id="knjaa"
              >{{getEPO(dialysisPrescription.epo)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div class="item" v-if="isShow('促红素支数')">
            <label class="name" for="knj">促红素支数</label>
            <div class="content">
              <input
                type="number"

                @focus="inputFocus"
                id="dt"

                v-model="dialysisPrescription.epo_count"
                onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)"
              />
            </div>
          </div>

         <div @click="showSubMenu('admin_user_id')" class="item" ref="admin_user_id" v-if="isShow('处方医生')">
            <label class="name" for="knj">处方医生</label>
            <div class="content">
              <span class="text" id="knj">{{getAdminMap(dialysisPrescription.admin_user_id)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div @click="showSubMenu('water_machine')" class="item" ref="water_machine" v-if="isShow('带水上机')">
            <label class="name" for="knj">带水上机</label>
            <div class="content">
              <span class="text" id="knj">{{getWaterMachine(dialysisPrescription.water_machine)}}</span>
              <span class="iconfont">&#xe6f9;</span>
            </div>
          </div>

          <div class="item" v-if="isShow('处方钠')">
            <label class="name" for="j">处方钠</label>
            <div class="content">
              <input type="number" @click="newClick($event)" @focus="inputFocus" id="j"
                     v-model="dialysisPrescription.prescription_sodium"/>
            </div>
          </div>

          <div class="item" v-if="isShow('开始钠')">
            <label class="name" for="j">开始钠</label>
            <div class="content">
              <input type="number" @click="newClick($event)" @focus="inputFocus" id="j"
                     v-model="dialysisPrescription.start_sodium"/>
            </div>
          </div>

          <div class="item" v-if="isShow('钠曲线')">
            <label class="name" for="j">钠曲线</label>
            <div class="content">
              <input type="number" @click="newClick($event)" @focus="inputFocus" id="j"
                     v-model="dialysisPrescription.sodium_curve"/>
            </div>
          </div>

          <div class="item" v-if="isShow('透析液流速')">
            <label class="name" for="j">透析液流速(ml/h)</label>
            <div class="content">
              <input type="number" @click="newClick($event)" @focus="inputFocus" id="j"
                     v-model="dialysisPrescription.dialysis_fluid_flow"/>
            </div>
          </div>

          <div class="item" v-if="isShow('碳酸氢钠流速')">
            <label class="name" for="j">碳酸氢钠流速(ml/h)</label>
            <div class="content">
              <input type="number" @click="newClick($event)" @focus="inputFocus" id="j"
                     v-model="dialysisPrescription.sodium_bicarbonate_flow"/>
            </div>
          </div>

          <div class="item" v-if="isShow('加糖')">
            <label class="name" for="j">加糖</label>
            <div class="content">
              <input  @click="newClick($event)" @focus="inputFocus" id="j"
                     v-model="dialysisPrescription.chaptalization"/>
            </div>
          </div>

          <div class="item" style="display: none">
            <label class="name" for="dtl">医生签名</label>
            <div class="content">
              <div v-if="isShowDesc">医生尚未签名</div>
              <img
                v-if="isShowDoctorSign"
                style="width: 100px;height: 30px"
                :src="signUrl"
                alt
                srcset
              />
            </div>
          </div>

          <div>
            <div class="item" v-if="isShow('病情处理')">
              <label class="name" for="bz">病情处理</label>
              <div class="content">
                <span class="text"></span>
              </div>
            </div>
            <textarea
              class="textarea"
              id="bz"
              placeholder="请输入内容"
              v-model="dialysisPrescription.treatment_remark"
              @focus="lastInputFocus"
              @blur="lastInputBlur"
            ></textarea>
          </div>

          <div class="line"></div>
          <div>
            <div class="item">
              <label class="name" for="bz">备注</label>
              <div class="content">
                <span class="text"></span>
              </div>
            </div>
            <textarea
              class="textarea"
              id="bz"
              placeholder="请输入内容"
              v-model="dialysisPrescription.remark"
              @focus="lastInputFocus"
              @blur="lastInputBlur"
            ></textarea>
          </div>
          <!-- <van-cell title='透析备注' v-if="isShow('透析备注')" @click="teachShow = true" is-link value="请选择"></van-cell>
          <van-popup v-model="teachShow" get-container="#app" class="listBoxPopup newListBoxPopupApp" style="z-index:5000">
              <div class="listBox">
                  <div @click="toTeach('')">请选择</div>
                  <div v-for="(item,index) in teachList" :key="index" @click="toTeach(item.id)">{{ item.text }}</div>
              </div>
          </van-popup>
          <van-field class="bgField" v-if="isShow('透析备注')" v-model="dialysisPrescription.dialysis_remark" rows="1" autosize type="textarea" placeholder="请输入"/> -->

        </div>
        <!--<div class="footer">-->
        <!--处方医生：刘小军 医生-->
        <!--</div>-->
        <div class="PrescSubmit">
          <button style="display: none" class="tj" @click="sign()">医生签名</button>
          <button class="tjcq" @click="commitSolutionInfo" v-if="isPermission()">保存并设为长期处方</button>
          <button class="tj" style="display:none;" @click="commitInfo" v-if="isPermission()">保存</button>
        </div>
      </div>
    </div>
    <!--<two-menu title="二级菜单" v-show="isShowModeSubMenu"></two-menu>-->
    <check-box-sub-menu
      :visibility="visibility"
      v-on:menu-cancle="menuCancle"
      v-on:menu-comfirm="menuComfirm"
      v-on:menu-empty="menuEmpty"
      :propsForm="propForm"
    ></check-box-sub-menu>
    <!--<multiple-sub-menu :goodTypes="types" :visibility="is_show" v-on:menu-cancle="menuCancle" v-on:menu-comfirm="menuComfirm" :propsForm="propForm"></multiple-sub-menu>-->
    <multiple-sub-menu
      :goodTypes="types"
      :info="info"
      :visibility="is_show"
      v-on:menu-cancel-two="menuCancleTwo"
      v-on:menu-comfirm-two="menuComfirmTwo"
      :propsForm="propForm"
      :dialysisPrescription="dialysisPrescription"
    ></multiple-sub-menu>

    <mt-datetime-picker
      ref="picker"
      type="time"
      hourFormat="{value}小时"
      minuteFormat="{value}分钟"
      @confirm="handleTimeConfirm"
      v-model="time"
    ></mt-datetime-picker>

    <mt-datetime-picker
      ref="anticoagulant_picker"
      type="time"
      hourFormat="{value}小时"
      minuteFormat="{value}分钟"
      @confirm="handleAnticoagulantTimeConfirm"
      v-model="anticoagulant_time"
    ></mt-datetime-picker>

    <long-advice-sub-menu
      :visibility="advice_visibility"
      v-on:menu-cancle-three="menuCancleThree"
      v-on:menu-comfirm-three="menuComfirmThree"
      :propsForm="advicePropForm"
    ></long-advice-sub-menu>

     <infor-sub-menu
      :visibility="infor_visibility"
      v-on:menu-cancle-three="menuCancleFour"
      v-on:menu-comfirm-three="menuComfirmFour"
      :propsForm="advicePropForm"
      :predialysis='predialysis'
      >
     </infor-sub-menu>

    <msg-tip
      :visibility="msgtip_visibility"
      :predialysis="predialysis"
      :last_predialysis="last_predialysis"
      :record="record"
      :dry_weight="dry_weight"
      :last_record="last_record"
      :patient_prop="patient"
      :prescription_prop="prescription_prop"
      v-on:menu-msg-tip="menuMsgTip"
    ></msg-tip>


   

  </div>
</template>

<script>
import CheckBoxSubMenu from './subMenu/checkBoxSubMenu'
import MultipleSubMenu from './subMenu/multipleSubMenu'

import {commitDialysisPrescription, CreateGroupAdvice, GetSolution, postSign, postSolution,saveMobileInformation} from '@/api/dialysis'
import {calculateAnticoagulantZL, replacementFlow} from '@/utils/tools'

import {Toast} from 'vant'
import {getDataConfig} from '@/utils/data'

import {parseTime} from '@/utils'
import LongAdviceSubMenu from './subMenu/LongAdviceSubMenu'
import InforSubMenu from './subMenu/InforSubMenu'
import MsgTip from './subMenu/MsgTip'

import request from '@/utils/request'

export default {
  name: 'PrescriptionDialog',
  props: {
    admin_users_prop: {
      type: Array,
      default: function () {
        return new Array()
      }
    },
    system_prescription: {
      type: Object
    },
    predialysis: {
      type: Object
    },
    last_predialysis: {
      type: Object
    },
    record: {
      type: Object
    },
    last_record: {
      type: Object
    },
    patient_prop: {
      type: Object
    },
    solution_prop: {
      type: Object
    },
    config: {
      type: Object
    },
    schedual: {
      type: Object
    },
    dry_weight: {
      type: Object
    },
    operators: {
      type: Array,
      default: function () {
        return new Array()
      }
    },
    types: {
      type: Array,
      default: function () {
        return new Array()
      }
    },
    info: {
      type: Array,
      default: function () {
        return new Array()
      }
    },
    last_prescription: {
      type: Object
    },
    prescription_prop: {
      type: Object
    },
    is_open: {
      type: Number
    },
    targetAdvices: {
      type: Array,
      default: function () {
        return new Array()
      }
    },
    waitUploadAdvices: {
      type: Array,
      default: function () {
        return new Array()
      }
    },
    machines_prop: {
      type: Array,
      default: function () {
        return new Array()
      }
    },
    stockType: {
      type: Array,
      default: function () {
        return new Array()
      }
    },
    admin_map: {
      type: Object
    },
    admins: {
      type: Array
    }
  },
  data () {
    return {
      showTxt: '',
      hasPermission: true,
      is_pre: 0,
      template_id: 0,
      loading: false,
      signUrl: '',
      isShowDesc: true,
      advice_visibility: false,
      msgtip_visibility: false,
      time: '03:00',
      anticoagulant_time: '00:00',
      timeValue: '',
      tempTimeValue: '',
      anticoagulantTimeValue: '',
      isShowSign: false,
      anticoagulantsConfit: {},
      anticoagulantsConfitTwo: {},
      dialysateFormulationOptions: [],
      bodyFluidOptions: [],
      hemodialysisPipelinesOptions: [],
      punctureNeedleOptions: [],
      epoOptions: [],

      specialMedicineOptions: [],
      displaceLiquiPartOptions: [],
      bloodAccessOptions: [],
      advicePropForm: {
        list: [],
        result: [],
        operators: [],
        sch: this.schedual
      },
      is_show: false,

      perfusion_apparatus: {},
      replacementWays: [],
      dialyserList: [],
      modeOption: [],
      isShowDoctorBtn: true,
      isShowDoctorSign: false,
      visibility: false,
      isShowDialog: true,
      isShowModeSubMenu: false,
      dialysisPrescription: {
        mode_id: '',
        dialysis_duration: '',
        dialysis_duration_hour: '',
        dialysis_duration_minute: '',
        mode_name: '',
        dialyzer: '',
        perfusion_apparatus: '',
        blood_flow_volume: '',
        dewater_amount: '',
        displace_liqui: '',
        replacement_total: '',
        replacement_way: '',
        anticoagulant: '',
        anticoagulant_shouji: '',
        anticoagulant_weichi: '',
        anticoagulant_zongliang: '',
        anticoagulant_gaimingcheng: '',
        anticoagulant_gaijiliang: '',
        dialyzer_perfusion_apparatus: '',

        no_anticoagulant_shouji: '0',
        no_anticoagulant_weichi: '0',
        no_anticoagulant_zongliang: '0',

        anticoagulant_stop_time_hour: '',
        anticoagulant_stop_time_min: '',

        kalium: '',
        sodium: '',
        calcium: '',
        bicarbonate: '',
        glucose: '',
        prescription_doctor: '',
        // dry_weight: "",
        dialysate_flow: '',
        dialysate_temperature: '',
        target_ultrafiltration: '',
        dialysate_formulation: '',
        conductivity: '',
        doctor: '',
        remark: '',
        body_fluid: '',
        special_medicine: '',
        special_medicine_other: '',
        displace_liqui_part: '',
        displace_liqui_value: '',
        blood_access: '',
        ultrafiltration: '',
        body_fluid_other: '',
        niprocart: '',
        jms: '',
        fistula_needle_set: '',
        fistula_needle_set_16: '',
        hemoperfusion: '',
        dialyser_sterilised: '',
        filtryzer: '',
        target_ktv: '',
        dialyzers: '',
        injector: '',
        bloodlines: '',
        tubing_hemodialysis: '',
        package: '',
        a_liquid: '',
        creater: '',
        modifier: '',
        pre_impulse: '',
        heparin_sodium: '',
        nucleoprotamine: '',
        push_the_protamine: '',
        no_heparin_remarks: '',
        blood: '',
        dialysis_dialyszers: '',
        dialysis_irrigation: '',
        displace_speed: '',
        hemodialysis_pipelines: '',
        hemodialysis_pipelines_count: '',
        puncture_needle: '',
        puncture_needle_count: '',
        epo: '',
        epo_count: '',
        water_machine: 2,
        add_amount: '',
        reduce_amount: '',
        replacement_flow: '',
        dialysis_remark: '',
        prescribing_number: '',
        treatment_remark: '',
        prescription_sodium: '',
        start_sodium: '',
        sodium_curve: '',
        dialysis_fluid_flow: '',
        sodium_bicarbonate_flow: '',
        prescription_water: '',
        dialysis_strainer: '',
        chaptalization:""
      },
      anticoagulant: {
        id: 0,
        name: '',
        type: 1,
        shouji: 1,
        weichi: 1,
        zongliang: 1,
        gaimingcheng: -1,
        gaijiliang: -1,
        shouji_unit: 'mg',
        weichi_unit: 'mg/h',
        zongliang_unit: 'mg',
        gaimingcheng_unit: '',
        gaijiliang_unit: '',
        admin_user_id: this.$store.getters.user.admin.id
      },
      zhiShow: true,
      totalShow: true,
      huShow: true,
      doctorAdvices: [],
      propForm: {
        title: '',
        list: [],
        optionList: [],
        isMultiple: 2,
        result: [], // 选中的值
        type: 1, // 用来区分不同子菜单，方便对返回值进行赋值
        selectId: 0
      },
      data: [],
      dialyzerPerfusionApparatus: [],
      bloods: [],
      dialyszers: [],
      irrigation: [],
      dialysis_dialyszers: '',
      dialysis_irrigation: '',
      machineList: [
        {id: 1, name: '是'},
        {id: 2, name: '否'}
      ],
      adminMapList: [],
      teachShow: false,
      teachList: [],
      dialysisStrainerList: [],
      infor_visibility:false
    }
  },
  computed: {
    // 计算属性的 getter
  },
  methods: {
    newClick (event) {
      event.currentTarget.select()
    },
    showmsgtip () {
      this.msgtip_visibility = true
      this.isShowDialog = false
    },
    isPermission () {
      if (
        this.$store.getters.user.user.user_type == 3 &&
          (this.$store.getters.user.template_info.template_id == 2 ||
            this.$store.getters.user.template_info.template_id == 6)
      ) {
        return false
      } else {
        return true
      }
    },
    isShow (name) {
      var filedList = this.$store.getters.user.fileds

      for (let i = 0; i < filedList.length; i++) {
        if (
          filedList[i].module == 1 &&
            filedList[i].filed_name_cn == name &&
            filedList[i].is_show == 1
        ) {
          return true
        }
      }
      return false
    },
    openAnticoagulantPicke: function () {
      this.$refs.picker.open()
    },
    openPicker: function () {
      this.$refs.picker.open()
    },
    openAnticoagulantPicker: function () {
      this.$refs.anticoagulant_picker.open()
    },
    handleStartTimeConfirm: function (val) {
      // console.log(val)
    },
    handleTimeConfirm: function (val) {
      val = val.replace('小时')
      val = val.replace('分钟')
      let timeArray = val.split(':')
      if (parseInt(timeArray[0].substring(0, 1)) == 0) {
        this.dialysisPrescription.dialysis_duration_hour = timeArray[0].charAt(
          timeArray[0].length - 1
        )
      } else {
        this.dialysisPrescription.dialysis_duration_hour = timeArray[0]
      }

      if (parseInt(timeArray[1].substring(0, 1)) == 0) {
        this.dialysisPrescription.dialysis_duration_minute = timeArray[1].charAt(
          timeArray[1].length - 1
        )
      } else {
        this.dialysisPrescription.dialysis_duration_minute = timeArray[1]
      }
      this.timeValue =
          this.dialysisPrescription.dialysis_duration_hour +
          '小时' +
          this.dialysisPrescription.dialysis_duration_minute +
          '分钟'

      this.dialysisPrescription.dialysis_duration =
          parseFloat(this.dialysisPrescription.dialysis_duration_hour) +
          parseFloat(
            (this.dialysisPrescription.dialysis_duration_minute / 60).toFixed(2)
          )
    },
    handleAnticoagulantTimeConfirm: function (val) {
      val = val.replace('小时')
      val = val.replace('分钟')
      let timeArray = val.split(':')
      if (parseInt(timeArray[0].substring(0, 1)) == 0) {
        this.dialysisPrescription.anticoagulant_stop_time_hour = timeArray[0].charAt(
          timeArray[0].length - 1
        )
      } else {
        this.dialysisPrescription.anticoagulant_stop_time_hour = timeArray[0]
      }

      if (parseInt(timeArray[1].substring(0, 1)) == 0) {
        this.dialysisPrescription.anticoagulant_stop_time_min = timeArray[1].charAt(
          timeArray[1].length - 1
        )
      } else {
        this.dialysisPrescription.anticoagulant_stop_time_min = timeArray[1]
      }
      this.anticoagulantTimeValue =
          this.dialysisPrescription.anticoagulant_stop_time_hour +
          '小时' +
          this.dialysisPrescription.anticoagulant_stop_time_min +
          '分钟'
    },

    inputFocus: function (event) {
      var input = event.target
      setTimeout(function () {
        input.scrollIntoView()
      }, 0)

      if (input.setSelectionRange) {
        setTimeout(function () {
          input.setSelectionRange(0, input.value.length)
        }, 0)
      } else if (input.createTextRange) {
        var rng = input.createTextRange()
        rng.move('character', input.value.length)
        rng.select()
      }
    },
    lastInputFocus: function (event) {
      var input = event.target
      event.currentTarget.select()

      setTimeout(function () {
        input.style.marginBottom = '2rem'
        input.parentNode.scrollIntoView()
      }, 0)
    },
    lastInputBlur: function (event) {
      var input = event.target
      setTimeout(function () {
        input.style.marginBottom = ''
      }, 0)
    },
    showSubMenu: function (val) {
      switch (val) {
        case 'hemodialysis_pipelines':
          this.propForm.type = 22
          this.isShowDialog = false
          this.propForm.title = '透析管路'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.hemodialysisPipelinesOptions
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.hemodialysis_pipelines
          this.propForm.click_ref = 'hemodialysis_pipelines'

          break

        case 'puncture_needle':
          this.propForm.type = 21
          this.isShowDialog = false
          this.propForm.title = '穿刺针'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.punctureNeedleOptions
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.puncture_needle
          this.propForm.click_ref = 'puncture_needle'

          break

        case 'epo':
          this.propForm.type = 20
          this.isShowDialog = false
          this.propForm.title = '促红素'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.epoOptions
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.epo
          this.propForm.click_ref = 'epo'
          break

        case 'mode':
          this.propForm.type = 1
          this.isShowDialog = false
          this.propForm.title = '透析模式'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.modeOption
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.mode_id
          this.propForm.click_ref = 'mode'

          break

        case 'replacement_way':
          this.propForm.type = 4
          this.isShowDialog = false
          this.propForm.title = '置换方式'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.replacementWays
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.replacement_way
          this.propForm.click_ref = 'replacement_way'

          break

        case 'anticoagulant':
          this.propForm.type = 5
          this.isShowDialog = false
          this.propForm.title = '抗疑剂'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.anticoagulantsConfit
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.anticoagulant

          this.propForm.click_ref = 'anticoagulant'
          break
        case 'dialysate_formulation':
          this.propForm.type = 6
          this.isShowDialog = false
          this.propForm.title = '透析液配方'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.dialysateFormulationOptions
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.dialysate_formulation
          this.propForm.click_ref = 'dialysate_formulation'
          break
        case 'body_fluid':
          this.propForm.type = 7
          this.isShowDialog = false
          this.propForm.title = '体液过多症状'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.bodyFluidOptions
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.body_fluid
          this.propForm.click_ref = 'body_fluid'
          break
        case 'special_medicine':
          this.propForm.type = 8
          this.isShowDialog = false
          this.propForm.title = '透析前使用特殊药物'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.specialMedicineOptions
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.special_medicine
          this.propForm.click_ref = 'special_medicine'
          break
        case 'displace_liqui_part':
          this.propForm.type = 9
          this.isShowDialog = false
          this.propForm.title = '置换液'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.displaceLiquiPartOptions
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.displace_liqui_part
          this.propForm.click_ref = 'displace_liqui_part'
          break
        case 'blood_access':
          this.propForm.type = 10
          this.isShowDialog = false
          this.propForm.title = '血管通路'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.bloodAccessOptions
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.blood_access
          this.propForm.click_ref = 'blood_access'
          break
        case 'vascular_access_desc':
          this.propForm.type = 10
          this.isShowDialog = false
          this.propForm.title = '血管通路'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.data
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.blood_access
          this.propForm.click_ref = 'vascular_access_desc'
          break

        case 'dialyzer_perfusion_apparatus':
          this.propForm.type = 11
          this.isShowDialog = false
          this.propForm.title = '透析器/灌流器'
          this.visibility = true
          this.propForm.result = []
          this.propForm.isHasOther = 2
          this.propForm.isShowOther = 1
          this.propForm.list = this.dialyzerPerfusionApparatus
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          var apparatus = this.dialysisPrescription.dialyzer_perfusion_apparatus.split(',')

          var newArr = []
          for (let i = 0; i < this.dialyzerPerfusionApparatus.length; i++) {
            for (let j = 0; j < apparatus.length; j++) {
              var name = this.dialyzerPerfusionApparatus[i].name.toUpperCase()
              var app = apparatus[j].toUpperCase()
              if (name == app) {
                newArr.push(this.dialyzerPerfusionApparatus[i].name)
              }
            }
          }
          // console.log('newArr', newArr)
          if (
            this.dialysisPrescription.dialyzer_perfusion_apparatus != undefined ||
              this.dialysisPrescription.dialyzer_perfusion_apparatus != null
          ) {
            if (this.dialysisPrescription.dialyzer_perfusion_apparatus.length > 0) {
              this.propForm.result = newArr
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'dialyzer_perfusion_apparatus'

          break

        case 'blood':
          this.propForm.type = 12
          this.isShowDialog = false
          this.propForm.title = '抽血'
          this.visibility = true
          this.propForm.result = []
          this.propForm.isHasOther = 2
          this.propForm.isShowOther = 1
          this.propForm.list = this.bloods
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          // eslint-disable-next-line no-redeclare
          var apparatus = this.dialysisPrescription.blood.split(',')
          // eslint-disable-next-line no-redeclare
          var newArr = []
          for (let i = 0; i < this.bloods.length; i++) {
            for (let j = 0; j < apparatus.length; j++) {
              var name = this.bloods[i].name.toUpperCase()
              var app = apparatus[j].toUpperCase()
              if (name == app) {
                newArr.push(this.bloods[i].name)
              }
            }
          }
     
          if (
            this.dialysisPrescription.blood != undefined ||
              this.dialysisPrescription.blood != null
          ) {
            if (this.dialysisPrescription.blood.length > 0) {
              this.propForm.result = newArr
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'blood'

          break

        case 'dialysis_dialyszers':

          for (let i = 0; i < this.dialyszers.length; i++) {
            this.dialyszers[i].name = this.dialyszers[i].specification_name
          }
          this.propForm.type = 14
          this.isShowDialog = false
          this.propForm.title = '透析器'
          this.visibility = true
          this.propForm.result = []
          this.propForm.isHasOther = 2
          this.propForm.isShowOther = 1
          this.propForm.list = this.dialyszers
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          var apparatus = this.dialysisPrescription.dialysis_dialyszers.split(',')

          var newArr = []
          for (let i = 0; i < this.dialyszers.length; i++) {
            for (let j = 0; j < apparatus.length; j++) {
              var name = this.dialyszers[i].name.toUpperCase()
              var app = apparatus[j].toUpperCase()
              if (name == app) {
                newArr.push(this.dialyszers[i].name)
              }
            }
          }

          if (this.dialysisPrescription.dialysis_dialyszers != undefined || this.dialysisPrescription.dialysis_dialyszers != null) {
            if (this.dialysisPrescription.dialysis_dialyszers.length > 0) {
              this.propForm.result = newArr
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'dialysis_dialyszers'
          break

        case 'dialysis_irrigation':
          for (let i = 0; i < this.irrigation.length; i++) {
            this.irrigation[i].name = this.irrigation[i].specification_name
          }

          this.propForm.type = 15
          this.isShowDialog = false
          this.propForm.title = '灌流器'
          this.visibility = true
          this.propForm.result = []
          this.propForm.isHasOther = 2
          this.propForm.isShowOther = 1
          this.propForm.list = this.irrigation
          this.propForm.optionList = []
          this.propForm.isMultiple = 2

          var apps = this.dialysisPrescription.dialysis_irrigation.split(',')

          var newArr = []
          for (let i = 0; i < this.irrigation.length; i++) {
            for (let j = 0; j < apps.length; j++) {
              var name = this.irrigation[i].name.toUpperCase()
              var app = apps[j].toUpperCase()
              if (name == app) {
                newArr.push(this.irrigation[i].name)
              }
            }
          }

          if (this.dialysisPrescription.dialysis_irrigation != undefined || this.dialysisPrescription.dialysis_irrigation != null) {
            if (this.dialysisPrescription.dialysis_irrigation.length > 0) {

            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.result = newArr
          this.propForm.click_ref = 'dialysis_irrigation'
          break

        case 'dialysis_strainer':
          for (let i = 0; i < this.dialysisStrainerList.length; i++) {
            this.dialysisStrainerList[i].name = this.dialysisStrainerList[i].specification_name
          }

          this.propForm.type = 27
          this.isShowDialog = false
          this.propForm.title = '滤过器'
          this.visibility = true
          this.propForm.result = []
          this.propForm.isHasOther = 2
          this.propForm.isShowOther = 1
          this.propForm.list = this.dialysisStrainerList
          this.propForm.optionList = []
          this.propForm.isMultiple = 2

          var apps = this.dialysisPrescription.dialysis_strainer.split(',')

          var newArr = []
          for (let i = 0; i < this.dialysisStrainerList.length; i++) {
            for (let j = 0; j < apps.length; j++) {
              var name = this.dialysisStrainerList[i].name.toUpperCase()
              var app = apps[j].toUpperCase()
              if (name == app) {
                newArr.push(this.dialysisStrainerList[i].name)
              }
            }
          }

          if (this.dialysisPrescription.dialysis_strainer != undefined || this.dialysisPrescription.dialysis_strainer != null) {
            if (this.dialysisPrescription.dialysis_strainer.length > 0) {

            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.result = newArr
          this.propForm.click_ref = 'dialysis_strainer'
          break
        case 'admin_user_id':
          this.propForm.type = 25
          this.isShowDialog = false
          this.propForm.title = '处方医生'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.adminMapList
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.admin_user_id

          this.propForm.click_ref = 'admin_user_id'
          break
        case 'water_machine':
          this.propForm.type = 26
          this.isShowDialog = false
          this.propForm.title = '带水上机'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.machineList
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.dialysisPrescription.water_machine

          this.propForm.click_ref = 'water_machine'
          break
      }
    },
    QueryPartById: function (val) {
      let vascular_access_part_name = ''
      let vascular_access = getDataConfig(
        'hemodialysis',
        'vascular_access_desc'
      )
      for (let i = 0; i < vascular_access.length; i++) {
        if (vascular_access[i].id == val) {
          vascular_access_part_name = vascular_access[i].name
        }
      }
      return vascular_access_part_name
    },
    menuCancle: function () {
      this.visibility = false
      this.isShowDialog = true
      this.$nextTick(() => {
        if (
          this.$refs[this.propForm.click_ref] != undefined &&
            this.$refs[this.propForm.click_ref] != null
        ) {
          this.$refs[this.propForm.click_ref].scrollIntoView()
        }
      })
    },
    menuCancleThree: function () {
      this.advice_visibility = false
      this.isShowDialog = true
    },
    menuCancleFour:function(){
     this.infor_visibility = false
     this.isShowDialog = true
    },

    menuMsgTip: function () {
      this.msgtip_visibility = false
      this.isShowDialog = true
    },

    menuComfirmThree: function (targetAdvices, start_time) {
      if (targetAdvices.length > 0) {
        if (this.is_pre == 1) {
          Toast.loading({forbidClick: true, duration: 0})
          var arr = this.dialysisPrescription

          let ParamsQuery = arr
          if (this.$route.query.patient_id) {
            ParamsQuery['patient'] = this.$route.query.patient_id
          } else {
            ParamsQuery['patient'] = this.patient_prop.id
          }

          ParamsQuery['record_date'] = this.record_date

          if (this.prescription_prop.id == '') {
            ParamsQuery['mode'] = '1'
          } else {
            if (this.prescription_prop.creater == 0) {
              ParamsQuery['mode'] = '1'
            } else {
              ParamsQuery['mode'] = '2'
              if (
                this.prescription_prop.creater !=
                  this.$store.getters.user.admin.id
              ) {
                ParamsQuery['mode'] = '3'
              }
            }
          }

          commitDialysisPrescription(ParamsQuery)
            .then(response => {
              if (response.data.state == 0) {
                Toast.fail(response.data.msg)
                if(response.data.code == 600000008){
                  this.advice_visibility = false
                  this.infor_visibility = true
                  
                }
                return false
              } else {
                Toast.success('提交成功')

                var date = new Date()
                var year = date.getFullYear()
                var month = date.getMonth() + 1
                var day = date.getDate()

                var hours = date.getHours()
                var minites = date.getMinutes()

                if (month < 10) {
                  month = '0' + month
                }
                if (day < 10) {
                  day = '0' + day
                }

                var nowDate = start_time

                var dateArr = nowDate.split(' ')
                let params = {
                  advices: targetAdvices,
                  advice_date: dateArr[0],
                  advice_doctor: targetAdvices[0].advice_doctor,
                  advice_type: targetAdvices[0].advice_type,
                  parent_id: this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id,
                  start_time: nowDate,
                  remark: ''
                }

                CreateGroupAdvice(this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id, 0, params).then(
                  rs => {
                    var resp = rs.data
                    if (resp.state == 1) {
                      this.$emit(
                        'prescription',
                        response.data.data.prescription,
                        resp.data.advices
                      )
                    } else {
                    }
                  }
                )

                this.finish()
              }
            })
            .catch(error => {
              Toast.fail('请求失败')
            })
        } else if (this.is_pre == 2) {
          Toast.loading({forbidClick: true, duration: 0})
          var arr = this.dialysisPrescription

          let ParamsQuery = arr

          if (this.$route.query.patient_id) {
            ParamsQuery['patient'] = this.$route.query.patient_id
          } else {
            ParamsQuery['patient'] = this.patient_prop.id
          }
          ParamsQuery['record_date'] = this.record_date
          ParamsQuery['mode'] = '1'

          postSolution(ParamsQuery)
            .then(response => {
              if (response.data.state == 0) {
                 if(response.data.code == 600000008){
                  this.advice_visibility = false
                  this.infor_visibility = true
                  
                }
                Toast.fail(response.data.msg)
                return false
              } else {
                Toast.success('提交成功')
                var date = new Date()
                var year = date.getFullYear()
                var month = date.getMonth() + 1
                var day = date.getDate()

                var hours = date.getHours()
                var minites = date.getMinutes()

                if (month < 10) {
                  month = '0' + month
                }
                if (day < 10) {
                  day = '0' + day
                }
                if (hours < 10) {
                  hours = '0' + hours
                }
                if (minites < 10) {
                  minites = '0' + minites
                }
                var nowDate =
                   start_time
                var dateArr = nowDate.split(' ')
                let params = {
                  advices: targetAdvices,
                  advice_date: dateArr[0],
                  advice_doctor: targetAdvices[0].advice_doctor,
                  advice_type: targetAdvices[0].advice_type,
                  parent_id: this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id,
                  start_time: nowDate,
                  remark: ''
                }
                CreateGroupAdvice(this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id, 0, params).then(
                  rs => {
                    var resp = rs.data
                    if (resp.state == 1) {
                      this.$emit(
                        'prescription',
                        response.data.data.prescription,
                        resp.data.advices
                      )
                      this.$emit(
                        'longSolution',
                        response.data.data.solution,
                        resp.data.advices
                      )
                    } else {
                    }
                  }
                )
                this.finish()
              }
            })
            .catch(error => {
              Toast.fail('请求失败')
            })
        }
      } else {
        if (this.is_pre == 1) {
          Toast.loading({forbidClick: true, duration: 0})
          var arr = this.dialysisPrescription

          let ParamsQuery = arr

          if (this.$route.query.patient_id) {
            ParamsQuery['patient'] = this.$route.query.patient_id
          } else {
            ParamsQuery['patient'] = this.patient_prop.id
          }
          ParamsQuery['record_date'] = this.record_date
          if (this.prescription_prop.id == '') {
            ParamsQuery['mode'] = '1'
          } else {
            if (this.prescription_prop.creater == 0) {
              ParamsQuery['mode'] = '1'
            } else {
              ParamsQuery['mode'] = '2'
              if (
                this.prescription_prop.creater !=
                  this.$store.getters.user.admin.id
              ) {
                ParamsQuery['mode'] = '3'
              }
            }
          }
          commitDialysisPrescription(ParamsQuery).then(response => {
            if (response.data.state == 0) {
               if(response.data.code == 600000008){
                  this.advice_visibility = false
                  this.infor_visibility = true
                  
              }
              Toast.fail(response.data.msg)
              return false
            } else {
              Toast.success('提交成功')

              this.$emit(
                'prescription',
                response.data.data.prescription,
                this.doctorAdvices
              )
              this.finish()
            }
          })
        } else if (this.is_pre == 2) {
          Toast.loading({forbidClick: true, duration: 0})
          var arr = this.dialysisPrescription

          let ParamsQuery = arr

          if (this.$route.query.patient_id) {
            ParamsQuery['patient'] = this.$route.query.patient_id
          } else {
            ParamsQuery['patient'] = this.patient_prop.id
          }
          ParamsQuery['record_date'] = this.record_date
          ParamsQuery['mode'] = '1'
          postSolution(ParamsQuery)
            .then(response => {
              if (response.data.state == 0) {
                 if(response.data.code == 600000008){
                  this.advice_visibility = false
                  this.infor_visibility = true
                  
              }
                Toast.fail(response.data.msg)
                return false
              } else {
                Toast.success('提交成功')
                this.$emit(
                  'longSolution',
                  response.data.data.solution,
                  this.doctorAdvices
                )
                this.$emit(
                  'prescription',
                  response.data.data.prescription,
                  this.doctorAdvices
                )
                this.finish()
              }
            })
            .catch(error => {
              Toast.fail('请求失败')
            })
        }
      }
    },

    menuComfirm: function (val) {
      this.visibility = false
      this.isShowDialog = true
      this.$nextTick(() => {
        if (
          this.$refs[this.propForm.click_ref] != undefined &&
            this.$refs[this.propForm.click_ref] != null
        ) {
          this.$refs[this.propForm.click_ref].scrollIntoView()
        }
      })
      switch (val.type) {
        case 1:
          Toast.loading({
            forbidClick: true,
            duration: 0,
            message: '切换模式中,请稍候'
          })
          // 从服务器获取对应模式的长期处方
          let ParamsQuery = {}
          ParamsQuery['patient_id'] = this.$route.query.patient_id
          ParamsQuery['mode_id'] = val.selectId
          GetSolution(ParamsQuery)
            .then(response => {
              if (response.data.state == 0) {
                Toast.fail(response.data.msg)
                return false
              } else {
                Toast.success('切换成功')
                if (response.data.data.solution != null) {
                  for (const key in response.data.data.solution) {
                    // 长期处方不为空
                    if (key != 'target_ultrafiltration' && key != 'niprocart' && key != 'target_ultrafiltration' && key != 'jms' && key != 'fistula_needle_set' && key != 'fistula_needle_set_16' &&
                        key != 'hemoperfusion' && key != 'dialyser_sterilised' && key != 'filtryzer' && key != 'target_ktv' && key != 'dialyzers' &&
                        key != 'injector' && key != 'bloodlines' && key != 'tubing_hemodialysis' && key != 'package' && key != 'a_liquid') {
                      this.dialysisPrescription[key] =
                          response.data.data.solution[key]
                    }
                  }
                  if (this.$store.getters.user.template_info.org_id == 9671 || this.$store.getters.user.template_info.org_id == 9675 || this.$store.getters.user.template_info.org_id == 10340) {
                    this.dialysisPrescription.sodium = 138
                    this.dialysisPrescription.bicarbonate = 31.1
                    this.dialysisPrescription.dialysate_flow = 500
                    if (this.last_prescription != null && response.data.data.dialysisPrescription != null) {
                      this.dialysisPrescription.remark = response.data.data.dialysisPrescription.remark
                    }
                  }
                } else {
                  if (response.data.data.prescription != null) {
                    // 临时处方不为空
                    for (const key in response.data.data.prescription) {
                      if (key != 'target_ultrafiltration' && key != 'niprocart' && key != 'target_ultrafiltration' && key != 'jms' && key != 'fistula_needle_set' && key != 'fistula_needle_set_16' &&
                          key != 'hemoperfusion' && key != 'dialyser_sterilised' && key != 'filtryzer' && key != 'target_ktv' && key != 'dialyzers' &&
                          key != 'injector' && key != 'bloodlines' && key != 'tubing_hemodialysis' && key != 'package' && key != 'a_liquid') {
                        this.dialysisPrescription[key] =
                            response.data.data.prescription[key]
                      }
                    }
                  } else if (response.data.data.system_prescription != null) {
                    for (const key in response.data.data.system_prescription) {
                      if (key != 'target_ultrafiltration' && key != 'niprocart' && key != 'target_ultrafiltration' && key != 'jms' && key != 'fistula_needle_set' && key != 'fistula_needle_set_16' &&
                          key != 'hemoperfusion' && key != 'dialyser_sterilised' && key != 'filtryzer' && key != 'target_ktv' && key != 'dialyzers' &&
                          key != 'injector' && key != 'bloodlines' && key != 'tubing_hemodialysis' && key != 'package' && key != 'a_liquid') {
                        this.dialysisPrescription[key] =
                            response.data.data.system_prescription[key]
                      }
                    }
                  } else {
                    for (const key in this.dialysisPrescription) {
                      // 临时处方为空
                      if (key != 'target_ultrafiltration' && key != 'niprocart' && key != 'target_ultrafiltration' && key != 'jms' && key != 'fistula_needle_set' && key != 'fistula_needle_set_16' &&
                          key != 'hemoperfusion' && key != 'dialyser_sterilised' && key != 'filtryzer' && key != 'target_ktv' && key != 'dialyzers' &&
                          key != 'injector' && key != 'bloodlines' && key != 'tubing_hemodialysis' && key != 'package' && key != 'a_liquid') {
                        this.dialysisPrescription[key] = ''
                      }
                    }
                    this.dialysisPrescription.mode_id = val.selectId
                    if (this.$store.getters.user.template_info.org_id == 9671 || this.$store.getters.user.template_info.org_id == 9675 || this.$store.getters.user.template_info.org_id == 10340) {
                      this.dialysisPrescription.sodium = 138
                      this.dialysisPrescription.bicarbonate = 31.1
                      this.dialysisPrescription.dialysate_flow = 500
                      if (this.last_prescription != null && response.data.data.system_prescription != null && response.data.data.system_prescription.remark == '') {
                        this.dialysisPrescription.remark = response.data.data.system_prescription.remark
                      }
                    }
                  }
                }
              }
              if (response.data.data.solution == null) {
                if (this.$store.getters.user.template_info.org_id == 9671 || this.$store.getters.user.template_info.org_id == 9675 || this.$store.getters.user.template_info.org_id == 10340) {
                  this.dialysisPrescription.sodium = 138
                  this.dialysisPrescription.bicarbonate = 31.1
                  this.dialysisPrescription.dialysate_flow = 500
                  if (this.last_prescription != null) {
                    this.dialysisPrescription.remark = this.last_prescription.remark
                  }
                }
              }

              if (
                this.dialysisPrescription.dialysis_duration_hour === '' ||
                  this.dialysisPrescription.dialysis_duration_minute === ''
              ) {
                this.timeValue = ''
                this.time = '03:00'
              } else {
                this.timeValue =
                    this.dialysisPrescription.dialysis_duration_hour +
                    '小时' +
                    this.dialysisPrescription.dialysis_duration_minute +
                    '分钟'
                this.time =
                    (this.dialysisPrescription.dialysis_duration_hour > 10
                      ? this.dialysisPrescription.dialysis_duration_hour
                      : '0' + this.dialysisPrescription.dialysis_duration_hour) +
                    ':' +
                    (this.dialysisPrescription.dialysis_duration_minute > 10
                      ? this.dialysisPrescription.dialysis_duration_minute
                      : '0' + this.dialysisPrescription.dialysis_duration_minute)
              }
            })
            .catch(error => {
              Toast.fail('请求失败')
            })
          break
        case 2:
          this.dialysisPrescription.dialyzer = val.selectId
          break

        case 3:
          this.dialysisPrescription.perfusion_apparatus = val.selectId
          break
        case 4:
          this.dialysisPrescription.replacement_way = val.selectId
          break
        case 5:
          this.dialysisPrescription.anticoagulant = val.selectId

          if (
            typeof this.anticoagulantsConfit[val.selectId] === 'undefined' ||
              this.anticoagulantsConfit[val.selectId] == null
          ) {
            return
          }
          this.anticoagulant = this.anticoagulantsConfit[val.selectId]
          break
        case 6:
          this.dialysisPrescription.dialysate_formulation = val.selectId
          break
        case 7:
          this.dialysisPrescription.body_fluid = val.selectId
          break
        case 8:
          this.dialysisPrescription.special_medicine = val.selectId
          break
        case 9:
          this.dialysisPrescription.displace_liqui_part = val.selectId
          break
        case 10:
          this.dialysisPrescription.blood_access = val.selectId
          break
        case 11:

          this.dialysisPrescription.dialyzer_perfusion_apparatus = val.result.join(',')
          break
        case 12:
          this.dialysisPrescription.blood = val.result.join(',')
          break
        case 14:
          this.dialysisPrescription.dialysis_dialyszers = val.result.join(',')

          break
        case 15:
          this.dialysisPrescription.dialysis_irrigation = val.result.join(',')
          break
        case 20:
          this.dialysisPrescription.epo = val.selectId
          break
        case 21:
          this.dialysisPrescription.puncture_needle = val.selectId
          break
        case 22:
          this.dialysisPrescription.hemodialysis_pipelines = val.selectId
          break
        case 25:
          this.dialysisPrescription.admin_user_id = val.selectId
          break
        case 26:
          this.dialysisPrescription.water_machine = val.selectId
          break
        case 27:
          this.dialysisPrescription.dialysis_strainer = val.result.join(',')
          break
      }
    },
    GetModeByModeId: function (val) {
      let treatment_mode_name = ''
      let treatment_mode = this.modeOption

      for (let keys in treatment_mode) {
        if (treatment_mode[keys].id == val) {
          treatment_mode_name = treatment_mode[keys].name
        }
      }
      for (let keys in treatment_mode) {
        if (treatment_mode[keys].id == val) {
          treatment_mode_name = treatment_mode[keys].name
          var treatment_mode_id = treatment_mode[keys].id
          if (
            treatment_mode_id === 1 ||
              treatment_mode_id === 3 ||
              treatment_mode_id === 4 ||
              treatment_mode_id === 6 ||
              treatment_mode_id === 7 ||
              treatment_mode_id === 8 ||
              treatment_mode_id === 9 ||
              treatment_mode_id === 10 ||
              treatment_mode_id === 11 ||
              treatment_mode_id === 13 ||
              treatment_mode_id === 14 ||
              treatment_mode_id === 15 ||
              treatment_mode_id === 16 ||
              treatment_mode_id === 19
          ) {
            this.zhiShow = false
            this.totalShow = false
            this.huShow = false
          } else {
            this.zhiShow = true
            this.totalShow = true
            this.huShow = true
          }
        }
      }

      return treatment_mode_name
    },

    GetDialysateFormulationById: function (val) {
      let name = ''
      let dfl = this.dialysateFormulationOptions.length
      for (let index = 0; index < dfl; index++) {
        if (this.dialysateFormulationOptions[index].id == val) {
          name = this.dialysateFormulationOptions[index].name
          break
        }
      }
      return name
    },
    GetDialyzerById: function (val) {
      let dialyzer_name = ''
      let machines = this.machines_prop

      for (let i = 0; i < machines.length; i++) {
        if (machines[i].id == val) {
          dialyzer_name = machines[i].name
        }
      }

      return dialyzer_name
    },
    GetPerfusionApparatusById: function (val) {
      let perfusion_apparatus_name = ''
      let perfusion_apparatus = this.perfusion_apparatus
      for (let i = 0; i < perfusion_apparatus.length; i++) {
        if (perfusion_apparatus[i].id == val) {
          perfusion_apparatus_name = perfusion_apparatus[i].name
        }
      }

      return perfusion_apparatus_name
    },
    GetReplacementWayById: function (val) {
      let replacement_ways_name = ''
      let replacement_ways = this.replacementWays
      for (let i = 0; i < replacement_ways.length; i++) {
        if (replacement_ways[i].id == val) {
          replacement_ways_name = replacement_ways[i].name
        }
      }
      return replacement_ways_name
    },
    GetAnticoagulantById: function (val) {

      let anticoagulan_name = ''
      let anticoagulant = this.anticoagulantsConfitTwo
      for (let keys in anticoagulant) {
        if (anticoagulant[keys].id == val) {
          anticoagulan_name = anticoagulant[keys].name
        }
      }
      return anticoagulan_name
    },
    getAdminMap: function (val) {
      let name = ''
      let anticoagulant = this.adminMapList
      for (let keys in anticoagulant) {
        if (anticoagulant[keys].id == val) {
          name = anticoagulant[keys].name
        }
      }
      return name
    },
    getWaterMachine (val) {
      let name = ''
      let anticoagulant = this.machineList
      for (let keys in anticoagulant) {
        if (anticoagulant[keys].id == val) {
          name = anticoagulant[keys].name
        }
      }
      return name
    },
    commitInfo: function () {
      if(this.$store.getters.user.template_info.org_id == 10340 || this.$store.getters.user.template_info.org_id == 3877){
       if(this.dialysisPrescription.prescribing_number == 0){
        Toast.fail('请填写开药数量!')
        return
       }
       if(this.dialysisPrescription.anticoagulant == 0){
        Toast.fail('请填写抗凝剂!')
        return
       }
      }
      if (this.dialysisPrescription.anticoagulant == 1) {
        this.dialysisPrescription.anticoagulant_weichi = '0'
        this.dialysisPrescription.anticoagulant_shouji = '0'
        this.dialysisPrescription.anticoagulant_zongliang = '0'
      }
      if (this.$store.getters.user.template_info.template_id == 6) {
        if (this.dialysisPrescription.mode_id == 2) {
          if (
            this.dialysisPrescription.displace_liqui_part == 0 ||
              this.dialysisPrescription.displace_liqui_part == -2 ||
              this.dialysisPrescription.displace_liqui_value == 0 ||
              this.dialysisPrescription.displace_liqui_value == ''
          ) {
            Toast.fail('HDF模式下置换方式和置换液总量不能为空！')
            return
          }
        }
      }

      this.is_pre = 1
      if (this.prescription_prop.id == '') {
        if (this.is_open == 0) {
          Toast.loading({forbidClick: true, duration: 0})
          var arr = this.dialysisPrescription

          let ParamsQuery = arr
          if (this.$route.query.patient_id) {
            ParamsQuery['patient'] = this.$route.query.patient_id
          } else {
            ParamsQuery['patient'] = this.patient_prop.id
          }

          ParamsQuery['record_date'] = this.record_date
          ParamsQuery['mode'] = '1'
          if (ParamsQuery.water_machine == '0') {
            ParamsQuery.water_machine = '请选择'
          }
          if (ParamsQuery.water_machine == '1') {
            ParamsQuery.water_machine = '是'
          }
          if (ParamsQuery.water_machine == '2') {
            ParamsQuery.water_machine = '否'
          }
          commitDialysisPrescription(ParamsQuery)
            .then(response => {
              if (response.data.state == 0) {
                Toast.fail(response.data.msg)
                 if(response.data.code == 600000008){
                  this.advice_visibility = false
                  this.infor_visibility = true
                  
                }
                return false
              } else {
                Toast.success('提交成功')

                this.$emit(
                  'prescription',
                  response.data.data.prescription,
                  this.doctorAdvices
                )
                this.finish()
              }
            })
            .catch(error => {
              Toast.fail('请求失败')
            })
        } else if (this.is_open == 1) {
          if (this.targetAdvices.length > 0) {
            // 弹框推送提醒
            this.advicePropForm.list = this.targetAdvices
            this.advicePropForm.operators = this.admin_users_prop
            this.advice_visibility = true
            this.isShowDialog = false
            for (let i = 0; i < this.advicePropForm.list.length; i++) {
              if (
                this.advicePropForm.list[i].parent_id == 0 &&
                  this.advicePropForm.list[i].isCheck == 1
              ) {
                this.advicePropForm.result.push(this.advicePropForm.list[i].id)
              }
            }
          } else {
            Toast.loading({forbidClick: true, duration: 0})
            var arr = this.dialysisPrescription

            let ParamsQuery = arr
            if (this.$route.query.patient_id) {
              ParamsQuery['patient'] = this.$route.query.patient_id
            } else {
              ParamsQuery['patient'] = this.patient_prop.id
            }
            ParamsQuery['record_date'] = this.record_date
            ParamsQuery['mode'] = '1'
            if (ParamsQuery.water_machine == '0') {
              ParamsQuery.water_machine = '请选择'
            }
            if (ParamsQuery.water_machine == '1') {
              ParamsQuery.water_machine = '是'
            }
            if (ParamsQuery.water_machine == '2') {
              ParamsQuery.water_machine = '否'
            }
            commitDialysisPrescription(ParamsQuery)
              .then(response => {
                if (response.data.state == 0) {
                   if(response.data.code == 600000008){
                    this.advice_visibility = false
                    this.infor_visibility = true
                  
                   }
                  Toast.fail(response.data.msg)
                  return false
                } else {
                  Toast.success('提交成功')

                  this.$emit(
                    'prescription',
                    response.data.data.prescription,
                    this.doctorAdvices
                  )
                  this.finish()
                }
              })
              .catch(error => {
                Toast.fail('请求失败')
              })
          }
        } else if (this.is_open == 2) {
          if (this.waitUploadAdvices.length > 0) {
            Toast.loading({forbidClick: true, duration: 0})
            var arr = this.dialysisPrescription

            let ParamsQuery = arr
            if (this.$route.query.patient_id) {
              ParamsQuery['patient'] = this.$route.query.patient_id
            } else {
              ParamsQuery['patient'] = this.patient_prop.id
            }
            ParamsQuery['record_date'] = this.record_date
            ParamsQuery['mode'] = '1'
            if (ParamsQuery.water_machine == '0') {
              ParamsQuery.water_machine = '请选择'
            }
            if (ParamsQuery.water_machine == '1') {
              ParamsQuery.water_machine = '是'
            }
            if (ParamsQuery.water_machine == '2') {
              ParamsQuery.water_machine = '否'
            }
            commitDialysisPrescription(ParamsQuery)
              .then(response => {
                if (response.data.state == 0) {
                   if(response.data.code == 600000008){
                    this.advice_visibility = false
                    this.infor_visibility = true
                  
                  }
                  Toast.fail(response.data.msg)
                  return false
                } else {
                  Toast.success('提交成功')

                  var date = new Date()
                  var year = date.getFullYear()
                  var month = date.getMonth() + 1
                  var day = date.getDate()

                  var hours = date.getHours()
                  var minites = date.getMinutes()

                  if (month < 10) {
                    month = '0' + month
                  }
                  if (day < 10) {
                    day = '0' + day
                  }
                  if (hours < 10) {
                    hours = '0' + hours
                  }
                  if (minites < 10) {
                    minites = '0' + minites
                  }
                  var nowDate =
                      year +
                      '-' +
                      month +
                      '-' +
                      day +
                      ' ' +
                      hours +
                      ':' +
                      minites

                  var advice_date = year + '-' + month + '-' + day

                  let params = {
                    advices: this.waitUploadAdvices,
                    advice_date: this.$route.query.date ? parseTime(
                      this.$route.query.date,
                      '{y}-{m}-{d}'
                    ) : advice_date,
                    advice_doctor: this.waitUploadAdvices[0].advice_doctor,
                    advice_type: this.waitUploadAdvices[0].advice_type,
                    parent_id: this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id,
                    start_time: nowDate,
                    remark: ''
                  }
                  CreateGroupAdvice(
                    this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id,
                    0,
                    params
                  ).then(rs => {
                    var resp = rs.data
                    if (resp.state == 1) {
                      this.$emit(
                        'prescription',
                        response.data.data.prescription,
                        resp.data.advices
                      )
                    } else {
                    }
                  })

                  this.finish()
                }
              })
              .catch(error => {
                Toast.fail('请求失败')
              })
          } else {
            Toast.loading({forbidClick: true, duration: 0})
            var arr = this.dialysisPrescription

            let ParamsQuery = arr
            if (this.$route.query.patient_id) {
              ParamsQuery['patient'] = this.$route.query.patient_id
            } else {
              ParamsQuery['patient'] = this.patient_prop.id
            }
            ParamsQuery['record_date'] = this.record_date
            if (ParamsQuery.water_machine == '0') {
              ParamsQuery.water_machine = '请选择'
            }
            if (ParamsQuery.water_machine == '1') {
              ParamsQuery.water_machine = '是'
            }
            if (ParamsQuery.water_machine == '2') {
              ParamsQuery.water_machine = '否'
            }
            commitDialysisPrescription(ParamsQuery)
              .then(response => {
                if (response.data.state == 0) {
                  Toast.fail(response.data.msg)
               if(response.data.code == 600000008){
                  this.advice_visibility = false
                  this.infor_visibility = true
                  
              }
                  return false
                } else {
                  this.advice_visibility = false

                  Toast.success('提交成功')
                  this.$emit(
                    'prescription',
                    response.data.data.prescription,
                    this.doctorAdvices
                  )
                  this.finish()
                }
              })
              .catch(error => {
                Toast.fail('请求失败')
              })
          }
        }
      } else {
        if (this.prescription_prop.creater == 0) {
          if (this.is_open == 0) {
            Toast.loading({forbidClick: true, duration: 0})
            var arr = this.dialysisPrescription

            let ParamsQuery = arr
            // console.log('ParamsQueryFive', ParamsQuery)
            if (this.$route.query.patient_id) {
              ParamsQuery['patient'] = this.$route.query.patient_id
            } else {
              ParamsQuery['patient'] = this.patient_prop.id
            }
            ParamsQuery['record_date'] = this.record_date
            ParamsQuery['mode'] = '1'
            if (ParamsQuery.water_machine == '0') {
              ParamsQuery.water_machine = '请选择'
            }
            if (ParamsQuery.water_machine == '1') {
              ParamsQuery.water_machine = '是'
            }
            if (ParamsQuery.water_machine == '2') {
              ParamsQuery.water_machine = '否'
            }
            commitDialysisPrescription(ParamsQuery)
              .then(response => {
                if (response.data.state == 0) {
                   if(response.data.code == 600000008){
                  this.advice_visibility = false
                  this.infor_visibility = true
                  
              }
                  Toast.fail(response.data.msg)
                  return false
                } else {
                  Toast.success('提交成功')

                  this.$emit(
                    'prescription',
                    response.data.data.prescription,
                    this.doctorAdvices
                  )
                  this.finish()
                }
              })
              .catch(error => {
                Toast.fail('请求失败')
              })
          } else
          if (this.is_open == 1) {
            if (this.targetAdvices.length > 0) {
              // 弹框推送提醒
              this.advicePropForm.list = this.targetAdvices
              this.advicePropForm.operators = this.admin_users_prop
              this.advice_visibility = true
              this.isShowDialog = false

              for (let i = 0; i < this.advicePropForm.list.length; i++) {
                if (
                  this.advicePropForm.list[i].parent_id == 0 &&
                    this.advicePropForm.list[i].isCheck == 1
                ) {
                  this.advicePropForm.result.push(
                    this.advicePropForm.list[i].id
                  )
                }
              }
            } else {
              Toast.loading({forbidClick: true, duration: 0})
              var arr = this.dialysisPrescription

              let ParamsQuery = arr
              // console.log('ParamsQuerySIx', ParamsQuery)
              if (this.$route.query.patient_id) {
                ParamsQuery['patient'] = this.$route.query.patient_id
              } else {
                ParamsQuery['patient'] = this.patient_prop.id
              }
              ParamsQuery['record_date'] = this.record_date
              ParamsQuery['mode'] = '1'
              if (ParamsQuery.water_machine == '0') {
                ParamsQuery.water_machine = '请选择'
              }
              if (ParamsQuery.water_machine == '1') {
                ParamsQuery.water_machine = '是'
              }
              if (ParamsQuery.water_machine == '2') {
                ParamsQuery.water_machine = '否'
              }
              commitDialysisPrescription(ParamsQuery)
                .then(response => {
                  if (response.data.state == 0) {
                     if(response.data.code == 600000008){
                      this.advice_visibility = false
                      this.infor_visibility = true
                  
                    }
                    Toast.fail(response.data.msg)
                    return false
                  } else {
                    Toast.success('提交成功')

                    this.$emit(
                      'prescription',
                      response.data.data.prescription,
                      this.doctorAdvices
                    )
                    this.finish()
                  }
                })
                .catch(error => {
                  Toast.fail('请求失败')
                })
            }
          } else
          if (this.is_open == 2) {
            if (this.waitUploadAdvices.length > 0) {
              Toast.loading({forbidClick: true, duration: 0})
              var arr = this.dialysisPrescription

              let ParamsQuery = arr
              // console.log('ParamsQuerySeven', ParamsQuery)
              if (this.$route.query.patient_id) {
                ParamsQuery['patient'] = this.$route.query.patient_id
              } else {
                ParamsQuery['patient'] = this.patient_prop.id
              }
              ParamsQuery['record_date'] = this.record_date
              ParamsQuery['mode'] = '1'
              if (ParamsQuery.water_machine == '0') {
                ParamsQuery.water_machine = '请选择'
              }
              if (ParamsQuery.water_machine == '1') {
                ParamsQuery.water_machine = '是'
              }
              if (ParamsQuery.water_machine == '2') {
                ParamsQuery.water_machine = '否'
              }
              commitDialysisPrescription(ParamsQuery)
                .then(response => {
                  if (response.data.state == 0) {
                     if(response.data.code == 600000008){
                        this.advice_visibility = false
                        this.infor_visibility = true
                  
                     }
                    Toast.fail(response.data.msg)
                    return false
                  } else {
                    var date = new Date()
                    var year = date.getFullYear()
                    var month = date.getMonth() + 1
                    var day = date.getDate()

                    var hours = date.getHours()
                    var minites = date.getMinutes()

                    if (month < 10) {
                      month = '0' + month
                    }
                    if (day < 10) {
                      day = '0' + day
                    }
                    if (hours < 10) {
                      hours = '0' + hours
                    }
                    if (minites < 10) {
                      minites = '0' + minites
                    }
                    var nowDate =
                        year +
                        '-' +
                        month +
                        '-' +
                        day +
                        ' ' +
                        hours +
                        ':' +
                        minites

                    var advice_date = year + '-' + month + '-' + day

                    let params = {
                      advices: this.waitUploadAdvices,
                      advice_date: this.$route.query.date ? parseTime(
                        this.$route.query.date,
                        '{y}-{m}-{d}'
                      ) : advice_date,
                      advice_doctor: this.waitUploadAdvices[0].advice_doctor,
                      advice_type: this.waitUploadAdvices[0].advice_type,
                      parent_id: this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id,
                      start_time: nowDate,
                      remark: ''
                    }

                    CreateGroupAdvice(
                      this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id,
                      0,
                      params
                    ).then(rs => {
                      var resp = rs.data
                      if (resp.state == 1) {
                        this.doctorAdvices = resp.data.advices
                        this.$emit(
                          'prescription',
                          response.data.data.prescription,
                          resp.data.advices
                        )
                      } else {
                      }
                    })

                    Toast.success('提交成功')
                    this.finish()
                  }
                })
                .catch(error => {
                  Toast.fail('请求失败')
                })
            } else {
              Toast.loading({forbidClick: true, duration: 0})
              var arr = this.dialysisPrescription

              let ParamsQuery = arr
              // console.log('ParamsQueryeight', ParamsQuery)
              if (this.$route.query.patient_id) {
                ParamsQuery['patient'] = this.$route.query.patient_id
              } else {
                ParamsQuery['patient'] = this.patient_prop.id
              }
              ParamsQuery['record_date'] = this.record_date
              ParamsQuery['mode'] = '1'
              if (ParamsQuery.water_machine == '0') {
                ParamsQuery.water_machine = '请选择'
              }
              if (ParamsQuery.water_machine == '1') {
                ParamsQuery.water_machine = '是'
              }
              if (ParamsQuery.water_machine == '2') {
                ParamsQuery.water_machine = '否'
              }
              commitDialysisPrescription(ParamsQuery)
                .then(response => {
                  if (response.data.state == 0) {
                     if(response.data.code == 600000008){
                        this.advice_visibility = false
                        this.infor_visibility = true
                  
                     }
                    Toast.fail(response.data.msg)
                    return false
                  } else {
                    Toast.success('提交成功')
                    this.$emit(
                      'prescription',
                      response.data.data.prescription,
                      this.doctorAdvices
                    )
                    this.finish()
                  }
                })
                .catch(error => {
                  Toast.fail('请求失败')
                })
            }
          }
        } else {
          Toast.loading({forbidClick: true, duration: 0})
          var arr = this.dialysisPrescription

          let ParamsQuery = arr

          if (this.$route.query.patient_id) {
            ParamsQuery['patient'] = this.$route.query.patient_id
          } else {
            ParamsQuery['patient'] = this.patient_prop.id
          }
          ParamsQuery['record_date'] = this.record_date

          ParamsQuery['mode'] = '2'
          if (
            this.prescription_prop.creater != this.$store.getters.user.admin.id
          ) {
            ParamsQuery['mode'] = '3'
          }
          if (ParamsQuery.water_machine == '0') {
            ParamsQuery.water_machine = '请选择'
          }
          if (ParamsQuery.water_machine == '1') {
            ParamsQuery.water_machine = '是'
          }
          if (ParamsQuery.water_machine == '2') {
            ParamsQuery.water_machine = '否'
          }
          commitDialysisPrescription(ParamsQuery)
            .then(response => {
              if (response.data.state == 0) {
                 if(response.data.code == 600000008){
                    this.advice_visibility = false
                    this.infor_visibility = true
                  
                }
                Toast.fail(response.data.msg)
                return false
              } else {
                Toast.success('提交成功')
                this.$emit(
                  'prescription',
                  response.data.data.prescription,
                  this.doctorAdvices
                )
                this.finish()
              }
            })
            .catch(error => {
              Toast.fail('请求失败')
            })
        }
      }
    },
    commitSolutionInfo: function () {
      if(this.$store.getters.user.template_info.org_id == 10340 || this.$store.getters.user.template_info.org_id == 3877){
       if(this.dialysisPrescription.prescribing_number == 0){
        Toast.fail('请填写开药数量!')
        return
       }
       if(this.dialysisPrescription.anticoagulant == 0){
        Toast.fail('请填写抗凝剂!')
        return
       }
      }
      if (this.$store.getters.user.template_info.template_id == 6) {
        if (this.dialysisPrescription.mode_id == 2) {
          if (
            this.dialysisPrescription.displace_liqui_part == 0 ||
              this.dialysisPrescription.displace_liqui_part == -2 ||
              this.dialysisPrescription.displace_liqui_value == 0 ||
              this.dialysisPrescription.displace_liqui_value == ''
          ) {
            Toast.fail('HDF模式下置换方式和置换液总量不能为空！')
            return
          }
        }
      }
      this.is_pre = 2

      if (this.prescription_prop.id == '') {
        if (this.is_open == 0) {
          Toast.loading({forbidClick: true, duration: 0})
          var arr = this.dialysisPrescription

          let ParamsQuery = arr
          // console.log('ParamsQueryOne', ParamsQuery)
          if (ParamsQuery.water_machine == '0') {
            ParamsQuery.water_machine = '请选择'
          }
          if (ParamsQuery.water_machine == '1') {
            ParamsQuery.water_machine = '是'
          }
          if (ParamsQuery.water_machine == '2') {
            ParamsQuery.water_machine = '否'
          }
          if (this.$route.query.patient_id) {
            ParamsQuery['patient'] = this.$route.query.patient_id
          } else {
            ParamsQuery['patient'] = this.patient_prop.id
          }
          ParamsQuery['record_date'] = this.record_date
          ParamsQuery['mode'] = '1'

          postSolution(ParamsQuery).then(response => {
            if (response.data.state == 0) {
              Toast.fail(response.data.msg)
               if(response.data.code == 600000008){
                  this.advice_visibility = false
                  this.infor_visibility = true
                  
              }
              return false
            } else {
              Toast.success('提交成功')

              this.$emit('advice')
              this.$emit('longSolution', response.data.data.solution)
              this.$emit('prescription', response.data.data.prescription)
              this.finish()
            }
          })
        } else if (this.is_open == 1) {
          if (this.targetAdvices.length > 0) {
            // 弹框推送提醒
            this.advicePropForm.list = this.targetAdvices
            this.advicePropForm.operators = this.admin_users_prop
            this.advice_visibility = true
            this.isShowDialog = false

            for (let i = 0; i < this.advicePropForm.list.length; i++) {
              if (
                this.advicePropForm.list[i].parent_id == 0 &&
                  this.advicePropForm.list[i].isCheck == 1
              ) {
                this.advicePropForm.result.push(this.advicePropForm.list[i].id)
              }
            }
          } else {
            Toast.loading({forbidClick: true, duration: 0})
            var arr = this.dialysisPrescription

            let ParamsQuery = arr
            // console.log('ParamsQueryOne', ParamsQuery)
            if (this.$route.query.patient_id) {
              ParamsQuery['patient'] = this.$route.query.patient_id
            } else {
              ParamsQuery['patient'] = this.patient_prop.id
            }
            ParamsQuery['record_date'] = this.record_date
            ParamsQuery['mode'] = '1'
            if (ParamsQuery.water_machine == '0') {
              ParamsQuery.water_machine = '请选择'
            }
            if (ParamsQuery.water_machine == '1') {
              ParamsQuery.water_machine = '是'
            }
            if (ParamsQuery.water_machine == '2') {
              ParamsQuery.water_machine = '否'
            }
            postSolution(ParamsQuery)
              .then(response => {
                if (response.data.state == 0) {
                   if(response.data.code == 600000008){
                    this.advice_visibility = false
                    this.infor_visibility = true
                  
                   }
                  Toast.fail(response.data.msg)
                  return false
                } else {
                  Toast.success('提交成功')

                  this.$emit('advice')
                  this.$emit('longSolution', response.data.data.solution)
                  this.$emit('prescription', response.data.data.prescription)
                  this.finish()
                }
              })
              .catch(error => {
                Toast.fail('请求失败')
              })
          }
        } else if (this.is_open == 2) {
          if (this.waitUploadAdvices.length > 0) {
            Toast.loading({forbidClick: true, duration: 0})
            var arr = this.dialysisPrescription

            let ParamsQuery = arr
            // console.log('ParamsQueryOne', ParamsQuery)
            if (this.$route.query.patient_id) {
              ParamsQuery['patient'] = this.$route.query.patient_id
            } else {
              ParamsQuery['patient'] = this.patient_prop.id
            }
            ParamsQuery['record_date'] = this.record_date
            ParamsQuery['mode'] = '1'
            if (ParamsQuery.water_machine == '0') {
              ParamsQuery.water_machine = '请选择'
            }
            if (ParamsQuery.water_machine == '1') {
              ParamsQuery.water_machine = '是'
            }
            if (ParamsQuery.water_machine == '2') {
              ParamsQuery.water_machine = '否'
            }
            postSolution(ParamsQuery)
              .then(response => {
                if (response.data.state == 0) {
                   if(response.data.code == 600000008){
                    this.advice_visibility = false
                    this.infor_visibility = true
                  
                  }
                  Toast.fail(response.data.msg)
                  return false
                } else {
                  Toast.success('提交成功')

                  var date = new Date()
                  var year = date.getFullYear()
                  var month = date.getMonth() + 1
                  var day = date.getDate()

                  var hours = date.getHours()
                  var minites = date.getMinutes()

                  if (month < 10) {
                    month = '0' + month
                  }
                  if (day < 10) {
                    day = '0' + day
                  }
                  if (hours < 10) {
                    hours = '0' + hours
                  }
                  if (minites < 10) {
                    minites = '0' + minites
                  }
                  var nowDate =
                      year +
                      '-' +
                      month +
                      '-' +
                      day +
                      ' ' +
                      hours +
                      ':' +
                      minites

                  let advice_date = year + '-' + month + '-' + day

                  let params = {
                    advices: this.waitUploadAdvices,
                    advice_date: this.$route.query.date ? parseTime(
                      this.$route.query.date,
                      '{y}-{m}-{d}'
                    ) : advice_date,
                    advice_doctor: this.waitUploadAdvices[0].advice_doctor,
                    advice_type: this.waitUploadAdvices[0].advice_type,
                    parent_id: this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id,
                    start_time: nowDate,
                    remark: ''
                  }
                  CreateGroupAdvice(
                    this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id,
                    0,
                    params
                  ).then(rs => {
                    var resp = rs.data
                    if (resp.state == 1) {
                      this.doctorAdvices = resp.data.advices
                      this.$emit(
                        'longSolution',
                        response.data.data.solution,
                        resp.data.advices
                      )
                      this.$emit(
                        'prescription',
                        response.data.data.prescription,
                        resp.data.advices
                      )
                    } else {
                    }
                  })

                  this.finish()
                }
              })
              .catch(error => {
                Toast.fail('请求失败')
              })
          } else {
            Toast.loading({forbidClick: true, duration: 0})
            var arr = this.dialysisPrescription

            let ParamsQuery = arr
            // console.log('ParamsQueryOne', ParamsQuery)
            if (this.$route.query.patient_id) {
              ParamsQuery['patient'] = this.$route.query.patient_id
            } else {
              ParamsQuery['patient'] = this.patient_prop.id
            }
            ParamsQuery['record_date'] = this.record_date
            ParamsQuery['mode'] = '1'
            if (ParamsQuery.water_machine == '0') {
              ParamsQuery.water_machine = '请选择'
            }
            if (ParamsQuery.water_machine == '1') {
              ParamsQuery.water_machine = '是'
            }
            if (ParamsQuery.water_machine == '2') {
              ParamsQuery.water_machine = '否'
            }
            postSolution(ParamsQuery)
              .then(response => {
                if (response.data.state == 0) {
                   if(response.data.code == 600000008){
                    this.advice_visibility = false
                    this.infor_visibility = true
                  
                  }
                  Toast.fail(response.data.msg)
                  return false
                } else {
                  Toast.success('提交成功')

                  this.$emit('longSolution', response.data.data.solution)
                  this.$emit('prescription', response.data.data.prescription)
                  this.finish()
                }
              })
              .catch(error => {
                Toast.fail('请求失败')
              })
          }
        }
      } else {
        if (this.prescription_prop.creater == 0) {
          if (this.is_open == 0) {
            Toast.loading({forbidClick: true, duration: 0})
            var arr = this.dialysisPrescription

            let ParamsQuery = arr
            // console.log('ParamsQueryOne', ParamsQuery)
            if (this.$route.query.patient_id) {
              ParamsQuery['patient'] = this.$route.query.patient_id
            } else {
              ParamsQuery['patient'] = this.patient_prop.id
            }
            ParamsQuery['record_date'] = this.record_date
            ParamsQuery['mode'] = '1'
            if (ParamsQuery.water_machine == '0') {
              ParamsQuery.water_machine = '请选择'
            }
            if (ParamsQuery.water_machine == '1') {
              ParamsQuery.water_machine = '是'
            }
            if (ParamsQuery.water_machine == '2') {
              ParamsQuery.water_machine = '否'
            }
            postSolution(ParamsQuery)
              .then(response => {
                if (response.data.state == 0) {
                   if(response.data.code == 600000008){
                    this.advice_visibility = false
                    this.infor_visibility = true
                  
                  }
                  Toast.fail(response.data.msg)
                  return false
                } else {
                  Toast.success('提交成功')

                  this.$emit('longSolution', response.data.data.solution)
                  this.$emit('prescription', response.data.data.prescription)
                  this.finish()
                }
              })
              .catch(error => {
                Toast.fail('请求失败')
              })
          } else if (this.is_open == 1) {
            if (this.targetAdvices.length > 0) {
              // 弹框推送提醒
              this.advicePropForm.list = this.targetAdvices
              this.advicePropForm.operators = this.admin_users_prop
              this.advice_visibility = true
              this.isShowDialog = false

              for (let i = 0; i < this.advicePropForm.list.length; i++) {
                if (
                  this.advicePropForm.list[i].parent_id == 0 &&
                    this.advicePropForm.list[i].isCheck == 1
                ) {
                  this.advicePropForm.result.push(
                    this.advicePropForm.list[i].id
                  )
                }
              }
            } else {
              Toast.loading({forbidClick: true, duration: 0})
              var arr = this.dialysisPrescription

              let ParamsQuery = arr
              // console.log('ParamsQueryOne', ParamsQuery)
              if (this.$route.query.patient_id) {
                ParamsQuery['patient'] = this.$route.query.patient_id
              } else {
                ParamsQuery['patient'] = this.patient_prop.id
              }
              ParamsQuery['record_date'] = this.record_date
              ParamsQuery['mode'] = '1'
              if (ParamsQuery.water_machine == '0') {
                ParamsQuery.water_machine = '请选择'
              }
              if (ParamsQuery.water_machine == '1') {
                ParamsQuery.water_machine = '是'
              }
              if (ParamsQuery.water_machine == '2') {
                ParamsQuery.water_machine = '否'
              }
              postSolution(ParamsQuery)
                .then(response => {
                  if (response.data.state == 0) {
                     if(response.data.code == 600000008){
                      this.advice_visibility = false
                      this.infor_visibility = true
                  
                    }
                    Toast.fail(response.data.msg)
                    return false
                  } else {
                    Toast.success('提交成功')

                    this.$emit('longSolution', response.data.data.solution)
                    this.$emit('prescription', response.data.data.prescription)
                    this.finish()
                  }
                })
                .catch(error => {
                  Toast.fail('请求失败')
                })
            }
          } else if (this.is_open == 2) {
            if (this.waitUploadAdvices.length > 0) {
              Toast.loading({forbidClick: true, duration: 0})
              var arr = this.dialysisPrescription

              let ParamsQuery = arr
              // console.log('ParamsQueryOne', ParamsQuery)
              if (this.$route.query.patient_id) {
                ParamsQuery['patient'] = this.$route.query.patient_id
              } else {
                ParamsQuery['patient'] = this.patient_prop.id
              }
              ParamsQuery['record_date'] = this.record_date
              ParamsQuery['mode'] = '2'
              if (ParamsQuery.water_machine == '0') {
                ParamsQuery.water_machine = '请选择'
              }
              if (ParamsQuery.water_machine == '1') {
                ParamsQuery.water_machine = '是'
              }
              if (ParamsQuery.water_machine == '2') {
                ParamsQuery.water_machine = '否'
              }
              postSolution(ParamsQuery)
                .then(response => {
                  if (response.data.state == 0) {
                    Toast.fail(response.data.msg)
                     if(response.data.code == 600000008){
                      this.advice_visibility = false
                      this.infor_visibility = true

                      }
                    return false
                  } else {
                    this.advice_visibility = false

                    var date = new Date()
                    var year = date.getFullYear()
                    var month = date.getMonth() + 1
                    var day = date.getDate()

                    var hours = date.getHours()
                    var minites = date.getMinutes()

                    if (month < 10) {
                      month = '0' + month
                    }
                    if (day < 10) {
                      day = '0' + day
                    }
                    if (hours < 10) {
                      hours = '0' + hours
                    }
                    if (minites < 10) {
                      minites = '0' + minites
                    }
                    var nowDate =
                        year +
                        '-' +
                        month +
                        '-' +
                        day +
                        ' ' +
                        hours +
                        ':' +
                        minites

                    let advice_date = year + '-' + month + '-' + day

                    let params = {
                      advices: this.waitUploadAdvices,
                      advice_date: this.$route.query.date ? parseTime(
                        this.$route.query.date,
                        '{y}-{m}-{d}'
                      ) : advice_date,
                      advice_doctor: this.waitUploadAdvices[0].advice_doctor,
                      advice_type: this.waitUploadAdvices[0].advice_type,
                      parent_id: this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id,
                      start_time: nowDate,
                      remark: ''
                    }
                    CreateGroupAdvice(
                      this.$route.query.patient_id ? this.$route.query.patient_id : this.patient_prop.id,
                      0,
                      params
                    ).then(rs => {
                      var resp = rs.data
                      if (resp.state == 1) {
                        this.doctorAdvices = resp.data.advices
                        this.$emit(
                          'longSolution',
                          response.data.data.solution,
                          resp.data.advices
                        )
                        this.$emit(
                          'prescription',
                          response.data.data.prescription,
                          resp.data.advices
                        )
                      } else {
                      }
                    })
                    Toast.success('提交成功')
                    this.finish()
                  }
                })
                .catch(error => {
                  Toast.fail('请求失败')
                })
            } else {
              Toast.loading({forbidClick: true, duration: 0})
              var arr = this.dialysisPrescription

              let ParamsQuery = arr
              // console.log('ParamsQueryOne', ParamsQuery)
              if (this.$route.query.patient_id) {
                ParamsQuery['patient'] = this.$route.query.patient_id
              } else {
                ParamsQuery['patient'] = this.patient_prop.id
              }
              ParamsQuery['record_date'] = this.record_date
              ParamsQuery['mode'] = '1'
              if (ParamsQuery.water_machine == '0') {
                ParamsQuery.water_machine = '请选择'
              }
              if (ParamsQuery.water_machine == '1') {
                ParamsQuery.water_machine = '是'
              }
              if (ParamsQuery.water_machine == '2') {
                ParamsQuery.water_machine = '否'
              }
              postSolution(ParamsQuery)
                .then(response => {
                  if (response.data.state == 0) {
                    Toast.fail(response.data.msg)
                     if(response.data.code == 600000008){
                      this.advice_visibility = false
                      this.infor_visibility = true
                  
                     }
                    return false
                  } else {
                    Toast.success('提交成功')
                    this.$emit('advice')
                    this.$emit('longSolution', response.data.data.solution)
                    this.$emit('prescription', response.data.data.prescription)
                    this.finish()
                  }
                })
                .catch(error => {
                  Toast.fail('请求失败')
                })
            }
          }
        } else {
          Toast.loading({forbidClick: true, duration: 0})
          var arr = this.dialysisPrescription

          let ParamsQuery = arr
          // console.log('ParamsQueryOne', ParamsQuery)
          if (this.$route.query.patient_id) {
            ParamsQuery['patient'] = this.$route.query.patient_id
          } else {
            ParamsQuery['patient'] = this.patient_prop.id
          }
          ParamsQuery['record_date'] = this.record_date
          ParamsQuery['mode'] = '1'
          if (ParamsQuery.water_machine == '0') {
            ParamsQuery.water_machine = '请选择'
          }
          if (ParamsQuery.water_machine == '1') {
            ParamsQuery.water_machine = '是'
          }
          if (ParamsQuery.water_machine == '2') {
            ParamsQuery.water_machine = '否'
          }
          postSolution(ParamsQuery)
            .then(response => {
              if (response.data.state == 0) {
               
                Toast.fail(response.data.msg)
                  if(response.data.code == 600000008){
                  this.advice_visibility = false
                  this.infor_visibility = true
                  
              }
                return false
              } else {
                Toast.success('提交成功')
                this.$emit('longSolution', response.data.data.solution)

                this.$emit('prescription', response.data.data.prescription)
                this.finish()
              }
            })
            .catch(error => {
              Toast.fail('请求失败')
            })
        }
      }
    },
    finish: function () {
      this.$emit('finish')
    },
    close: function () {
      this.$emit('close')
    },
    open: function () {
      this.isShowDialog = true
      this.visibility = false
      this.$refs.picker.close()
      var dialogTop = document.querySelector('#dialogTop')
      if (dialogTop != null) {
        this.$nextTick(() => {
          dialogTop.scrollTop = 0
        })
      }
    },
    sign: function () {
      let params = {
        patient_id: this.$route.query.patient_id,
        date: this.record_date
      }
      postSign(params)
        .then(response => {
          if (response.data.state == 0) {
            Toast.fail(response.data.msg)
            return false
          } else {
            this.isShowDesc = false
            this.isShowDoctorSign = true
            this.dialysisPrescription.prescription_doctor =
                response.data.data.doctor_id
            for (let i = 0; i < this.operators.length; i++) {
              if (this.operators[i].creator == response.data.data.doctor_id) {
                // console.log(this.operators[i].url);
                this.signUrl = this.operators[i].url
              }
            }
            Toast.success('签名成功')
          }
        })
        .catch(error => {
          Toast.fail('请求失败')
        })
    },
    getBodyFluid: function (val) {
      let body_fluid_name = ''
      let body_fluid = this.bodyFluidOptions
      for (let i = 0; i < body_fluid.length; i++) {
        if (body_fluid[i].id == val) {
          body_fluid_name = body_fluid[i].name
        }
      }
      return body_fluid_name
    },
    getHemodialysisPipelines: function (val) {
      let name = ''
      let names = this.hemodialysisPipelinesOptions
      for (let i = 0; i < names.length; i++) {
        if (names[i].id == val) {
          name = names[i].name
        }
      }
      return name
    },
    getPunctureNeedle: function (val) {
      let name = ''
      let names = this.punctureNeedleOptions
      for (let i = 0; i < names.length; i++) {
        if (names[i].id == val) {
          name = names[i].name
        }
      }
      return name
    },
    getEPO: function (val) {
      let name = ''
      let names = this.epoOptions
      for (let i = 0; i < names.length; i++) {
        if (names[i].id == val) {
          name = names[i].name
        }
      }
      return name
    },
    getSpecialMedicine: function (val) {
      let special_medicine_name = ''
      let special_medicine = this.specialMedicineOptions
      for (let i = 0; i < special_medicine.length; i++) {
        if (special_medicine[i].id == val) {
          special_medicine_name = special_medicine[i].name
        }
      }
      return special_medicine_name
    },
    getDisplaceLiquiPart: function (val) {
      let displace_liqui_part_name = ''
      let displace_liqui_part = this.displaceLiquiPartOptions
      for (let i = 0; i < displace_liqui_part.length; i++) {
        if (displace_liqui_part[i].id == val) {
          displace_liqui_part_name = displace_liqui_part[i].name
        }
      }
      return displace_liqui_part_name
    },
    getBloodAccess: function (val) {
      let blood_access_name = ''
      let blood_access = this.bloodAccessOptions
      for (let i = 0; i < blood_access.length; i++) {
        if (blood_access[i].id == val) {
          blood_access_name = blood_access[i].name
        }
      }
      return blood_access_name
    },
    getBloodAccessTwo: function (val) {
      let blood_access_name = ''
      for (let i = 0; i < this.data.length; i++) {
        if (val == this.data[i].id) {
          blood_access_name = this.data[i].name
        }
      }
      return blood_access_name
    },

    menuEmpty: function (val) {
      this.visibility = false
      this.isShowDialog = true
      switch (val.type) {
        case 1:
          this.dialysisPrescription.mode_id = ''

          break
        case 2:
          this.dialysisPrescription.dialyzer = ''
          break

        case 3:
          this.dialysisPrescription.perfusion_apparatus = ''
          break
        case 4:
          this.dialysisPrescription.replacement_way = ''
          break
        case 5:
          this.anticoagulant = ''
          break
        case 6:
          this.dialysisPrescription.dialysate_formulation = ''
          break
        case 7:
          this.dialysisPrescription.body_fluid = ''
          break
        case 8:
          this.dialysisPrescription.special_medicine = ''
          break
        case 9:
          this.dialysisPrescription.displace_liqui_part = ''
          break
        case 10:
          this.dialysisPrescription.blood_access = ''
          break
        case 20:
          this.dialysisPrescription.epo = ''
          break
        case 21:
          this.dialysisPrescription.puncture_needle = ''
          break
      }
    },
    getFloat: function (x) {
      if (x != '.') {
        var f = Math.round(x * 100) / 100
        var s = f.toString()
        var rs = s.indexOf('.')
        if (rs <= 0) {
          rs = s.length
          s += '.'
        }
        while (s.length <= rs + 1) {
          s += '0'
        }
        return s
      } else {
        return '0.0'
      }
    },
    dialysisGoodsClick: function () {
      this.isShowDialog = false
      this.is_show = true
    },
    menuCancleTwo: function () {
      this.isShowDialog = true
      this.is_show = false
    },
    menuComfirmTwo: function (dialysisPrescription) {
      this.isShowDialog = true
      this.is_show = false
      this.dialysisPrescription.niprocart = dialysisPrescription.niprocart
      this.dialysisPrescription.jms = dialysisPrescription.jms
      this.dialysisPrescription.fistula_needle_set =
          dialysisPrescription.fistula_needle_set
      this.dialysisPrescription.fistula_needle_set_16 =
          dialysisPrescription.fistula_needle_set_16
      this.dialysisPrescription.hemoperfusion =
          dialysisPrescription.hemoperfusion
      this.dialysisPrescription.dialyser_sterilised =
          dialysisPrescription.dialyser_sterilised
      this.dialysisPrescription.filtryzer = dialysisPrescription.filtryzer

      this.dialysisPrescription.dialyzers = dialysisPrescription.dialyzers
      this.dialysisPrescription.injector = dialysisPrescription.injector
      this.dialysisPrescription.bloodlines = dialysisPrescription.bloodlines
      this.dialysisPrescription.tubing_hemodialysis =
          dialysisPrescription.tubing_hemodialysis
      this.dialysisPrescription.package = dialysisPrescription.package
      this.dialysisPrescription.a_liquid = dialysisPrescription.a_liquid
    },
    getPermission () {
      request
        .get('/m/api/permission/get', {
          params: {
            create_url: '/m/api/dialysis/dialysisPrescription?mode=1',
            modify_url: '/m/api/dialysis/dialysisPrescription?mode=2',
            modify_other_url: '/m/api/dialysis/dialysisPrescription?mode=3',
            module: 1
          }
        })
        .then(res => {
          if (res.data.state == 0) {
            this.hasPermission = false
          } else if (res.data.state == 1) {
            if (
              this.prescription_prop.id != '' &&
                this.prescription_prop.creater != 0
            ) {
              // 有数据
              if (
                this.prescription_prop.creater ==
                  this.$store.getters.user.admin.id
              ) {
                // 创建人是自己
                if (res.data.data.is_has_modify == false) {
                  this.hasPermission = false
                  this.showTxt = '你没有修改透析处方权限'
                }
              } else {
                // 创建人不是自己
                if (res.data.data.is_has_modify_other == false) {
                  this.hasPermission = false
                  this.showTxt = '你没有修改他人透析处方权限'
                }
              }
            } else if (
              this.prescription_prop.id == '' ||
                this.prescription_prop.creater == 0
            ) {
              if (res.data.data.is_has_create == false) {
                this.hasPermission = false
                this.showTxt = '你没有新增透析处方权限'
              }
            }
          }
        })
    },

    toTeach (val) {
      if (val >= 0) {
        this.teachList.map(item => {
          if (item.id == val) {
            var theValue = item.value
            this.dialysisAfterTeachSelectChange(theValue)
          }
        })
      }
      this.teachShow = false
    },
    dialysisAfterTeachSelectChange: function (values) {
      if (this.dialysisPrescription.dialysis_remark == null) {
        this.dialysisPrescription.dialysis_remark == ''
      }
      if (this.dialysisPrescription.dialysis_remark == '' || this.dialysisPrescription.dialysis_remark == undefined) {
        this.dialysisPrescription.dialysis_remark = values
      } else {
        if (this.dialysisPrescription.dialysis_remark.indexOf(values) == -1) {
          if (this.dialysisPrescription.dialysis_remark.charAt(this.dialysisPrescription.dialysis_remark.length - 1).indexOf('。') == -1) {
            this.dialysisPrescription.dialysis_remark = this.dialysisPrescription.dialysis_remark + ',' + values
          } else {
            this.dialysisPrescription.dialysis_remark = this.dialysisPrescription.dialysis_remark + values
          }
        }
      }
    },
     menuComfirmFour:function(start_time,remark){
      
       var params = {
         patient_id: this.patient_prop.id,
         record_date:this.switchMsec(this.record_date),
         start_time:start_time,
         module:1,
         remark:remark,
       }
      saveMobileInformation(params).then(response=>{
        if(response.data.state == 1){
           this.infor_visibility = false
           this.advice_visibility = false
           this.finish()
           Toast.success('申请成功')
        }
      })
    },
    switchMsec (time){ // 日期转换成毫秒
      let date = new Date(time);
      // 有三种方式获取
      let time1 = date.getTime(); // 精确到毫秒;
      return (time1/1000)-28800
    },

  },
  created () {
    this.getPermission()
    this.template_id = this.$store.getters.user.template_info.template_id
    this.dialysisPrescription.admin_user_id = this.$store.getters.user.admin.id
    this.dialysisPrescription.water_machine = 2
    this.modeOption = this.$store.getters.treatment_mode
    delete this.modeOption['0']

    var perfusion_apparatus = getDataConfig(
      'hemodialysis',
      'perfusion_apparatus'
    )

    this.data = getDataConfig('hemodialysis', 'vascular_access_desc')

    this.perfusion_apparatus = perfusion_apparatus

    this.anticoagulantsConfitTwo = this.$store.getters.anticoagulants_confit

    var anticoagulantsConfitOne = this.$store.getters.anticoagulants_confit

    this.teachList = getDataConfig('dialysis_remark', 'dialysis_remark')

    let arrFour = []
    Object.keys(anticoagulantsConfitOne).map((item, index) => {
      if (index != 2) {
        arrFour.push(anticoagulantsConfitOne[item])
      }
    })
    this.anticoagulantsConfit = arrFour

    this.bodyFluidOptions = this.$store.getters.body_fluid
    var special_medicine = [
      {id: 1, name: '无'},
      {id: 2, name: '降压药'},
      {id: 3, name: '抗凝'},
      {id: 4, name: '其他'},
      {id: 5, name: '降糖药'}
    ]
    this.specialMedicineOptions = special_medicine
    // this.specialMedicineOptions = this.$store.getters.special_medicine
    this.displaceLiquiPartOptions = this.$store.getters.displace_liqui
    this.bloodAccessOptions = this.$store.getters.blood_access

    this.hemodialysisPipelinesOptions = getDataConfig('hemodialysis', 'hemodialysis_pipelines')
    this.punctureNeedleOptions = getDataConfig('hemodialysis', 'puncture_needle')
    // console.log('初次合作呢个2323232', this.punctureNeedleOptions)
    this.epoOptions = getDataConfig('hemodialysis', 'epo')

    this.dialysateFormulationOptions = getDataConfig(
      'hemodialysis',
      'dialysate_formulation'
    )
    this.replacementWays = getDataConfig('hemodialysis', 'replacement_ways')

    this.patient = this.patient_prop

    if (
      this.prescription_prop != null &&
        typeof this.prescription_prop.id !== 'undefined' &&
        this.prescription_prop.id > 0
    ) {
      for (const key in this.prescription_prop) {
        this.dialysisPrescription[key] = this.prescription_prop[key]
      }
    } else if (
      this.solution_prop != null &&
        typeof this.solution_prop.id !== 'undefined' &&
        this.solution_prop.id
    ) {
      for (const key in this.solution_prop) {
        if (key != 'target_ultrafiltration') {
          this.dialysisPrescription[key] = this.solution_prop[key]
        }
      }
    } else if (
      this.last_prescription != null &&
        typeof this.last_prescription.id !== 'undefined' &&
        this.last_prescription.id
    ) {
      for (const key in this.last_prescription) {
        if (key != 'target_ultrafiltration') {
          this.dialysisPrescription[key] = this.last_prescription[key]
        }
      }
    } else if (
      this.system_prescription != null &&
        typeof this.system_prescription.id !== 'undefined' &&
        this.system_prescription.id
    ) {
      for (const key in this.system_prescription) {
        if (key != 'target_ultrafiltration') {
          this.dialysisPrescription[key] = this.system_prescription[key]
        }
      }
    } else {
      this.dialysisPrescription.mode_id = this.schedual.mode_id
    }

    if (
      this.dialysisPrescription.dialysis_duration_hour.length == 0 ||
        this.dialysisPrescription.dialysis_duration_minute.length == 0
    ) {
      this.timeValue = ''
      this.time = '03:00'
      this.dialysisPrescription.dialysis_duration = 3
    } else {
      this.timeValue =
          this.dialysisPrescription.dialysis_duration_hour +
          '小时' +
          this.dialysisPrescription.dialysis_duration_minute +
          '分钟'
      this.time =
          (this.dialysisPrescription.dialysis_duration_hour > 10
            ? this.dialysisPrescription.dialysis_duration_hour
            : '0' + this.dialysisPrescription.dialysis_duration_hour) +
          ':' +
          (this.dialysisPrescription.dialysis_duration_minute > 10
            ? this.dialysisPrescription.dialysis_duration_minute
            : '0' + this.dialysisPrescription.dialysis_duration_minute)

      this.dialysisPrescription.dialysis_duration =
          parseFloat(this.dialysisPrescription.dialysis_duration_hour) +
          parseFloat(
            (this.dialysisPrescription.dialysis_duration_minute / 60).toFixed(2)
          )
    }

    if (this.dialysisPrescription.anticoagulant_stop_time_hour.length == 0 || this.dialysisPrescription.anticoagulant_stop_time_min.length == 0) {
      this.anticoagulantTimeValue = ''
    } else {
      this.anticoagulantTimeValue =
          this.dialysisPrescription.anticoagulant_stop_time_hour +
          '小时' +
          this.dialysisPrescription.anticoagulant_stop_time_min +
          '分钟'
      this.anticoagulant_time =
          (this.dialysisPrescription.anticoagulant_stop_time_hour > 10
            ? this.dialysisPrescription.anticoagulant_stop_time_hour
            : '0' + this.dialysisPrescription.anticoagulant_stop_time_hour) +
          ':' +
          (this.dialysisPrescription.anticoagulant_stop_time_min > 10
            ? this.dialysisPrescription.anticoagulant_stop_time_min
            : '0' + this.dialysisPrescription.anticoagulant_stop_time_min)
    }

    this.dialyserList = this.machines_prop
    // this.doctor = this.$store.getters.user.user.user_type;

    if (this.$route.query && this.$route.query.date) {
      var date = this.$route.query && this.$route.query.date
      date *= 1000
      var newDate = new Date(date)

      var y = newDate.getFullYear()
      var m = newDate.getMonth() + 1
      var d = newDate.getDate()
      if (isNaN(y) || isNaN(m) || isNaN(d)) {
        newDate = new Date()
        y = newDate.getFullYear()
        m = newDate.getMonth() + 1
        d = newDate.getDate()
      }
      this.record_date =
          y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d)
    } else {
      var date = this.schedual.schedule_date
      date *= 1000
      var newDate = new Date(date)

      var y = newDate.getFullYear()
      var m = newDate.getMonth() + 1
      var d = newDate.getDate()
      if (isNaN(y) || isNaN(m) || isNaN(d)) {
        newDate = new Date()
        y = newDate.getFullYear()
        m = newDate.getMonth() + 1
        d = newDate.getDate()
      }
      this.record_date =
          y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d)
    }

    // this.patient.id = this.patient_prop.id
    if (this.prescription_prop != undefined && this.prescription_prop.id == 0) {
      if (this.$store.getters.user.template_info.org_id == 9671 || this.$store.getters.user.template_info.org_id == 3877 || this.$store.getters.user.template_info.org_id == 10340) {
        this.dialysisPrescription.sodium = 138
        this.dialysisPrescription.bicarbonate = 31.1
        this.dialysisPrescription.dialysate_flow = 500
        this.dialysisPrescription.dialysate_temperature = 36.5
        this.dialysisPrescription.prescribing_number = 1
        if(this.$route.query.patient_id == 14682 || this.$route.query.patient_id ==18560){
          this.dialysisPrescription.prescribing_number = 2
        }
        this.dialysisPrescription.admin_user_id = this.$store.getters.user.admin.id
        if (this.last_prescription != null) {
          this.dialysisPrescription.remark = this.last_prescription.remark
        }
      }
    }

    if (this.prescription_prop != undefined && this.prescription_prop.id == 0) {
    
      if (this.$store.getters.user.template_info.org_id == 9671 || this.$store.getters.user.template_info.org_id == 3877 || this.$store.getters.user.template_info.org_id == 10340) {
        if(this.dialysisPrescription.prescribing_number == 0){
         this.dialysisPrescription.prescribing_number = 1
          if(this.$route.query.patient_id == 14682 || this.$route.query.patient_id ==18560){
           this.dialysisPrescription.prescribing_number = 2
          }
       }
      }
    }

    this.dialysisPrescription.kalium = this.getFloat(
      this.dialysisPrescription.kalium
    )
    this.dialysisPrescription.sodium = this.getFloat(
      this.dialysisPrescription.sodium
    )
    this.dialysisPrescription.calcium = this.getFloat(
      this.dialysisPrescription.calcium
    )
    this.dialysisPrescription.ultrafiltration = this.getFloat(
      this.dialysisPrescription.ultrafiltration
    )
    this.dialysisPrescription.target_ultrafiltration = this.getFloat(
      this.dialysisPrescription.target_ultrafiltration
    )

    if (this.dialysisPrescription.anticoagulant_shouji == '') {
      this.dialysisPrescription.anticoagulant_shouji = '0'
    }

    if (this.dialysisPrescription.anticoagulant_weichi == '') {
      this.dialysisPrescription.anticoagulant_weichi = '0'
    }

    if (this.dialysisPrescription.anticoagulant_zongliang == '') {
      this.dialysisPrescription.anticoagulant_weichi = '0'
    }

    var dialyzerPerfusionApparatus = getDataConfig(
      'hemodialysis',
      'dialyzer_perfusion_apparatus'
    )
    // dialyzerPerfusionApparatus.map(item => {
    //   item.name = item.name.toUpperCase()
    // })
    // // 去重
    this.dialyzerPerfusionApparatus = dialyzerPerfusionApparatus
    var blood = getDataConfig(
      'hemodialysis',
      'blood'
    )
    this.bloods = blood
    if (this.prescription_prop != null && this.prescription_prop.id == '') {
      this.dialysisPrescription.niprocart = this.last_prescription.niprocart
      this.dialysisPrescription.jms = this.last_prescription.jms
      this.dialysisPrescription.fistula_needle_set =
          this.last_prescription.fistula_needle_set
      this.dialysisPrescription.fistula_needle_set_16 =
          this.last_prescription.fistula_needle_set_16
      this.dialysisPrescription.hemoperfusion =
          this.last_prescription.hemoperfusion
      this.dialysisPrescription.dialyser_sterilised =
          this.last_prescription.dialyser_sterilised
      this.dialysisPrescription.filtryzer = this.last_prescription.filtryzer

      this.dialysisPrescription.dialyzers = this.last_prescription.dialyzers
      this.dialysisPrescription.injector = this.last_prescription.injector
      this.dialysisPrescription.bloodlines = this.last_prescription.bloodlines
      this.dialysisPrescription.tubing_hemodialysis =
          this.last_prescription.tubing_hemodialysis
      this.dialysisPrescription.package = this.last_prescription.package
      this.dialysisPrescription.a_liquid = this.last_prescription.a_liquid
      this.dialysisPrescription.dialysis_dialyszers = this.last_prescription.dialysis_dialyszers
      this.dialysisPrescription.dialysis_irrigation = this.last_prescription.dialysis_irrigation
      this.dialysisPrescription.remark = this.last_prescription.remark
    }
    var arr = []
    var arrTwo = []
    var arrThree = []
    var dialyzer = []
    var irrigation = []
    var dialysisStrainer = []
    // console.log('happ', this.stockType)
    if (this.stockType.length > 0) {
      for (let i = 0; i < this.stockType.length; i++) {
        if (this.stockType[i].stock_attribute == 2) {
          arr.push(this.stockType[i])
        }
        if (this.stockType[i].stock_attribute == 3) {
          arrTwo.push(this.stockType[i])
        }
        if (this.stockType[i].stock_attribute == 4) {
          arrThree.push(this.stockType[i])
        }
      }

      for (let i = 0; i < arr.length; i++) {
        for (let j = 0; j < arr[i].GoodInfo.length; j++) {
          dialyzer.push(arr[i].GoodInfo[j])
        }
      }

      for (let i = 0; i < arrTwo.length; i++) {
        for (let j = 0; j < arrTwo[i].GoodInfo.length; j++) {
          irrigation.push(arrTwo[i].GoodInfo[j])
        }
      }
      for (let i = 0; i < arrThree.length; i++) {
        for (let j = 0; j < arrThree[i].GoodInfo.length; j++) {
          dialysisStrainer.push(arrThree[i].GoodInfo[j])
        }
      }
      this.dialyszers = dialyzer

      this.irrigation = irrigation

      this.dialysisStrainerList = dialysisStrainer

      for (let keys in this.admin_map) {
        if (this.admin_map[keys].user_type == 2 || this.admin_map[keys].user_type == 3) {
          this.adminMapList.push(this.admin_map[keys])
        }
      }
    }
  },

  components: {
    LongAdviceSubMenu,
    MultipleSubMenu,
    MsgTip,
    // MultipleSubMenu,
    CheckBoxSubMenu,
    InforSubMenu,
  },
  watch: {
    'dialysisPrescription.blood_flow_volume': function () {
      this.dialysisPrescription.replacement_flow = replacementFlow(this.dialysisPrescription.blood_flow_volume)
    },
    'dialysisPrescription.dialysis_duration': function () {
      this.dialysisPrescription.anticoagulant_zongliang = calculateAnticoagulantZL(
        1,
        this.dialysisPrescription.anticoagulant_shouji,
        this.dialysisPrescription.dialysis_duration,
        this.dialysisPrescription.anticoagulant_weichi,
        this.dialysisPrescription.add_amount,
        this.dialysisPrescription.reduce_amount
      )
      if (isNaN(this.dialysisPrescription.anticoagulant_zongliang)) {
        this.dialysisPrescription.anticoagulant_zongliang = ''
      }
    },
    'dialysisPrescription.anticoagulant_shouji': function () {
      this.dialysisPrescription.anticoagulant_zongliang = calculateAnticoagulantZL(
        1,
        this.dialysisPrescription.anticoagulant_shouji,
        this.dialysisPrescription.dialysis_duration,
        this.dialysisPrescription.anticoagulant_weichi,
        this.dialysisPrescription.add_amount,
        this.dialysisPrescription.reduce_amount
      )
      if (isNaN(this.dialysisPrescription.anticoagulant_zongliang)) {
        this.dialysisPrescription.anticoagulant_zongliang = ''
      }
    },
    'dialysisPrescription.anticoagulant_weichi': function () {
      this.dialysisPrescription.anticoagulant_zongliang = calculateAnticoagulantZL(
        1,
        this.dialysisPrescription.anticoagulant_shouji,
        this.dialysisPrescription.dialysis_duration,
        this.dialysisPrescription.anticoagulant_weichi,
        this.dialysisPrescription.add_amount,
        this.dialysisPrescription.reduce_amount
      )
      if (isNaN(this.dialysisPrescription.anticoagulant_zongliang)) {
        this.dialysisPrescription.anticoagulant_zongliang = ''
      }
    },
    'dialysisPrescription.add_amount': function () {
      this.dialysisPrescription.anticoagulant_zongliang = calculateAnticoagulantZL(
        1,
        this.dialysisPrescription.anticoagulant_shouji,
        this.dialysisPrescription.dialysis_duration,
        this.dialysisPrescription.anticoagulant_weichi,
        this.dialysisPrescription.add_amount,
        this.dialysisPrescription.reduce_amount
      )
      if (isNaN(this.dialysisPrescription.anticoagulant_zongliang)) {
        this.dialysisPrescription.anticoagulant_zongliang = ''
      }
    },
    'dialysisPrescription.reduce_amount': function () {
      this.dialysisPrescription.anticoagulant_zongliang = calculateAnticoagulantZL(
        1,
        this.dialysisPrescription.anticoagulant_shouji,
        this.dialysisPrescription.dialysis_duration,
        this.dialysisPrescription.anticoagulant_weichi,
        this.dialysisPrescription.add_amount,
        this.dialysisPrescription.reduce_amount
      )
      if (isNaN(this.dialysisPrescription.anticoagulant_zongliang)) {
        this.dialysisPrescription.anticoagulant_zongliang = ''
      }
    },
    isShowDialog (val) {
      if (val) {
        this.advice_visibility = false
      }
    }

  }
}
</script>

<style style="stylesheet/scss" lang="scss" scoped>
  .DialogContent {
  .textarea {
  width: 100%;
  height: 2.4rem;
  line-height: 0.6rem;
  color: $pgh-color;
  font-size: 0.45rem;
  padding-left: 0.36rem;
  border: none;
  border-bottom: 1px #e5e5e5 solid;
  }

  .newButton {
  background: #258ffc;
  padding: 0 0.2rem;
  height: 0.85rem;
  line-height: 0.85rem;
  border-radius: 5px;
  color: #fff;
  margin-right: -3.5rem;
  }
  .newName {
  margin-right: -3rem;
  }
  .newDialogContent {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  > :first-child {
  flex: 1;
  overflow: auto;
  }
  }
  }
  .warnTxt {
  font-size: 0.5rem;
  height: 1rem;
  line-height: 1rem;
  text-align: center;
  background: #faa331;
  color: #fff;
  }
</style>

<style lang="scss">
.DialogTit {

.newButton {
  background: #258ffc;
  padding: 0 0.2rem;
  height: 0.85rem;
  line-height: 0.85rem;
  border-radius: 5px;
  color: #fff;
  margin-right: -2.5rem;
}

.PrescSubmit {
  position: fixed;
  bottom: 0;
}

}

.newListBoxPopupApp{
    width: 80%;
    height: 80%;
    left: 50% !important;
    top: 50% !important;
    transform: translate3d(-50%,-50%,0) !important;
    overflow-y: auto;
    border-radius: .625rem;
    z-index: 5002 !important;
}
.newListBoxPopupApp{
    .listBox{
        >div{
            padding: 1rem .625rem;
            border-bottom: 1px solid #e5e5e5;
            font-size: .175rem;
            color:#323233;
        }
    }
}

</style>
