<template>
  <div>
    <el-dialog
      class="newDialog"
      title="透前评估"
      :visible.sync="isVisibility"
      width="1010px"
      :modal-append-to-body="false"
    >
      <div class="warnTxt" v-if="showTxt != ''">{{ showTxt }}</div>
      <!--<check-box-dialog-->
      <!--:propsForm="InnerDialogProps"-->
      <!--v-on:dialog-comfirm="innerDialogComfirm"-->
      <!--v-on:dialog-cancle="innerDialogCancle"-->
      <!--&gt;</check-box-dialog>-->

      <multi-select-box
        :propsForm="InnerDialogProps"
        v-on:dialog-comfirm="innerDialogComfirm"
        v-on:dialog-cancle="innerDialogCancle"
      ></multi-select-box>


      <el-form ref="assessmentBeforeDislysis" :model="assessmentBeforeDislysis" label-width="125px">
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="透前称重(kg)： " v-if="isShow('透前称重')">
              <el-input type="number" v-model="assessmentBeforeDislysis.weight_before"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="干体重(kg)："
                          v-if="isShow('干体重')">
              <el-input type="number" v-model="assessmentBeforeDislysis.dry_weight" readonly
                        @focus="showDryWeightDialog"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="衣物重(kg)：" v-if="isShow('衣物重')">
              <el-input type="number" v-model="assessmentBeforeDislysis.additional_weight"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="透析机型号:" v-if="isShow('透析机型号')">
              <el-input v-model="assessmentBeforeDislysis.machine_type"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="isShow('透析频次')">
            <el-form-item label="透析频次(次/周):">
              <el-input v-model="assessmentBeforeDislysis.dialysis_count"></el-input>
            </el-form-item>
          </el-col>




          <el-col :span="8">
            <el-form-item label="体温(℃)：" v-if="isShow('体温')">
              <el-input type="number" v-model="assessmentBeforeDislysis.temperature"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="收缩压(mmHg)： " v-if="isShow('收缩压')">
              <el-input type="number" v-model="assessmentBeforeDislysis.systolic_blood_pressure"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="舒张压(mmHg)： " v-if="isShow('舒张压')">
              <el-input type="number" v-model="assessmentBeforeDislysis.diastolic_blood_pressure"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="呼吸频率(次/分)：" v-if="isShow('呼吸频率')">
              <el-input type="number" v-model="assessmentBeforeDislysis.breathing_rate"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="脉搏(次/分)：" v-if="isShow('脉搏')">
              <el-input type="number" v-model="assessmentBeforeDislysis.pulse_frequency"></el-input>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="血管通路： " v-if="isShow('血管通路')">
              <el-select v-model="assessmentBeforeDislysis.blood_access_part_opera_id">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option v-for="item in blood_access_part_opera" :label="item.name" :value="item.id"
                           :key="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="血管通路部位： " v-if="isShow('血管通路部位')">
              <el-select v-model="assessmentBeforeDislysis.blood_access_part_id">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option v-for="item in blood_access_part" :label="item.name" :value="item.id"
                           :key="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="血管通路其他部位:" v-if="isShow('血管通路其他部位')">
              <el-input v-model="assessmentBeforeDislysis.venous_catheterization_part_other"></el-input>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="内瘘: " v-if="isShow('内瘘')">
              <el-input v-model="assessmentBeforeDislysis.internal_fistula" readonly
                        @focus="showInnerDialog('7')"></el-input>
            </el-form-item>
          </el-col>





          <el-col :span="8" v-if="assessmentBeforeDislysis.is_hemorrhage == 1&&isShow('出血选项')">
            <el-form-item label="出血选项： ">
              <div>
                <el-input v-model="assessmentBeforeDislysis.hemorrhage" @focus="showInnerDialog('6')"></el-input>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="8" v-if="assessmentBeforeDislysis.is_hemorrhage == 1&&isShow('其他出血情况')">
            <el-form-item label="其他出血情况： ">
              <el-input v-model="assessmentBeforeDislysis.hemorrhage_other"></el-input>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="血管通路(内瘘)其他:" v-if="isShow('血管通路(内瘘)其他')">
              <el-input v-model="assessmentBeforeDislysis.internal_fistula_other"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="isShow('血管杂音')">
            <el-form-item label="血管杂音： ">
              <el-select v-model="assessmentBeforeDislysis.blood_access_noise">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option v-for="item in blood_access_noise" :label="item.name" :value="item.id"
                           :key="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <!-- </el-row>

          <el-row :gutter="20"> -->


          <el-col :span="8">
            <el-form-item label="内瘘皮肤情况: " v-if="isShow('内瘘皮肤情况')">
              <el-input v-model="assessmentBeforeDislysis.internal_fistula_skin" readonly
                        @focus="showInnerDialog('8')"></el-input>
            </el-form-item>
          </el-col>


          <el-col :span="8">

            <el-form-item label="中心静脉置管： " v-if="isShow('中心静脉置管')">
              <el-select v-model="assessmentBeforeDislysis.venous_catheterization">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option v-for="item in this.$store.getters.venous_catheterization" :label="item.name"
                           :value="item.id"
                           :key="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="导管： " v-if="isShow('导管')">
              <el-input v-model="assessmentBeforeDislysis.catheter" @focus="showInnerDialog('4')"></el-input>
            </el-form-item>
          </el-col>




          <!--<el-col :span="8">-->
          <!--<el-form-item label="附加物重(kg)： ">-->
          <!--<el-input type="number" v-model="assessmentBeforeDislysis.additional_weight"></el-input>-->
          <!--</el-form-item>-->
          <!--</el-col>-->

          <!-- </el-row>


          <el-row :gutter="20"> -->
          <el-col :span="8">
            <el-form-item label="导管打折： " v-if="isShow('导管打折')">
              <el-select v-model="assessmentBeforeDislysis.catheter_bend">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option label="有" value="1"></el-option>
                <el-option label="无" value="2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>



          <!-- </el-row>


          <el-row :gutter="20"> -->

          <el-col :span="8">
            <el-form-item label="穿刺针： " v-if="isShow('穿刺针')">
              <el-input v-model="assessmentBeforeDislysis.puncture_needle" @focus="showInnerDialog('11')"></el-input>
            </el-form-item>
          </el-col>



          <el-col :span="8">
            <el-form-item label="穿刺方式： " v-if="isShow('穿刺方式')">
              <el-select v-model="assessmentBeforeDislysis.puncture_way">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option v-for="item in this.$store.getters.puncture_way" :label="item.name" :value="item.id"
                           :key="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="出血： " v-if="isShow('出血')">
              <el-select v-model="assessmentBeforeDislysis.is_hemorrhage">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option label="是" value="1"></el-option>
                <el-option label="否" value="2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="8" v-if="isShow('皮肤')">
            <el-form-item label="皮肤： ">
              <el-select v-model="assessmentBeforeDislysis.skin">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option v-for="item in this.$store.getters.skin" :label="item.name" :value="item.id"
                           :key="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="并发症： " v-if="isShow('并发症')">

              <el-input v-model="assessmentBeforeDislysis.complication" @focus="showInnerDialog('5')"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="透析前症状： " v-if="isShow('透析前症状')">
              <el-input v-model="assessmentBeforeDislysis.symptom_before_dialysis"
                        @focus="showInnerDialog('3')"></el-input>
            </el-form-item>
          </el-col>


          <el-col :span="8">
            <el-form-item label="前次透析后症状：" v-if="isShow('前次透析后症状')">
              <el-input v-model="assessmentBeforeDislysis.last_post_dialysis" @focus="showInnerDialog('1')"></el-input>
            </el-form-item>
          </el-col>


          <el-col :span="8" v-if="isShow('急诊')">
            <el-form-item label="急诊： ">
              <el-select v-model="assessmentBeforeDislysis.emergency_treatment">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option v-for="item in this.$store.getters.emergency_treatment" :label="item.name" :value="item.id"
                           :key="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="isShow('其他急诊情况')">
            <el-form-item label="其他急诊情况:">
              <el-input v-model="assessmentBeforeDislysis.emergency_treatment_other"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="备注： ">
              <el-input type="textarea" v-model="assessmentBeforeDislysis.remark" :rows="5"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="透析期间： " v-if="isShow('透析期间')">
              <el-input v-model="assessmentBeforeDislysis.dialysis_interphase" @focus="showInnerDialog('2')">>
              </el-input>
            </el-form-item>
          </el-col>









          <!--          <el-col :span="8" v-if="isShow('血管通路(内瘘)')">-->
          <!--            <el-form-item label="血管通路(内瘘):">-->
          <!--              <div>-->
          <!--                <el-input v-model="assessmentBeforeDislysis.blood_access_internal_fistula"-->
          <!--                          @focus="showInnerDialog('9')"></el-input>-->
          <!--              </div>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->












                    <el-col :span="8">

                      <el-form-item label="位置： " v-if="isShow('位置')">
                        <el-select v-model="assessmentBeforeDislysis.venous_catheterization_part">
                          <el-option :key="0" label="请选择" :value="0"></el-option>

                          <el-option v-for="item in this.$store.getters.venous_catheterization_part" :label="item.name"
                                     :value="item.id"
                                     :key="item.id"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>




          <!--          <el-col :span="8" v-if="isShow('导管')">-->
          <!--            <el-form-item label="导管:">-->
          <!--              <div>-->
          <!--                <el-input v-model="assessmentBeforeDislysis.ductus_arantii" @focus="showInnerDialog('10')"></el-input>-->
          <!--              </div>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->


          <el-col :span="8" v-if="isShow('其他中心静脉导管')">
            <el-form-item label="其他中心静脉导管:">
              <div>
                <el-input v-model="assessmentBeforeDislysis.ductus_arantii_other"></el-input>
              </div>
            </el-form-item>
          </el-col>
          <!-- </el-row>


          <el-row :gutter="20"> -->



          <el-col :span="8">
            <el-form-item label="感染： " v-if="isShow('感染')">
              <el-select v-model="assessmentBeforeDislysis.is_infect">
                <el-option :key="0" label="请选择" :value="0"></el-option>
                <el-option label="无" value="1"></el-option>
                <el-option label="有" value="2"></el-option>
              </el-select>
            </el-form-item>
          </el-col>



          <el-col :span="8" v-if="isShow('其他感染情况')">
            <el-form-item label="其他感染情况:">
              <el-input v-model="assessmentBeforeDislysis.infect_other"></el-input>
            </el-form-item>
          </el-col>




          <el-col :span="8" v-if="isShow('外露')">
            <el-form-item label="外露(cm):">
              <el-input v-model="assessmentBeforeDislysis.exposed"></el-input>
            </el-form-item>
          </el-col>





          <el-col :span="8" v-if="isShow('其他皮肤情况')">
            <el-form-item label="其他皮肤情况:">
              <el-input v-model="assessmentBeforeDislysis.skin_other"></el-input>
            </el-form-item>
          </el-col>


          <!-- </el-row>


          <el-row :gutter="20"> -->
          <!--<el-col :span="8">-->
          <!--<el-form-item label="穿刺方法： " v-if="isShow('穿刺方法')">-->

          <!--<el-select v-model="assessmentBeforeDislysis.puncture_method">-->
          <!--<el-option :key="0" label="请选择" :value="0"></el-option>-->

          <!--<el-option v-for="item in puncture_method" :label="item.name" :value="item.name"-->
          <!--:key="item.id"></el-option>-->
          <!--</el-select>-->

          <!--</el-form-item>-->
          <!--</el-col>-->

        </el-row>


      </el-form>
      <span slot="footer" class="dialog-footer">
                <el-button @click="handleCancle">取 消</el-button>
                <el-button type="primary" v-if="hasPermission" @click="handleComfirm">保 存</el-button>
            </span>
    </el-dialog>


    <el-dialog title="调整干体重  " :visible.sync="dialogFormVisible" width="50%"   @close="cancleDryWeight()">
      <el-form :model="weight_adjust" ref="weight_adjust">
        <el-form-item label="干体重 :" label-width="80px" >
          <el-input style="width: 200px" v-model="weight_adjust.weight" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="医生 : " label-width="80px">
          <el-select v-model="weight_adjust.doctor" placeholder="请选择医生">
            <el-option v-for="(item,index) in doctorOptions" :label="item.name" :value="item.id" :key="index"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注 : " label-width="80px">
          <el-input
            type="textarea"
            :rows="2"
            style="width:200px;"
            placeholder="请输入内容"
            v-model="weight_adjust.remark">
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancleDryWeight()">取 消</el-button>
        <el-button type="primary" @click="submitDryWeight()">保 存</el-button>
      </div>
    </el-dialog>
  </div>


