<template>
  <div>
    <div v-if="isShowDialog" class="Dialog">
      <div class="DialogTit">
        <span class="iconfont" @click="close()">&#xe6e9;</span>
        <h1 class="name">透前评估</h1>
        <span @click="commitInfo" class="success" v-if="hasPermission">保存</span>
        <span class="success" style="visibility: hidden;" v-if="!hasPermission">保存</span>
      </div>
      <div class="warnTxt" v-if="showTxt != ''">
        {{ showTxt }}
      </div>

      <div class="DialogContent" id="dialogTop">
        <div class="item" v-if="isShow('透前称重')">
          <h2 class="name">透前称重(kg)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.weight_before"
            />
          </div>
        </div>

        <div
          class="item" v-if="isShow('干体重')" >
          <h2 class="name">干体重(kg)</h2>
          <div class="content" @click="showDryWeight">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.dry_weight"
              disabled="disabled"
            />
          </div>
          <span class="iconfont">&#xe6f9;</span>
        </div>

        <div class="item" v-if="isShow('衣物重')">
          <h2 class="name">衣物重(kg)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.additional_weight"
            />
          </div>
        </div>

        <div
          @click="showSubMenu('machine_type')"
          class="item"
          ref="machine_type"
          v-if="isShow('透析机型号')"
        >
          <h2 class="name">透析机型号</h2>
          <div class="content">
            <span class="text">{{DialysisModel(formValue.machine_type)}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div class="item" ref="symptom_before_dialysis" v-if="isShow('透析频次')">
          <h2 class="name">透析频次(次/周)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.dialysis_count"
            />
          </div>
        </div>

        <div class="item" v-if="isShow('体温')">
          <h2 class="name">体温(℃)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.temperature"
            />
          </div>
        </div>

        <div class="line"></div>
        <div class="item" v-if="isShow('收缩压')">
          <h2 class="name">收缩压(mmHg)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.systolic_blood_pressure"
            />
          </div>
        </div>
        <div class="item" v-if="isShow('舒张压')">
          <h2 class="name">舒张压(mmHg)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.diastolic_blood_pressure"
            />
          </div>
        </div>

        <div class="item" v-if="isShow('呼吸频率')">
          <h2 class="name">呼吸频率(次/分)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.breathing_rate"
            />
          </div>
        </div>

        <div class="item" v-if="isShow('脉搏')">
          <h2 class="name">脉搏(次/分)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.pulse_frequency"
            />
          </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">{{QueryOperaById(formValue.blood_access_part_opera_id)}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>
        <div class="line"></div>

        <!-- <div
          @click="showSubMenu('blood_access_part')"
          class="item"
          ref="blood_access_part"
          v-if="isShow('血管通路部位')"
        >
          <h2 class="name">血管通路部位</h2>
          <div class="content">
            <span class="text">{{QueryPartById(formValue.blood_access_part_id)}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div> -->

        <div @click="showSubMenu('blood_access_part')" class="item"  ref="blood_access_part"  v-if="isShow('血管通路部位')" >
          <h2 class="name">血管通路部位</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{formValue.blood_access_part_id}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div class="item" ref="venous_catheterization_part_other" v-if="isShow('血管通路其他部位')">
          <h2 class="name">血管通路其他部位</h2>
          <div class="content">
            <input @focus="inputFocus" v-model="formValue.venous_catheterization_part_other" />
          </div>
        </div>

        <div @click="showSubMenu('humor_excessive_symptom_info')" class="item"  ref="humor_excessive_symptom_info"  v-if="isShow('体液过多症状')" >
          <h2 class="name">体液过多症状</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{QueryHumorById(formValue.humor_excessive_symptom)}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div @click="showSubMenu('internal_fistula')" class="item"  ref="internal_fistula"  v-if="isShow('内瘘')" >
          <h2 class="name">内瘘</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{formValue.internal_fistula}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div class="item" ref="internal_fistula_other" v-if="isShow('血管通路(内瘘)其他')">
          <h2 class="name">血管通路(内瘘)其他</h2>
          <div class="content">
            <input @focus="inputFocus" v-model="formValue.internal_fistula_other" />
          </div>
        </div>

        <div
          @click="showSubMenu('blood_access_noise')"
          class="item"
          ref="blood_access_noise"
          v-if="isShow('血管杂音')"
        >
          <h2 class="name">血管杂音</h2>
          <div class="content">
            <span
              class="text"
              style="width: 100px"
            >{{getBloodAccessNoise(formValue.blood_access_noise)}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div
          @click="showSubMenu('internal_fistula_skin')"
          class="item"
          ref="internal_fistula_skin"
          v-if="isShow('血管通路皮肤情况')"
        >
          <h2 class="name">血管通路皮肤情况</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{formValue.internal_fistula_skin}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div
          @click="showSubMenu('venous_catheterization')"
          class="item"
          ref="venous_catheterization"
          v-if="isShow('中心静脉置管')"
        >
          <h2 class="name">中心静脉置管</h2>
          <div class="content">
            <span
              class="text"
              style="width: 100px"
            >{{getVenousCatheterization(formValue.venous_catheterization)}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div @click="showSubMenu('catheter')" class="item" ref="catheter" v-if="isShow('导管')">
          <h2 class="name">导管</h2>
          <div class="content">
            <span class="text">{{formValue.catheter}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div
          @click="showSubMenu('catheter_bend')"
          class="item"
          ref="catheter_bend"
          v-if="isShow('导管打折')"
        >
          <h2 class="name">导管打折</h2>
          <div class="content">
            <span class="text">{{GetCatheterBendById(formValue.catheter_bend)}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div
          @click="showSubMenu('puncture_needle')"
          class="item"
          ref="puncture_needle"
          v-if="isShow('穿刺针')"
        >
          <h2 class="name">穿刺针</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{formValue.puncture_needle}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div
          @click="showSubMenu('pinholing')"
          class="item"
          ref="pinholing"
          v-if="isShow('针眼')"
        >
          <h2 class="name">针眼</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{formValue.pinholing}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div
          @click="showSubMenu('puncture_way')"
          class="item"
          ref="puncture_way"
          v-if="isShow('穿刺方式')"
        >
          <h2 class="name">穿刺方式</h2>
          <!-- <div class="content">
            <span class="text" style="width: 100px">{{getWay(formValue.puncture_way)}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div> -->
           <div class="content">
            <span class="text" style="width: 100px">{{formValue.puncture_way}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div class="item" v-if="isShow('出血')" ref="hemorrhage_state" @click="showSubMenu('hemorrhage_state')">
          <h2 class="name">出血</h2>
          <div class="content">
            <span v-if="formValue.is_hemorrhage == 0" class="text" style="width: 50px"></span>
            <span v-if="formValue.is_hemorrhage == 1" class="text" style="width: 50px">有</span>
            <span v-if="formValue.is_hemorrhage == 2" class="text" style="width: 50px">无</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

          <div
          @click="showSubMenu('hemorrhage')"
          class="item"
          ref="hemorrhage"
          v-if="formValue.is_hemorrhage == 1&&isShow('出血选项')"
        >
          <h2 class="name">—— 出血选项</h2>
          <div class="content">
            <span class="text" style="width: 50px">{{formValue.hemorrhage}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>
      

          <div class="item" v-if="isShow('血栓')" ref="thromubus_type" @click="showSubMenu('thromubus_type')">
          <h2 class="name">血栓</h2>
          <div class="content">
            <span v-if="formValue.thromubus_type == 0" class="text" style="width: 50px"></span>
            <span v-if="formValue.thromubus_type == 1" class="text" style="width: 50px">有</span>
            <span v-if="formValue.thromubus_type == 2" class="text" style="width: 50px">无</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>


       <div class="item" v-show="thromubusShow">
          <h2 class="name">导管AV端各约(cm)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.thrombus_av"
            />
          </div>
        </div>

       <div class="item" v-show="thromubusShow">
          <h2 class="name">导管A端约(cm)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.thromubus_a"
            />
          </div>
        </div>

        <div class="item" v-show="thromubusShow">
          <h2 class="name">导管V端约(cm)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.thromubus_v"
            />
          </div>
        </div>



        <div class="item" v-if="formValue.is_hemorrhage == 1&&isShow('其他出血情况')">
          <h2 class="name">—— 其他出血情况</h2>
          <div class="content">
            <input @focus="inputFocus" v-model="formValue.hemorrhage_other" />
          </div>
        </div>

        <div @click="showSubMenu('skin')" class="item" ref="skin" v-if="isShow('皮肤')">
          <h2 class="name">皮肤</h2>
          <!-- <div class="content">
            <span class="text" style="width: 100px">{{getSkin(formValue.skin)}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div> -->
            <div class="content">
            <span class="text" style="width: 100px">{{formValue.skin}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div
          @click="showSubMenu('complication')"
          class="item"
          ref="complication"
          v-if="isShow('并发症')"
        >
          <h2 class="name">并发症</h2>
          <div class="content">
            <span class="text" style="width: 50px">{{formValue.complication}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div
          @click="showSubMenu('symptom_before_dialysis')"
          class="item"
          ref="symptom_before_dialysis"
          v-if="isShow('透析前症状')"
        >
          <h2 class="name">透析前症状</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{formValue.symptom_before_dialysis}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div
          @click="showSubMenu('last_post_dialysis')"
          class="item"
          ref="last_post_dialysis"
          v-if="isShow('前次透析后症状')"
        >
          <h2 class="name">前次透析后症状</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{formValue.last_post_dialysis}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div
          @click="showSubMenu('emergency_treatment')"
          class="item"
          ref="emergency_treatment"
          v-if="isShow('急诊')"
        >
          <h2 class="name">急诊</h2>
          <div class="content">
            <span
              class="text"
              style="width: 100px"
            >{{getEmergencyTreatment(formValue.emergency_treatment)}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div class="item" ref="emergency_treatment_other" v-if="isShow('其他急诊情况')">
          <h2 class="name">其他急诊情况</h2>
          <div class="content">
            <input @focus="inputFocus" v-model="formValue.emergency_treatment_other" />
          </div>
        </div>

        <div class="item" v-if="this.$store.getters.user.template_info.template_id == 6">
          <h2 class="name">透前净体重(kg)</h2>
          <div class="content">
            <input
              type="number"
              readonly
              disabled="disabled"
              v-model="body_weight_before"
            />
          </div>
        </div>

        <!-- <div
          @click="showSubMenu('hemorrhage')"
          class="item"
          ref="hemorrhage"
          v-if="hemorrhage_state&&isShow('出血选项')"
        >
          <h2 class="name">—— 出血选项</h2>
          <div class="content">
            <span class="text" style="width: 50px">{{formValue.hemorrhage}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>
        <div class="item" v-if="hemorrhage_state&&isShow('其他出血情况')">
          <h2 class="name">—— 其他出血情况</h2>
          <div class="content">
            <input @focus="inputFocus" v-model="formValue.hemorrhage_other" />
          </div>
        </div> -->

        <div
          @click="showSubMenu('dialysis_interphase')"
          class="item"
          ref="dialysis_interphase"
          v-if="isShow('透析期间')"
        >
          <h2 class="name">透析期间</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{formValue.dialysis_interphase}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

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

<!--        <div-->
<!--          @click="showSubMenu('blood_access_internal_fistula')"-->
<!--          class="item"-->
<!--          ref="blood_access_internal_fistula"-->
<!--          v-if="isShow('血管通路(内瘘)')"-->
<!--        >-->
<!--          <h2 class="name">血管通路(内瘘)</h2>-->
<!--          <div class="content">-->
<!--            <span class="text" style="width: 100px">{{formValue.blood_access_internal_fistula}}</span>-->
<!--            <span class="iconfont">&#xe6f9;</span>-->
<!--          </div>-->
<!--        </div>-->

<!--        <div-->
<!--          @click="showSubMenu('venous_catheterization_part')"-->
<!--          class="item"-->
<!--          ref="venous_catheterization_part"-->
<!--          v-if="isShow('位置')"-->
<!--        >-->
<!--          <h2 class="name">位置</h2>-->
<!--          <div class="content">-->
<!--            <span-->
<!--              class="text"-->
<!--              style="width: 100px"-->
<!--            >{{getVenousCatheterizationPart(formValue.venous_catheterization_part)}}</span>-->
<!--            <span class="iconfont">&#xe6f9;</span>-->
<!--          </div>-->
<!--        </div>-->

        <div
          @click="showSubMenu('ductus_arantii')"
          class="item"
          ref="ductus_arantii"
          v-if="isShow('中心静脉导管')"
        >
          <h2 class="name">中心静脉导管</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{formValue.ductus_arantii}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div class="item" ref="ductus_arantii_other" v-if="isShow('导管其他')">
          <h2 class="name">导管其他</h2>
          <div class="content">
            <input @focus="inputFocus" v-model="formValue.ductus_arantii_other" />
          </div>
        </div>

        <div
          class="item"
          v-if="isShow('感染')"
          @click="showSubMenu('infect_state')"
          ref="infect_state"
        >
          <h2 class="name">感染</h2>
          <div class="content">
            <span v-if="formValue.is_infect == 0" class="text" style="width: 50px"></span>
            <span v-if="formValue.is_infect == 1" class="text" style="width: 50px">无</span>
            <span v-if="formValue.is_infect == 2" class="text" style="width: 50px">有</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div class="item" ref="skin_other" v-if="isShow('其他感染情况')">
          <h2 class="name">其他感染情况</h2>
          <div class="content">
            <input @focus="inputFocus" v-model="formValue.infect_other" />
          </div>
        </div>

        <div class="item" v-if="isShow('外露')">
          <h2 class="name">外露(cm)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.exposed"
            />
          </div>
        </div>

        <div class="item" ref="skin_other" v-if="isShow('其他皮肤情况')">
          <h2 class="name">其他皮肤情况</h2>
          <div class="content">
            <input @focus="inputFocus" v-model="formValue.skin_other" />
          </div>
        </div>

        <div
          @click="showSubMenu('catheter_suture')"
          class="item"
          ref="catheter_suture"
          v-if="isShow('导管缝线')"
        >
          <h2 class="name">导管缝线</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{formValue.catheter_suture}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div class="item" ref="skin_other" v-if="isShow('导管缝线(其他)')">
          <h2 class="name">导管缝线(其他)</h2>
          <div class="content">
            <input @focus="inputFocus" v-model="formValue.catheter_suture_other" />
          </div>
        </div>

        <div class="item" v-if="isShow('尿量')">
          <h2 class="name">尿量(ml)</h2>
          <div class="content">
            <input
              type="number"
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.urine_volume"
            />
          </div>
        </div>

        <div
          @click="showSubMenu('edema')"
          class="item"
          ref="edema"
          v-if="isShow('水肿')"
        >
         <h2 class="name">水肿</h2>
          <div class="content">
            <span class="text" style="width: 100px">{{formValue.edema}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>

        <div class="item" v-if="isShow('特殊处理情况')">
          <h2 class="name">特殊处理情况:</h2>
          <div class="content">
            <input
              @click="newClick($event)"
              @focus="inputFocus"
              v-model="formValue.special_treatment"
            />
          </div>
        </div>

        <div
          @click="showSubMenu('catheter_maintenance')"
          class="item"
          ref="catheter_maintenance"
          v-if="isShow('导管维护')"
        >
          <h2 class="name">导管维护</h2>
          <div class="content">
            <span class="text" style="width: 50px">{{formValue.catheter_maintenance}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>
         

     
        

        <div class="line"></div>
        <div>
          <div class="item">
            <h2 class="name">备注</h2>
            <div class="content">
              <span class="text"></span>
            </div>
          </div>
          <textarea
            class="textarea"
            placeholder="请输入内容"
            @focus="lastInputFocus"
            @blur="lastInputBlur"
            v-model="formValue.remark"
          ></textarea>
        </div>
      </div>
    </div>

    <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>

    <dry-weight-menu
      ref="dry"
      v-on:menu-cancle-two="menuDryCancle"
      v-on:menu-comfirm-two="menuDryComfirm"
      :propsForm="propDryForm"
    ></dry-weight-menu>
  </div>
</template>

<script>
// import TwoMenu from "./TwoMenu";
import axios from 'axios'
import CheckBoxSubMenu from './subMenu/checkBoxSubMenu'
import { EditAssessmentBeforeDislysis } from '@/api/patient'
import { Toast } from 'vant'
import { getDataConfig } from '@/utils/data'
import DryWeightMenu from './subMenu/dryWeightMenu'

import request from '@/utils/request'

export default {
  name: 'PrescriptionDialog',
  props: {
    dry_weight: {
      type: Object
    },
    patient_prop: {
      type: Object
    },
    predialysis: {
      type: Object
    },
    last_predialysis: {
      type: Object
    },
    admin_users_prop: {
      type: Array
    },
    lastAssessment:{
      type:Object
    }
  },
  data () {
    return {
      showTxt: '',
      hasPermission: true,
      propDryForm: {
        weight: 0,
        doctor: []
      },
      isShowDialog: true,
      // sub menu prop
      visibility: false,
      body_weight_before: '',
      is_show_dry_weight: false,
      propForm: {
        title: '',
        list: [],
        optionList: [],
        isMultiple: 2,
        result: [], // 选中的值
        type: 1, // 用来区分不同子菜单，方便对返回值进行赋值
        selectId: 0,
        isHasOther: 1 // 是否有其他选项  1是 2否
      },
      hemorrhage_state: false,
      infect_state: false,
      hemorrhages: [{ id: 1, name: '有' }, { id: 2, name: '无' }],
      
      infects: [{ id: 1, name: '无' }, { id: 2, name: '有' }],
      thromubustype:[{id:1,name:'有'},{id:2,name:'无'}],
      formValue: {
        weight_before: '',
        dry_weight: '',
        additional_weight: '',
        temperature: '',
        systolic_blood_pressure: '',
        diastolic_blood_pressure: '',
        symptom_before_dialysis: '',
        pulse_frequency: '',
        last_post_dialysis: '',
        dialysis_interphase: '',
        catheter: '',
        catheter_bend: 2,
        complication: '',
        remark: '',
        blood_access_part_id: '',
        blood_access_part_opera_id: '',
        humor_excessive_symptom: '',
        internal_fistula: '',
        internal_fistula_skin: '',
        is_hemorrhage: 0,
        hemorrhage: '',
        hemorrhage_other: '',
        dialysis_count: '',
        emergency_treatment: '',
        emergency_treatment_other: '',
        ductus_arantii: '',
        venous_catheterization_part_other: '',
        venous_catheterization_part: '',
        venous_catheterization: '',
        puncture_way: '',
        blood_access_noise: '',
        internal_fistula_other: '',
        blood_access_internal_fistula: '',
        machine_type: '',
        breathing_rate: '',
        is_infect: 0,
        exposed: '',
        skin: '',
        skin_other: '',
        infect_other: '',
        ductus_arantii_other: '',
        puncture_needle: '',
        pinholing: '',
        catheter_suture: '',
        catheter_suture_other: '',
        urine_volume: '',
        edema: '',
        special_treatment: '',
        catheter_maintenance: '',
        thromubus_type:0,
        thrombus_av:'',
        thromubus_a:'',
        thromubus_v:'',
      },

      record_date: '',
      machineType: [],
      thromubusShow:false,
    }
  },
  watch: {
    'formValue.weight_before': {
      handler (newWeight, oldWeight) {
        // eslint-disable-next-line no-unused-vars
        let weight = parseFloat(
          newWeight - this.formValue.additional_weight
        ).toFixed(1)
        if (weight > 0) {
          this.body_weight_before = weight
        } else {
          this.body_weight_before = ''
        }
      },
      deep: true,
      immediate: true
    },
    'formValue.additional_weight': {
      handler (newWeight, oldWeight) {
        // eslint-disable-next-line no-unused-vars
        if (newWeight > 0) {
          let weight = parseFloat(
            this.formValue.weight_before - newWeight
          ).toFixed(1)
          if (weight > 0) {
            this.body_weight_before = weight
          } else {
            this.body_weight_before = ''
          }
        }
      },
      deep: true,
      immediate: true,
      data: []
    }
  },
  methods: {
    newClick (event) {
      event.currentTarget.select()
    },
    menuDryComfirm (val) {
      this.isShowDialog = true
      this.$refs.dry.close()
      this.formValue.dry_weight = val.dry_weight
      this.propDryForm.weight = val.dry_weight
      this.dry_weight = val
      this.$emit('weight_update', this.dry_weight)
    },
    menuDryCancle () {
      this.isShowDialog = true
      this.$refs.dry.close()

      // this.is_show_dry_weight = false
    },
    isShow (name) {
      var filedList = this.$store.getters.user.fileds

      for (let i = 0; i < filedList.length; i++) {
        if (
          filedList[i].module == 3 &&
          filedList[i].filed_name_cn == name &&
          filedList[i].is_show == 1
        ) {
          return true
        }
      }
      return false
    },
    getBloodAccessInternalFistula: function (id) {
      if (id == -1) {
        return '其他'
      }
      var BloodAccessInternalFistulaName = ''
      var BloodAccessInternalFistulaOptions = this.$store.getters
        .blood_access_internal_fistula
      for (let i = 0; i < BloodAccessInternalFistulaOptions.length; i++) {
        if (BloodAccessInternalFistulaOptions[i].id == id) {
          BloodAccessInternalFistulaName =
            BloodAccessInternalFistulaOptions[i].name
        }
      }
      return BloodAccessInternalFistulaName
    },
    getBloodAccessNoise: function (id) {
      var BloodAccessNoiseOptions = this.$store.getters.blood_access_noise
      var BloodAccessNoiseName = ''
      for (let i = 0; i < BloodAccessNoiseOptions.length; i++) {
        if (BloodAccessNoiseOptions[i].id == id) {
          BloodAccessNoiseName = BloodAccessNoiseOptions[i].name
        }
      }
      return BloodAccessNoiseName
    },
    getVenousCatheterization: function (id) {
      var VenousCatheterizationOptions = this.$store.getters
        .venous_catheterization
      var VenousCatheterizationName = ''
      for (let i = 0; i < VenousCatheterizationOptions.length; i++) {
        if (VenousCatheterizationOptions[i].id == id) {
          VenousCatheterizationName = VenousCatheterizationOptions[i].name
        }
      }
      return VenousCatheterizationName
    },
    getWay: function (id) {
      var PunctureWayOptions = getDataConfig('hemodialysis', 'puncture_method')
      var PunctureWayOptionsName = ''
      for (let i = 0; i < PunctureWayOptions.length; i++) {
        if (PunctureWayOptions[i].id == id) {
          PunctureWayOptionsName = PunctureWayOptions[i].name
        }
      }
      return PunctureWayOptionsName
    },
    getVenousCatheterizationPart: function (id) {
      if (id == -1) {
        return '其他'
      }
      var venousCatheterizationPartOptions = this.$store.getters
        .venous_catheterization_part
      var venousCatheterizationPartName = ''
      for (let i = 0; i < venousCatheterizationPartOptions.length; i++) {
        if (venousCatheterizationPartOptions[i].id == id) {
          venousCatheterizationPartName =
            venousCatheterizationPartOptions[i].name
        }
      }
      return venousCatheterizationPartName
    },
    getEmergencyTreatment: function (id) {
      if (id == -1) {
        return '其他'
      }
      var emergencyTreatmentOptions = this.$store.getters.emergency_treatment
      var emergencyTreatmentName = ''
      for (let i = 0; i < emergencyTreatmentOptions.length; i++) {
        if (emergencyTreatmentOptions[i].id == id) {
          emergencyTreatmentName = emergencyTreatmentOptions[i].name
        }
      }
      return emergencyTreatmentName
    },
    getSkin: function (id) {
      if (id == -1) {
        return '其他'
      }
      var skinOptions = this.$store.getters.skin
      var skinName = ''
      for (let i = 0; i < skinOptions.length; i++) {
        if (skinOptions[i].id == id) {
          skinName = skinOptions[i].name
        }
      }
      return skinName
    },
    hemorrhageStateChange: function (is_select) {
      this.formValue.is_hemorrhage = is_select == true ? 1 : 2
    },
    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
      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 'last_post_dialysis':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.type = 1
          this.isShowDialog = false
          this.propForm.isShowOther = 2

          this.propForm.title = '前次透析后'
          this.visibility = true
          this.propForm.list = getDataConfig(
            'hemodialysis',
            'last_dialysis_after'
          )
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          if (
            this.formValue.last_post_dialysis != undefined ||
            this.formValue.last_post_dialysis != null
          ) {
            if (this.formValue.last_post_dialysis.length > 0) {
              this.propForm.result = this.formValue.last_post_dialysis.split(
                ','
              )
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }

          this.propForm.click_ref = 'last_post_dialysis'

          break
        case 'dialysis_interphase':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.isShowOther = 2

          this.propForm.type = 2
          this.isShowDialog = false
          this.propForm.title = '透析期间'
          this.visibility = true
          this.propForm.list = getDataConfig(
            'hemodialysis',
            'dialysis_duration'
          )
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          if (
            this.formValue.dialysis_interphase != undefined ||
            this.formValue.dialysis_interphase != null
          ) {
            if (this.formValue.dialysis_interphase.length > 0) {
              this.propForm.result = this.formValue.dialysis_interphase.split(
                ','
              )
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'dialysis_interphase'
          break

        case 'symptom_before_dialysis':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.isShowOther = 2

          this.propForm.type = 3
          this.isShowDialog = false
          this.propForm.title = '透析前症状'
          this.visibility = true
          this.propForm.list = getDataConfig('hemodialysis', 'dialysis_before')
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          if (
            this.formValue.symptom_before_dialysis != undefined ||
            this.formValue.symptom_before_dialysis != null
          ) {
            if (this.formValue.symptom_before_dialysis.length > 0) {
              this.propForm.result = this.formValue.symptom_before_dialysis.split(
                ','
              )
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'symptom_before_dialysis'
          break

        case 'catheter':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 4
          this.isShowDialog = false
          this.propForm.title = '导管'
          this.visibility = true
          this.propForm.list = getDataConfig('hemodialysis', 'catheter')
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          if (
            this.formValue.catheter != undefined ||
            this.formValue.catheter != null
          ) {
            if (this.formValue.catheter.length > 0) {
              this.propForm.result = this.formValue.catheter.split(',')
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }

          this.propForm.click_ref = 'catheter'

          break
        case 'complication':
          this.propForm.result = []
          this.isHasOther = 1
          this.propForm.isShowOther = 2

          this.propForm.type = 5
          this.isShowDialog = false
          this.propForm.title = '并发症'
          this.visibility = true
          this.propForm.list = getDataConfig('hemodialysis', 'complication')
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          // this.propForm.result = this.formValue.complication.split(",")
          if (
            this.formValue.complication != undefined ||
            this.formValue.complication != null
          ) {
            if (this.formValue.complication.length > 0) {
              this.propForm.result = this.formValue.complication.split(',')
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }

          this.propForm.click_ref = 'complication'
          break

        case 'blood_access_part':
          // this.isHasOther = 2
          // this.propForm.isShowOther = 1

          // this.propForm.type = 6
          // this.isShowDialog = false
          // this.propForm.title = '血管通路部位'
          // this.visibility = true
          // this.propForm.list = []
          // this.propForm.optionList = getDataConfig(
          //   'hemodialysis',
          //   'vascular_access'
          // )
          // this.propForm.isMultiple = 1
          // this.propForm.selectId = this.formValue.blood_access_part_id
          // this.propForm.click_ref = 'blood_access_part'

          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 6
          this.isShowDialog = false
          this.propForm.title = '血管通路部位'
          this.visibility = true
          this.propForm.list = []
          this.propForm.list = getDataConfig(
            'hemodialysis',
            'vascular_access'
          )
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          if (
            this.formValue.blood_access_part_id != undefined ||
            this.formValue.blood_access_part_id != null
          ) {
            if (this.formValue.blood_access_part_id.length > 0) {
              this.propForm.result = this.formValue.blood_access_part_id.split(',')
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'blood_access_part_id'
          break

        case 'vascular_access_desc':
          this.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 7
          this.isShowDialog = false
          this.propForm.title = '血管通路'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = getDataConfig(
            'hemodialysis',
            'vascular_access_desc'
          )
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.formValue.blood_access_part_opera_id
          this.propForm.click_ref = 'vascular_access_desc'
          break

        case 'humor_excessive_symptom_info':
          this.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 24
          this.isShowDialog = false
          this.propForm.title = '体液过多症状'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = getDataConfig('hemodialysis', 'humor_excessive_symptom')
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.formValue.humor_excessive_symptom
          this.propForm.click_ref = 'humor_excessive_symptom_info'
          break

        case 'internal_fistula':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 8
          this.isShowDialog = false
          this.propForm.title = '内瘘'
          this.visibility = true
          this.propForm.list = []
          this.propForm.list = getDataConfig(
            'hemodialysis',
            'internal_fistula'
          )

          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          // this.propForm.result = this.formValue.internal_fistula.split(",")
          if (
            this.formValue.internal_fistula != undefined ||
            this.formValue.internal_fistula != null
          ) {
            if (this.formValue.internal_fistula.length > 0) {
              this.propForm.result = this.formValue.internal_fistula.split(',')
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'internal_fistula'
          break

        case 'hemorrhage':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 9
          this.isShowDialog = false
          this.propForm.title = '出血'
          this.visibility = true
          this.propForm.list = []
          this.propForm.list = getDataConfig('hemodialysis', 'hemorrhage')
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          // this.propForm.result = typeof(this.formValue.hemorrhage) == "string"? this.formValue.hemorrhage.split(","):[]
          if (
            this.formValue.hemorrhage != undefined ||
            this.formValue.hemorrhage != null
          ) {
            if (this.formValue.hemorrhage.length > 0) {
              this.propForm.result = this.formValue.hemorrhage.split(',')
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'hemorrhage'
          break
        case 'internal_fistula_skin':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 10
          this.isShowDialog = false
          this.propForm.title = '血管通路皮肤情况'
          this.visibility = true
          this.propForm.list = getDataConfig('hemodialysis', 'internal_fistula_skin')
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          // this.propForm.result = this.formValue.hemorrhage.split(",")
          if (
            this.formValue.internal_fistula_skin != undefined ||
            this.formValue.internal_fistula_skin != null
          ) {
            if (this.formValue.internal_fistula_skin.length > 0) {
              this.propForm.result = this.formValue.internal_fistula_skin.split(
                ','
              )
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'internal_fistula_skin'
          break

        case 'catheter_bend':
          this.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 11
          this.isShowDialog = false
          this.propForm.title = '导管打折'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.$store.getters.catheter_bend
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.formValue.catheter_bend
          this.propForm.click_ref = 'catheter_bend'
          break

        case 'blood_access_internal_fistula':
          this.propForm.result = []
          this.propForm.isHasOther = 2
          this.propForm.type = 12
          this.propForm.isShowOther = 1

          this.isShowDialog = false
          this.propForm.title = '血管通路(内瘘)'
          this.visibility = true
          this.propForm.list = this.$store.getters.blood_access_internal_fistula
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          // this.propForm.result = this.formValue.hemorrhage.split(",")
          if (
            this.formValue.blood_access_internal_fistula != undefined ||
            this.formValue.blood_access_internal_fistula != null
          ) {
            if (this.formValue.blood_access_internal_fistula.length > 0) {
              this.propForm.result = this.formValue.blood_access_internal_fistula.split(
                ','
              )
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'blood_access_internal_fistula'
          break

        case 'blood_access_noise':
          this.propForm.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 13
          this.isShowDialog = false
          this.propForm.title = '血管杂音'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.$store.getters.blood_access_noise
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.formValue.blood_access_noise
          this.propForm.click_ref = 'blood_access_noise'
          break

        case 'venous_catheterization':
          this.propForm.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 14
          this.isShowDialog = false
          this.propForm.title = '中心静脉置管'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.$store.getters.venous_catheterization
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.formValue.venous_catheterization
          this.propForm.click_ref = 'venous_catheterization'
          break
        case 'venous_catheterization_part':
          this.propForm.isHasOther = 1

          this.propForm.type = 15
          this.isShowDialog = false
          this.propForm.title = '位置'
          this.propForm.isShowOther = 1

          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = this.$store.getters.venous_catheterization_part
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.formValue.venous_catheterization_part
          this.propForm.click_ref = 'venous_catheterization_part'
          break
        case 'ductus_arantii':
          this.propForm.result = []
          this.propForm.isHasOther = 2
          this.propForm.type = 16
          this.isShowDialog = false
          this.propForm.title = '中心静脉导管'
          this.propForm.isShowOther = 1

          this.visibility = true
          this.propForm.list = this.$store.getters.ductus_arantii
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          // this.propForm.result = this.formValue.hemorrhage.split(",")
          if (
            this.formValue.ductus_arantii != undefined ||
            this.formValue.ductus_arantii != null
          ) {
            if (this.formValue.ductus_arantii.length > 0) {
              this.propForm.result = this.formValue.ductus_arantii.split(',')
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'ductus_arantii'

          break

        case 'emergency_treatment':
          this.propForm.isHasOther = 1

          this.propForm.type = 17
          this.isShowDialog = false
          this.propForm.title = '急诊'
          this.visibility = true
          this.propForm.isShowOther = 1

          this.propForm.list = []
          this.propForm.optionList = this.$store.getters.emergency_treatment
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.formValue.emergency_treatment
          this.propForm.click_ref = 'emergency_treatment'
          break
        // case 'puncture_way':
        //   this.propForm.isHasOther = 2
        //   this.propForm.type = 18
        //   this.isShowDialog = false
        //   this.propForm.title = '穿刺方式'
        //   this.visibility = true
        //   this.propForm.list = []
        //   this.propForm.isShowOther = 1

        //   this.propForm.optionList = getDataConfig('hemodialysis', 'puncture_method')
        //   this.propForm.isMultiple = 1
        //   this.propForm.selectId = this.formValue.puncture_way
        //   this.propForm.click_ref = 'puncture_way'
        //   break
        case 'hemorrhage_state':
          this.propForm.type = 19
          this.isShowDialog = false
          this.propForm.title = '出血'
          this.visibility = true
          this.propForm.isShowOther = 1

          this.propForm.list = []
          this.propForm.optionList = this.hemorrhages
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.formValue.is_hemorrhage
          this.propForm.click_ref = 'hemorrhage_state'
          break

        case 'infect_state':
          this.propForm.type = 20
          this.isShowDialog = false
          this.propForm.title = '感染'
          this.visibility = true
          this.propForm.isShowOther = 1

          this.propForm.list = []
          this.propForm.optionList = this.infects
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.formValue.is_infect
          this.propForm.click_ref = 'infect_state'
          break

        // case 'skin':
        //   this.propForm.type = 21
        //   this.isShowDialog = false
        //   this.propForm.title = '皮肤'
        //   this.visibility = true
        //   this.propForm.isShowOther = 1

        //   this.propForm.list = []
        //   this.propForm.optionList = this.$store.getters.skin
        //   this.propForm.isMultiple = 1
        //   this.propForm.selectId = this.formValue.skin
        //   this.propForm.click_ref = 'skin'
        //   break

        case 'puncture_needle':
          this.propForm.result = []
          this.propForm.isHasOther = 2
          this.propForm.type = 22
          this.isShowDialog = false
          this.propForm.isShowOther = 1

          this.propForm.title = '穿刺针'
          this.visibility = true
          this.propForm.list = getDataConfig(
            'hemodialysis',
            'puncture_needle'
          )
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          if (
            this.formValue.puncture_needle != undefined ||
            this.formValue.puncture_needle != null
          ) {
            if (this.formValue.puncture_needle.length > 0) {
              this.propForm.result = this.formValue.puncture_needle.split(',')
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'puncture_needle'
          break

        case 'machine_type':
          this.isHasOther = 2
          this.propForm.isShowOther = 1
          this.propForm.type = 23
          this.isShowDialog = false
          this.propForm.title = '透析机型号'
          this.visibility = true
          this.propForm.list = []
          this.propForm.optionList = getDataConfig(
            'hemodialysis',
            'machine_type'
          )
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.formValue.machine_type
          this.propForm.click_ref = 'machine_type'
          break
        // eslint-disable-next-line no-duplicate-case
        case 'skin':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 25
          this.isShowDialog = false
          this.propForm.title = '皮肤'
          this.visibility = true
          this.propForm.list = getDataConfig('hemodialysis', 'skin')
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          // this.propForm.result = this.formValue.hemorrhage.split(",")
          if (
            this.formValue.skin != undefined ||
            this.formValue.skin != null
          ) {
            if (this.formValue.skin.length > 0) {
              this.propForm.result = this.formValue.skin.split(
                ','
              )
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'skin'
          break
        case 'puncture_way':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 26
          this.isShowDialog = false
          this.propForm.title = '穿刺方式'
          this.visibility = true
          this.propForm.list = getDataConfig('hemodialysis', 'puncture_method')
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          // this.propForm.result = this.formValue.hemorrhage.split(",")
          if (
            this.formValue.puncture_way != undefined ||
            this.formValue.puncture_way != null
          ) {
            if (this.formValue.puncture_way.length > 0) {
              this.propForm.result = this.formValue.puncture_way.split(
                ','
              )
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'puncture_way'
          break

        case 'pinholing':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.isShowOther = 1

          this.propForm.type = 30
          this.isShowDialog = false
          this.propForm.title = '针眼'
          this.visibility = true
          this.propForm.list = getDataConfig('hemodialysis', 'pinholing')
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          // this.propForm.result = this.formValue.hemorrhage.split(",")
          if (
            this.formValue.pinholing != undefined ||
            this.formValue.pinholing != null
          ) {
            if (this.formValue.pinholing.length > 0) {
              this.propForm.result = this.formValue.pinholing.split(',')
              // console.log("箴言------",this.propForm.result)
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }
          this.propForm.click_ref = 'puncture_way'
          break

        case 'edema':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.type = 28
          this.isShowDialog = false
          this.propForm.isShowOther = 2
          this.propForm.title = '水肿'
          this.visibility = true
          this.propForm.list = getDataConfig(
            'hemodialysis',
            'edema'
          )
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          if (
            this.formValue.edema != undefined ||
            this.formValue.edema != null
          ) {
            if (this.formValue.edema.length > 0) {
              this.propForm.result = this.formValue.edema.split(
                ','
              )
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }

          this.propForm.click_ref = 'edema'

          break
        case 'catheter_suture':
          this.propForm.result = []
          this.isHasOther = 2
          this.propForm.type = 27
          this.isShowDialog = false
          this.propForm.isShowOther = 2

          this.propForm.title = '导管缝线'
          this.visibility = true
          this.propForm.list = getDataConfig(
            'hemodialysis',
            'catheter_suture'
          )
          this.propForm.optionList = []
          this.propForm.isMultiple = 2
          if (
            this.formValue.catheter_suture != undefined ||
            this.formValue.catheter_suture != null
          ) {
            if (this.formValue.catheter_suture.length > 0) {
              this.propForm.result = this.formValue.catheter_suture.split(
                ','
              )
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }

          this.propForm.click_ref = 'catheter_suture'

          break

        case 'catheter_maintenance':
          this.propForm.result = []
          this.isHasOther = 1
          this.propForm.isShowOther = 2

          this.propForm.type = 31
          this.isShowDialog = false
          this.propForm.title = '导管维护'
          this.visibility = true
          this.propForm.list = getDataConfig('hemodialysis', 'catheter_maintenance')
          this.propForm.optionList = []
          this.propForm.isMultiple = 2

          if (
            this.formValue.catheter_maintenance != undefined ||
            this.formValue.catheter_maintenance != null
          ) {
            if (this.formValue.catheter_maintenance.length > 0) {
              this.propForm.result = this.formValue.catheter_maintenance.split(',')
            } else {
              this.propForm.result = []
            }
          } else {
            this.propForm.result = []
          }

          this.propForm.click_ref = 'catheter_maintenance'
          break

        case 'thromubus_type':
          this.propForm.type = 32
          this.isShowDialog = false
          this.propForm.title = '出血'
          this.visibility = true
          this.propForm.isShowOther = 1

          this.propForm.list = []
          this.propForm.optionList = this.thromubustype
          this.propForm.isMultiple = 1
          this.propForm.selectId = this.formValue.thromubus_type
          this.propForm.click_ref = 'thromubus_type'
          break
      }
    },
    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()
        }
      })
    },
    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:
          this.formValue.last_post_dialysis = val.result.join(',')
          break
        case 2:
          this.formValue.dialysis_interphase = val.result.join(',')
          break

        case 3:
          this.formValue.symptom_before_dialysis = val.result.join(',')
          break
        case 4:
          this.formValue.catheter = val.result.join(',')
          break
        case 5:
          this.formValue.complication = val.result.join(',')
          break
        case 6:
          this.formValue.blood_access_part_id = val.result.join(',')
          break
        case 7:
          this.formValue.blood_access_part_opera_id = val.selectId
          break
        case 8:
          this.formValue.internal_fistula = val.result.join(',')
          break
        case 9:
          this.formValue.hemorrhage = val.result.join(',')
          break
        case 10:
          this.formValue.internal_fistula_skin = val.result.join(',')
          break
        case 11:
          this.formValue.catheter_bend = val.selectId
          break
        case 12:
          this.formValue.blood_access_internal_fistula = val.result.join(',')
          break
        case 13:
          this.formValue.blood_access_noise = val.selectId
          break
        case 14:
          this.formValue.venous_catheterization = val.selectId
          break
        case 15:
          this.formValue.venous_catheterization_part = val.selectId
          break
        case 16:
          this.formValue.ductus_arantii = val.result.join(',')
          break
        case 17:
          this.formValue.emergency_treatment = val.selectId
          break
        case 18:
          this.formValue.puncture_way = val.selectId
          break
        case 19:
          if (val.selectId == 1) {
            this.hemorrhage_state = true
            this.formValue.is_hemorrhage = parseInt(val.selectId)
          } else if (val.selectId == 2) {
            this.hemorrhage_state = false
            this.formValue.is_hemorrhage = parseInt(val.selectId)
          } else if (this.formValue.is_hemorrhage == -2) {
          }
          break
        case 20:
          if (val.selectId == 1) {
            this.infect_state = true
            this.formValue.is_infect = val.selectId.toString()
          } else if (val.selectId == 2) {
            this.infect_state = false
            this.formValue.is_infect = val.selectId.toString()
          } else if (this.formValue.is_infect == -2) {
          }
          break
        case 21:
          this.formValue.skin = val.selectId.toString()
          break
        case 22:
          this.formValue.puncture_needle = val.result.join(',')
          break
        case 23:
          this.formValue.machine_type = val.selectId
          break
        case 24:
          this.formValue.humor_excessive_symptom = val.selectId
          break
        case 25:
          this.formValue.skin = val.result.join(',')
          break
        case 26:
          this.formValue.puncture_way = val.result.join(',')
          break
        case 27:
          this.formValue.catheter_suture = val.result.join(',')
          break
        case 28:
          this.formValue.edema = val.result.join(',')
          break
        case 30:
          this.formValue.pinholing = val.result.join(',')
          break
        case 31:
          this.formValue.catheter_maintenance = val.result.join(',')
        case 32:
          if (val.selectId == 1) {
            this.thromubusShow = true
            this.thromubus_type = true
            this.formValue.thromubus_type = parseInt(val.selectId)
          } else if (val.selectId == 2) {
            this.thromubusShow = false
            this.thromubus_type = false
            this.formValue.thromubus_type = parseInt(val.selectId)
          } else if (this.formValue.thromubus_type == -2) {
          }
         break
      }
    },
    QueryHumorById: function (val) {
      let humor_excessive_symptom_name = ''
      let humor_excessive_symptom_array = getDataConfig('hemodialysis', 'humor_excessive_symptom')
      for (let i = 0; i < humor_excessive_symptom_array.length; i++) {
        if (humor_excessive_symptom_array[i].id == val) {
          humor_excessive_symptom_name = humor_excessive_symptom_array[i].name
        }
      }
      return humor_excessive_symptom_name
    },
    QueryPartById: function (val) {
      let vascular_access_part_name = ''
      let vascular_access = getDataConfig('hemodialysis', 'vascular_access')
      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
    },
    QueryOperaById: function (val) {
      let vascular_access_desc_name = ''
      let vascular_access_desc = getDataConfig(
        'hemodialysis',
        'vascular_access_desc'
      )
      for (let i = 0; i < vascular_access_desc.length; i++) {
        if (vascular_access_desc[i].id == val) {
          vascular_access_desc_name = vascular_access_desc[i].name
        }
      }

      return vascular_access_desc_name
    },
    GetCatheterBendById: function (val) {
      let name = ''
      let options = this.$store.getters.catheter_bend
      for (let index = 0; index < options.length; index++) {
        const option = options[index]
        if (option.id == val) {
          name = option.name
          break
        }
      }
      return name
    },
    DialysisModel: function (val) {
      let name = ''
      let options = getDataConfig('hemodialysis', 'machine_type')
      for (let index = 0; index < options.length; index++) {
        const option = options[index]
        if (option.id == val) {
          name = option.name
          break
        }
      }
      return name
    },
    commitInfo: function () {
      let mode = 1
      Toast.loading({ forbidClick: true, duration: 0 })
      if (this.formValue.dry_weight == undefined) {
        this.formValue.dry_weight = '0'
      } else {
        this.formValue.dry_weight = this.formValue.dry_weight.toString()
      }
      // if (this.formValue.dry_weight == ""){
      //   this.formValue.
      // }

      if (this.predialysis.id > 0) {
        mode = 1
        if (this.predialysis.creater == 0) {
          mode = 1
        } else {
          mode = 2
          if (this.predialysis.creater != this.$store.getters.user.admin.id) {
            mode = 3
          }
        }
      }
      this.machineType = getDataConfig('hemodialysis', 'machine_type')
      var arr = this.formValue
      for (let i = 0; i < this.machineType.length; i++) {
        if (arr.machine_type == this.machineType[i].id) {
          arr.machine_type = this.machineType[i].name
        }
      }

      if (arr.is_hemorrhage != undefined) {
        arr.is_hemorrhage = arr.is_hemorrhage.toString()
      }
      if (arr.catheter_bend != undefined) {
        arr.catheter_bend = parseInt(arr.catheter_bend)
      }
      
      
      this.formValue = arr
      EditAssessmentBeforeDislysis(
        this.$route.query.patient_id,
        this.record_date,
        this.formValue,
        mode
      ).then(response => {
        if (response.data.state == 0) {
          Toast(response.data.msg)
          return false
        } else {
          let orgId = parseInt(sessionStorage.getItem('org_id'))
          axios.get('/api/index/patientsign/' + orgId + '/' + this.$route.query.patient_id).then((res) => {
            console.log('res', res.data)
          })
          

          this.$emit('evaluation', response.data.data.evaluation)
          var obj = this.predialysis
          var arr = getDataConfig('hemodialysis', 'machine_type')
          for (let i = 0; i < arr.length; i++) {
            if (obj.machine_type == arr[i].name) {
              obj.machine_type = arr[i].id
            }
          }
          this.formValue = obj
          if (this.formValue.dry_weight == undefined) {
            this.formValue.dry_weight = '0'
          } else {
            this.formValue.dry_weight = response.data.data.evaluation.dry_weight.toString()
          }
          Toast('提交完成')
        }
      })
        .catch(error => {
          Toast.fail('请求失败')
        })
    },
    showDryWeight: function () {
      this.isShowDialog = false
      this.$refs.dry.open()
      this.propDryForm.doctor = []
      for (let i = 0; i < this.admin_users_prop.length; i++) {
        if (
          this.admin_users_prop[i].user_type == 2 ||
          this.admin_users_prop[i].user_type == 1
        ) {
          this.propDryForm.doctor.push(this.admin_users_prop[i])
        }
      }
    },
    close: function () {
      this.$emit('close')
    },
    open: function () {
      this.isShowDialog = true
      this.visibility = false
      var dialogTop = document.querySelector('#dialogTop')
      if (dialogTop != null) {
        this.$nextTick(() => {
          dialogTop.scrollTop = 0
        })
      }
    },
    menuEmpty: function (val) {
      this.visibility = false
      this.isShowDialog = true
      switch (val.type) {
        case 6:
          this.formValue.blood_access_part_id = ''
          break
        case 7:
          this.formValue.blood_access_part_opera_id = ''
          break
        case 11:
          this.formValue.catheter_bend = ''
          break

        case 13:
          this.formValue.blood_access_noise = ''
          break
        case 14:
          this.formValue.venous_catheterization = ''
          break
        case 15:
          this.formValue.venous_catheterization_part = ''
          break
        case 17:
          this.formValue.emergency_treatment = ''
          break
        case 18:
          this.formValue.puncture_way = ''
          break
      }
    },
    getPermission () {
      request
        .get('/m/api/permission/get', {
          params: {
            create_url: '/m/api/assessmentbefore/commit?mode=1',
            modify_url: '/m/api/assessmentbefore/commit?mode=2',
            modify_other_url: '/m/api/assessmentbefore/commit?mode=3',
            module: 3
          }
        })
        .then(res => {
          console.log('透前', this.predialysis)
          if (res.data.state == 0) {
            this.hasPermission = false
          } else if (res.data.state == 1) {
            if (this.predialysis.id != '' && this.predialysis.creater != 0) {
              // 有数据
              if (
                this.predialysis.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.predialysis.id == '' ||
              this.predialysis.creater == 0
            ) {
              if (res.data.data.is_has_create == false) {
                this.hasPermission = false
                this.showTxt = '你没有新增透前评估权限'
              }
            }
          }
        })
    }
  },
  components: {
    DryWeightMenu,
    CheckBoxSubMenu
  },
  created () {
    if(this.predialysis!=null){
       if(this.predialysis.thromubus_type ==1){ 
          this.thromubusShow = true    
       }
    }
    if(this.last_predialysis != null){
       if(this.last_predialysis.thromubus_type == 1){
          this.thromubusShow = true
       }
    }
    this.getPermission()

    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)

    var obj = this.predialysis
    var arr = getDataConfig('hemodialysis', 'machine_type')
    console.log('arr', arr)
    for (let i = 0; i < arr.length; i++) {
      if (obj.machine_type == arr[i].name) {
        obj.machine_type = arr[i].id
      }
    }
    this.formValue = obj
    if (this.predialysis.id == undefined && this.last_predialysis.id != undefined) {
      for (var key in this.last_predialysis) {
        if (key != 'systolic_blood_pressure' && key != 'diastolic_blood_pressure' && key != 'pulse_frequency' && key != 'weight_before') {
          this.$set(
            this.formValue,
            key,
            this.last_predialysis[key].toString()
          )
        }
      }
    }
    if (this.dry_weight != null && this.dry_weight.id != undefined) {
      this.$set(this.formValue,'dry_weight',this.dry_weight.dry_weight.toString()
      )
      this.propDryForm.weight = this.dry_weight.dry_weight.toString()
    } else {
      if (this.predialysis.id == undefined && this.last_predialysis.id != undefined) {
        this.$set(
          this.formValue,
          'dry_weight',
          this.last_predialysis['dry_weight'].toString()
        )
        this.propDryForm.weight = this.formValue.dry_weight
      }
    }
    this.hemorrhage_state = this.formValue.is_hemorrhage == 0
    this.data = getDataConfig('hemodialysis', 'vascular_access_desc')
    

    if(this.predialysis.id == 0 && this.lastAssessment.id != 0){
       
        let vascular_access_desc = getDataConfig(
            'hemodialysis',
            'vascular_access_desc'
        )
        var vascular_access_desc_name = ""
        for (let i = 0; i < vascular_access_desc.length; i++) {
          if (vascular_access_desc[i].name ==  this.lastAssessment.blood_access_part_opera_id) {
            vascular_access_desc_name = vascular_access_desc[i].id
          }
        }
       this.formValue.blood_access_part_opera_id = vascular_access_desc_name
       this.formValue.blood_access_part_id =   this.lastAssessment.blood_access_part_id 
     

    }
       if (this.predialysis.id == 0 && this.last_predialysis.id != 0) {

          let vascular_access_desc = getDataConfig(
              'hemodialysis',
              'vascular_access_desc'
          )
           var vascular_access_desc_name = ""
          for (let i = 0; i < vascular_access_desc.length; i++) {
            if (vascular_access_desc[i].name ==  this.last_predialysis.blood_access_part_opera_id) {
              vascular_access_desc_name = vascular_access_desc[i].id
            }
          }
          this.formValue.blood_access_part_opera_id = vascular_access_desc_name  
          this.formValue.blood_access_part_id =  this.last_predialysis.blood_access_part_id
       }
    
  
   
  }
}
</script>

<style style="stylesheet/scss" lang="scss" scoped>
.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;
}
.warnTxt {
  font-size: 0.5rem;
  height: 1rem;
  line-height: 1rem;
  text-align: center;
  background: #faa331;
  color: #fff;
}
</style>
