<template>
  <div class="assessment-after-box">
    <el-dialog
      class="newDialog"
      title="透后评估"
      :visible.sync="isVisibility"
      width="1010px"
      :modal-append-to-body="false"
    >
      <div class="warnTxt" v-if="showTxt != ''">{{ showTxt }}</div>
      <el-form ref="form" :model="form" label-width="160px">
        <el-row :gutter="20">
          <el-col :span="8" v-if="isShow('实际治疗时长')">
            <el-form-item label="实际治疗时长(时):">
              <!-- <el-input v-model="form.actual_treatment_hour"></el-input> -->
              <el-time-picker
                v-model="actualTreatmentHourShow"
                placeholder="透析时长"
                style="width:100%;"
                value-format="H:m"
                format="H:m"
                @change="selectActualTreatmentHour"
              >
              </el-time-picker>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="isShow('实际超滤量')">
            <el-form-item
              label="实际超滤量(ml): "
              v-if=" this.template_id == 6 || this.template_id == 9 || this.template_id == 10 || this.template_id == 11  || this.template_id == 17 || this.template_id == 20 || this.template_id == 21 || this.template_id == 22 || this.template_id == 23 || this.template_id == 24"  >
              <el-input v-model="form.actual_ultrafiltration"></el-input>
            </el-form-item>
            <el-form-item label="实际超滤量(L): " v-else>
              <el-input v-model="form.actual_ultrafiltration"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="isShow('透后称重')">
            <el-form-item label="透后称重(kg): ">
              <el-input v-model="form.weight_after"></el-input>
            </el-form-item>
          </el-col>

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

        <el-row :gutter="20">
          <el-col :span="8" v-if="isShow('体重减少')">
            <el-form-item label="体重减少(kg): ">
              <el-input v-model="form.weight_loss"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="isShow('穿刺处血肿')">
            <el-form-item label="穿刺处血肿: ">
              <el-radio-group v-model="form.puncture_point_haematoma">
                <el-radio :label="1">有</el-radio>
                <el-radio :label="2">无</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="isShow('并发症')">
            <el-form-item label="并发症: ">
              <el-input
                v-model="form.complication"
                readonly
                @focus="showDialog('5')"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="8" v-if="isShow('内瘘')">
            <el-form-item label="内瘘: ">
              <el-input
                v-model="form.internal_fistula"
                readonly
                @focus="showDialog('3')"
              ></el-input>
            </el-form-item>
          </el-col>

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

          <el-col :span="8" v-if="isShow('透析过程')">
            <el-form-item label="透析过程: ">
              <el-select v-model="form.dialysis_process">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option
                  v-for="item in this.$store.getters.dialysis_process"
                  :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="透析过程提前时间(min): ">
              <el-input v-model="form.in_advance_minute"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="isShow('透析过程提前原因')">
            <el-form-item label="透析过程提前原因: ">
              <el-input
                v-model="form.in_advance_reason"
                readonly
                @focus="showDialog('7')"
              ></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="isShow('透析过程提前其他原因')">
            <el-form-item label="透析过程提前其他原因: ">
              <el-input
                v-model="form.in_advance_reason_other"
                :rows="2"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="8" v-if="isShow('内瘘管拔针后压迫止血时间')">
            <el-form-item label="内瘘管拔针后压迫止血时间(min): ">
              <el-input v-model="form.hemostasis_minute" :rows="5"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="isShow('内瘘管拔针后压迫止血操作')">
            <el-form-item label="内瘘管拔针后压迫止血操作: ">
              <el-select v-model="form.hemostasis_opera">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option
                  v-for="item in this.$store.getters.hemostasis_opera"
                  :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-select v-model="form.arterial_tube">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option
                  v-for="item in this.$store.getters.arterial_tube"
                  :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" v-if="isShow('静脉管道')">
            <el-form-item label="静脉管道: ">
              <el-select v-model="form.intravenous_tube">
                <el-option :key="0" label="请选择" :value="0"></el-option>

                <el-option
                  v-for="item in this.$store.getters.intravenous_tube"
                  :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="form.cruor"
                readonly
                @focus="showDialog('1')"
              ></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8" v-if="isShow('患者去向')">
            <el-form-item label="患者去向: ">
              <el-select v-model="form.patient_gose">
                <el-option :key="0" label="请选择" :value="0"></el-option>
                <el-option
                  v-for="item in patientGoseOptions"
                  :label="item.name"
                  :value="item.id"
                  :key="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8" v-if="isShow('拔针后穿刺点渗血')">
            <el-form-item label="拔针后穿刺点渗血: ">
              <el-radio-group v-model="form.puncture_point_oozing_blood">
                <el-radio :label="1">有</el-radio>
                <el-radio :label="2">无</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <!--          <el-col :span="8" v-if="isShow('压迫后内瘘震颤')">-->
        <!--            <el-form-item label="压迫后内瘘震颤: ">-->
        <!--              <el-select v-model="form.internal_fistula_tremor_ac">-->
        <!--                <el-option :key="0" label="请选择" :value="0"></el-option>-->

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

        <el-row :gutter="20" v-if="form.patient_gose == 3 && isShow('科室')">
          <el-col :span="24">
            <el-form-item label="科室: ">
              <el-input
                v-model="form.inpatient_department"
                :rows="5"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row
          :gutter="20"
          v-if="
            form.patient_gose == 3 && isShow('交待病房护士/患者/陪人观察内容')
          "
        >
          <el-col :span="24">
            <el-form-item label="交待病房护士/患者/陪人观察内容: ">
              <el-input
                placeholder="交待病房护士/患者/陪人观察内容"
                v-model="form.observation_content"
                :rows="5"
                readonly
                @focus="showDialog('6')"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row
          :gutter="20"
          v-show="form.patient_gose == 3 && isShow('其他观察内容')"
        >
          <el-col :span="24">
            <el-form-item label="其他观察内容: ">
              <el-input
                v-model="form.observation_content_other"
                :rows="5"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

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

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


         <el-col :span="8" v-if="isShow('卧位收缩压')">
          <el-form-item label="卧位收缩压(mmHg):">
              <el-input v-model="form.supine_systolic_blood_pressure"></el-input>
          </el-form-item>
        </el-col>

       <el-col :span="8" v-if="isShow('卧位舒张压')">
          <el-form-item label="卧位舒张压(mmHg):">
              <el-input v-model="form.supine_diastolic_blood_pressure"></el-input>
          </el-form-item>
        </el-col>

        <el-col :span="8" v-if="isShow('坐位收缩压')">
          <el-form-item label="坐位收缩压(mmHg):">
              <el-input v-model="form.setting_pressure"></el-input>
          </el-form-item>
        </el-col>

         <el-col :span="8" v-if="isShow('坐位舒张压')">
          <el-form-item label="坐位舒张压(mmHg):">
              <el-input v-model="form.diastolic_pressure"></el-input>
          </el-form-item>
        </el-col>

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

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

        <el-col :span="8" v-if="isShow('透后症状')">
          <el-form-item label="透后症状: ">
            <el-input
              v-model="form.symptom_after_dialysis"
              readonly
              @focus="showDialog('2')"
            ></el-input>
          </el-form-item>
        </el-col>

        <el-col :span="8" v-if="isShow('透析中入量')">
          <el-form-item label="透析中入量: ">
            <el-input v-model="form.dialysis_intakes"></el-input>
          </el-form-item>
        </el-col>

        <el-col :span="8" v-if="isShow('透析中入量单位')">
          <el-form-item label="透析中入量单位: ">
            <el-select v-model="form.dialysis_intakes_unit">
              <el-option :key="0" label="请选择" :value="0"></el-option>
              <el-option
                v-for="item in unit"
                :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="回血(ml): ">
            <el-input v-model="form.return_blood"></el-input>
          </el-form-item>
        </el-col>

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

        <el-col :span="8" v-if="isShow('透析中进食')">
          <el-form-item label="透析中进食(ml): ">
            <el-input v-model="form.dialysis_during"></el-input>
          </el-form-item>
        </el-col>

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

        <el-col :span="8" v-if="isShow('血流量')">
          <el-form-item label="血流量: ">
            <el-select v-model="form.blood_flow">
              <el-option :key="0" label="请选择" :value="0"></el-option>
              <el-option v-for="item in this.bloodFlowOptions" :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-select v-model="form.sealing_fluid_dispose">
              <el-option :key="0" label="请选择" :value="0"></el-option>
              <el-option v-for="item in this.sealingFluidDisposeOptions" :label="item.name" :value="item.id" :key="item.id"></el-option>
            </el-select> -->
             <el-input
                v-model="form.sealing_fluid_dispose"
                readonly
                @focus="showDialog('9')"
              ></el-input>
          </el-form-item>
        </el-col>

        <el-col :span="8" v-if="sealing_fluid_special_name == '特殊'&&isShow('封管液特殊')">
          <el-form-item label="封管液配置(特殊)： ">
            <el-input v-model="form.sealing_fluid_special"></el-input>
          </el-form-item>
        </el-col>

        <!-- </el-row>

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

        <el-col :span="8" v-if="isShow('实际置换量')">
          <el-form-item v-if="this.template_id == 20 || this.template_id == 21" label="实际置换量(ml): ">
            <el-input v-model="form.actual_displacement"></el-input>
          </el-form-item>
          <el-form-item v-else label="实际置换量(L): ">
            <el-input v-model="form.actual_displacement"></el-input>
          </el-form-item>
        </el-col>

        <!-- </el-row>

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

        <!-- </el-row>

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

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

        <!--                <el-option-->
        <!--                  v-for="item in vascularAccessOptions"-->
        <!--                  :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-select v-model="form.blood_access_part_opera_id">-->
        <!--                <el-option :key="0" label="请选择" :value="0"></el-option>-->

        <!--                <el-option-->
        <!--                  v-for="item in vascularAccessDescOptions"-->
        <!--                  :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-row>



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

        <!--
                  </el-row>




                  <el-row :gutter="20"> -->
        <!--          <el-col :span="8" v-if="isShow('内瘘震颤和血管杂音')">-->
        <!--            <el-form-item label="内瘘震颤和血管杂音: ">-->
        <!--              <el-select v-model="form.tremor_noise">-->
        <!--                <el-option :key="0" label="请选择" :value="0"></el-option>-->

        <!--                <el-option-->
        <!--                  v-for="item in this.$store.getters.tremor_noise"-->
        <!--                  :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-select v-model="form.disequilibrium_syndrome">
              <el-option :key="0" label="请选择" :value="0"></el-option>

              <el-option
                v-for="item in this.$store.getters.disequilibrium_syndrome"
                :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="form.disequilibrium_syndrome_option"-->
        <!--                readonly-->
        <!--                @focus="showDialog('8')"-->
        <!--              ></el-input>-->
        <!--            </el-form-item>-->
        <!--          </el-col>-->

        <!-- </el-row>



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

        <!--          <el-col :span="8" v-if="isShow('透析器')">-->
        <!--            <el-form-item label="透析器凝血: ">-->
        <!--              <el-select v-model="form.dialyzer">-->
        <!--                <el-option :key="0" label="请选择" :value="0"></el-option>-->

        <!--                <el-option-->
        <!--                  v-for="item in this.$store.getters.dialyzer"-->
        <!--                  :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-radio-group v-model="form.is_eat">
              <el-radio :label="1">有</el-radio>
              <el-radio :label="2">无</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>

        <el-col :span="8" v-if="isShow('中心静脉封管(肝素-A端)')">
          <el-form-item label="中心静脉封管(肝素-A端): ">
            <el-input v-model="form.cvc_a"></el-input>
          </el-form-item>
        </el-col>

        <el-col :span="8" v-if="isShow('中心静脉封管(肝素-V端)')">
          <el-form-item label="中心静脉封管(肝素-V端): ">
            <el-input v-model="form.cvc_v"></el-input>
          </el-form-item>
        </el-col>

        <el-col :span="8" v-if="isShow('管路')">
          <el-form-item label="管路: ">
            <el-select v-model="form.channel">
              <el-option :key="0" label="请选择" :value="0"></el-option>
              <el-option
                v-for="item in channels"
                :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="form.dosage_of_anticoagulants"></el-input>
          </el-form-item>
        </el-col>


      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="hide">取 消</el-button>
        <el-button
          type="primary"
          @click="submitForm"
          :loading="loading"
          v-if="hasPermission"
          >保 存</el-button
        >
      </span>
    </el-dialog>

    <multi-select-box
      :propsForm="InnerDialogProps"
      v-on:dialog-comfirm="DialogComfirm"
      v-on:dialog-cancle="DialogCancle"
    ></multi-select-box>
  </div>
