<template>
  <div class="app-container ">
    <el-form ref="form"  :model="form" label-width="134px" class="clearfix" id="patient-info" >

    <div class="dataTitle">基本资料</div>
      <el-row >
        <el-col :span="20" >
          <el-row :gutter="10">


            <el-col :span="8">
              <el-form-item label="登记人员 : ">
                <el-input style="width: 120px" v-model="form.registrars" disabled id="registrars"></el-input>
                <el-button type="primary" size="mini" v-clipboard:copy="form.registrars"
                           v-clipboard:success="onCopy" v-clipboard:error="onError">复制</el-button>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="创建日期 : ">
                <el-date-picker style="width: 120px" v-model="form.created_time" type="date" disabled placeholder="选择日期" :suffix-icon="'el-icon-menu'" format="yyyy-MM-dd" value-format="yyyy-MM-dd"></el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="姓名 : "  class="is-required" >
                <el-input style="width: 100px" v-model="form.name" disabled></el-input>
                <el-button type="primary" size="mini"  v-clipboard:copy="form.name"
                           v-clipboard:success="onCopy" v-clipboard:error="onError">复制</el-button>
              </el-form-item>

            </el-col>
            <el-col :span="8" style="height:59px;">
              <el-form-item label="性别 : " class="is-required"  >
                <el-radio-group v-model="form.gender">
                  <el-radio v-for="item in sexOptions" :key="item.value" :label="item.value" :value="item.value" disabled>{{item.label}}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>



            <el-col :span="8">
              <el-form-item label="身份证号 : "  class="is-required"  >
                <el-input style="width: 150px"  v-model="form.idCardNo" disabled></el-input>
                <el-button type="primary" size="mini" v-clipboard:copy="form.idCardNo"
                           v-clipboard:success="onCopy" v-clipboard:error="onError">复制</el-button>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="民族 : " >
                <el-input style="width: 100px;" v-model="form.nation" maxlength="30" disabled></el-input>
                <el-button type="primary" size="mini" v-clipboard:copy="form.nation"
                           v-clipboard:success="onCopy" v-clipboard:error="onError">复制</el-button>

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

            <el-col :span="8">
              <el-form-item label="婚姻状况 : " >
                <el-select v-model="form.maritalStatus"  placeholder="请选择婚姻状况" disabled>
                  <el-option v-for="item in maritalOptions" :key="item.id" :label="item.name" :value="item.id"/>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="职业 : "  prop="profession">
                <el-select v-model="form.profession" disabled >
                  <el-option v-for="item in professionOptions" :key="item.id" :label="item.name" :value="item.id"/>
                </el-select>
              </el-form-item>
            </el-col>


            <el-col :span="8"  style="height:59px;" >
              <el-form-item label="年龄 : " class="is-required" >
                <el-input style="width: 50px" v-model="form.age" disabled ></el-input>
                <el-button type="primary" size="mini" v-clipboard:copy="form.age"
                           v-clipboard:success="onCopy" v-clipboard:error="onError">复制</el-button>
              </el-form-item>
            </el-col>


            <el-col :span="8">
              <el-form-item label="出生日期 : "  class="is-required"  >
                <el-date-picker style="width: 150px" v-model="form.birth" type="date" disabled placeholder="选择日期" :suffix-icon="'el-icon-menu'" format="yyyy-MM-dd" value-format="yyyy-MM-dd"></el-date-picker>

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


            <el-col :span="8">
              <el-form-item label="教育程度 : "  >
                <el-select v-model="form.education" disabled >
                  <el-option v-for="item in educationOptions" :key="item.id" :label="item.name" :value="item.id"/>
                </el-select>
              </el-form-item>
            </el-col>


            <el-col :span="8">
              <el-form-item label="住院(门诊)号 : ">
                <el-input  style="width: 150px"  v-model="form.admissionNumber" disabled></el-input>
                <el-button type="primary" size="mini" v-clipboard:copy="form.admissionNumber"
                           v-clipboard:success="onCopy" v-clipboard:error="onError">复制</el-button>

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

            <el-col :span="8">
              <el-form-item label="透析号 : " class="is-required">
                <el-input disabled v-model="form.dialysisNo" placeholder="填写或自动生成" style="width:110px;float:left;margin-right: 1%;" ></el-input>
                <el-button type="primary" size="mini" v-clipboard:copy="form.dialysisNo"
                           v-clipboard:success="onCopy" v-clipboard:error="onError">复制</el-button>

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


            <el-col :span="8">
              <el-form-item label="籍贯 : " >
                <el-input style="width: 150px" v-model="form.native_place" maxlength="30" disabled></el-input>
                <el-button type="primary" size="mini" v-clipboard:copy="form.native_place"
                           v-clipboard:success="onCopy" v-clipboard:error="onError">复制</el-button>


              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="家庭住址 : ">
                <el-input style="width: 150px" v-model="form.homeAddress" disabled></el-input>
                <el-button type="primary" size="mini"  v-clipboard:copy="form.homeAddress"
                           v-clipboard:success="onCopy" v-clipboard:error="onError">复制</el-button>

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

            <el-col :span="8">
              <el-form-item label="本人电话: " class="is-required" >
                <el-input style="width: 150px" v-model="form.phone" maxlength="20" disabled></el-input>
                <el-button type="primary" size="mini" v-clipboard:copy="form.phone"
                           v-clipboard:success="onCopy" v-clipboard:error="onError">复制</el-button>


              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="家属电话: " prop="homeTelephone">
                <el-input style="width: 150px" v-model="form.homeTelephone" maxlength="20" disabled></el-input>
                <el-button type="primary" size="mini" v-clipboard:copy="form.homeTelephone"
                           v-clipboard:success="onCopy" v-clipboard:error="onError">复制</el-button>

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

            <el-col :span="8">
              <el-form-item label="首次透析日期 : "  prop="firstDialysisDate">
                <el-date-picker style="width: 150px" v-model="form.firstDialysisDate" type="date" disabled format="yyyy-MM-dd" value-format="yyyy-MM-dd"></el-date-picker>
              </el-form-item>
            </el-col>



          </el-row>
        </el-col>
      </el-row>



    </el-form>

  </div>