</template>

<script>
  import multiSelectBox from './MultiSelectBox'
  import { getDataConfig } from '@/utils/data'
  import { postAssessmentBeforeDislysis,CreateDryWeight } from '@/api/dialysis'
  import store from '@/store'
  import { uParseTime } from '@/utils/tools'

  import request from '@/utils/request'

  export default {
    components: {
      multiSelectBox
    },
    name: 'assessment-after-dislysis-dialog',
    data() {
      return {
        showTxt:'',
        hasPermission:true,
        weight_adjust: {
          weight: '',
          doctor: '',
          remark: ''

        },
        lastPredialysisEvaluation:null,
        lastDryWeightDislysis: null,
        doctorOptions: [],
        isVisibility: false,
        dialogFormVisible: false,
        actualTreatmentHourShow: new Date(2018, 1, 1, 3, 0),
        record_date: '',
        cruorOptions: [],
        last_dialysis_after: [],
        dialysis_interphase: [],
        symptom_before_dialysis: [],
        blood_access_noise: [],
        catheter: [],
        complication: [],
        hemorrhage: [],
        blood_access_part: [],
        blood_access_part_opera: [],
        internal_fistula: [],
        internal_fistula_skin: [],
        puncture_method: [],
        isVisibiltyForCruorDialog: false,
        assessmentBeforeDislysis: {
          puncture_needle: '',
          catheter_bend: '',
          internal_fistula_skin: '',
          weight_before: '',
          additional_weight: '',
          temperature: '',
          dry_weight: '',
          systolic_blood_pressure: '',
          diastolic_blood_pressure: '',
          symptom_before_dialysis: '',
          pulse_frequency: '',
          last_post_dialysis: '',
          dialysis_interphase: '',
          catheter: '',
          complication: '',
          remark: '',
          blood_access_part_id: '',
          blood_access_part_opera_id: '',
          internal_fistula: '',
          is_hemorrhage: '',
          hemorrhage: '',
          hemorrhage_other: '',
          puncture_method: '',
          breathing_rate: '',
          dialysis_count: '',
          emergency_treatment: '',
          emergency_treatment_other: '',
          ductus_arantii_other: '',
          ductus_arantii: '',
          venous_catheterization_part_other: '',
          venous_catheterization_part: '',
          venous_catheterization: '',
          puncture_way: '',
          blood_access_noise: '',
          internal_fistula_other: '',
          blood_access_internal_fistula: '',
          is_infect: '',
          exposed: '',
          skin: '',
          skin_other: '',
          infect_other: '',
          machine_type: ''
        },

        InnerDialogProps: {
          values: [],
          visibility: false,
          isShowTextArea: true,
          customContent: '',
          titles: '',
          type: '' // 不同弹框类型，用来匹配数据
        }

      }
    },
    props: {

      predialysis_evaluation: { // 透前评估
        type: Object,
        default: () => {
          return { id: 0 }
        }
      },
      patient: { // 患者信息
        type: Object,
        default: () => {
          return { id: 0 }
        }
      },
      admin_users: { // 系统用户列表
        type: Array,
        default: () => {
          return []
        }
      }

    },
    methods: {
      setLastRecord(lastPredialysisEvaluation,lastDryWeightDislysis){
        this.lastPredialysisEvaluation = lastPredialysisEvaluation
        this.lastDryWeightDislysis = lastDryWeightDislysis


      },
      isShow(name) {
        var filedList = store.getters.xt_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
      },
      show(assessment) {
        this.assessment = assessment
        console.log("透前",assessment)
        this.getPermission()
        this.isVisibility = true
        for (let i = 0; i < this.admin_users.length; i++) {
          if (this.admin_users[i].user_type != 3) {
            this.doctorOptions.push(this.admin_users[i])
          }
        }
        if (this.$store.getters.xt_user.user.user_type == 1 || this.$store.getters.xt_user.user.user_type == 2) {
          this.weight_adjust.doctor = this.$store.getters.xt_user.user.id
        }


        if (this.predialysis_evaluation.id == 0){
          if (this.lastDryWeightDislysis != null){
            this.weight_adjust.weight = this.lastDryWeightDislysis.dry_weight
            this.assessmentBeforeDislysis.dry_weight = this.lastDryWeightDislysis.dry_weight

          }else{
            if(this.lastPredialysisEvaluation != null){
              this.weight_adjust.weight = this.lastPredialysisEvaluation.dry_weight
              this.assessmentBeforeDislysis.dry_weight = this.lastPredialysisEvaluation.dry_weight
            }
          }
        }else{
          this.assessmentBeforeDislysis.dry_weight = this.predialysis_evaluation['dry_weight']
          this.weight_adjust.weight = this.predialysis_evaluation['dry_weight']

        }
      },
      hide() {
        this.isVisibility = false
      },
      showInnerDialog: function(val) {
        this.InnerDialogProps.visibility = true
        switch (val) {
          case '1': // 前次透析后

            this.InnerDialogProps.values = this.last_dialysis_after
            this.InnerDialogProps.titles = '前次透析后'
            this.InnerDialogProps.type = 'last_dialysis_after'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.last_post_dialysis
            this.InnerDialogProps.isShowTextArea = false

            break
          case '2': // 透析期间

            this.InnerDialogProps.values = this.dialysis_interphase
            this.InnerDialogProps.titles = '透析期间'
            this.InnerDialogProps.type = 'dialysis_interphase'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.dialysis_interphase
            this.InnerDialogProps.isShowTextArea = false
            break

            break
          case '3': // 透析前症状

            this.InnerDialogProps.values = this.symptom_before_dialysis
            this.InnerDialogProps.titles = '透析期间'
            this.InnerDialogProps.type = 'symptom_before_dialysis'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.symptom_before_dialysis
            this.InnerDialogProps.isShowTextArea = false
            break

          case '4': // 导管

            this.InnerDialogProps.values = this.catheter
            this.InnerDialogProps.titles = '导管'
            this.InnerDialogProps.type = 'catheter'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.catheter
            this.InnerDialogProps.isShowTextArea = false
            break

            break
          case '5': // 并发症

            this.InnerDialogProps.values = this.complication
            this.InnerDialogProps.titles = '并发症'
            this.InnerDialogProps.type = 'complication'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.complication
            this.InnerDialogProps.isShowTextArea = false

            break

          case '6': // 出血选项

            this.InnerDialogProps.values = this.hemorrhage
            this.InnerDialogProps.titles = '出血选项'
            this.InnerDialogProps.type = 'hemorrhage'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.hemorrhage
            this.InnerDialogProps.isShowTextArea = false

            break
          case '7': // 内瘘

            this.InnerDialogProps.values = this.internal_fistula
            this.InnerDialogProps.titles = '内瘘'
            this.InnerDialogProps.type = 'internal_fistula'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.internal_fistula
            this.InnerDialogProps.isShowTextArea = false

            break
          case '8': // 内瘘皮肤情况
            this.InnerDialogProps.values = this.internal_fistula_skin
            this.InnerDialogProps.titles = '内瘘皮肤情况'
            this.InnerDialogProps.type = 'internal_fistula_skin'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.internal_fistula_skin
            this.InnerDialogProps.isShowTextArea = false

            break
          case '9': //

            this.InnerDialogProps.values = this.$store.getters.blood_access_internal_fistula
            this.InnerDialogProps.titles = '血管通路(内瘘)'
            this.InnerDialogProps.type = 'blood_access_internal_fistula'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.blood_access_internal_fistula
            this.InnerDialogProps.isShowTextArea = false

            break
          case '10': //
            this.InnerDialogProps.values = this.$store.getters.ductus_arantii
            this.InnerDialogProps.titles = '中心静脉导管'
            this.InnerDialogProps.type = 'ductus_arantii'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.ductus_arantii
            this.InnerDialogProps.isShowTextArea = false

            break
          case '11': //
            this.InnerDialogProps.values = this.$store.getters.puncture_needle
            this.InnerDialogProps.titles = '穿刺针'
            this.InnerDialogProps.type = 'puncture_needle'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.puncture_needle
            this.InnerDialogProps.isShowTextArea = false

            break
        }
      }, innerDialogComfirm: function(val) {
        this.InnerDialogProps.visibility = false
        switch (val.type) {
          case 'last_dialysis_after':
            this.assessmentBeforeDislysis.last_post_dialysis = val.value.join(',')
            break
          case 'dialysis_interphase':
            this.assessmentBeforeDislysis.dialysis_interphase = val.value.join(',')

            break
          case 'symptom_before_dialysis':
            this.assessmentBeforeDislysis.symptom_before_dialysis = val.value.join(',')

            break
          case 'catheter':
            this.assessmentBeforeDislysis.catheter = val.value.join(',')

            break
          case 'complication':
            this.assessmentBeforeDislysis.complication = val.value.join(',')

            break
          case 'hemorrhage':
            this.assessmentBeforeDislysis.hemorrhage = val.value.join(',')
            break
          case 'internal_fistula':
            this.assessmentBeforeDislysis.internal_fistula = val.value.join(',')
            break
          case 'internal_fistula_skin':
            this.assessmentBeforeDislysis.internal_fistula_skin = val.value.join(',')
            break
          case 'blood_access_internal_fistula':
            this.assessmentBeforeDislysis.blood_access_internal_fistula = val.value.join(',')
            break
          case 'ductus_arantii':
            this.assessmentBeforeDislysis.ductus_arantii = val.value.join(',')
            break
          case 'puncture_needle':
            this.assessmentBeforeDislysis.puncture_needle = val.value.join(',')
            break
        }
      }, innerDialogCancle: function() {
        this.InnerDialogProps.visibility = false
      }, handleComfirm: function() {
        const ParamsQuery = this.assessmentBeforeDislysis
        ParamsQuery['patient'] = this.patient.id
        ParamsQuery['record_date'] = this.record_date
        ParamsQuery['mode'] = "1"

        console.log(this.predialysis_evaluation)

        if(this.predialysis_evaluation.id == 0){
          ParamsQuery['mode'] = "1"

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

          }


        }

        postAssessmentBeforeDislysis(ParamsQuery).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.$notify({
              title: '成功',
              message: '提交成功',
              type: 'success',
              duration: 2000
            })

            const assessment_before_dislysis_resp = response.data.data.assessmentBeforeDislysis

            // prop
            var predialysis_evaluation = this.predialysis_evaluation
            for (var index in assessment_before_dislysis_resp) {
              // predialysis_evaluation[index] = assessment_before_dislysis_resp[index];
              this.$set(predialysis_evaluation, index, assessment_before_dislysis_resp[index])
            }
            this.hide()
          }
        })
      }, handleCancle: function() {
        this.isVisibility = false
      }, showDryWeightDialog: function() {
        if (this.$store.getters.xt_user.user.user_type == 3) {
          this.$message.error("您没有权限调整干体重")
          return;
        }
        this.dialogFormVisible = true
        this.isVisibility = false

      }, submitDryWeight() {

        let params = {
          id:this.patient.id,
          dry_weight: this.weight_adjust.weight,
          remark: this.weight_adjust.remark,
          doctor_id: this.weight_adjust.doctor,
          mode : "1",
        };
        CreateDryWeight(params).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.$message.success('提交成功')
            this.assessmentBeforeDislysis.dry_weight = this.weight_adjust.weight
            this.dialogFormVisible = false
            this.isVisibility = true
          }
        })
      },cancleDryWeight(){
        this.dialogFormVisible = false
        this.isVisibility = true
      },
      getPermission(){
        request.get("/api/func_per/get",{
          params:{
            create_url:"/api/dialysis/assessmentbeforedislysis?mode=1",
            modify_url:"/api/dialysis/assessmentbeforedislysis?mode=2",
            modify_other_url:"/api/dialysis/assessmentbeforedislysis?mode=3",
            module:3
          }
        }).then(res => {
          console.log(res)
          console.log("透前",this.patient_prop)
          console.log("透前",this.assessment)
          if(res.data.state == 0){
            this.hasPermission = false
          }else if(res.data.state == 1){
            if(this.assessment.id != "" && this.assessment.creater != 0){//有数据
              if(this.assessment.creater == this.$store.getters.xt_user.user.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.assessment.id == "" || this.assessment.creater == 0){
              if(res.data.data.is_has_create  == false){
                this.hasPermission = false
                this.showTxt = "你没有新增透前评估权限"
              }
            }
          }
        })
      }
    },
    created() {
      this.last_dialysis_after = getDataConfig('hemodialysis', 'last_dialysis_after')
      this.dialysis_interphase = getDataConfig('hemodialysis', 'dialysis_duration')
      this.symptom_before_dialysis = getDataConfig('hemodialysis', 'dialysis_before')
      this.catheter = getDataConfig('hemodialysis', 'catheter')
      this.complication = getDataConfig('hemodialysis', 'complication')
      this.hemorrhage = getDataConfig('hemodialysis', 'hemorrhage')
      this.blood_access_part = getDataConfig('hemodialysis', 'vascular_access')
      this.blood_access_part_opera = getDataConfig('hemodialysis', 'vascular_access_desc')
      this.internal_fistula = getDataConfig('hemodialysis', 'internal_fistula')
      this.internal_fistula_skin = getDataConfig('hemodialysis', 'internal_fistula_skin')
      this.puncture_method = getDataConfig('hemodialysis', 'puncture_method')
      this.blood_access_noise = this.$store.getters.blood_access_noise
      var date = this.$route.query && this.$route.query.date
      this.record_date = uParseTime(date, '{y}-{m}-{d}')


      // this.weight_adjust.weight = this.dry_weight.dry_weight


      // if(this.predialysis_evaluation.id == 0){
      //
      //
      //
      // }els

      // if(this.dry_weight == null){
      //   if (this.predialysis_evaluation['dry_weight'] == 0) {
      //     this.assessmentBeforeDislysis['dry_weight'] = ''
      //   }
      //
      // }

    }, watch: {
      isVisibility(val) {

      },
      'predialysis_evaluation.id': function() {

        console.log(this.last_predialysis)

        if (this.predialysis_evaluation.id > 0) {
          for (var index in this.assessmentBeforeDislysis) {
            this.assessmentBeforeDislysis[index] = this.predialysis_evaluation[index]
          }

          // this.assessmentBeforeDislysis['catheter_bend'] = this.predialysis_evaluation['catheter_bend'].toString()
          // this.assessmentBeforeDislysis['is_hemorrhage'] = this.predialysis_evaluation['is_hemorrhage'].toString()
          if (this.predialysis_evaluation['catheter_bend'] == 0) {
            this.assessmentBeforeDislysis['catheter_bend'] = ''
          } else {
            this.assessmentBeforeDislysis['catheter_bend'] = this.predialysis_evaluation['catheter_bend'] + ''
          }
          if (this.predialysis_evaluation['is_hemorrhage'] == 0) {
            this.assessmentBeforeDislysis['is_hemorrhage'] = ''
          } else {
            this.assessmentBeforeDislysis['is_hemorrhage'] = this.predialysis_evaluation['is_hemorrhage'] + ''
          }

          if (this.predialysis_evaluation['is_infect'] == 0) {
            this.assessmentBeforeDislysis['is_infect'] = ''
          } else {
            this.assessmentBeforeDislysis['is_infect'] = this.predialysis_evaluation['is_infect'] + ''
          }

          //
          //
          // if (this.predialysis_evaluation['puncture_way'] == 0) {
          //   this.assessmentBeforeDislysis['puncture_way'] = ''
          // } else {
          //   this.assessmentBeforeDislysis['puncture_way'] = this.predialysis_evaluation['puncture_way'] + ''
          // }
          //
          //
          // if (this.predialysis_evaluation['venous_catheterization'] == 0) {
          //   this.assessmentBeforeDislysis['venous_catheterization'] = ''
          // } else {
          //   this.assessmentBeforeDislysis['venous_catheterization'] = this.predialysis_evaluation['venous_catheterization'] + ''
          // }
          //
          //
          // if (this.predialysis_evaluation['venous_catheterization_part'] == 0) {
          //   this.assessmentBeforeDislysis['venous_catheterization_part'] = ''
          // } else {
          //   this.assessmentBeforeDislysis['venous_catheterization_part'] = this.predialysis_evaluation['venous_catheterization_part'] + ''
          // }
          //
          //
          // if (this.predialysis_evaluation['emergency_treatment'] == 0) {
          //   this.assessmentBeforeDislysis['emergency_treatment'] = ''
          // } else {
          //   this.assessmentBeforeDislysis['emergency_treatment'] = this.predialysis_evaluation['emergency_treatment'] + ''
          // }

          if (this.predialysis_evaluation['blood_access_part_id'] == 0) {
            this.assessmentBeforeDislysis['blood_access_part_id'] = ''
          }
          if (this.predialysis_evaluation['blood_access_part_opera_id'] == 0) {
            this.assessmentBeforeDislysis['blood_access_part_opera_id'] = ''
          }
          if (this.predialysis_evaluation['weight_before'] == 0) {
            this.assessmentBeforeDislysis['weight_before'] = ''
          }

          if (this.predialysis_evaluation['temperature'] == 0) {
            this.assessmentBeforeDislysis['temperature'] = ''
          }
          if (this.predialysis_evaluation['systolic_blood_pressure'] == 0) {
            this.assessmentBeforeDislysis['systolic_blood_pressure'] = ''
          }
          if (this.predialysis_evaluation['diastolic_blood_pressure'] == 0) {
            this.assessmentBeforeDislysis['diastolic_blood_pressure'] = ''
          }
          if (this.predialysis_evaluation['pulse_frequency'] == 0) {
            this.assessmentBeforeDislysis['pulse_frequency'] = ''
          }
          if (this.predialysis_evaluation['pulse_frequency'] == 0) {
            this.assessmentBeforeDislysis['pulse_frequency'] = ''
          }
        }
      }
    }
  }

</script>

<style scoped>
  .warnTxt{
    text-align: center;
    margin: 0 auto;
    background: #faa331;
    max-width: 240px;
    padding: 10px 20px;
    border-radius: 4px;
    margin-bottom: 10px;
    color:#fff;
  }
</style>
<style lang="scss">
  .newDialog{
  .el-dialog__body{
    padding: 10px 20px 30px;
  }
  }
</style>
