<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
      <!-- 			<el-form-item label="市" prop="city">
				<el-input v-model="queryParams.city" placeholder="请输入市" clearable size="small" @keyup.enter.native="handleQuery" />
			</el-form-item> -->
      <!-- <el-form-item
				label="省市区镇"
				prop="area"
			>
				<area-select type='text' v-model='selectedtwo' :data='$pcaa' :level='3' style="display: flex;line-height: 18px;" @change="onSelectedtwo"></area-select>
			</el-form-item> -->
			<el-row>
				<el-col :span="8">
					<el-form-item label="姓名" prop="userName">
					  <el-input v-model="queryParams.userName" placeholder="请输入姓名" clearable  @keyup.enter.native="handleQuery" />
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="身份证号" prop="idCard">
					  <el-input v-model="queryParams.idCard" placeholder="请输入身份证号码" clearable  @keyup.enter.native="handleQuery" />
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="联系号码" prop="phoneNum">
					  <el-input v-model="queryParams.phoneNum" placeholder="请输入联系号码" clearable  @keyup.enter.native="handleQuery" />
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-row>
						<el-col :span="8">
							<el-form-item label="进度" prop="progress">
							  <!-- <el-input v-model="queryParams.progress" placeholder="请输入进度" clearable size="small" @keyup.enter.native="handleQuery" /> -->
							  <el-select v-model="queryParams.progress" placeholder="进度" clearable >
							    <el-option v-for="dict in statusOptionstue" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
							  </el-select>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="接种情况" prop="isVaccination">
							  <el-input v-model="queryParams.isVaccination" placeholder="请输入接种情况" clearable  @keyup.enter.native="handleQuery" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="疫苗名称" prop="vaccineName">
							  <!-- <el-input v-model="queryParams.vaccineName" placeholder="请输入疫苗名称" clearable size="small" @keyup.enter.native="handleQuery" /> -->
							  <el-select v-model="queryParams.vaccineName" placeholder="疫苗名称" clearable >
							    <el-option v-for="dict in typeOptionsname" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
							  </el-select>
							</el-form-item>
						</el-col>
					</el-row>
				</el-col>
				
				<el-col :span="8">
					<el-form-item label="剂次" prop="jici">
					  <el-select v-model="queryParams.jici" placeholder="剂次" clearable >
					    <el-option v-for="dict in typeOptionstimes" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
					  </el-select>
					  <!-- <el-input v-model="queryParams.jici" placeholder="请输入剂次" clearable size="small" @keyup.enter.native="handleQuery" /> -->
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="接种时间" prop="vaccinationTime">
					  <el-date-picker
					    clearable
					    v-model="queryParams.vaccinationTime"
					    type="datetime"
					    value-format="yyyy-MM-dd HH:mm:ss"
					    format="yyyy-MM-dd HH:mm:ss"
					    placeholder="选择接种时间"
						
					  ></el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="接种地点" prop="vaccinationPlace">
					  <!-- <el-input v-model="queryParams.vaccinationPlace" placeholder="请输入接种地点" clearable size="small" @keyup.enter.native="handleQuery" /> -->
					  <el-select v-model="queryParams.vaccinationPlace" placeholder="接种地点" clearable >
					    <el-option v-for="dict in typeOptionsvaccinatio" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
					  </el-select>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-row>
						<el-col :span="8">
							<el-form-item
							        label="应种未种"
							        prop="shouldBe"
							      >
							        <el-radio-group v-model="queryParams.shouldBe">
							          <el-radio v-for="dict in typeOptionsty" :key="dict.dictValue" :label="dict.dictValue">{{ dict.dictLabel }}</el-radio>
							        </el-radio-group>
							        <!-- <el-input
												v-model="queryParams.shouldBe"
												placeholder="请输入应种未种
							"
												clearable
												size="small"
												@keyup.enter.native="handleQuery"
											/> -->
							      </el-form-item>
						</el-col>
						
						<el-col :span="8">
							<el-form-item label="户籍地" prop="villagerGroup">
							  <el-cascader placeholder="点击选择户籍地" :options="options" filterable @change="chahetwo" :props="optionProps" style="width: 100%;"></el-cascader>
							</el-form-item>
						</el-col>
						<el-col :span="8" style="text-align: center;">
							<el-form-item>
							  <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
							  <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
							</el-form-item>
						</el-col>
					</el-row>
				</el-col>
				
			</el-row>

      <!-- <el-form-item
      	label="现居住地省市区镇"
      	prop="region"
      >
      	<area-select type='text' v-model='selectedtwo' :data='$pcaa' :level='2' style="display: flex;line-height: 18px;" @change="onSelectedtwo"></area-select>
      </el-form-item> -->
      <!-- <el-form-item label="状态" prop="status">
				<el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small"><el-option label="请选择字典生成" value="" /></el-select>
			</el-form-item> -->
      <!-- <el-form-item label="是否删除" prop="isDel">
				<el-input v-model="queryParams.isDel" placeholder="请输入是否删除" clearable size="small" @keyup.enter.native="handleQuery" />
			</el-form-item> -->
      
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5"><el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['core:info:add']">新增</el-button></el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['core:info:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['core:info:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5"><el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['core:info:export']">导出</el-button></el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange" stripe style="width: 100%" height="350">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="编号" align="center" prop="code" fixed />
      <el-table-column label="姓名" align="center" prop="userName" fixed />
      <el-table-column label="性别" align="center" prop="gender" />
      <el-table-column label="身份证号码" align="center" prop="idCard" width="180" />
      <el-table-column label="现居住地省份" align="center" prop="province" />
      <el-table-column label="现居住地市" align="center" prop="city" />
      <el-table-column label="现居住地区" align="center" prop="region" />
      <el-table-column label="现居住地详细地址" align="center" prop="nowIn" width="180" />
      <el-table-column label="联系号码" align="center" prop="phoneNum" />
      <el-table-column label="户籍乡镇" align="center" prop="villageTowns" />
      <el-table-column label="户籍村居" align="center" prop="village" />
      <el-table-column label="户籍村民组" align="center" prop="villagerGroup" />
      <el-table-column label="户别" align="center" prop="houseType" />
      <el-table-column label="户籍地" align="center" prop="domicile" />

      <!-- <el-table-column label="重点行业" align="center" prop="keyIndustries" /> -->
      <el-table-column label="接种情况" align="center" prop="isVaccination" />
      <el-table-column label="疫苗名称" align="center" prop="vaccineName" />
      <el-table-column label="剂次" align="center" prop="jici" />
      <el-table-column label="接种时间" align="center" prop="vaccinationTime" width="180">
        <template slot-scope="scope">
          <span>{{ scope.row.vaccinationTime }}</span>
        </template>
      </el-table-column>
      <el-table-column label="接种地点" align="center" prop="vaccinationPlace" />
      <!-- <el-table-column label="禁忌症" align="center" prop="contraindication" /> -->
      <!-- <el-table-column
				label="暂缓
"
				align="center"
				prop="suspend"
			/> -->
      <!-- <el-table-column label="死亡" align="center" prop="death" /> -->
      <!-- <el-table-column
				label="失联失踪
"
				align="center"
				prop="lostInMissing"
			/> -->
      <el-table-column
        label="应种未种
"
        align="center"
        prop="shouldBe"
      />
      <el-table-column label="其他" align="center" prop="other" />
      <el-table-column label="进度" align="center" prop="progress" />
      <el-table-column label="备注" align="center" prop="remark" />
      <!-- <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
        	<span>{{ scope.row.status==0?'启用' :'停用' }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="是否删除" align="center" prop="isDel" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['core:info:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['core:info:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

    <!-- 添加或修改疫苗信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1300px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="140px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="身份证号" prop="idCard"><el-input v-model="form.idCard" placeholder="请输入身份证号码" @blur="idcde" /></el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="姓名" prop="userName"><el-input v-model="form.userName" placeholder="请输入姓名" /></el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="出生日期" prop="birthday">
              <el-date-picker clearable  v-model="form.birthday" type="date" value-format="yyyy-MM-dd" format="yyyy-MM-dd " style="width: 100%;" placeholder="选择出生日期"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="性别" prop="gender">
              <!-- <el-input v-model="form.gender" placeholder="请输入性别" /> -->
              <el-select v-model="form.gender" placeholder="性别" clearable size="small" >
                <el-option v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="联系号码" prop="phoneNum"><el-input v-model="form.phoneNum" placeholder="请输入联系号码" /></el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="编号" prop="code"><el-input v-model="form.code" placeholder="请输入编号" /></el-form-item>
          </el-col>
         <el-col :span="6">
           <el-form-item label="重点行业" prop="keyIndustries">
             <el-select v-model="form.keyIndustries" placeholder="重点行业" clearable style="width: 100%;" >
               <el-option v-for="dict in typeOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
             </el-select>
           </el-form-item>
         </el-col>
          <el-col :span="6">
            <el-form-item label="户别" prop="houseType">
              <!-- <el-select v-model="form.houseType" placeholder="请选择户别"><el-option label="请选择字典生成" value="" /></el-select> -->
              <!-- <el-input v-model="form.houseType" placeholder="请输入内容" /> -->
			  <el-select v-model="form.houseType" placeholder="户别" clearable style="width: 100%;" >
			    <el-option v-for="dict in typeOptionshuuj" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
			  </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="现居省市区" prop="region">
              <area-select type="text" v-model="selected" :data="$pcaa" :level="2" style="display: flex;line-height: 18px;" @change="onSelected"></area-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="详细地址" prop="nowIn"><el-input v-model="form.nowIn" type="input" placeholder="请输入内容" /></el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="乡/村/村组" prop="villagerGroup">
              <!-- <el-input v-model="form.villageTowns" type="textarea" placeholder="请输入内容" /> -->
              <!-- <treeselect v-model="form.parentId" :options="deptOptionstwo" :normalizer="normalizer" :flat="true" :maxHeight="150" @select="djieskle" :multiple=true placeholder="点击选择户籍地" /> -->
              <el-cascader placeholder="点击选择户籍地" :options="options" :filterable="true" @change="chahe" v-model="form.villagerGroup" :props="optionProps" style="width: 100%;"></el-cascader>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="详细地址" prop="domicile"><el-input v-model="form.domicile" type="input" placeholder="请输入户籍详细地址" /></el-form-item>
          </el-col>


  <el-col :span="12">
            <el-form-item label="其他" prop="other"><el-input v-model="form.other" placeholder="请输入其他" /></el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark"><el-input v-model="form.remark" placeholder="请输入备注" /></el-form-item>
          </el-col>
          <el-col :span="24">
             <el-row>
               <el-col :span="4.8">
                 <el-form-item label="接种情况" prop="isVaccination">
                   <!-- <el-input v-model="form.isVaccination" placeholder="请输入接种情况" /> -->
                   <el-radio-group v-model="form.isVaccination" @change="gywoa">
                     <el-radio v-for="dict in typeOptionsty" :key="dict.dictValue" :label="dict.dictValue">{{ dict.dictLabel }}</el-radio>
                   </el-radio-group>
                   </el-form-item>
               </el-col>
               <el-col :span="4.8">
                 <el-form-item label="暂缓" prop="suspend">
                   <!-- <el-input
                  						v-model="form.suspend"
                  						placeholder="请输入暂缓"
                  					/> -->
                   <el-radio-group v-model="form.suspend" :disabled="shouwes">
                     <el-radio v-for="dict in typeOptionsty" :key="dict.dictValue" :label="dict.dictValue">{{ dict.dictLabel }}</el-radio>
                   </el-radio-group>
                 </el-form-item>
               </el-col>
               <el-col :span="4.8">
                 <el-form-item label="死亡" prop="death">
                   <!-- <el-input v-model="form.death" placeholder="请输入死亡" /> -->
                   <el-radio-group v-model="form.death" :disabled="shouwes">
                     <el-radio v-for="dict in typeOptionsty" :key="dict.dictValue" :label="dict.dictValue">{{ dict.dictLabel }}</el-radio>
                   </el-radio-group>
                 </el-form-item>
               </el-col>
               <el-col :span="4.8">
                 <el-form-item
                   label="失联失踪
                  "
                   prop="lostInMissing"
                 >
                   <el-radio-group v-model="form.lostInMissing" :disabled="shouwes">
                     <el-radio v-for="dict in typeOptionsty" :key="dict.dictValue" :label="dict.dictValue">{{ dict.dictLabel }}</el-radio>
                   </el-radio-group>
                 </el-form-item>
               </el-col>
               <el-col :span="4.8">
                 <el-form-item label="应种未种" prop="shouldBe">
                   <el-radio-group v-model="form.shouldBe" :disabled="shouwes">
                     <el-radio v-for="dict in typeOptionsty" :key="dict.dictValue" :label="dict.dictValue">{{ dict.dictLabel }}</el-radio>
                   </el-radio-group>
                 </el-form-item>
               </el-col>
             </el-row>
          </el-col>
          <el-col :span="6">
            <el-form-item label="人群分类" prop="crowd_classification"><el-input v-model="form.crowd_classification" placeholder="请输入人群分类" /></el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="疫苗名称" prop="vaccineName">
              <!-- <el-input v-model="form.vaccineName" placeholder="请输入疫苗名称" /> -->
              <el-select v-model="form.vaccineName" placeholder="疫苗名称" clearable :disabled="naneme" @change="changeheu">
                <el-option v-for="dict in typeOptionsname" :key="dict.dictValue" :label="dict.dictLabel" :value="{value:dict.dictValue,label:dict.dictLabel}" />
				<!-- dict.dictValue -->
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="接种时间" prop="vaccinationTime">
              <el-date-picker
                clearable
                v-model="form.vaccinationTime"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择接种时间"
                style="width: 100%;"
                :disabled="naneme"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="剂次" prop="jici">
              <!-- <el-input v-model="form.jici" placeholder="请输入剂次" /> -->
              <el-select @change="changeheujici" v-model="form.jici" placeholder="剂次" clearable size="small" :disabled="naneme">
                <el-option v-for="dict in typeOptionstimes" :key="dict.dictValue" :label="dict.dictLabel" :value="{value:dict.dictValue,label:dict.dictLabel}" />
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="6">
            <el-form-item label="接种地点" prop="vaccinationPlace">
              <!-- <el-input v-model="form.vaccinationPlace" placeholder="请输入接种地点" /> -->
              <el-select :disabled="naneme" v-model="form.vaccinationPlace" placeholder="接种地点" clearable size="small">
                <el-option v-for="dict in typeOptionsvaccinatio" :key="dict.dictValue"  :label="dict.dictLabel" :value="dict.dictValue" />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item  label="进度" prop="progress">
              <!-- <el-input v-model="form.progress" placeholder="请输入进度" /> -->
              <el-select v-model="form.progress" placeholder="进度" clearable size="small" :disabled="naneme">
                <el-option   v-for="dict in statusOptionstue" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictLabel" />
				<!-- dictValue -->
              </el-select>
            </el-form-item>
          </el-col>


         <el-col :span="24">
           <el-form-item label="禁忌症" prop="contraindication" class="ehiqya">
             <!-- <el-input v-model="form.contraindication" placeholder="请输入禁忌症" /> -->
             <el-select  :disabled="shouwes"   v-model="form.contraindication" placeholder="禁忌症" clearable style="100%">
               <el-option v-for="dict in typeOptionscont" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
             </el-select>
             <div class="jdidur">
               <el-upload  :disabled="shouwes" class="upload-demo" :headers="{Authorization: 'Bearer ' + getToken()}"
                            :action="process + '/boman-file/upload'" :on-change="handleChangert"
                           :on-success="upImageFn" :on-error="err" :on-remove="reseImage" :file-list="config" :on-preview="handlePictureCardPreview" :before-upload="befors">
                           <el-button size="small" type="primary">点击上传</el-button>

                         </el-upload>
               <div  class="el-upload__tip" style="margin-left: 5px; color: red; margin-top: 0;">
                             请上传png/jpg文档,且不超过50MB
                       </div>
             </div>
           </el-form-item>
         </el-col>
        </el-row>
        <!-- <el-form-item label="户籍地村居" prop="village">
          <el-input v-model="form.village" type="textarea" placeholder="请输入内容" /></el-form-item> -->
        <!-- <el-form-item label="户籍地村居" prop="village">
          <el-input v-model="form.village" type="textarea" placeholder="请输入内容" /></el-form-item>
				<el-form-item label="户籍地村民组" prop="villagerGroup"><el-input v-model="form.villagerGroup" type="textarea" placeholder="请输入内容" /></el-form-item> -->

        <!-- <el-form-item label="省" prop="province"><el-input v-model="form.province" type="textarea" placeholder="请输入内容" /></el-form-item>
				<el-form-item label="市" prop="city"><el-input v-model="form.city" placeholder="请输入市" /></el-form-item>
				<el-form-item
					label="区"
					prop="area"
				>
					<el-input v-model="form.area" placeholder="请输入区" />
				</el-form-item> -->

        <!-- <el-form-item label="状态">
					<el-radio-group v-model="form.status"><el-radio label="1">请选择字典生成</el-radio></el-radio-group>
				</el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 图片预览 -->
    <el-dialog   :close-on-click-modal="false" title="预览" :visible.sync="imashow" width="1200px" append-to-body>
    <div class="demo-image__preview">
      <img  :src="dialogImageUrl" alt="" style="width: 100%;">
      <!-- <iframe v-if="shouewhu" :src="dialogImageUrl" frameborder="0" style="width: 100%; height: 100vh;"></iframe>
      <a v-if="exelshow"  :href="dialogImageUrl" :download="dialogImageUrlname" >{{dialogImageUrlname}} <span style="color: #039BE5;">点击下载</span></a> -->
    </div>
    </el-dialog>
  </div>
</template>

<script>
import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo, listRoleer,idces } from '@/api/system/time';
import { treeselect } from '@/api/system/dept';
import Treeselect from '@riophae/vue-treeselect';
import {
    getToken
  } from "@/utils/auth";
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
export default {
  name: 'Info',
  components: { Treeselect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 疫苗信息表格数据
      infoList: [],
      dialogImageUrl: '',
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      process: process.env.VUE_APP_BASE_API,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        villageTowns: null,
        village: null,
        villagerGroup: null,
        houseType: null,
        domicile: null,
        province: null,
        city: null,
        region: null,
        userName: null,
        gender: null,
        idCard: null,
        phoneNum: null,
        keyIndustries: null,
        isVaccination: null,
        vaccineName: null,
        jici: null,
        vaccinationTime: null,
        vaccinationPlace: null,
        contraindication: null,
        suspend: null,
        death: null,
        lostInMissing: null,
        shouldBe: null,
        other: null,
        progress: null,
        status: null,
        isDel: null
      },
       config: [],
      // 表单参数
      form: {
        birthday: ''
      },
      // 表单校验
      rules: {
        region: [{ required: true, message: '区不能为空', trigger: 'blur' }],
        idCard: [{ required: true, message: '身份证号码不能为空', trigger: 'blur' }],
        userName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
      },
      selected: ['安徽省', '安庆市', '潜山市'],
      selectedtwo: ['安徽省', '安庆市', '潜山市'],
      statusOptions: [
        {
          dictValue: '女',
          dictLabel: '女'
        },
        {
          dictValue: '男',
          dictLabel: '男'
        }
      ],
      statusOptionstue: [
        {
          dictValue: '已完成',
          dictLabel: '已完成'
        },
        {
          dictValue: '未完成',
          dictLabel: '未完成'
        }
      ],
	  typeOptionshuuj:[
		  {
		    dictValue: '农业',
		    dictLabel: '农业'
		  },
		  {
		    dictValue: '非农业',
		    dictLabel: '非农业'
		  }
	  ],
      deptOptionstwo: [],
      options: [],
      optionProps: {
        value: 'label',
        label: 'label',
        children: 'children'
      },
      heuiq: [],
      typeOptions: [],
      typeOptionsty: [
        {
          dictValue: '是',
          dictLabel: '是'
        },
        {
          dictValue: '否',
          dictLabel: '否'
        }
      ],
      typeOptionsname: [],
      typeOptionstimes: [],
      typeOptionsvaccinatio: [],
      typeOptionscont: [],
      imashow:false,
      naneme:false,
      shouwes:false
    };
  },
  created() {
    this.getList();
    this.getTreeselectjue();
    // 重点行业
    this.getDicts('key_trades').then(response => {
      this.typeOptions = response.data;
    });
    // 疫苗名称
    this.getDicts('vaccine_name').then(response => {
      this.typeOptionsname = response.data;
    });
    
    // 接种地点
    this.getDicts('vaccination_site').then(response => {
      this.typeOptionsvaccinatio = response.data;
    });
    // 禁忌症
    this.getDicts('contraindication').then(response => {
      this.typeOptionscont = response.data;
    });
    this.form.province = this.selected[0];
    this.form.city = this.selected[1];
    this.form.region = this.selected[2];
  },
  methods: {
    onSelected(data) {
      console.log(data);
      // province
      this.form.province = data[0];
      this.form.city = data[1];
      this.form.region = data[2];
      // this.form.villageTowns = data[3]
    },
    onSelectedtwo(data) {
      console.log(data);
      // province
      this.queryParams.province = data[0];
      this.queryParams.city = data[1];
      this.queryParams.region = data[2];
      // this.queryParams.villageTowns = data[3]
    },
    /** 查询疫苗信息列表 */
    getList() {
      this.loading = true;
      listInfo(this.queryParams).then(response => {
        this.infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getToken() {
      return getToken()
    },
    getTreeselectjue() {
      this.loading = true;
      listRoleer(this.queryParams).then(response => {
        this.options = response.data;
        this.loading = false;
      });
    },
    /** 转换角色数据结构 */
    normalizer(node) {
      // if (node.children && !node.children.length) {
      //   delete node.children;
      // }
      return {
        id: node.id,
        label: node.roleName
      };
    },
    // 点击组/角色
    djieskle(node, instanceId) {
      // this.personnel(node.id);
      console.log(node, instanceId);
    },
    // 身份证
    idcde(event) {
      console.log(event);
      // 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X
      let reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
      if (reg.test(this.form.idCard)) {
		  this.idea()
        // this.go(this.form.idCard.length);
        // callback()
      } else {
        // callback(new Error('身份证号码不正确'))
        this.msgInfo('身份证号码不正确');
      }
    },
    // 实现自动生成生日，性别，年龄
    go(val) {
      let iden = this.form.idCard;
      let sex = null;
      let birth = null;
      let birthr = '';
      let myDate = new Date();
      let month = myDate.getMonth() + 1;
      let day = myDate.getDate();
      let age = 0;

      if (val === 18) {
        age = myDate.getFullYear() - iden.substring(6, 10) - 1;
        sex = iden.substring(16, 17);
        birth = iden.substring(6, 10) + '-' + iden.substring(10, 12) + '-' + iden.substring(12, 14);
        if (iden.substring(10, 12) < month || (iden.substring(10, 12) == month && iden.substring(12, 14) <= day)) age++;
      }
      if (val === 15) {
        age = myDate.getFullYear() - iden.substring(6, 8) - 1901;
        sex = iden.substring(13, 14);
        birth = '19' + iden.substring(6, 8) + '-' + iden.substring(8, 10) + '-' + iden.substring(10, 12);
        if (iden.substring(8, 10) < month || (iden.substring(8, 10) == month && iden.substring(10, 12) <= day)) age++;
      }

      if (sex % 2 === 0) sex = '女';
      else sex = '男';
      this.form.gender = sex;
      // this.baseInfo.age = age;
      birthr = birth + '';
      console.log(birthr);
      this.form.birthday = birthr;
      // this.$set(this.form.birthday, birthr)
      // this.baseInfo.birthplace = this.area[iden.substring(0,2)];
    },
	// 请求身份证数据
	idea(){
		idces({idCard:this.form.idCard}).then(response => {
		   console.log(response)
		   this.form.gender = response.data.gender;
		   this.form.birthday = response.data.birthday;
		   if(response.data.userName == null){
			   this.form.userName = undefined
		   }else{
			   this.form.userName = response.data.userName
		   }
		});
	},
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 上传前控制
    befors(res, file){
      console.log(res,file)
      console.log(res.name.substr(0,res.name.length-4))
      // if(res.type !== 'application/pdf'){
      //   this.msgSuccess('只能上传pdf文件');
      //   return false
      // }else{
      //   return true
      // }
      return   true
    },
    gywoa(){
     console.log(this.form.isVaccination)
     if(this.form.isVaccination == '是'){
       // 接种疫苗
       this.naneme = false,
       this.shouwes = true
     }else{
       this.naneme = true,
       this.shouwes = false
     }
    },
    // 图片预览
    handlePictureCardPreview(file) {
      console.log(file,87)
      console.log(file.name.split('.'))
      let hegs = file.name.split('.')
      console.log(hegs[hegs.length - 1])
      if(hegs[hegs.length - 1] == 'pdf'){
        this.shouewhu = true
      }else{
        if(hegs[hegs.length - 1] == 'jpg' || hegs[hegs.length - 1] == 'png'){
          this.shouewhu = false
          this.exelshow = false
        }else{
          this.exelshow = true
        }
      }
      console.log(this.shouewhu,this.exelshow)
      this.dialogImageUrl = file.url;
      this.dialogImageUrlname = file.name
      console.log(this.dialogImageUrlname)
      this.dialogVisible = true;
      this.imashow = true
    },
    // 上传文件
    handleChangert(file, fileList) {
      this.fileList = fileList.slice(-3);
    },
    upImageFn(res, file) {
      if(res.code !== 200){
        this.msgSuccess('上传失败');
        return false
      }else{
        this.msgSuccess('上传成功');
        this.config.push(res.data);
        console.log(res.data)
        console.log(res.data.name.substr(0,res.data.name.length-4))
        this.form.url = this.config
        // console.log(this.querjtgoe.message_upload)
        // this.querjtgoe.message_title = res.data.name
        // this.form.message_title = res.data.name.substr(0,res.data.name.length-4)
        this.form.url = JSON.stringify(this.form.url)
      }
      // querjtgoe.message_title
      console.log(res)
      console.log(res.data.name.substr(-4))
    },
    err(){
      this.msgSuccess("上传失败");
     console.log(35)
    },
    reseImage(file, fileList) {
      let urls = ""
      if (file.response) {
        urls = file.response.url
      } else {
        urls = file.url
      }
      for (let i = this.config.length - 1; i >= 0; i--) {
        if (this.config[i].url == urls) {
          this.config.splice(i, 1);
        }
      }
      if(this.config.length == 0){
        this.form.url = undefined
      }else{
        this.form.url = JSON.stringify(this.config)
      }

    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        villageTowns: null,
        village: null,
        birthday: '',
        villagerGroup: null,
        houseType: null,
        domicile: null,
        province: null,
        city: null,
        region: null,
        userName: null,
        gender: null,
        idCard: null,
        phoneNum: null,
        keyIndustries: null,
        isVaccination: null,
        vaccineName: null,
        jici: null,
        vaccinationTime: null,
        vaccinationPlace: null,
        contraindication: null,
        suspend: null,
        death: null,
        lostInMissing: null,
        shouldBe: null,
        other: null,
        progress: null,
        remark: null,
        status: '0',
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        isDel: null
      };
      this.resetForm('form');
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm');
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
	  this.naneme= false,
	  this.shouwes =false
	  this.selected = ['安徽省', '安庆市', '潜山市'],
	  this.form.province = this.selected[0];
	  this.form.city = this.selected[1];
	  this.form.region = this.selected[2];
      this.title = '添加疫苗信息';
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getInfo(id).then(response => {
        this.form = response.data;
        this.selected[0] = response.data.province;
        this.selected[1] = response.data.city;
        this.selected[2] = response.data.region;
		// if(this.form){
			if(this.form.isVaccination == '是'){
			  // 接种疫苗
			  this.naneme = false,
			  this.shouwes = true
			}else{
			  this.naneme = true,
			  this.shouwes = false
			}
			
			if(this.form.dictValue !== null && this.form.dictValue !== undefined){
				this.jicheru(this.form.dictValue)
			}
		// }
        // this.heuiq.push()
        this.open = true;
        this.title = '修改疫苗信息';
      });
    },
    chahe(data) {
      console.log(data);
      this.form.villageTowns = data[1];
      this.form.village = data[2];
      this.form.villagerGroup = data[3];
    },
    chahetwo(data) {
      this.queryParams.villageTowns = data[1];
      this.queryParams.village = data[2];
      this.queryParams.villagerGroup = data[3];
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
        console.log(this.selected);
        if (valid) {
          if (this.form.id != null) {
            updateInfo(this.form).then(response => {
              this.msgSuccess('修改成功');
              this.open = false;
              this.getList();
            });
          } else {
            addInfo(this.form).then(response => {
              this.msgSuccess('新增成功');
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除疫苗信息编号为"' + ids + '"的数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(function() {
          return delInfo(ids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess('删除成功');
        });
    },
    /** 导出按钮操作 */
    handleExport() {
        this.download('/boman-web-core/core/info/export', {
          ...this.queryParams
        }, `post_${new Date().getTime()}.xlsx`)
    },
	// 疫苗名称改变
	changeheu(data){
		console.log(data)
		this.form.vaccineName = this.form.vaccineName.label
		console.log(this.form.vaccineName)
		this.jicheru(data.value)
	},
	
	// 剂次
	jicheru(data){
		// 计次
		this.getDicts(data).then(response => {
		  this.typeOptionstimes = response.data;
		});
	},
	// 剂次改变
	changeheujici(data){
		console.log(data)
		this.form.jici = this.form.jici.label
		console.log(this.form.jici)
		if(data.value == this.typeOptionstimes.length){
			this.form.progress = '已完成'
		}else{
			this.form.progress = '未完成'
		}
	}
  }
};
</script>
<style  lang="scss">
  .el-dialog__body{
    padding-top: 0;
    padding-bottom: 0;
  }
  .ehiqya{
    .el-form-item__content{
     display: flex;
     .jdidur{
       flex: 1;
       margin-left: 10px;
       // display: flex;
     }
    }
    .upload-demo{
      display: flex;
    }
  }
</style>