</template>

<script>
  import { getDataConfig } from '@/utils/data'
  import { getToken } from '@/api/qiniu'
  import { fetchAllList } from "@/api/patient";

  import {
    getFileExtension,
    isCardNo,
    jsGetAge,
    isPositiveInteger,
    dialysisAge,
    uParseTime
  } from '@/utils/tools'
  import {
    generateDialysisNo,
    createPatient,
    editPatient,
    fetchPatient
  } from '@/api/patient'
  import { fetchAllDoctorAndNurse, fetchAllAdminUsers } from '@/api/doctor'
  import { getZones } from '@/api/device/device'
  import { parse } from 'path'
  const defaultForm = {
    avatar: '',
    patientType: '',
    dialysisNo: '',
    admissionNumber: '',
    source: '',
    lapseto: '',
    partition: '',
    bed: '',
    name: '',
    gender: '',
    nation: '',
    native_place: '',
    maritalStatus: '',
    idCardNo: '',
    birth: '',
    age: '',
    reimbursementWayID: '',
    healthCareNo: '',
    healthCareDueDate: '',
    height: '',
    blood: '',
    rh: '',
    healthCareDueAlertDate: '',
    education: '',
    profession: '',
    phone: '',
    homeTelephone: '',
    homeAddress: '',
    work: '',
    receivingDate: '',
    firstDialysisDate: '',
    dialysisAge: '',
    induction: '',
    initial: '',
    dialysisTotal: '',
    contagions: [],
    doctor: '',
    nurse: '',
    assessment: '',
    diseases: [],
    diagnose: '',
    registrars: '',

    patient_complains: '',
    present_history: '',
    past_history: '',
    temperature: '',
    pulse: '',
    respiratory: '',
    sbp: '',
    dbp: '',
    created_time:'',

  }

  export default {
    name: 'FastUploadDetail',
    components: { },
    props: {
      id: 0,
    },

    data() {
      return {
        generic_info_fold: true,
        treat_info_fold: true,

        orgname: '',
        adminusername: '',
        form: Object.assign({}, defaultForm),
        formSubmit: true,
        submitMethod: '',
        uploadData: { token: '', key: '' },
        dialogImageUrl: '',
        qiniuDomain: 'https://images.shengws.com/',
        dialogVisible: false,
        typeOptions: null,
        styleOptions: null,
        sourceOptions: [{ value: 1, label: '门诊' }, { value: 2, label: '住院' }],
        lapsetoOptions: [{ value: 1, label: '留治' }, { value: 2, label: '转出' }],
        partitionOptions: [],
        sexOptions: [{ value: 1, label: '男' }, { value: 2, label: '女' }],
        isHospitalFirstDialysisOptions: [{ value: 1, label: '是' }, { value: 2, label: '否' }],
        predialysisConditionOptions: [{ value: 1, label: '腹膜透析' }, { value: 2, label: '肾移植' }],
        maritalOptions: null,
        wayOptions: null,
        educationOptions: null,
        professionOptions: null,
        inductionOptions: null,
        doctorOptions: null,
        nurseOptions: null,
        adminUserOptions: [],
        rhOptions: null,
        checkDisease: null,
        contagionList: null,
        loading: null,
        patientID: 0,
        patientPrint: {},
        print_time: '',

      }
    },
    computed: {
      generic_fold_icon: function() {
        return this.generic_info_fold ? 'el-icon-arrow-down' : 'el-icon-arrow-up'
      },
      treat_fold_icon: function() {
        return this.treat_info_fold ? 'el-icon-arrow-down' : 'el-icon-arrow-up'
      }
    },
    created() {
      this.styleOptions = this.$store.getters.patient_types
      this.maritalOptions = getDataConfig('patient', 'marital_options')
      this.wayOptions = getDataConfig('patient', 'reimbursement_ways')
      this.typeOptions = this.$store.getters.blood_types
      this.rhOptions = this.$store.getters.rh
      this.educationOptions = getDataConfig('patient', 'education_types')
      this.professionOptions = getDataConfig('patient', 'profession_options')
      this.inductionOptions = this.$store.getters.induction_options
      this.contagionList = this.$store.getters.contagions
      this.checkDisease = this.$store.getters.disease

      var xtuser = this.$store.getters.xt_user
      this.orgname = xtuser.org.org_name
      this.adminusername = xtuser.user.user_name

      this.fetchAllAdminUsers()


      const id = this.$route.query && this.$route.query.id
      this.patientID = parseInt(id)


      if (isNaN(this.patientID) || this.patientID <= 0) {
        this.getList()
      }
      this.fetchPatient(id)
      this.getZones()
      var ptime = Math.round(new Date().getTime() / 1000)
      // this.print_time = uParseTime(ptime, '{y}-{m}-{d} {h}:{i}');
    },
    methods: {
      onCopy(){
        this.$message.success('复制成功')

      },onError(){
        this.$message.success('复制失败,请重试')
      },
      getList() {
        fetchAllList().then(response => {
          if (response.data.state == 1) {
            this.patientsList = response.data.data.patients;
            this.fetchPatient(this.patientsList[0].id)

          }
        });
      },
      copy(val){



      },
      printThisInfo() {
        var ptime = Math.round(new Date().getTime() / 1000)
        this.print_time = uParseTime(ptime, '{y}年{m}月{d}日')

        const style = '@media print { .print_main_content { background-color: white; width:960px; margin:0 auto; padding: 0 0 20px 0; } .print_main_content .order_title { text-align: center; font-size: 23px; line-height: 50px; font-weight: 500; } .print_main_content table { width: 100%; border: 1px solid; border-collapse: collapse; padding: 2px; } .print_main_content table tbody tr td { border: 1px solid; text-align: center; padding: 10px 8px; } .td_proj_title { font-size: 18px; line-height: 25px; font-weight: 500; } .td_proj_content { font-size: 18px; line-height: 25px; } .td_align_left { text-align: left; } .print_footnote_panel { font-size: 17px; line-height: 40px; } .print_footnote_panel .proj { display: inline-block; width: 49%; } .print_footnote_panel .proj .proj_title { font-weight: 500;} }'

        setTimeout(() => {
          printJS({
            printable: 'print-info-box',
            type: 'html',
            style: style,
            scanStyles: false
          })
        }, 1)
      },
      getZones() {
        getZones().then(response => {
          if (response.data.state === 1) {
            this.partitionOptions = response.data.data.zones
          }
        })
      },
      fetchPatient(id) {
        fetchPatient(id)
          .then(response => {
            if (response.data.state === 1) {
              this.$emit('tran-patient-info', response.data.data.patient)
              var patietInfo = response.data.data.patient
              this.form.avatar = patietInfo.avatar
              this.form.name = patietInfo.name
              this.form.alias = patietInfo.alias
              this.form.lapseto = patietInfo.lapseto
              this.form.idCardNo = patietInfo.id_card_no
              this.form.dialysisNo = patietInfo.dialysis_no
              this.form.gender = patietInfo.gender
              if (patietInfo.gender === 1 || patietInfo.gender === 2) {
                this.form.gender = patietInfo.gender
              }
              this.form.nation = patietInfo.nation
              this.form.native_place = patietInfo.native_place
              this.form.birth = uParseTime(patietInfo.birthday, '{y}-{m}-{d}')
              this.form.height = patietInfo.height + ''
              // this.form.age = jsGetAge(this.form.birth, "-");
              if (patietInfo.marital_status > 0) {
                this.form.maritalStatus = patietInfo.marital_status
              }
              this.form.children = patietInfo.children
              this.form.admissionNumber = patietInfo.admission_number
              if (patietInfo.reimbursement_way_id > 0) {
                this.form.reimbursementWayID = patietInfo.reimbursement_way_id
              }
              this.form.healthCareNo = patietInfo.health_care_no
              this.form.phone = patietInfo.phone
              this.form.homeTelephone = patietInfo.home_telephone
              this.form.relative_phone = patietInfo.relative_phone
              this.form.relative_relations = patietInfo.relative_relations
              this.form.homeAddress = patietInfo.home_address
              this.form.work = patietInfo.work_unit
              this.form.unit_address = patietInfo.unit_address
              this.form.created_time = patietInfo.created_time

              if (patietInfo.age == 0){
                this.form.age = jsGetAge(this.form.birth, '-')
              }else{
                this.form.age = patietInfo.age
              }

              if (patietInfo.profession > 0) {
                this.form.profession = patietInfo.profession
              }
              if (patietInfo.education_level > 0) {
                this.form.education = patietInfo.education_level
              }
              if (patietInfo.source === 1 || patietInfo.source === 2) {
                this.form.source = patietInfo.source
              }
              if (patietInfo.lapseto === 1 || patietInfo.lapseto === 2) {
                this.form.lapseto = patietInfo.lapseto
              }
              if (patietInfo.is_hospital_first_dialysis === 1 || patietInfo.is_hospital_first_dialysis === 2) {
                this.form.is_hospital_first_dialysis = patietInfo.is_hospital_first_dialysis
              }
              if (patietInfo.first_dialysis_date !== 0) {
                this.form.firstDialysisDate = uParseTime(
                  patietInfo.first_dialysis_date,
                  '{y}-{m}-{d}'
                )
              }
              this.form.first_dialysis_hospital = patietInfo.first_dialysis_hospital
              if (patietInfo.predialysis_condition.length > 0) {
                this.form.predialysis_condition = patietInfo.predialysis_condition.split(',')
              }
              this.form.pre_hospital_dialysis_frequency = patietInfo.pre_hospital_dialysis_frequency
              this.form.pre_hospital_dialysis_times = patietInfo.pre_hospital_dialysis_times
              if (patietInfo.hospital_first_dialysis_date !== 0) {
                this.form.hospital_first_dialysis_date = uParseTime(
                  patietInfo.hospital_first_dialysis_date,
                  '{y}-{m}-{d}'
                )
              }
              this.form.contagions = response.data.data.contagions
              this.form.diseases = response.data.data.diseases
              this.form.remark = patietInfo.remark
              this.form.diagnose = patietInfo.diagnose

              this.form.patient_complains = patietInfo.patient_complains
              this.form.present_history = patietInfo.present_history
              this.form.past_history = patietInfo.past_history
              this.form.temperature = patietInfo.temperature
              this.form.pulse = patietInfo.pulse
              this.form.respiratory = patietInfo.respiratory
              this.form.sbp = patietInfo.sbp
              this.form.dbp = patietInfo.dbp

              // this.form.initial = patietInfo.initial_dialysis + "";
              // this.form.dialysisTotal = patietInfo.total_dialysis + "";
              // this.form.assessment = patietInfo.evaluate;
              // if (patietInfo.patient_type > 0) {
              //   this.form.patientType = patietInfo.patient_type;
              // }
              // if (patietInfo.partition_id > 0) {
              //   this.form.partition = patietInfo.partition_id;
              // }
              // if (patietInfo.bed_id > 0) {
              //   this.form.bed = patietInfo.bed_id;
              // }
              // this.form.healthCareDueDate = uParseTime(
              //   patietInfo.health_care_due_date,
              //   "{y}-{m}-{d}"
              // );
              // if (patietInfo.blood_type > 0) {
              //   this.form.blood = patietInfo.blood_type;
              // }
              // if (patietInfo.rh > 0) {
              //   this.form.rh = patietInfo.rh;
              // }
              // this.form.healthCareDueAlertDate = uParseTime(
              //   patietInfo.health_care_due_alert_date,
              //   "{y}-{m}-{d}"
              // );
              // this.form.receivingDate = uParseTime(
              //   patietInfo.receiving_date,
              //   "{y}-{m}-{d}"
              // );
              // this.form.dialysisAge = dialysisAge(
              //   this.form.firstDialysisDate,
              //   "-"
              // );
              // if (patietInfo.induction_period > 0) {
              //   this.form.induction = patietInfo.induction_period;
              // }
              // if (patietInfo.attending_doctor_id > 0) {
              //   this.form.doctor = patietInfo.attending_doctor_id;
              // }
              // if (patietInfo.head_nurse_id > 0) {
              //   this.form.nurse = patietInfo.head_nurse_id;
              // }
              // if (patietInfo.registrars_id > 0) {
              //   this.form.registrars = patietInfo.registrars_id;
              // }

              var contagionsArr = response.data.data.contagions
              var diseasesArr = response.data.data.diseases
              this.patientPrint = patietInfo

              var sourceLen = this.sourceOptions.length
              for (let index = 0; index < sourceLen; index++) {
                if (this.sourceOptions[index].value === patietInfo.source) {
                  this.patientPrint.source = this.sourceOptions[index].label
                  break
                }
              }
              var styleLen = this.styleOptions.length
              for (let index = 0; index < styleLen; index++) {
                if (this.styleOptions[index].id === patietInfo.patient_type) {
                  this.patientPrint.patient_type = this.styleOptions[index].name
                  break
                }
              }
              var partitionLen = this.partitionOptions.length
              for (let index = 0; index < partitionLen; index++) {
                if (this.partitionOptions[index].id === patietInfo.partition_id) {
                  this.patientPrint.partition_id = this.partitionOptions[index].name
                  break
                }
              }
              this.patientPrint.bed_id = patietInfo.bed_id > 0 ? patietInfo.bed_id : ''
              if (patietInfo.gender === 1) {
                this.patientPrint.gender = '男'
              } else if (patietInfo.gender === 2) {
                this.patientPrint.gender = '女'
              } else {
                this.patientPrint.gender = ''
              }
              var maritalLen = this.maritalOptions.length
              this.patientPrint.marital_status = ''
              for (let index = 0; index < maritalLen; index++) {
                if (this.maritalOptions[index].id === patietInfo.marital_status) {
                  this.patientPrint.marital_status = this.maritalOptions[index].name
                  break
                }
              }
              this.patientPrint.birthday = uParseTime(patietInfo.birthday, '{y}-{m}-{d}')
              this.patientPrint.age = jsGetAge(this.patientPrint.birthday, '-')

              this.patientPrint.patient_complains = patietInfo.patient_complains.replace(/\n/g, '<br/>')
              this.patientPrint.present_history = patietInfo.present_history.replace(/\n/g, '<br/>')
              this.patientPrint.past_history = patietInfo.past_history.replace(/\n/g, '<br/>')
              this.patientPrint.remark = patietInfo.remark.replace(/\n/g, '<br/>')
              this.patientPrint.diagnose = patietInfo.diagnose.replace(/\n/g, '<br/>')
              if (typeof patietInfo.temperature === 'number') {
                this.patientPrint.temperature = patietInfo.temperature.toFixed(1)
              }

              if (patietInfo.reimbursement_way_id > 0) {
                var wayLen = this.wayOptions.length
                for (let index = 0; index < wayLen; index++) {
                  if (this.wayOptions[index].id === patietInfo.reimbursement_way_id) {
                    this.patientPrint.reimbursement_way_id = this.wayOptions[index].name
                    break
                  }
                }
              } else {
                this.patientPrint.reimbursement_way_id = ''
              }
              if (patietInfo.health_care_due_date !== 0) {
                this.patientPrint.health_care_due_date = uParseTime(patietInfo.health_care_due_date, '{y}-{m}-{d}')
              } else {
                this.patientPrint.health_care_due_date = ''
              }
              if (patietInfo.blood_type > 0) {
                var typeLen = this.typeOptions.length
                for (let index = 0; index < typeLen; index++) {
                  if (this.typeOptions[index].id === patietInfo.blood_type) {
                    this.patientPrint.blood_type = this.typeOptions[index].name
                    break
                  }
                }
              } else {
                this.patientPrint.blood_type = ''
              }
              if (patietInfo.rh > 0) {
                var rhLen = this.rhOptions.length
                for (let index = 0; index < rhLen; index++) {
                  if (this.rhOptions[index].id === patietInfo.rh) {
                    this.patientPrint.rh = this.rhOptions[index].name
                    break
                  }
                }
              } else {
                this.patientPrint.rh = ''
              }
              if (patietInfo.health_care_due_alert_date !== 0) {
                this.patientPrint.health_care_due_alert_date = uParseTime(patietInfo.health_care_due_alert_date, '{y}-{m}-{d}')
              } else {
                this.patientPrint.health_care_due_alert_date = ''
              }
              if (patietInfo.education_level > 0) {
                var eLen = this.educationOptions.length
                for (let index = 0; index < eLen; index++) {
                  if (this.educationOptions[index].id === patietInfo.education_level) {
                    this.patientPrint.education_level = this.educationOptions[index].name
                    break
                  }
                }
              } else {
                this.patientPrint.education_level = ''
              }
              if (patietInfo.profession > 0) {
                var eLen = this.professionOptions.length
                for (let index = 0; index < eLen; index++) {
                  if (this.professionOptions[index].id === patietInfo.profession) {
                    this.patientPrint.profession = this.professionOptions[index].name
                    break
                  }
                }
              } else {
                this.patientPrint.profession = ''
              }
              if (patietInfo.receiving_date !== 0) {
                this.patientPrint.receiving_date = uParseTime(patietInfo.receiving_date, '{y}-{m}-{d}')
              } else {
                this.patientPrint.receiving_date = ''
              }
              if (patietInfo.first_dialysis_date !== 0) {
                this.patientPrint.first_dialysis_date = uParseTime(patietInfo.first_dialysis_date, '{y}-{m}-{d}')
                this.patientPrint.dialysis_age = dialysisAge(this.patientPrint.first_dialysis_date)
              } else {
                this.patientPrint.first_dialysis_date = ''
                this.patientPrint.dialysis_age = ''
              }
              if (patietInfo.induction_period > 0) {
                var eLen = this.inductionOptions.length
                for (let index = 0; index < eLen; index++) {
                  if (this.inductionOptions[index].id === patietInfo.induction_period) {
                    this.patientPrint.induction_period = this.inductionOptions[index].name
                    break
                  }
                }
              } else {
                this.patientPrint.induction_period = ''
              }
              if (patietInfo.attending_doctor_id > 0) {
                var eLen = this.adminUserOptions.length
                for (let index = 0; index < eLen; index++) {
                  if (this.adminUserOptions[index].id === patietInfo.attending_doctor_id) {
                    this.patientPrint.attending_doctor_id = this.adminUserOptions[index].name
                    break
                  }
                }
              } else {
                this.patientPrint.attending_doctor_id = ''
              }
              if (patietInfo.head_nurse_id > 0) {
                var eLen = this.adminUserOptions.length
                for (let index = 0; index < eLen; index++) {
                  if (this.adminUserOptions[index].id === patietInfo.head_nurse_id) {
                    this.patientPrint.head_nurse_id = this.adminUserOptions[index].name
                    break
                  }
                }
              } else {
                this.patientPrint.head_nurse_id = ''
              }

              if (contagionsArr.length > 0) {
                var contagionsIdArr = {}
                var alen = contagionsArr.length
                for (let index = 0; index < alen; index++) {
                  contagionsIdArr[contagionsArr[index]] = 1
                }
                var printContagions = []
                var clen = this.contagionList.length
                for (let index = 0; index < clen; index++) {
                  if (this.contagionList[index].id in contagionsIdArr) {
                    printContagions.push(this.contagionList[index].name)
                  }
                }
                this.patientPrint.contagions = printContagions.join('、')
              } else {
                this.patientPrint.contagions = '无'
              }

              if (diseasesArr.length > 0) {
                var diseasesIdArr = {}
                var alen = diseasesArr.length
                for (let index = 0; index < alen; index++) {
                  diseasesIdArr[diseasesArr[index]] = 1
                }
                var printDisease = []
                var clen = this.checkDisease.length
                for (let index = 0; index < clen; index++) {
                  if (this.checkDisease[index].id in diseasesIdArr) {
                    printDisease.push(this.checkDisease[index].name)
                  }
                }
                this.patientPrint.diseases = printDisease.join('、')
              } else {
                this.patientPrint.diseases = ''
              }

              if (patietInfo.registrars_id > 0) {
                var eLen = this.adminUserOptions.length
                for (let index = 0; index < eLen; index++) {
                  if (this.adminUserOptions[index].id === patietInfo.registrars_id) {
                    this.patientPrint.registrars = this.adminUserOptions[index].name
                    this.form.registrars = this.adminUserOptions[index].name
                    break
                  }
                }
              } else {
                this.patientPrint.registrars = ''
              }

              if (patietInfo.hospital_first_dialysis_date !== 0) {
                this.patientPrint.hospital_first_dialysis_date = uParseTime(patietInfo.hospital_first_dialysis_date, '{y}-{m}-{d}')
              } else {
                this.patientPrint.hospital_first_dialysis_date = ''
              }
            } else {
              // console.log('patient get err state')
              // this.$notify.error({
              //   title: '错误',
              //   message: '网络异常'
              // })
              // this.$router.push('/patients/patients')
            }

            // this.postForm = response.data
            // // Just for test
            // this.postForm.title += `   Article Id:${this.postForm.id}`
            // this.postForm.content_short += `   Article Id:${this.postForm.id}`
          }).catch(err => {
          // console.log('patient get err', err)
          // this.$notify.error({
          //   title: '错误',
          //   message: '网络异常'
          // })
          // this.$router.push('/patients/patients')
        })
      },
      fetchAllDoctorAndNurse() {
        fetchAllDoctorAndNurse().then(response => {
          if (response.data.state === 1) {
            this.doctorOptions = response.data.data.doctors
            this.nurseOptions = response.data.data.nursers
          }
        })
      },
      fetchAllAdminUsers() {
        fetchAllAdminUsers().then(response => {
          if (response.data.state === 1) {
            this.adminUserOptions = response.data.data.users
          }
        })
      },

      printCard() {
        var ptime = Math.round(new Date().getTime() / 1000)
        this.print_time = uParseTime(ptime, '{y}年{m}月{d}日')

        const style = '@media print { .print_main_content { background-color: white; width:960px; margin:0 auto; padding: 0 0 20px 0; } .print_main_content .order_title { text-align: center; font-size: 23px; line-height: 50px; font-weight: 500; } .print_main_content table { width: 100%; border: 1px solid; border-collapse: collapse; padding: 2px; } .print_main_content table tbody tr td { border: 1px solid; text-align: center; padding: 10px 8px; } .td_proj_title { font-size: 18px; line-height: 25px; font-weight: 500; } .td_proj_content { font-size: 18px; line-height: 25px; } .td_align_left { text-align: left; } .print_footnote_panel { font-size: 17px; line-height: 40px; } .print_footnote_panel .proj { display: inline-block; width: 49%; } .print_footnote_panel .proj .proj_title { font-weight: 500;} }'

        setTimeout(() => {
          printJS({
            printable: 'print-card-info',
            type: 'html',
            style: style,
            scanStyles: false
          })
        }, 1)

        var patientID = this.patientPrint.id
        var name = this.patientPrint.name
        var gender = this.patientPrint.gender
        if (gender === 1) {
          gender = '男'
        }
        if (gender === 2) {
          gender = '女'
        }
        var idCardNo = this.patientPrint.id_card_no
        var dialysisNo = this.patientPrint.dialysis_no
        var phone = this.patientPrint.phone
        var healthCareNo = this.patientPrint.health_care_no

        // Base64加密
        var epatientID = this.Base64.encode(patientID)
        var ename = this.Base64.encode(name)
        var egender = this.Base64.encode(gender)
        var eidCardNo = this.Base64.encode(idCardNo)
        var edialysisNo = this.Base64.encode(dialysisNo)
        var ephone = this.Base64.encode(phone)
        var eheathCareNo = this.Base64.encode(healthCareNo)
        console.log('id号:' + epatientID, '姓名:' + ename, '性别:' + egender, '身份证:' + eidCardNo, '透析号:' + edialysisNo, '电话:' + ephone, '社保号:' + eheathCareNo)
        //  var params =new Object();
        //    params.id = this.patientPrint.id
        //    params.name =  this.patientPrint.name;
        this.$options.methods.qrcode(epatientID, ename, egender, eidCardNo, edialysisNo, ephone, eheathCareNo)// 调用生成二维码的方法
        // this.$options.methods.qrcode(params)
      },

      qrcode(patientID, name, gender, idCardNo, dialysisNo, phone, healthCareNo) {
        document.getElementById("qrcode").innerHTML = "";
        new QRCode('qrcode', {
          width: 200,
          height: 200,
          text: 'user_id:' + patientID + ',' + 'name:' + name + ',' + 'dialysis_no:' + dialysisNo + ',' + 'gender:' + gender + ',' + 'idcard_no:' + idCardNo + ',' + 'phone:' + phone + ',' + 'healthcare_no:' + healthCareNo
        })
      }

    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .uploadHead {
    margin-top: 25%;
  }
  .uploadHeadBtn {
    width: 148px;
    margin-top: 10px;
  }
  .el-form {
  .el-col-6,
  .el-col-8 {
    width: 360px;
    height:59px!important;
  }
  .el-form-item {
  // margin-bottom: 17px !important;
  .el-select {
    width: 100%;
  }
  .el-date-editor.el-input {
    width: 100%;
  }
  .textarea {
    width: 100%;
    height: 70px;
    border-color: #dcdfe6;
    padding: 5px;
  }
  }
  }

  // #print-info-box .info_print {
     //     width: 920px;
     //     margin: 0 auto !important;
     //     position: relative;
     //     top: 0;
     //     left: 0;
     //     padding: 20px 30px;
     // }
  // #print-info-box .box-title {
     //     text-align: center;
     //     font-weight: 600;
     //     font-size: 30px;
     //     line-height: 80px;
     //     margin-bottom: 20px;
     // }

  // #print-info-box .unit-title {
     //     text-align: center;
     //     line-height: 40px;
     //     font-size: 20px;
     //     font-weight: 400;
     //     padding-top: 10px;
     //     /* border: 1px solid #333; */
     // }

  // #print-info-box .unit-box {
     //     padding: 15px;
     // }

  // #print-info-box .unit-box-item {
     //     display: flex;
     //     align-items: center;
     //     justify-content: space-between;
     //     padding: 4px 1em;
     // }

  // #print-info-box .unit-box-item-col3 {
     //     width: 30%;
     //     display: flex;
     //     padding: 4px 0;
     // }

  // #print-info-box .unit-box-item-col4 {
     //     width: 23%;
     //     display: flex;
     //     padding: 4px 0;
     // }

  // #print-info-box .item-value {
     //     flex: 1;
     //     border-bottom: 1px solid #333;
     // }
</style>

<style scoped>
  /* 打印表格的样式 */
  .print_main_content {
    background-color: white;
    width:960px;
    margin:0 auto;
    padding: 0 0 20px 0;
  }
  .print_main_content .order_title {
    text-align: center;
    font-size: 23px;
    line-height: 50px;
    font-weight: 500;
  }
  .print_main_content table {
    width: 100%;
    border: 1px solid;
    border-collapse: collapse;
    padding: 2px;
  }
  .print_main_content table tbody tr td {
    border: 1px solid;
    text-align: center;
    /* font-size: 17px; */
    padding: 10px 8px;
  }
  .td_proj_title {
    font-size: 18px;
    line-height: 25px;
    font-weight: 500;
  }
  .td_proj_content {
    font-size: 18px;
    line-height: 25px;
  }
  .td_align_left {
    text-align: left;
  }
  .print_footnote_panel {
    font-size: 17px;
    line-height: 40px;
  }
  .print_footnote_panel .proj {
    display: inline-block;
    width: 49%;
  }
  .print_footnote_panel .proj .proj_title {
    font-weight: 500;
  }
  .el-select-dropdown{
    z-index: 998!important;
  }
</style>
