<template>
    <div class="main-contain">
        <div class="position">
            <bread-crumb :crumbs='crumbs'></bread-crumb>
        </div>
        <!--<div v-if="this.$store.getters.xt_user.org_id == 9504 || this.$store.getters.xt_user.org_id == 10028 || this.$store.getters.xt_user.org_id == 10138"-->
        <!--class="app-container">-->
        <!--<div class="nameTitle">患者基本信息:</div>-->
        <!--<div class="formMain">-->
        <!--<el-form class="basicForm" :model="form" :rules="rules2" ref="form" label-width="100px">-->

        <!--<el-form-item label="患者姓名：" prop="name" :validate-event="is_Name">-->
        <!--<el-autocomplete-->
        <!--class="checkSearch"-->
        <!--popper-class="my-autocomplete"-->
        <!--v-model="form.name"-->
        <!--:fetch-suggestions="querySearchAsync"-->
        <!--:trigger-on-focus="false"-->
        <!--placeholder="请输入病人名字"-->
        <!--@select="handleSelect"-->
        <!--style="width:160px;"-->
        <!--&gt;-->
        <!--<i class="el-icon-search el-input__icon" slot="suffix"></i>-->
        <!--<template slot-scope="{ item }">-->
        <!--<div class="name">{{ item.name }}</div>-->
        <!--</template>-->
        <!--</el-autocomplete>-->
        <!--</el-form-item>-->


        <!--<el-form-item label="性别：" prop="sex" :validate-event="is_Name">-->
        <!--<el-select v-model="form.sex" placeholder="请选择">-->
        <!--<el-option-->
        <!--v-for="item in sex"-->
        <!--:key="item.value"-->
        <!--:label="item.label"-->
        <!--:value="item.value">-->
        <!--</el-option>-->
        <!--</el-select>-->
        <!--</el-form-item>-->

        <!--<el-form-item label="年龄：" prop="age" :validate-event="is_Name">-->
        <!--<el-input v-model="form.age"></el-input>-->
        <!--</el-form-item>-->


        <!--<el-form-item label="出生日期：" prop="birthday" :validate-event="is_Name">-->
        <!--<el-date-picker v-model="form.birthday" type="date" @change="getBirthday"-->
        <!--placeholder="选择日期"></el-date-picker>-->
        <!--</el-form-item>-->

        <!--<el-form-item label="手机号码：" prop="phone">-->
        <!--<el-input v-model="form.phone"></el-input>-->
        <!--</el-form-item>-->


        <!--<el-form-item label="证件类型：" prop="certificates" :validate-event="is_Name">-->
        <!--<el-select v-model="form.certificates" placeholder="请选择">-->
        <!--<el-option-->
        <!--v-for="item in certificates"-->
        <!--:key="item.value"-->
        <!--:label="item.label"-->
        <!--:value="item.value">-->
        <!--</el-option>-->
        <!--</el-select>-->
        <!--</el-form-item>-->

        <!--<el-form-item label="证件号码：" prop="idCard" :validate-event="is_Name">-->
        <!--<el-input v-model="form.idCard"></el-input>-->
        <!--</el-form-item>-->


        <!--<el-form-item label="结算类型：">-->
        <!--<el-select v-model="form.settlementValue" placeholder="请选择">-->
        <!--<el-option-->
        <!--v-for="item in settlement"-->
        <!--:key="item.value"-->
        <!--:label="item.label"-->
        <!--:value="item.value">-->
        <!--</el-option>-->
        <!--</el-select>-->
        <!--</el-form-item>-->


        <!--<el-form-item label="社保类型：">-->
        <!--<el-select v-model="form.social_type" placeholder="请选择">-->
        <!--&lt;!&ndash; <el-option-->
        <!--v-for="(item,index) in getDictionaryDataConfig('system','social_type')"-->
        <!--:key="index"-->
        <!--:label="item.name"-->
        <!--:value="item.id">-->
        <!--</el-option> &ndash;&gt;-->
        <!--<el-option-->
        <!--v-for="item in medicalCare"-->
        <!--:key="item.value"-->
        <!--:label="item.label"-->
        <!--:value="item.value">-->
        <!--</el-option>-->
        <!--</el-select>-->
        <!--</el-form-item>-->


        <!--<el-form-item label="读卡类型：" prop="id_card_type" :validate-event="is_Name">-->
        <!--<el-select v-model="form.id_card_type" placeholder="请选择">-->
        <!--<el-option-->
        <!--v-for="item in IDCardTypes"-->
        <!--:key="item.value"-->
        <!--:label="item.label"-->
        <!--:value="item.value">-->
        <!--</el-option>-->
        <!--</el-select>-->
        <!--</el-form-item>-->

        <!--<el-form-item class="specialFormItem" label="医保卡号：">-->
        <!--<div style="display:flex;">-->
        <!--<el-input v-model="form.medicalInsuranceCard"></el-input>-->
        <!--<el-button style="margin-left:10px;" type="primary" @click="readingSZ"-->
        <!--v-loading="read_loading">读卡-->
        <!--</el-button>-->
        <!--</div>-->
        <!--</el-form-item>-->

        <!--</el-form>-->
        <!--</div>-->
        <!--<div class="nameTitle">患者挂号信息:</div>-->
        <!--<div class="formMain">-->
        <!--<el-form class="basicForm" :model="form" :rules="rules2" ref="form" label-width="100px">-->
        <!--<el-form-item label="挂号类型：" :validate-event="is_Name">-->
        <!--<el-select v-model="form.register" placeholder="请选择" @change="changeReg">-->
        <!--<el-option-->
        <!--v-for="item in his_registers"-->
        <!--:key="item.value"-->
        <!--:label="item.label"-->
        <!--:value="item.value">-->
        <!--</el-option>-->
        <!--</el-select>-->
        <!--</el-form-item>-->

        <!--<el-form-item label="医疗类别：" :validate-event="is_Name" prop="medicalCare">-->
        <!--<el-select v-model="form.medicalCare" placeholder="请选择">-->
        <!--<el-option-->
        <!--v-for="(item,index) in medical_care"-->
        <!--:key="index"-->
        <!--:label="item.label"-->
        <!--:value="item.value">-->
        <!--</el-option>-->
        <!--</el-select>-->
        <!--</el-form-item>-->

        <!--<el-form-item label="医生：" prop="doctor" :validate-event="is_Name">-->
        <!--<el-select v-model="form.doctor" placeholder="请选择" @change="changeDoctor">-->
        <!--<el-option-->
        <!--v-for="item in doctorList"-->
        <!--:key="item.admin_user_id"-->
        <!--:label="item.user_name"-->
        <!--:value="item.admin_user_id">-->
        <!--</el-option>-->
        <!--</el-select>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="科室：" prop="department" :validate-event="is_Name">-->
        <!--<el-select v-model="form.department" placeholder="请选择">-->
        <!--<el-option-->
        <!--v-for="item in departmentList"-->
        <!--:key="item.id"-->
        <!--:label="item.name"-->
        <!--:value="item.id">-->
        <!--</el-option>-->
        <!--</el-select>-->
        <!--</el-form-item>-->

        <!--<el-form-item label="挂号费：">-->
        <!--<el-input v-model="form.registrationFee" readonly></el-input>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="诊疗费：">-->
        <!--<el-input v-model="form.medicalExpenses" readonly></el-input>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="合计：">-->
        <!--<el-input v-model.number="total" readonly></el-input>-->
        <!--</el-form-item>-->
        <!--</el-form>-->
        <!--<el-button style="float:right" v-loading="loadingone" @click="saveHisPatient9504('form')"-->
        <!--type="primary">挂号-->
        <!--</el-button>-->
        <!--</div>-->

        <!--</div>-->

        <div class="app-container">
            <div class="nameTitle">患者基本信息:</div>
            <div class="formMain">
                <el-form class="basicForm" :model="form" :rules="rules" ref="form" label-width="100px">
                    <!--<el-form-item label="患者姓名：" prop="name" :validate-event="is_Name">-->
                    <!--&lt;!&ndash; <el-input  v-model="form.name"></el-input> &ndash;&gt;-->
                    <!--<el-select v-model="form.name" placeholder="请选择" @change="changeName">-->
                    <!--<el-option-->
                    <!--v-for="item,index in patient"-->
                    <!--:key="index"-->
                    <!--:label="item.name"-->
                    <!--:value="item.id">-->
                    <!--</el-option>-->
                    <!--</el-select>-->
                    <!--</el-form-item>-->

                    <el-form-item label="患者姓名：" prop="name" :validate-event="is_Name">
                        <el-autocomplete
                                class="checkSearch"
                                popper-class="my-autocomplete"
                                v-model="form.name"
                                :fetch-suggestions="querySearchAsync"
                                :trigger-on-focus="false"
                                placeholder="请输入病人名字"
                                @select="handleSelect"
                                style="width:160px;"
                        >
                            <i class="el-icon-search el-input__icon" slot="suffix"></i>
                            <template slot-scope="{ item }">
                                <div class="name">{{ item.name }}</div>
                            </template>
                        </el-autocomplete>
                    </el-form-item>


                    <el-form-item label="性别：" prop="sex" :validate-event="is_Name">
                        <el-select v-model="form.sex" placeholder="请选择">
                            <el-option
                                    v-for="item in sex"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="年龄：" prop="age" :validate-event="is_Name">
                        <el-input v-model="form.age"></el-input>
                    </el-form-item>


                    <el-form-item label="出生日期：" prop="birthday" :validate-event="is_Name">
                        <el-date-picker v-model="form.birthday" type="date" @change="getBirthday"
                                        placeholder="选择日期"></el-date-picker>
                    </el-form-item>

                    <el-form-item label="手机号码：" prop="phone">
                        <el-input v-model="form.phone"></el-input>
                    </el-form-item>


                    <el-form-item label="证件类型：" prop="certificates" :validate-event="is_Name">
                        <el-select v-model="form.certificates" placeholder="请选择">
                            <el-option
                                    v-for="item in certificates"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="证件号码：" prop="idCard" :validate-event="is_Name">
                        <el-input v-model="form.idCard"></el-input>
                    </el-form-item>


                    <el-form-item label="结算类型：">
                        <el-select v-model="form.settlementValue" placeholder="请选择">
                            <el-option
                                    v-for="item in settlement"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>


                    <el-form-item label="社保类型：">
                        <el-select v-model="form.social_type" placeholder="请选择">
                            <!-- <el-option
                            v-for="(item,index) in getDictionaryDataConfig('system','social_type')"
                            :key="index"
                            :label="item.name"
                            :value="item.id">
                            </el-option> -->
                            <el-option
                                    v-for="item in medicalCare"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>


                    <el-form-item label="读卡类型：" prop="id_card_type" :validate-event="is_Name">
                        <el-select v-model="form.id_card_type" placeholder="请选择">
                            <el-option
                                    v-for="item in IDCardTypes"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item class="specialFormItem" label="医保卡号：">
                        <div style="display:flex;">
                            <el-input v-model="form.medicalInsuranceCard"></el-input>
                            <el-button style="margin-left:10px;" type="primary" @click="reading">读卡</el-button>
                        </div>
                    </el-form-item>

                </el-form>
            </div>
            <div class="nameTitle">患者挂号信息:</div>
            <div class="formMain">
                <el-form class="basicForm" :model="form" :rules="rules" ref="form" label-width="100px">
                    <el-form-item label="挂号类型：">
                        <el-select v-model="form.register" placeholder="请选择">
                            <el-option
                                    v-for="item in his_registers"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <!--<el-form-item label="处方类型：" prop="p_type" :validate-event="is_Name">-->
                    <!--<el-select style="margin-right:5px;width:100px;" v-model="form.p_type" placeholder=""-->
                    <!--&gt;-->
                    <!--<el-option-->
                    <!--v-for="(item,index) in registers"-->
                    <!--:key="index"-->
                    <!--:label="item.label"-->
                    <!--:value="item.value">-->
                    <!--</el-option>-->
                    <!--</el-select>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="大病类别：" prop="sick_type" :validate-event="is_Name">-->
                    <!--<el-select style="margin-right:5px;width:100px;" v-model="form.sick_type" placeholder="">-->
                    <!--<el-option-->
                    <!--v-for="(item,index) in sick"-->
                    <!--:key="index"-->
                    <!--:label="item.class_name"-->
                    <!--:value="item.id">-->
                    <!--</el-option>-->
                    <!--</el-select>-->
                    <!--</el-form-item>-->

                    <!--<el-form-item label="诊断：" prop="diagnosis" :validate-event="is_Name">-->
                    <!--<el-select style="margin-right:5px;width:100px;" v-model="form.diagnosis" placeholder="">-->
                    <!--<el-option-->
                    <!--v-for="(item,index) in diagnoses"-->
                    <!--:key="index"-->
                    <!--:label="item.class_name"-->
                    <!--:value="item.id">-->
                    <!--</el-option>-->
                    <!--</el-select>-->
                    <!--</el-form-item>-->


                    <!--<el-form-item label="医疗类别：">-->
                    <!--<el-select v-model="form.medicalCare" placeholder="请选择">-->
                    <!--<el-option-->
                    <!--v-for="(item,index) in medical_care"-->
                    <!--:key="index"-->
                    <!--:label="item.label"-->
                    <!--:value="item.value">-->
                    <!--</el-option>-->
                    <!--</el-select>-->
                    <!--</el-form-item>-->

                    <el-form-item label="医生：" prop="doctor" :validate-event="is_Name">
                        <el-select v-model="form.doctor" placeholder="请选择" @change="changeDoctor">
                            <el-option
                                    v-for="item in doctorList"
                                    :key="item.admin_user_id"
                                    :label="item.user_name"
                                    :value="item.admin_user_id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="科室：" prop="department" :validate-event="is_Name">
                        <el-select v-model="form.department" placeholder="请选择">
                            <el-option
                                    v-for="item in departmentList"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <!-- <el-form-item>
                        <el-checkbox v-model="form.costChecked">是否需要工本费</el-checkbox>
                    </el-form-item> -->
                    <el-form-item label="挂号费：">
                        <el-input v-model.number="form.registrationFee"></el-input>
                    </el-form-item>
                    <el-form-item label="诊疗费：">
                        <el-input v-model.number="form.medicalExpenses"></el-input>
                    </el-form-item>
                    <el-form-item label="工本费：">
                        <el-input v-model.number="form.cost"></el-input>
                    </el-form-item>
                    <el-form-item label="合计：">
                        <el-input v-model.number="total" readonly></el-input>
                    </el-form-item>
                    <el-form-item>
                        <!-- <el-input v-model="form.name"></el-input> -->
                    </el-form-item>
                </el-form>
                <el-button style="float:right" @click="saveHisPatient('form')" v-loading="loadingone" type="primary">
                    挂号
                </el-button>
            </div>

        </div>
    </div>
