<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">完成</span>
      </div>

      <div class="DialogContent" id="dialogTop">
        <div class="item" v-if="isShow('透前体重')">
          <h2 class="name">透前体重(kg)</h2>
          <div class="content">
            <input type="tel" @focus="inputFocus" v-model="formValue.weight_before"/>
          </div>
        </div>
        <div class="item" v-if="isShow('干体重')">
          <h2 class="name">干体重(kg)</h2>
          <div class="content">
            <input type="tel" @focus="inputFocus" v-model="formValue.dry_weight"/>
          </div>
        </div>
        <div class="item" v-if="isShow('体温')">
          <h2 class="name">体温(℃)</h2>
          <div class="content">
            <input type="tel" @focus="inputFocus" v-model="formValue.temperature"/>
          </div>
        </div>
        <div class="item" v-if="isShow('出血')">
          <h2 class="name">出血</h2>
          <div class="content">
            <span class="text" style="width: 50px;"><div style="padding-top: 0.08rem; height: 0.8rem;"><van-switch
              v-model="hemorrhage_state" @change="hemorrhageStateChange"/></div></span>
          </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('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 @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('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 class="line"></div>
        <div class="item" v-if="isShow('收缩压')">
          <h2 class="name">收缩压(mmHg)</h2>
          <div class="content">
            <input type="tel" @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="tel" @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="tel" @focus="inputFocus" v-model="formValue.pulse_frequency"/>
          </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">{{QueryPartById(formValue.blood_access_part_id)}}</span>
            <span class="iconfont">&#xe6f9;</span>
          </div>
        </div>
        <div @click="showSubMenu('blood_access_opera')" class="item" ref="blood_access_opera" 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('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('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('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 @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 class="line"></div>

        <div class="item" ref="symptom_before_dialysis" v-if="isShow('透析机型号')">
          <h2 class="name">透析机型号</h2>
          <div class="content">
            <input type="tel" @focus="inputFocus" v-model="formValue.machine_type"/>
          </div>
        </div>

        <div class="item" ref="symptom_before_dialysis" v-if="isShow('透析频次')">
          <h2 class="name">透析频次(次/周)</h2>
          <div class="content">
            <input type="tel" @focus="inputFocus" v-model="formValue.dialysis_count"/>
          </div>
        </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 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('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>


        <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('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 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('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 @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="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>
    <!--<two-menu title="二级菜单" v-show="true" ></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>
  </div>
</template>

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

  export default {
    name: 'PrescriptionDialog',
    props: {
      patient_prop: {
        type: Object,
      },
      predialysis: {
        type: Object,
      },
      last_predialysis: {
        type: Object,
      },
    },
    data () {
      return {
        isShowDialog: true,
        //sub menu prop
        visibility: false,
        propForm: {
          title: '',
          list: [],
          optionList: [],
          isMultiple: 2,
          result: [], //选中的值
          type: 1, //用来区分不同子菜单，方便对返回值进行赋值
          selectId: 0,
          isHasOther: 1 //是否有其他选项  1是 2否
        },
        hemorrhage_state: false,

        formValue: {
          weight_before: '',
          dry_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: '',
          internal_fistula: '',
          internal_fistula_skin: '',
          is_hemorrhage: 1,
          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:'',
        },

        record_date: ''

      }
    },
    methods: {
      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 = this.$store.getters.puncture_way
        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

      },
      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.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.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.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.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 = 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.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'
            break

          case 'blood_access_opera':
            this.isHasOther = 2

            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 = 'blood_access_opera'
            break

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

            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.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.type = 10
            this.isShowDialog = false
            this.propForm.title = '内瘘皮肤情况'
            this.visibility = true
            this.propForm.list = this.$store.getters.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.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.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.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.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.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.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

            break

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

            this.propForm.type = 17
            this.isShowDialog = false
            this.propForm.title = '急诊'
            this.visibility = true
            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.optionList = this.$store.getters.puncture_way
            this.propForm.isMultiple = 1
            this.propForm.selectId = this.formValue.puncture_way
            this.propForm.click_ref = 'puncture_way'
            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.selectId
            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
        }

      }, 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
      },
      commitInfo: function () {
        Toast.loading({forbidClick: true, duration: 0})
        console.log(this.formValue)
        EditAssessmentBeforeDislysis(this.$route.query.patient_id, this.record_date, this.formValue).then(response => {
          if (response.data.state == 0) {
            Toast(response.data.msg)
            return false
          } else {
            Toast('提交完成')
            this.$emit('evaluation', response.data.data.evaluation)
          }
        })
      },
      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
        }
      }

    }, components: {
      CheckBoxSubMenu,

    }, created () {

      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)
      // console.log(this.predialysis)
      this.formValue = this.predialysis
      if (this.predialysis.id == undefined && this.last_predialysis.id != undefined) {

        this.$set(this.formValue, 'dry_weight', this.last_predialysis['dry_weight'].toString())
        this.$set(this.formValue, 'internal_fistula', this.last_predialysis['internal_fistula'])
        this.$set(this.formValue, 'internal_fistula_skin', this.last_predialysis['internal_fistula_skin'])
        this.$set(this.formValue, 'blood_access_part_id', this.last_predialysis['blood_access_part_id'])
        this.$set(this.formValue, 'blood_access_part_opera_id', this.last_predialysis['blood_access_part_opera_id'])
      }
      console.log(this.formValue)
      this.hemorrhage_state = this.formValue.is_hemorrhage == 1
    }
  }
</script>

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

</style>