</template>

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

import request from '@/utils/request'

export default {
  name: 'AssessmentAfterDislysis',
  props: {
    assessment_after_dislysis: {
      // 透后评估
      type: Object,
      default: () => {
        return { id: 0 }
      }
    },
    dialysis_order: {
      // 透析记录
      type: Object,
      default: () => {
        return { id: 0 }
      }
    },
    patient: {
      // 患者信息
      type: Object,
      default: () => {
        return { id: 0 }
      }
    }
  },
  data() {
    return {
      showTxt: '',
      hasPermission: true,
      loading: false,
      record_date: '',
      isVisibility: false,
      template_id: 0,
      cruorOptions: [],
      symptomsOptions: [],
      internalFistulaOptions: [],
      vascularAccessOptions: [],
      unit: [{ id: 1, name: 'g' }, { id: 2, name: 'ml' }],
      actualTreatmentHourShow: '',
      vascularAccessDescOptions: [],
      catheterOptions: [],
      complicationOptions: [],
      internalFistulaTremorAcOptions: [],
      patientGoseOptions: [],
      observationContentOptions: [],
      channels: [],
      bloodFlowOptions: [],
      sealingFluidDisposeOptions: [],

      isVisibiltyForCruorDialog: false,
      dialogCruorTitle: '凝血',
      sealing_fluid_special_name: '',

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

      form: {
        weight_after: '',
        weight_loss: '',
        temperature: '',
        systolic_blood_pressure: '',
        diastolic_blood_pressure: '',
        pulse_frequency: '',
        actual_ultrafiltration: '',
        actual_displacement: '',
        actual_treatment_hour: '',
        actual_treatment_minute: '',
        cruor: '',
        symptom_after_dialysis: '',
        dialysis_intakes: '',
        internal_fistula: '',
        blood_access_part_id: '',
        blood_access_part_opera_id: '',
        catheter: '',
        complication: '',
        puncture_point_oozing_blood: 2,
        puncture_point_haematoma: 2,
        internal_fistula_tremor_ac: '',
        patient_gose: '',
        inpatient_department: '',
        observation_content: '',
        observation_content_other: '',
        remark: '',
        dialysis_order_id: 0,
        is_eat: 2,
        dialysis_process: '',
        in_advance_minute: '',
        in_advance_reason: '',
        in_advance_reason_other: '',
        hemostasis_minute: '',
        hemostasis_opera: '',
        tremor_noise: '',
        disequilibrium_syndrome: '',
        disequilibrium_syndrome_option: '',
        arterial_tube: '',
        intravenous_tube: '',
        dialyzer: '',
        breathing_rate: '',
        dialysis_intakes_unit: 0,
        cvc_a: 0,
        cvc_v: 0,
        channel: '',
        return_blood: '',
        rehydration_volume: '',
        dialysis_during: '',
        stroke_volume: '',
        blood_flow: '',
        sealing_fluid_dispose: '',
        sealing_fluid_special: '',
        dosage_of_anticoagulants:'',
        supine_systolic_blood_pressure:'',
        setting_pressure:'',
        supine_diastolic_blood_pressure:'',
        diastolic_pressure:'',
        additional_weight:'',
      }
    }
  },
  watch: {
    'form.sealing_fluid_dispose': function() {
      // var tempsealingFluidDisposeOptions = getDataConfig('hemodialysis', 'sealing_fluid_dispose')
      // for (let i = 0; i < tempsealingFluidDisposeOptions.length; i++) {
      //   if (tempsealingFluidDisposeOptions[i].id == this.form.sealing_fluid_dispose) {
      //     this.sealing_fluid_special_name = tempsealingFluidDisposeOptions[i].name
      //   }
      // }
      var name =""
      var str = this.form.sealing_fluid_dispose
      var arr = str.split(',')
      for(let i=0;i<arr.length;i++){
        if(arr[i]== "特殊"){
           name = "特殊"
        }
      }
      this.sealing_fluid_special_name = name
      return this.sealing_fluid_special_name
    },
    'assessment_after_dislysis.id': function() {
      if (this.assessment_after_dislysis.id > 0) {
        for (var index in this.form) {
          this.form[index] = this.assessment_after_dislysis[index]
        }

        if (this.assessment_after_dislysis['blood_access_part_id'] == 0) {
          this.form['blood_access_part_id'] = ''
        }
        if (this.assessment_after_dislysis['blood_access_part_opera_id'] == 0) {
          this.form['blood_access_part_opera_id'] = ''
        }
        if (this.assessment_after_dislysis['internal_fistula_tremor_ac'] == 0) {
          this.form['internal_fistula_tremor_ac'] = ''
        }
        if (this.assessment_after_dislysis['patient_gose'] == 0) {
          this.form['patient_gose'] = ''
        }
        if (this.assessment_after_dislysis['weight_after'] == 0) {
          this.form['weight_after'] = ''
        }
        if (this.assessment_after_dislysis['weight_loss'] == 0) {
          this.form['weight_loss'] = ''
        }
        if (this.assessment_after_dislysis['temperature'] == 0) {
          this.form['temperature'] = ''
        }
        if (this.assessment_after_dislysis['systolic_blood_pressure'] == 0) {
          this.form['systolic_blood_pressure'] = ''
        }
        if (this.assessment_after_dislysis['diastolic_blood_pressure'] == 0) {
          this.form['diastolic_blood_pressure'] = ''
        }
        if (this.assessment_after_dislysis['pulse_frequency'] == 0) {
          this.form['pulse_frequency'] = ''
        }
        if (this.assessment_after_dislysis['breathing_rate'] == 0) {
          this.form['breathing_rate'] = ''
        }
        if (this.assessment_after_dislysis['actual_ultrafiltration'] == 0) {
          this.form['actual_ultrafiltration'] = ''
        }
        if (this.assessment_after_dislysis['actual_displacement'] == 0) {
          this.form['actual_displacement'] = ''
        }
        if (this.assessment_after_dislysis['dialysis_intakes'] == 0) {
          this.form['dialysis_intakes'] = ''
        }
        if (this.assessment_after_dislysis['return_blood'] == 0) {
          this.form['return_blood'] = ''
        }
        if (this.assessment_after_dislysis['rehydration_volume'] == 0) {
          this.form['rehydration_volume'] = ''
        }
        if (this.assessment_after_dislysis['dialysis_during'] == 0) {
          this.form['dialysis_during'] = ''
        }
        if (this.assessment_after_dislysis['stroke_volume'] == 0) {
          this.form['stroke_volume'] = ''
        }
        if (this.assessment_after_dislysis['blood_flow'] == 0) {
          this.form['blood_flow'] = ''
        }
        if (this.assessment_after_dislysis['sealing_fluid_dispose'] == 0) {
          this.form['sealing_fluid_dispose'] = ''
        }
        this.actualTreatmentHourShow = new Date(
          2018,
          1,
          1,
          this.assessment_after_dislysis['actual_treatment_hour'],
          this.assessment_after_dislysis['actual_treatment_minute']
        )
      }
    },
    'dialysis_order.id': function() {
      this.form['dialysis_order_id'] = this.assessment_after_dislysis[
        'dialysis_order_id'
      ]
    },
    'form.patient_gose': function() {
      if (this.form.patient_gose.patient_gose != 3) {
        this.form.inpatient_department = ''
        this.form.observation_content = ''
        this.form.observation_content_other = ''
      }
    },
    'form.weight_after': function() {
      if (this) {
      }
    }
  },
  methods: {
    submitForm() {
      this.loading = true
      const ParamsQuery = {}

      if (!(this.patient.id > 0)) {
        this.$message.error('没有选择患者')
        this.loading = false
        return false
      }
      if (this.record_date.length != 10) {
        this.$message.error('无效的日期')
        this.loading = false
        return false
      }

      ParamsQuery['patient'] = this.patient.id
      ParamsQuery['record_date'] = this.record_date
      ParamsQuery['mode'] = '1'
      if (this.assessment_after_dislysis.creater > 0) {
        ParamsQuery['mode'] = '2'
        if (
          this.assessment_after_dislysis.creater !=
          this.$store.getters.xt_user.user.id
        ) {
          ParamsQuery['mode'] = '3'
        }
      }

      const data = {}
      data['weight_after'] = this.form.weight_after ? parseFloat(this.form.weight_after) : 0
      data['weight_loss'] = this.form.weight_loss ? parseFloat(this.form.weight_loss) : 0
      data['temperature'] = this.form.temperature ? parseFloat(this.form.temperature) : 0
      data['breathing_rate'] = this.form.temperature ? parseFloat(this.form.breathing_rate) : 0
      data['systolic_blood_pressure'] = this.form.systolic_blood_pressure ? parseFloat(this.form.systolic_blood_pressure) : 0
      data['diastolic_blood_pressure'] = this.form.diastolic_blood_pressure ? parseFloat(this.form.diastolic_blood_pressure) : 0
      data['pulse_frequency'] = this.form.pulse_frequency ? parseFloat(this.form.pulse_frequency) : 0
      data['actual_ultrafiltration'] = this.form.actual_ultrafiltration ? parseFloat(this.form.actual_ultrafiltration) : 0
      data['actual_displacement'] = this.form.actual_displacement ? parseFloat(this.form.actual_displacement) : 0
      data['actual_treatment_hour'] = this.form.actual_treatment_hour ? parseFloat(this.form.actual_treatment_hour) : 0
      data['actual_treatment_minute'] = this.form.actual_treatment_minute ? parseFloat(this.form.actual_treatment_minute) : 0
      data['cruor'] = this.form.cruor
      data['symptom_after_dialysis'] = this.form.symptom_after_dialysis
      data['dialysis_intakes'] = this.form.dialysis_intakes ? parseFloat(this.form.dialysis_intakes) : 0
      data['internal_fistula'] = this.form.internal_fistula
      data['blood_access_part_id'] = this.form.blood_access_part_id ? parseFloat(this.form.blood_access_part_id) : 0
      data['blood_access_part_opera_id'] = this.form.blood_access_part_opera_id ? parseFloat(this.form.blood_access_part_opera_id) : 0
      data['catheter'] = this.form.catheter
      data['complication'] = this.form.complication
      data['puncture_point_oozing_blood'] = this.form.puncture_point_oozing_blood ? parseFloat(this.form.puncture_point_oozing_blood) : 0
      data['puncture_point_haematoma'] = this.form.puncture_point_haematoma ? parseFloat(this.form.puncture_point_haematoma) : 0
      data['internal_fistula_tremor_ac'] = this.form.internal_fistula_tremor_ac ? parseFloat(this.form.internal_fistula_tremor_ac) : 0
      data['patient_gose'] = this.form.patient_gose ? parseFloat(this.form.patient_gose) : 0
      data['inpatient_department'] = this.form.inpatient_department
      data['observation_content'] = this.form.observation_content
      data['observation_content_other'] = this.form.observation_content_other
      data['remark'] = this.form.remark
      data['dialysis_order_id'] = this.form.dialysis_order_id ? parseFloat(this.form.dialysis_order_id) : 0
      data['dialysis_process'] = this.form.dialysis_process ? parseFloat(this.form.dialysis_process) : 0
      data['in_advance_minute'] = this.form.in_advance_minute ? parseFloat(this.form.in_advance_minute) : 0
      data['in_advance_reason_other'] = this.form.in_advance_reason_other
      data['in_advance_reason'] = this.form.in_advance_reason
      data['hemostasis_minute'] = this.form.hemostasis_minute ? parseFloat(this.form.hemostasis_minute) : 0
      data['hemostasis_opera'] = this.form.hemostasis_opera ? parseFloat(this.form.hemostasis_opera) : 0
      data['tremor_noise'] = this.form.tremor_noise ? parseFloat(this.form.tremor_noise) : 0
      data['disequilibrium_syndrome'] = this.form.disequilibrium_syndrome ? parseFloat(this.form.disequilibrium_syndrome) : 0
      data['disequilibrium_syndrome_option'] = this.form.disequilibrium_syndrome_option
      data['arterial_tube'] = this.form.arterial_tube ? parseFloat(this.form.arterial_tube) : 0
      data['intravenous_tube'] = this.form.intravenous_tube ? parseFloat(this.form.intravenous_tube) : 0
      data['dialysis_intakes_unit'] = this.form.dialysis_intakes_unit
      data['dialyzer'] = this.form.dialyzer ? parseFloat(this.form.dialyzer) : 0
      data['is_eat'] = this.form.is_eat ? parseFloat(this.form.is_eat) : 0
      data['cvc_a'] = this.form.cvc_a ? parseFloat(this.form.cvc_a) : 0
      data['cvc_v'] = this.form.cvc_v ? parseFloat(this.form.cvc_v) : 0
      data['return_blood'] = this.form.return_blood ? parseFloat(this.form.return_blood) : 0
      data['rehydration_volume'] = this.form.rehydration_volume ? parseFloat(this.form.rehydration_volume) : 0
      data['dialysis_during'] = this.form.dialysis_during ? parseFloat(this.form.dialysis_during) : 0
      data['stroke_volume'] = this.form.stroke_volume ? parseFloat(this.form.stroke_volume) : 0
      data['blood_flow'] = this.form.blood_flow ? parseFloat(this.form.blood_flow) : 0
      // data['sealing_fluid_dispose'] = this.form.sealing_fluid_dispose ? parseFloat(this.form.sealing_fluid_dispose) : 0
      data['sealing_fluid_dispose'] = this.form.sealing_fluid_dispose
      data['sealing_fluid_special'] = this.form.sealing_fluid_special
      data['dosage_of_anticoagulants'] = this.form.dosage_of_anticoagulants ? parseFloat(this.form.dosage_of_anticoagulants) : 0
      data['supine_systolic_blood_pressure'] = this.form.supine_systolic_blood_pressure
      data['setting_pressure'] = this.form.setting_pressure
      data["supine_diastolic_blood_pressure"] = this.form.supine_diastolic_blood_pressure
      data["diastolic_pressure"] = this.form.diastolic_pressure
      data["additional_weight"] = this.form.additional_weight ? parseFloat(this.form.additional_weight) : 0
      postAssessmentAfterDislysis(ParamsQuery, data)
        .then(response => {
          this.loading = false
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.$notify({
              title: '成功',
              message: '提交成功',
              type: 'success',
              duration: 2000
            })

            var assement = response.data.data.AssessmentAfterDislysis

            var assessment_after_dislysis = this.assessment_after_dislysis

            for (var index in assement) {
              // assessment_after_dislysis[index] = assement[index];
              this.$set(assessment_after_dislysis, index, assement[index])
            }
            this.hide()
          }
        })
        .catch(v => {
          this.loading = false
        })
    },
    showDialog: function(val) {
      this.InnerDialogProps.visibility = true
      switch (val) {
        case '1':
          this.InnerDialogProps.values = this.cruorOptions
          this.InnerDialogProps.titles = '凝血'
          this.InnerDialogProps.type = 'cruor'
          this.InnerDialogProps.selected = this.form.cruor
          this.InnerDialogProps.isShowTextArea = false
          break
        case '2':
          this.InnerDialogProps.values = this.symptomsOptions
          this.InnerDialogProps.titles = '透后症状'
          this.InnerDialogProps.type = 'symptom_after_dialysis'
          this.InnerDialogProps.selected = this.form.symptom_after_dialysis
          this.InnerDialogProps.isShowTextArea = false
          break
        case '3':
          this.InnerDialogProps.values = this.internalFistulaOptions
          this.InnerDialogProps.titles = '内瘘'
          this.InnerDialogProps.type = 'internal_fistula'
          this.InnerDialogProps.selected = this.form.internal_fistula
          this.InnerDialogProps.isShowTextArea = false
          break
        case '4':
          this.InnerDialogProps.values = this.catheterOptions
          this.InnerDialogProps.titles = '导管'
          this.InnerDialogProps.type = 'catheter'
          this.InnerDialogProps.selected = this.form.catheter
          this.InnerDialogProps.isShowTextArea = false
          break
        case '5':
          this.InnerDialogProps.values = this.complicationOptions
          this.InnerDialogProps.titles = '并发症'
          this.InnerDialogProps.type = 'complication'
          this.InnerDialogProps.selected = this.form.complication
          this.InnerDialogProps.isShowTextArea = false
          break
        case '6':
          this.InnerDialogProps.values = this.observationContentOptions
          this.InnerDialogProps.titles = '交待病房护士/患者/陪人观察内容'
          this.InnerDialogProps.type = 'observation_content'
          this.InnerDialogProps.selected = this.form.observation_content
          this.InnerDialogProps.isShowTextArea = false
          break
        case '7':
          this.InnerDialogProps.values = this.$store.getters.in_advance_reason
          this.InnerDialogProps.titles = '透析过程提前原因'
          this.InnerDialogProps.type = 'in_advance_reason'
          this.InnerDialogProps.selected = this.form.in_advance_reason
          this.InnerDialogProps.isShowTextArea = false
          break

        case '8':
          this.InnerDialogProps.values = this.$store.getters.disequilibrium_syndrome_option
          this.InnerDialogProps.titles = '失衡综合症症状'
          this.InnerDialogProps.type = 'disequilibrium_syndrome_option'
          this.InnerDialogProps.selected = this.form.disequilibrium_syndrome_option
          this.InnerDialogProps.isShowTextArea = false
          break
       case '9':
          this.InnerDialogProps.values = this.sealingFluidDisposeOptions
          this.InnerDialogProps.titles = '封管液配置'
          this.InnerDialogProps.type = 'sealing_fluid_dispose'
          this.InnerDialogProps.selected = this.form.sealing_fluid_dispose
          this.InnerDialogProps.isShowTextArea = false
          break
      }
    },
    selectActualTreatmentHour(val) {
      var valTime = val.split(':')
      this.form.actual_treatment_hour = valTime[0]
      this.form.actual_treatment_minute = valTime[1]
    },
    DialogComfirm: function(val) {
      this.InnerDialogProps.visibility = false
      switch (val.type) {
        case 'cruor':
          this.form.cruor = val.value.join(',')
          break
        case 'symptom_after_dialysis':
          this.form.symptom_after_dialysis = val.value.join(',')
          break
        case 'internal_fistula':
          this.form.internal_fistula = val.value.join(',')
          break
        case 'catheter':
          this.form.catheter = val.value.join(',')
          break
        case 'complication':
          this.form.complication = val.value.join(',')
          break
        case 'observation_content':
          this.form.observation_content = val.value.join(',')
          break
        case 'in_advance_reason':
          this.form.in_advance_reason = val.value.join(',')
          break
        case 'disequilibrium_syndrome_option':
          this.form.disequilibrium_syndrome_option = val.value.join(',')
          break
        case 'sealing_fluid_dispose':
          this.form.sealing_fluid_dispose = val.value.join(',')
          break
        default:
          break
      }
      // console.log(val);
    },
    DialogCancle: function(val) {
      this.InnerDialogProps.visibility = false
    },

    // 数据开始
    show(predialysis,last_after) {
      this.isVisibility = true
      this.predialysis = predialysis
      this.form.observation_content = predialysis.observation_content
      this.form.inpatient_department = predialysis.inpatient_department
      this.form.observation_content_other =
        predialysis.observation_content_other
      // console.log("透后", predialysis);

      if(predialysis != null && predialysis.id == 0){
        if (last_after != null) {
          for (var key in last_after){
            if (key != 'actual_treatment_hour' && key != 'actual_treatment_minute' && key != 'weight_loss' && key != 'weight_after'  && key != 'systolic_blood_pressure' && key != 'diastolic_blood_pressure' && key != 'pulse_frequency' ){
              this.$set(
                this.form,
                key,
                last_after[key]
              )

            }
          }
        }
      }




      this.getPermission()


    },

    hide() {
      this.isVisibility = false
    },
    isShow(name) {
      var filedList = store.getters.xt_user.fileds

      for (let i = 0; i < filedList.length; i++) {
        if (
          filedList[i].module == 5 &&
          filedList[i].filed_name_cn == name &&
          filedList[i].is_show == 1
        ) {
          return true
        }
      }
      return false
    },
    setRecords(records) {
      for (var index in records) {
        this.$set(this.assessment_after_dislysis, index, records[index])
      }
      this.actualTreatmentHourShow = new Date(
        2018,
        1,
        1,
        this.assessment_after_dislysis['actual_treatment_hour'],
        this.assessment_after_dislysis['actual_treatment_minute']
      )
    },
    getPermission() {
      request
        .get('/api/func_per/get', {
          params: {
            create_url: '/api/dialysis/assessmentafterdislysis?mode=1',
            modify_url: '/api/dialysis/assessmentafterdislysis?mode=2',
            modify_other_url: '/api/dialysis/assessmentafterdislysis?mode=3',
            module: 8
          }
        })
        .then(res => {
          console.log(res)
          // console.log("透后", this.predialysis);
          if (res.data.state == 0) {
            this.hasPermission = false
          } else if (res.data.state == 1) {
            if (this.predialysis.id != '' && this.predialysis.creater != 0) {
              // 有数据
              if (
                this.predialysis.creater == this.$store.getters.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.predialysis.id == '' ||
              this.predialysis.creater == 0
            ) {
              if (res.data.data.is_has_create == false) {
                this.hasPermission = false
                this.showTxt = '你没有新增透后评估权限'
              }
            }
          }
        })
    }
  },
  created() {
    // console.log("this.form", this.form);
    this.cruorOptions = getDataConfig('hemodialysis', 'cruor')
    this.symptomsOptions = getDataConfig('hemodialysis', 'symptoms')
    this.internalFistulaOptions = getDataConfig('hemodialysis', 'internal_fistula')
    this.vascularAccessOptions = getDataConfig('hemodialysis', 'vascular_access')
    this.vascularAccessDescOptions = getDataConfig('hemodialysis', 'vascular_access_desc')
    this.catheterOptions = getDataConfig('hemodialysis', 'catheter')
    this.complicationOptions = getDataConfig('hemodialysis', 'complication')
    this.bloodFlowOptions = getDataConfig('hemodialysis', 'blood_flow')
    this.sealingFluidDisposeOptions = getDataConfig('hemodialysis', 'sealing_fluid_dispose')
    this.internalFistulaTremorAcOptions = this.$store.getters.internal_fistula_tremor_ac
    this.patientGoseOptions = this.$store.getters.patient_gose
    this.observationContentOptions = this.$store.getters.observation_content
    this.template_id = this.$store.getters.xt_user.template_info.template_id
    this.channels = this.$store.getters.channels
    var date = this.$route.query && this.$route.query.date
    this.record_date = uParseTime(date, '{y}-{m}-{d}')
  },
  components: {
    MultiSelectBox
  }
}
</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>