</template>

<script>
  import { PostSearch } from '@/api/patient'
  import BreadCrumb from '@/xt_pages/components/bread-crumb'
  import { basename } from 'path'
  import {
    getAllDoctorList,
    getPatientDetail,
    getTodaySchedulePatient,
    getUnRegisterHisPatientList,
    saveHisPatient
  } from '@/api/project/project'
  import { getDictionaryDataConfig } from '@/utils/data'
  import { jsGetAge, uParseTime } from '@/utils/tools'
  import { getInitData } from '@/api/his/his'
  import axios from 'axios'

  const moment = require('moment')
  export default {
    components: {
      BreadCrumb
    },
    data() {
      return {
        loadingone: false,
        read_loading: false,
        registers: [
          { value: 11, label: '普通门诊' },
          // { value: 12, label: '门诊挂号' },
          // { value: 13, label: '急诊' },
          { value: 14, label: '门诊特殊病' },
          // { value: 15, label: '门诊统筹' },
          // { value: 16, label: '门诊慢性病' },
          // { value: 21, label: '普通住院' }

        ],
        sick: [],
        diagnoses: [],
        crumbs: [
          { path: false, name: '门诊挂号' },
          { path: false, name: '门诊挂号' }
        ],
        form: {
          id: 0,
          p_type: '',
          sick_type: '',
          diagnosis: '',
          settlementValue: '',
          medicalInsuranceCard: '',
          name: '',
          sex: '',
          certificates: 1,
          medicalCare: '',
          birthday: '',
          age: '',
          idCard: '',
          register: '',
          doctor: '',
          department: '',
          costChecked: false,
          registrationFee: '',
          medicalExpenses: '',
          cost: '',
          total: '',
          phone: '',
          social_type: '',
          id_card_type: 2

        },
        medical_care: [
          { value: 11, label: '普通门诊' },
          { value: 12, label: '家庭通道' },
          { value: 13, label: '门诊大病' },
          { value: 14, label: '重疾特药' },
          { value: 15, label: '门诊慢病' },
          { value: 16, label: '门诊特检' },
          { value: 17, label: '健康体检' },
          { value: 18, label: '预防接种' },
          { value: 19, label: '门诊输血' },
          { value: 91, label: '新冠肺炎门诊' }
        ],

        settlement:
          [
            { value: 1, label: '医保' },
            { value: 2, label: '自费' },
            { value: 3, label: '公费' },
            { value: 4, label: '农保' },
            { value: 5, label: '会员' },
            { value: 6, label: '职工' },
            { value: 7, label: '合同' },
            { value: 8, label: '医保自费' }

          ],
        sex: [{
          value: 1,
          label: '男'
        }, {
          value: 2,
          label: '女'
        }],
        certificates: [{
          value: 1,
          label: '内地身份证'
        }, {
          value: 2,
          label: '社保卡'
        }, {
          value: 3,
          label: '护照'
        }, {
          value: 4,
          label: '军官证'
        }, {
          value: 5,
          label: '台胞证'
        }, {
          value: 6,
          label: '港澳地区身份证'
        }],
        IDCardTypes: [{
          value: 1,
          label: '社保卡'
        }, {
          value: 2,
          label: '身份证'
        }, {
          value: 3,
          label: '电子凭证'
        }],
        medicalCare: [{
          value: 390,
          label: '城乡居民基本医疗保险'
        }, {
          value: 310,
          label: '职工基本医疗保险'
        }],
        his_registers: [{
          value: 1,
          label: '普通'
        }, {
          value: 2,
          label: '主治'
        }, {
          value: 3,
          label: '主任'
        }, {
          value: 4,
          label: '免收诊金'
        }, {
          value: 5,
          label: '专家'
        }],
        baseinfo: {
          certno: '440221195903290027',
          psn_no: '0221201972',
          gend: '2',
          brdy: '1960-03-29',
          naty: '01',
          psn_cert_type: '01',
          psn_name: '杨美英',
          age: 60.7
        },
        rules2: {
          name: [{ required: true, message: '患者姓名不能为空', trigger: 'blur' }],
          sex: [{ required: true, message: '患者性别不能为空', trigger: 'blur' }],
          idCard: [{ required: true, message: '证件号码不能为空', trigger: 'blur' }],
          register: [{ required: true, message: '请选择挂号类型', trigger: 'blur' }],
          doctor: [{ required: true, message: '请选择医生', trigger: 'blur' }],
          department: [{ required: true, message: '请填写科室', trigger: 'blur' }],
          age: [{ required: true, message: '患者年龄不能为空', trigger: 'blur' }],
          birthday: [{ required: true, message: '患者出生日期不能为空', trigger: 'blur' }],
          certificates: [{ required: true, message: '证件类型不能为空', trigger: 'change' }],
          id_card_type: [{ required: true, message: '读卡类型不能为空', trigger: 'change' }],
          medicalCare: [{ required: true, message: '医疗类别不能为空', trigger: 'change' }]

        },
        rules: {
          name: [{ required: true, message: '患者姓名不能为空', trigger: 'blur' }],
          sex: [{ required: true, message: '患者性别不能为空', trigger: 'blur' }],
          idCard: [{ required: true, message: '证件号码不能为空', trigger: 'blur' }],
          doctor: [{ required: true, message: '请选择医生', trigger: 'blur' }],
          department: [{ required: true, message: '请填写科室', trigger: 'blur' }],
          age: [{ required: true, message: '患者年龄不能为空', trigger: 'blur' }],
          birthday: [{ required: true, message: '患者出生日期不能为空', trigger: 'blur' }],
          certificates: [{ required: true, message: '证件类型不能为空', trigger: 'change' }],
          id_card_type: [{ required: true, message: '读卡类型不能为空', trigger: 'change' }],

          p_type: [{ required: true, message: '处方类型不能为空', trigger: 'change' }],
          sick_type: [{ required: true, message: '大病类别不能为空', trigger: 'change' }],
          diagnosis: [{ required: true, message: '诊断不能为空', trigger: 'change' }]

        },
        doctorList: [],
        departmentList: [],
        check: 0,
        show: false,
        is_Name: false,
        patient: [],
        scialType: []
      }
    },
    computed: {
      total() {
        if (this.form.registrationFee || this.form.medicalExpenses || this.form.cost) {
          return parseFloat(this.form.registrationFee ? this.form.registrationFee : 0) + parseFloat(this.form.medicalExpenses ? this.form.medicalExpenses : 0) + parseFloat(this.form.cost ? this.form.cost : 0)
        }
      }
    },
    methods: {
      changeReg() {
        if (this.form.register != 4) {
          this.form.registrationFee = 10
        } else {
          this.form.registrationFee = 0

        }
      },
      handleSelect(val) {
        this.form.id = val.id
        this.form.name = val.name
        this.form.sex = val.gender
        this.form.age = val.age
        this.form.birthday = uParseTime(val.birthday, '{y}-{m}-{d}')
        this.form.phone = val.phone
        this.form.idCard = val.id_card_no

        var thisLen = this.form.idCard.length
        var birth = ''
        if (thisLen == 15) {
          birth = '19' + this.form.idCard.substr(6, 6)
        } else {
          birth = this.form.idCard.substr(6, 8)
        }
        var births =
          birth.substr(0, 4) +
          '-' +
          birth.substr(4, 2) +
          '-' +
          birth.substr(6, 2)
        this.form.age = jsGetAge(births, '-')
      },
      querySearchAsync(keyword, cb) {
        let key = ''
        if (keyword != undefined) {
          key = keyword
        }
        let searchArray = []
        PostSearch(key).then(response => {
          if (response.data.state == 1) {
            searchArray = response.data.data.patient
            cb(searchArray)
          } else {
            cb([])
          }
        })
      },
      readingSZ() {
        var that = this
        if (this.form.id_card_type.length == 0 || this.form.id_card_type == 0) {
          this.$message.error('请先选择读卡类型')
          return
        }
        this.read_loading = true
        let params = {
          'id_card_type': this.form.id_card_type

        }
        axios.get('http://127.0.0.1:9532/sz/api/readcard', {
          params: params
        })
          .then(function(response) {
            if (response.data.state == 0) {
              that.read_loading = false

              that.$message.error(response.data.msg)
              return false
            } else {
              that.read_loading = false

              var patient = response.data.data.patient
              if (that.form.id_card_type == 1) {
                that.form.id = patient.id
                that.form.name = patient.name
                that.form.sex = patient.gender
                that.form.birthday = uParseTime(patient.birthday, '{y}-{m}-{d}')
                that.form.phone = patient.phone
                that.form.idCard = patient.id_card_no
                that.form.medicalInsuranceCard = response.data.data.health_card_no

                var thisLen = that.form.idCard.length
                var birth = ''
                if (thisLen == 15) {
                  birth = '19' + that.form.idCard.substr(6, 6)
                } else {
                  birth = that.form.idCard.substr(6, 8)
                }
                var births =
                  birth.substr(0, 4) +
                  '-' +
                  birth.substr(4, 2) +
                  '-' +
                  birth.substr(6, 2)
                that.form.age = jsGetAge(births, '-')

              } else if (that.form.id_card_type == 2) {
                that.form.id = patient.id
                that.form.name = patient.name
                that.form.sex = patient.gender
                that.form.age = patient.age
                that.form.birthday = uParseTime(patient.birthday, '{y}-{m}-{d}')
                that.form.phone = patient.phone
                that.form.idCard = patient.id_card_no

                var thisLen = that.form.idCard.length
                var birth = ''
                if (thisLen == 15) {
                  birth = '19' + that.form.idCard.substr(6, 6)
                } else {
                  birth = that.form.idCard.substr(6, 8)
                }
                var births =
                  birth.substr(0, 4) +
                  '-' +
                  birth.substr(4, 2) +
                  '-' +
                  birth.substr(6, 2)
                that.form.age = jsGetAge(births, '-')

              }
              that.$message({ message: '读卡成功', type: 'success' })

            }
          })
          .catch(function(error) {

          })
      },
      // reading() {
      //   var that = this
      //   if (this.form.id_card_type.length == 0 || this.form.id_card_type == 0) {
      //     this.$message.error('请先选择读卡类型')
      //     return
      //   }
      //   let params = {
      //     'id_card_type': this.form.id_card_type,
      //     'admin_user_id': this.$store.getters.xt_user.user.id,
      //     'certificates':this.form.certificates,
      //   }
      //   axios.get('http://127.0.0.1:9532/api/readcard', {
      //     params: params
      //   })
      //     .then(function(response) {
      //       if (response.data.state == 0) {
      //         that.$message.error(response.data.msg)
      //         return false
      //       } else {
      //         var patient = response.data.data.patient
      //
      //         if (that.form.id_card_type == 1) {
      //           this.form.id = patient.id
      //           that.form.name = patient.name
      //           that.form.sex = patient.gender
      //           that.form.age = patient.age
      //           that.form.birthday = uParseTime(patient.birthday, '{y}-{m}-{d}')
      //           that.form.phone = patient.phone
      //           that.form.idCard = patient.id_card_no
      //           that.form.medicalInsuranceCard = response.data.data.number
      //
      //         } else if (that.form.id_card_type == 2) {
      //           this.form.id = patient.id
      //           that.form.name = patient.name
      //           that.form.sex = patient.gender
      //           that.form.age = patient.age
      //           that.form.birthday = uParseTime(patient.birthday, '{y}-{m}-{d}')
      //           that.form.phone = patient.phone
      //           that.form.idCard = patient.id_card_no
      //         }
      //         that.$message({ message: '读卡成功', type: 'success' })
      //       }
      //     })
      //     .catch(function(error) {
      //
      //     })
      //
      // },

      reading() {
        var that = this
        if (this.form.id_card_type.length == 0 || this.form.id_card_type == 0) {
          this.$message.error('请先选择读卡类型')
          return
        }
        let params = {
          'id_card_type': this.form.id_card_type,
          'admin_user_id': this.$store.getters.xt_user.user.id,
          'certificates': this.form.certificates
        }
        axios.get('http://127.0.0.1:9532/api/readcard', {
          params: params
        })
          .then(function(response) {
            if (response.data.state == 0) {
              that.$message.error(response.data.msg)
              return false
            } else {
              var patient = response.data.data.patient

              if (that.form.id_card_type == 1) {
                that.form.id = patient.id
                that.form.name = patient.name
                that.form.sex = patient.gender
                that.form.age = patient.age
                that.form.birthday = uParseTime(patient.birthday, '{y}-{m}-{d}')
                that.form.phone = patient.phone
                that.form.idCard = patient.id_card_no
                that.form.medicalInsuranceCard = response.data.data.number

              } else if (that.form.id_card_type == 2) {
                that.form.id = patient.id
                that.form.name = patient.name
                that.form.sex = patient.gender
                that.form.age = patient.age
                that.form.birthday = uParseTime(patient.birthday, '{y}-{m}-{d}')
                that.form.phone = patient.phone
                that.form.idCard = patient.id_card_no
              }
              that.$message({ message: '读卡成功', type: 'success' })
            }
          })
          .catch(function(error) {

          })

      },
      getBirthday(date) {
        console.log(date)
        let curTime = moment(new Date(date)).format('YYYY-MM-DD')
        console.log('curTime22222', curTime)

        console.log(this.jsGetAge(curTime))

        this.form.age = this.jsGetAge(curTime)
      },
      jsGetAge(strBirthday) { //传入形式yyyy-MM-dd
        //strBirthday = util.formatTime(strBirthday);转换成yyyy-MM-dd形式
        var returnAge
        var strBirthdayArr = strBirthday.split('-')
        var birthYear = strBirthdayArr[0]
        var birthMonth = strBirthdayArr[1]
        var birthDay = strBirthdayArr[2]
        var d = new Date()
        var nowYear = d.getFullYear()
        var nowMonth = d.getMonth() + 1
        var nowDay = d.getDate()
        if (nowYear == birthYear) {
          returnAge = 0 //同年 则为0岁
        } else {
          var ageDiff = nowYear - birthYear //年之差
          if (ageDiff > 0) {
            if (nowMonth == birthMonth) {
              var dayDiff = nowDay - birthDay //日之差
              if (dayDiff < 0) {
                returnAge = ageDiff - 1
              } else {
                returnAge = ageDiff
              }
            } else {
              var monthDiff = nowMonth - birthMonth //月之差
              if (monthDiff < 0) {
                returnAge = ageDiff - 1
              } else {
                returnAge = ageDiff
              }
            }
          } else {
            returnAge = -1 //返回-1 表示出生日期输入错误 晚于今天
          }
        }
        return returnAge //返回周岁年龄
      },
      getForm() {
        this.form.total = this.total
        if (localStorage.getItem('temp')) {
          let a = JSON.parse(localStorage.getItem('temp'))
          // let arr = []
          this.form.create_time = new Date(new Date().toLocaleDateString()).getTime() / 1000
          this.form.org_id = this.$store.getters.xt_user.org_id
          a.push(this.form)
          console.log(111, a)
          localStorage.setItem('temp', JSON.stringify(a))
          Object.keys(this.form).forEach((key) => {
            this.form[key] = ''
          })
          this.$message({ message: '添加成功', type: 'success' })
        } else {
          let arr = []
          this.form.create_time = new Date(new Date().toLocaleDateString()).getTime() / 1000
          this.form.org_id = this.$store.getters.xt_user.org_id
          arr.push(this.form)
          localStorage.setItem('temp', JSON.stringify(arr))
          Object.keys(this.form).forEach((key) => {
            this.form[key] = ''
          })
          this.$message({ message: '添加成功', type: 'success' })
        }
      },

      getAllDoctorList() {
        getAllDoctorList().then(response => {
          if (response.data.state == 1) {
            var doctor = response.data.data.doctor
            console.log('doctor-----', doctor)
            this.doctorList = doctor
            var department = response.data.data.department
            console.log('department', department)
            this.departmentList = department
          }
        })
      }, saveHisPatient(formName) {
        if (this.form.name == '') {
          this.$message.error('患者姓名不能为空')
          this.is_Name = true
          return
        }
        if (this.form.sex == '') {
          this.$message.error('患者性别不能为空')
        }


        if (this.form.doctor == '') {
          this.$message.error('医生不能为空')
          this.is_Name = true
          return
        }

        if (this.form.department == '') {
          this.$message.error('科室不能为空')
          this.is_Name = true
          return
        }
        if (this.form.age == '') {
          this.$message.error('患者年龄不能为空')
          this.is_Name = true
          return
        }
        if (this.form.birthday == '') {
          this.$message.error('出生日期不能为空')
          this.is_Name = true
          return
        }
        if (this.form.id_card_type == '') {
          this.$message.error('读卡类型不能为空')
          this.is_Name = true
          return
        }

        if (this.form.idCard == '') {
          this.$message.error('证件号码不能为空')
          this.is_Name = true
          return
        }

        if (this.form.settlementValue == 2) {
          this.$refs[formName].validate((valid) => {
              if (valid) {
                var params = {
                  id: this.form.id,
                  settlement_value: this.form.settlementValue,
                  medical_insurance_card: this.form.medicalInsuranceCard,
                  name: this.form.name,
                  sex: this.form.sex,
                  id_card_type: this.form.id_card_type,
                  certificates: this.form.certificates,
                  medical_care: this.form.medicalCare,
                  birthday: moment(new Date(this.form.birthday)).format('YYYY-MM-DD'),
                  age: parseInt(this.form.age),
                  id_card: this.form.idCard,
                  register: this.form.register,
                  doctor: this.form.doctor,
                  department: this.form.department,
                  costChecked: this.check,
                  registration_fee: this.form.registrationFee,
                  medical_expenses: this.form.medicalExpenses,
                  cost: this.form.cost,
                  total: this.total,
                  phone: this.form.phone,
                  social_type: this.form.social_type,
                  p_type: this.form.p_type,
                  diagnosis: this.form.diagnosis,
                  sick_type: this.form.sick_type
                }
                params['record_time'] = this.record_date
                params['admin_user_id'] = this.$store.getters.xt_user.user.id
                this.loadingone = true

                saveHisPatient(params).then(response => {
                  if (response.data.state == 1) {
                    var patient = response.data.data.patient
                    this.getTodaySchedulePatient()
                    this.$message({ message: '挂号成功', type: 'success' })
                    this.form.medicalInsuranceCard = ''
                    this.form.name = ''
                    this.form.sex = ''
                    this.form.birthday = ''
                    this.form.age = ''
                    this.form.idCard = ''
                    this.form.register = ''
                    this.form.doctor = ''
                    this.form.department = ''
                    this.form.costChecked = false
                    this.form.registrationFee = ''
                    this.form.medicalExpenses = ''
                    this.form.cost = ''
                    this.form.total = ''
                    this.form.phone = ''
                    this.form.social_type = ''
                    this.loadingone = false
                    this.form.p_type = 14
                    this.form.sick_type = this.sick[0].id
                    this.form.diagnosis = this.diagnoses[0].id
                    this.form.certificates = 2
                    this.form.id_card_type = 1
                    this.form.settlementValue = 1

                    this.form.register = 4
                    this.form.registrationFee = 0
                    this.form.medicalExpenses = 0

                  } else {
                    this.$message.error('今日患者已挂号!')
                  }
                })
              }
            }
          )

        } else {

          this.$refs[formName].validate((valid) => {
            if (valid) {
              var params = {
                id: this.form.id,
                settlement_value: this.form.settlementValue,
                medical_insurance_card: this.form.medicalInsuranceCard,
                name: this.form.name,
                sex: this.form.sex,
                id_card_type: this.form.id_card_type,
                certificates: this.form.certificates,
                medical_care: this.form.medicalCare,
                birthday: moment(new Date(this.form.birthday)).format('YYYY-MM-DD'),
                age: parseInt(this.form.age),
                id_card: this.form.idCard,
                register: this.form.register,
                doctor: this.form.doctor,
                department: this.form.department,
                costChecked: this.check,
                registration_fee: this.form.registrationFee,
                medical_expenses: this.form.medicalExpenses,
                cost: this.form.cost,
                total: this.total,
                phone: this.form.phone,
                social_type: this.form.social_type,
                p_type: this.form.p_type,
                diagnosis: this.form.diagnosis,
                sick_type: this.form.sick_type
              }
              params['record_time'] = this.record_date
              params['admin_user_id'] = this.$store.getters.xt_user.user.id
              this.loadingone = true

              // if (this.$store.getters.xt_user.org_id == 9504 || this.$store.getters.xt_user.org_id == 10028 || this.$store.getters.xt_user.org_id == 10138) {
              //   var that = this
              //   axios.get('http://127.0.0.1:9532/sz/api/register/get', {
              //     params: params,
              //     headers: {
              //       'Permission': 5
              //     }
              //   })
              //     .then(function(response) {
              //       if (response.data.state == 0) {
              //         that.$message.error(response.data.msg)
              //         that.loadingone = false
              //         return false
              //       } else {
              //         if (response.data.data.failed_code == -10) {
              //           // that.$message.error(response.data.data.msg)
              //           that.$confirm(response.data.data.msg, '医保错误信息', {
              //             confirmButtonText: '确 定',
              //             type: 'warning'
              //           }).then(() => {
              //
              //           }).catch(() => {
              //           })
              //         } else {
              //           that.$message({ message: '挂号成功', type: 'success' })
              //
              //           that.form.name = ''
              //           that.form.sex = ''
              //           that.form.medicalCare = ''
              //           that.form.birthday = ''
              //           that.form.age = ''
              //           that.form.idCard = ''
              //           that.form.register = ''
              //           that.form.doctor = ''
              //           that.form.department = ''
              //           that.form.costChecked = false
              //           that.form.registrationFee = ''
              //           that.form.medicalExpenses = ''
              //           that.form.cost = ''
              //           that.form.total = ''
              //           that.form.phone = ''
              //           that.form.social_type = ''
              //           that.loadingone = false
              //
              //           that.form.medicalInsuranceCard = ''
              //
              //           that.form.medicalCare = 11
              //           that.form.settlementValue = 1
              //           that.form.certificates = 2
              //           that.form.id_card_type = 1
              //
              //           that.form.register = 4
              //           that.form.registrationFee = 0
              //           that.form.medicalExpenses = 0
              //
              //           that.form.p_type = 14
              //           that.form.sick_type = that.sick[0].id
              //           that.form.diagnosis = that.diagnoses[0].id
              //
              //         }
              //       }
              //     })
              //     .catch(function(error) {
              //
              //     })
              // } else
              //   if (this.$store.getters.xt_user.org_id == 9919 || this.$store.getters.xt_user.org_id == 10106 || this.$store.getters.xt_user.org_id == 9538 || this.$store.getters.xt_user.org_id == 9990) {
              var that = this

              axios.get('http://127.0.0.1:9532/api/register/get', {
                params: params,
                headers: {
                  'Permission': 5
                }
              })
                .then(function(response) {
                  if (response.data.state == 0) {
                    that.$message.error(response.data.msg)
                    that.loadingone = false
                    that.$refs.register.hide()
                    return false
                  } else {
                    that.loadingone = false

                    if (response.data.data.failed_code == -10) {
                      // that.$message.error(response.data.data.msg);
                      that.$confirm(response.data.data.msg, '医保错误信息', {
                        confirmButtonText: '确 定',
                        type: 'warning'
                      }).then(() => {

                      }).catch(() => {
                      })

                    } else {
                      that.$message({ message: '挂号成功', type: 'success' })
                      that.form.settlementValue = ''
                      that.form.medicalInsuranceCard = ''
                      that.form.name = ''
                      that.form.sex = ''
                      that.form.certificates = ''
                      that.form.medicalCare = ''
                      that.form.birthday = ''
                      that.form.age = ''
                      that.form.idCard = ''
                      that.form.register = ''
                      that.form.doctor = ''
                      that.form.department = ''
                      that.form.costChecked = false
                      that.form.registrationFee = ''
                      that.form.medicalExpenses = ''
                      that.form.cost = ''
                      that.form.total = ''
                      that.form.phone = ''
                      that.form.social_type = ''
                      that.form.register = 4
                      that.form.registrationFee = 0
                      that.form.medicalExpenses = 0
                    }
                    // var his_info = response.data.data.his_info
                    // that.hisPatientInfo = his_info
                  }
                })
                .catch(function(error) {

                })
            }
          })
        }

      }
      ,
      // saveHisPatient(formName) {
      //   if (this.form.name == '') {
      //     this.$message.error('患者姓名不能为空')
      //     this.is_Name = true
      //     return
      //   }
      //
      //   if (this.form.sex == '') {
      //     this.$message.error('患者性别不能为空')
      //   }
      //
      //   // if (this.form.doctor == '') {
      //   //   this.$message.error('医生不能为空')
      //   //   this.is_Name = true
      //   //   return
      //   // }
      //
      //   if (this.form.department == '') {
      //     this.$message.error('科室不能为空')
      //     this.is_Name = true
      //     return
      //   }
      //   if (this.form.age == '') {
      //     this.$message.error('患者年龄不能为空')
      //     this.is_Name = true
      //     return
      //   }
      //   if (this.form.birthday == '') {
      //     this.$message.error('出生日期不能为空')
      //     this.is_Name = true
      //     return
      //   }
      //   if (this.form.id_card_type == '') {
      //     this.$message.error('读卡类型不能为空')
      //     this.is_Name = true
      //     return
      //   }
      //
      //   if (this.form.idCard == '') {
      //     this.$message.error('证件号码不能为空')
      //     this.is_Name = true
      //     return
      //   }
      //
      //   if (this.form.p_type == '') {
      //     this.$message.error('处方类型不能为空')
      //     this.is_Name = true
      //     return
      //   }
      //
      //   if (this.form.diagnosis == '') {
      //     this.$message.error('诊断不能为空')
      //     this.is_Name = true
      //     return
      //   }
      //
      //   if (this.form.sick_type == '') {
      //     this.$message.error('大病类别不能为空')
      //     this.is_Name = true
      //     return
      //   }
      //
      //   this.$refs[formName].validate((valid) => {
      //     if (valid) {
      //       if (this.form.costChecked == true) {
      //         this.check = 1
      //       }
      //       if (this.form.costChecked == false) {
      //         this.check = 2
      //       }
      //       if (this.form.idCard == '') {
      //         this.show = true
      //       }
      //
      //       var params = {
      //         id: this.form.id,
      //         settlement_value: this.form.settlementValue,
      //         medical_insurance_card: this.form.medicalInsuranceCard,
      //         name: this.form.name,
      //         sex: this.form.sex,
      //         id_card_type: this.form.id_card_type,
      //         certificates: this.form.certificates,
      //         medical_care: this.form.medicalCare,
      //         birthday: moment(new Date(this.form.birthday)).format('YYYY-MM-DD'),
      //         age: parseInt(this.form.age),
      //         id_card: this.form.idCard,
      //         register: this.form.register,
      //         doctor: this.form.doctor,
      //         department: this.form.department,
      //         costChecked: this.check,
      //         registration_fee: this.form.registrationFee,
      //         medical_expenses: this.form.medicalExpenses,
      //         cost: this.form.cost,
      //         total: this.total,
      //         phone: this.form.phone,
      //         social_type: this.form.social_type,
      //         p_type: this.form.p_type,
      //         diagnosis: this.form.diagnosis,
      //         sick_type: this.form.sick_type
      //       }
      //       params['record_time'] = this.record_date,
      //         params['admin_user_id'] = this.$store.getters.xt_user.user.id
      //       this.loadingone = true
      //
      //       if (this.$store.getters.xt_user.org_id == 9504 || this.$store.getters.xt_user.org_id == 10028 || this.$store.getters.xt_user.org_id == 10138) {
      //         var that = this
      //
      //         axios.get('http://127.0.0.1:9532/sz/api/register/get', {
      //           params: params,
      //           headers: {
      //             'Permission': 5
      //           }
      //         })
      //           .then(function(response) {
      //             if (response.data.state == 0) {
      //               that.$message.error(response.data.msg)
      //               that.loadingone = false
      //               that.$refs.register.hide()
      //               return false
      //             } else {
      //               that.loadingone = false
      //
      //               if (response.data.data.failed_code == -10) {
      //                 // that.$message.error(response.data.data.msg)
      //                 that.$confirm(response.data.data.msg, '医保错误信息', {
      //                   confirmButtonText: '确 定',
      //                   type: 'warning'
      //                 }).then(() => {
      //
      //                 }).catch(() => {
      //                 })
      //               } else {
      //                 that.$message({ message: '挂号成功', type: 'success' })
      //                 that.form.settlementValue = ''
      //                 that.form.medicalInsuranceCard = ''
      //                 that.form.name = ''
      //                 that.form.sex = ''
      //                 that.form.certificates = ''
      //                 that.form.medicalCare = ''
      //                 that.form.birthday = ''
      //                 that.form.age = ''
      //                 that.form.idCard = ''
      //                 that.form.register = ''
      //                 that.form.doctor = ''
      //                 that.form.department = ''
      //                 that.form.costChecked = false
      //                 that.form.registrationFee = ''
      //                 that.form.medicalExpenses = ''
      //                 that.form.cost = ''
      //                 that.form.total = ''
      //                 that.form.phone = ''
      //                 that.form.social_type = ''
      //
      //                 that.form.register = 4
      //                 that.form.registrationFee = 0
      //                 that.form.medicalExpenses = 0
      //
      //                 that.form.p_type = 14
      //                 that.form.sick_type = that.sick[0].id
      //                 that.form.diagnosis = that.diagnoses[0].id
      //
      //               }
      //
      //             }
      //           })
      //           .catch(function(error) {
      //
      //           })
      //       } else if (this.$store.getters.xt_user.org_id == 9919 || this.$store.getters.xt_user.org_id == 10106 || this.$store.getters.xt_user.org_id == 4 || this.$store.getters.xt_user.org_id == 9538 || this.$store.getters.xt_user.org_id == 9990) {
      //         var that = this
      //
      //         axios.get('http://127.0.0.1:9532/api/register/get', {
      //           params: params,
      //           headers: {
      //             'Permission': 5
      //           }
      //         })
      //           .then(function(response) {
      //             if (response.data.state == 0) {
      //               that.$message.error(response.data.msg)
      //               that.loadingone = false
      //               return false
      //             } else {
      //               that.loadingone = false
      //               if (response.data.data.failed_code == -10) {
      //                 // that.$message.error(response.data.data.msg)
      //                 that.$confirm(response.data.data.msg, '医保错误信息', {
      //                   confirmButtonText: '确 定',
      //                   type: 'warning'
      //                 }).then(() => {
      //
      //                 }).catch(() => {
      //                 })
      //               } else {
      //                 that.$message({ message: '挂号成功', type: 'success' })
      //                 that.form.settlementValue = ''
      //                 that.form.medicalInsuranceCard = ''
      //                 that.form.name = ''
      //                 that.form.sex = ''
      //                 that.form.certificates = ''
      //                 that.form.medicalCare = ''
      //                 that.form.birthday = ''
      //                 that.form.age = ''
      //                 that.form.idCard = ''
      //                 that.form.register = ''
      //                 that.form.doctor = ''
      //                 that.form.department = ''
      //                 that.form.costChecked = false
      //                 that.form.registrationFee = ''
      //                 that.form.medicalExpenses = ''
      //                 that.form.cost = ''
      //                 that.form.total = ''
      //                 that.form.phone = ''
      //                 that.form.social_type = ''
      //
      //                 that.form.p_type = 14
      //                 that.form.sick_type = that.sick[0].id
      //                 that.form.diagnosis = that.diagnoses[0].id
      //               }
      //             }
      //           })
      //           .catch(function(error) {
      //
      //           })
      //       } else {
      //         saveHisPatient(params).then(response => {
      //           if (response.data.state == 1) {
      //             var patient = response.data.data.patient
      //             this.getTodaySchedulePatient()
      //             this.$message({ message: '挂号成功', type: 'success' })
      //             this.form.settlementValue = ''
      //             this.form.medicalInsuranceCard = ''
      //             this.form.name = ''
      //             this.form.sex = ''
      //             this.form.certificates = ''
      //             this.form.medicalCare = ''
      //             this.form.birthday = ''
      //             this.form.age = ''
      //             this.form.idCard = ''
      //             this.form.register = ''
      //             this.form.doctor = ''
      //             this.form.department = ''
      //             this.form.costChecked = false
      //             this.form.registrationFee = ''
      //             this.form.medicalExpenses = ''
      //             this.form.cost = ''
      //             this.form.total = ''
      //             this.form.phone = ''
      //             this.form.social_type = ''
      //             this.loadingone = false
      //             this.form.p_type = 14
      //             this.form.sick_type = this.sick[0].id
      //             this.form.diagnosis = this.diagnoses[0].id
      //           } else {
      //             this.$message.error('今日患者已挂号!')
      //           }
      //         })
      //
      //       }
      //
      //     }
      //   })
      // }
      // ,
      getTodaySchedulePatient() {
        var nowDate = new Date()
        var nowYear = nowDate.getFullYear()
        var nowMonth = nowDate.getMonth() + 1
        var nowDay = nowDate.getDate()
        this.record_date =
          nowYear +
          '-' +
          (nowMonth < 10 ? '0' + nowMonth : nowMonth) +
          '-' +
          (nowDay < 10 ? '0' + nowDay : nowDay)
        let params = {

          record_date: this.record_date
        }
        getUnRegisterHisPatientList(params).then(response => {
          if (response.data.state == 1) {
            var patient = response.data.data.list
            console.log('今日排班', patient)
            this.patient = patient
          }
        })
      }
      ,
      getDictionaryDataConfig(module, filed_name) {
        return getDictionaryDataConfig(module, filed_name)
      }
      ,

      changeDoctor(id) {

        for (let i = 0; i < this.doctorList.length; i++) {
          if (this.doctorList[i].admin_user_id == id) {
            if (this.doctorList[i].department_id == 0) {
              this.form.department = this.departmentList[0].id
            } else {
              this.form.department = this.doctorList[i].department_id
            }

          }
        }
      },
      changeName(id) {
        this.form.sex = ''
        this.form.age = ''
        this.form.birthday = ''
        this.form.phone = ''
        this.form.idCard = ''
        getPatientDetail(id).then(response => {
          if (response.data.state == 1) {
            var patient = response.data.data.patient
            console.log('patient', patient)
            this.form.sex = patient.gender
            this.form.age = patient.age
            this.form.birthday = uParseTime(patient.birthday, '{y}-{m}-{d}')
            this.form.phone = patient.phone
            this.form.idCard = patient.id_card_no
          }
        })
      }
      ,
      getInitData() {
        getInitData().then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.doctors = response.data.data.doctors
            this.department = response.data.data.department
            for (let i = 0; i < this.department.length; i++) {
              this.form.department = this.department[0].id
            }

          }
        })

      }

    },
    created() {
      if (this.$store.getters.xt_user.org_id == 9504 || this.$store.getters.xt_user.org_id == 10028 || this.$store.getters.xt_user.org_id == 10138 || this.$store.getters.xt_user.org_id == 10088) {
        this.form.certificates = 2
        this.form.id_card_type = 1
        this.form.settlementValue = 1
        this.form.registrationFee = 0
        this.form.medicalExpenses = 0
      } else {
        this.form.certificates = 1
        this.form.id_card_type = 2
        this.form.settlementValue = 1
        this.form.registrationFee = 0
        this.form.medicalExpenses = 0

      }

      this.getInitData()
      //获取当前机构有人员信息
      this.getAllDoctorList()
      //获取今日排班的患者
      this.getTodaySchedulePatient()
    }
  }
</script>

<style lang="scss" scoped>
    .nameTitle {
        font-weight: bold;
        font-size: 16px;
    }

    .formMain {
        /*/ / padding: 10 px 90 px;*/
        width: 80%;
        margin: 0 auto;
    }

    .basicForm {

        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;

    .el-form-item {
        width: 33%;
    }

    .specialFormItem {
        width: 66.5%;

    .el-input {
        min-width: 150px;
    }

    }
    .el-select {
        width: 100%;
    }

    .el-input {
        width: 100%;
    }

    }
    .el-form-item__error {
        color: #F56C6C;
        font-size: 12px;
        line-height: 1;
        padding-top: 4px;
        position: absolute;
        top: 100%;
        left: 0;
    }
</style>
