<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">
            <el-form-item label="透析机型号" v-if="isShow('透析机型号')">
              <el-select v-model="assessmentBeforeDislysis.machine_type">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option v-for="item in machineType" :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.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.humor_excessive_symptom">
                <el-option :key="0" label="请选择" :value="0"></el-option>
                <el-option v-for="item in humor_excessive_symptom_array" :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_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-input v-model="assessmentBeforeDislysis.blood_access_part_id" readonly @focus="showInnerDialog('17')"></el-input>
            </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="其他出血情况： ">
              <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="导管维护： " v-if="isShow('导管维护')">
              <el-input v-model="assessmentBeforeDislysis.catheter_maintenance" @focus="showInnerDialog('18')"></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-select v-model="assessmentBeforeDislysis.catheter_bend" placeholder="请选择">
                <el-option
                  v-for="item in catheters"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </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-input v-model="assessmentBeforeDislysis.pinholing" readonly
                        @focus="showInnerDialog('14')"></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.puncture_ways" :label="item.name" :value="item.id"
                           :key="item.id"></el-option>
              </el-select> -->
              <el-input v-model="assessmentBeforeDislysis.puncture_way" readonly
                      @focus="showInnerDialog('13')">
              </el-input>
            </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-select v-model="assessmentBeforeDislysis.is_hemorrhage" placeholder="请选择">
                <el-option
                  v-for="item in hemorrhages"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select> -->
            </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="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-input v-model="assessmentBeforeDislysis.skin" readonly
                      @focus="showInnerDialog('12')">
              </el-input>
            </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="8" v-if="isShow('特殊处理情况')">
            <el-form-item label="特殊处理情况:">
              <el-input v-model="assessmentBeforeDislysis.special_treatment"></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-col :span="8">
            <el-form-item label="导管缝线：" v-if="isShow('导管缝线')">
              <el-input v-model="assessmentBeforeDislysis.catheter_suture" @focus="showInnerDialog('15')"></el-input>
            </el-form-item>
          </el-col>


          <el-col :span="8" v-if="isShow('导管缝线(其他)')">
            <el-form-item label="导管缝线(其他):">
              <el-input v-model="assessmentBeforeDislysis.catheter_suture_other"></el-input>
            </el-form-item>
          </el-col>



          <el-col :span="8" v-if="isShow('尿量')">
            <el-form-item label="尿量(ml):">
              <el-input v-model="assessmentBeforeDislysis.urine_volume"></el-input>
            </el-form-item>
          </el-col>




          <el-col :span="8">
            <el-form-item label="水肿：" v-if="isShow('水肿')">
              <el-input v-model="assessmentBeforeDislysis.edema" @focus="showInnerDialog('16')"></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 axios from 'axios'
  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 {
        hemorrhages:[
          {value:0,label:'请选择'},
          {value:1,label: '是'},
          {value:2,label: '否'},
        ],
        catheters:[
          {value:0,label:'请选择'},
          {value:1,label:'有'},
          {value:2,label:'无'}
          ],
        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_suture:[],
        edema:[],
        catheter: [],
        complication: [],
        hemorrhage: [],
        blood_access_part: [],
        blood_access_part_opera: [],
        humor_excessive_symptom_array: [],
        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: '',
          humor_excessive_symptom: '',
          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: '',
          pinholing:'',
          catheter_suture:'',
          catheter_suture_other:'',
          urine_volume:'',
          edema:'',
          special_treatment:'',
          catheter_maintenance:"",
        },

        InnerDialogProps: {
          values: [],
          visibility: false,
          isShowTextArea: true,
          customContent: '',
          titles: '',
          type: '' // 不同弹框类型，用来匹配数据
        },
        machineType: [],
        puncture_ways: '',
        skins:[],
        pinholings:[],
        catheter_maintenancelist:[]
      }
    },
    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, lastDryWeightDislysis,last_predialysis_evaluation) {
        this.lastPredialysisEvaluation = last_predialysis_evaluation
        if(this.lastPredialysisEvaluation != null) {
          if (this.lastPredialysisEvaluation.is_hemorrhage == 1) {
            this.lastPredialysisEvaluation.is_hemorrhage = "1"
          }
          if (this.lastPredialysisEvaluation.is_hemorrhage == 2) {
            this.lastPredialysisEvaluation.is_hemorrhage = "2"
          }
          if (this.lastPredialysisEvaluation.catheter_bend == 1) {
            this.lastPredialysisEvaluation.catheter_bend = "1"
          }
          if (this.lastPredialysisEvaluation.catheter_bend == 2) {
            this.lastPredialysisEvaluation.catheter_bend = "2"
          }
          if (this.lastPredialysisEvaluation.is_infect == 1) {
            this.lastPredialysisEvaluation.is_infect = "1"
          }
          if (this.lastPredialysisEvaluation.is_infect == 2) {
            this.lastPredialysisEvaluation.is_infect = "2"
          }
        }


        this.assessment = 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 (lastDryWeightDislysis != null) {
            this.weight_adjust.weight = lastDryWeightDislysis.dry_weight
            this.$set(
              this.assessmentBeforeDislysis,
              'dry_weight',
              lastDryWeightDislysis.dry_weight.toString()
            )

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

          if (this.lastPredialysisEvaluation != null) {
            for (var key in this.lastPredialysisEvaluation){
              if (key != 'systolic_blood_pressure' && key != 'diastolic_blood_pressure' && key != 'pulse_frequency' && key != 'dry_weight' && key != 'weight_before'){
                this.$set(
                  this.assessmentBeforeDislysis,
                  key,
                  this.lastPredialysisEvaluation[key]
                )

              }
            }
          }

        } 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 =getDataConfig('hemodialysis', 'puncture_needle')
            this.InnerDialogProps.titles = '穿刺针'
            this.InnerDialogProps.type = 'puncture_needle'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.puncture_needle
            this.InnerDialogProps.isShowTextArea = false

            break
            case '12': // 皮肤
            this.InnerDialogProps.values = this.skins
            this.InnerDialogProps.titles = '皮肤'
            this.InnerDialogProps.type = 'skin'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.skin
            this.InnerDialogProps.isShowTextArea = false

            break
            case '13': // 穿刺方式
            this.InnerDialogProps.values =  this.puncture_ways
            this.InnerDialogProps.titles = '穿刺方式'
            this.InnerDialogProps.type = 'puncture_way'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.puncture_way
            this.InnerDialogProps.isShowTextArea = false

            break
            case '14': // 针眼
            this.InnerDialogProps.values = this.pinholings
            this.InnerDialogProps.titles = '针眼'
            this.InnerDialogProps.type = 'pinholing'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.pinholing
            this.InnerDialogProps.isShowTextArea = false

            break
          case '15': // 导管缝线
            this.InnerDialogProps.values = this.catheter_suture
            this.InnerDialogProps.titles = '导管缝线'
            this.InnerDialogProps.type = 'catheter_suture'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.catheter_suture
            this.InnerDialogProps.isShowTextArea = false

            break
          case '16': // 水肿
            this.InnerDialogProps.values = this.edema
            this.InnerDialogProps.titles = '水肿'
            this.InnerDialogProps.type = 'edema'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.edema
            this.InnerDialogProps.isShowTextArea = false

            break
          case '17': // 水肿
            this.InnerDialogProps.values = this.blood_access_part
            this.InnerDialogProps.titles = '血管通路部位'
            this.InnerDialogProps.type = 'blood_access_part_id'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.blood_access_part_id
            this.InnerDialogProps.isShowTextArea = false

            break

           case '18': // 导管维护
            this.InnerDialogProps.values = this.catheter_maintenancelist
            this.InnerDialogProps.titles = '导管维护'
            this.InnerDialogProps.type = 'catheter_maintenance'
            this.InnerDialogProps.selected = this.assessmentBeforeDislysis.catheter_maintenance
            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
          case 'skin':
            this.assessmentBeforeDislysis.skin = val.value.join(',')
            break
          case 'puncture_way':
            this.assessmentBeforeDislysis.puncture_way = val.value.join(',')
            break
          case 'pinholing':
            this.assessmentBeforeDislysis.pinholing = val.value.join(',')
            break
          case 'catheter_suture':
            this.assessmentBeforeDislysis.catheter_suture = val.value.join(',')
            break
          case 'edema':
            this.assessmentBeforeDislysis.edema = val.value.join(',')
            break
          case 'blood_access_part_id':
            this.assessmentBeforeDislysis.blood_access_part_id = val.value.join(',')
           break
          case 'catheter_maintenance':
           this.assessmentBeforeDislysis.catheter_maintenance = val.value.join(',')
           break
        }
      },
      innerDialogCancle: function() {
        this.InnerDialogProps.visibility = false
      }, handleComfirm: function() {

        var arr = this.assessmentBeforeDislysis
        for (let i = 0; i < this.machineType.length; i++) {
          if (arr.machine_type == this.machineType[i].id) {
            arr.machine_type = this.machineType[i].name
          }
        }
        // console.log('arr', arr)
        const ParamsQuery = arr
        // console.log('paramsquery', ParamsQuery)
        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'
            }
          }
        }
         console.log("params",ParamsQuery)
         
        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
            // console.log("返回数据",assessment_before_dislysis_resp)
            // 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])
            }
            let orgId = parseInt(sessionStorage.getItem("org_id"));
            axios.get('/api/index/patientsign/'+ orgId + '/'+ this.patient.id).then((res) => {
              console.log('res',res.data)

            }) 
            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() {
        const 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.puncture_ways = getDataConfig('hemodialysis', 'puncture_method')
      this.blood_access_part = getDataConfig('hemodialysis', 'vascular_access')
      this.blood_access_part_opera = getDataConfig('hemodialysis', 'vascular_access_desc')
      this.humor_excessive_symptom_array = getDataConfig('hemodialysis', 'humor_excessive_symptom')
      // console.log("血管通路部位",this.blood_access_part_opera)
      this.internal_fistula = getDataConfig('hemodialysis', 'internal_fistula')
      this.internal_fistula_skin = getDataConfig('hemodialysis', 'internal_fistula_skin')
      this.puncture_method = getDataConfig('hemodialysis', 'puncture_method')
      this.machineType = getDataConfig('hemodialysis', 'machine_type')

      this.catheter_suture = getDataConfig('hemodialysis', 'catheter_suture')
      this.edema = getDataConfig('hemodialysis', 'edema')

      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.skins = getDataConfig('hemodialysis','skin')
      console.log("皮肤",this.skins)
      this.pinholings = getDataConfig('hemodialysis','pinholing')
      console.log("针眼",this.pinholings)
      this.catheter_maintenancelist = getDataConfig('hemodialysis','catheter_maintenance')
      console.log("导管维护",this.catheter_maintenancelist)
      // 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() {

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

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