<template>
  <div class="app-container fixed-scroll-error">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <div style="display:inline-block; height: 32px; line-height:32px;   margin: 0 15px 0 0;">
        <b>{{ title }} </b>
      </div>

      <el-form-item label="身份证号" prop="idCard">
        <el-input v-model="queryParams.idCard" placeholder="请输入身份证号" clearable
                  @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="学生姓名" prop="studentName">
        <el-input v-model="queryParams.studentName" placeholder="请输入学生姓名" clearable
                  @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="注册序号" prop="schoolNo">
        <el-input v-model="queryParams.schoolNo" placeholder="请输入注册序号" clearable
                  @keyup.enter.native="handleQuery"/>
      </el-form-item>

      <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-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button v-if="infoType==0" type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          v-if="infoType==0"
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <!--        <el-button-->
        <!--          v-if="infoType==0" type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"-->
        <!--          @click="handleDelete">删除-->
        <!--        </el-button>-->
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" v-if="infoType==0" plain icon="el-icon-upload" size="mini" @click="handleUpload">导入
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="detailList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" align="center"></el-table-column>
      <el-table-column type="index" fixed="left" label="序号" width="55" align="center"/>
      <el-table-column label="学生姓名" fixed="left" align="center" prop="studentName"/>
      <el-table-column label="身份证号" min-width="180" align="center" prop="idCard"/>
      <el-table-column label="注册序号" min-width="180" align="center" prop="schoolNo"/>
      <el-table-column label="性别" align="center" prop="sex">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex"/>
        </template>
      </el-table-column>
      <el-table-column label="出生日期" align="center" prop="birthday" min-width="140">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.birthday, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="民族" align="center" prop="nation"/>
      <el-table-column label="省学籍辅号" max-width="150px" min-width="120px" align="center" prop="provincialNumber"/>
      <el-table-column label="全国学籍号" max-width="150px" min-width="120px" align="center" prop="nationalNumber"/>
      <el-table-column label="联系电话" align="center" prop="stuTelephone"/>
      <el-table-column label="现住地址" max-width="200px" min-width="120px" align="center" prop="homeAddress"/>
      <el-table-column label="通讯地址" max-width="200px" min-width="120px" align="center" prop="postalAddress"/>
      <el-table-column label="出生地" align="center" prop="birthAddress"/>
      <el-table-column label="邮政编码" align="center" prop="postalCode"/>
      <el-table-column label="籍贯" align="center" prop="nativePlace"/>
      <el-table-column label="户口所在地" max-width="200px" min-width="120px" align="center" prop="registeredAddress"/>
      <el-table-column label="户口性质" align="center" prop="registeredType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.regist_type" :value="scope.row.registeredType"/>
        </template>
      </el-table-column>
      <el-table-column label="初中学校" align="center" prop="juniorSchool"/>
      <el-table-column label="国家地区" align="center" prop="region"/>
      <el-table-column label="外语语种" align="center" prop="foreignLanguages"/>
      <el-table-column label="政治面貌" align="center" prop="appearance">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.politics_tatus" :value="scope.row.appearance"/>
        </template>
      </el-table-column>
      <el-table-column label="血型" align="center" prop="bloodType"/>
      <el-table-column label="健康状况" align="center" prop="health"/>
      <el-table-column label="港澳台侨" align="center" prop="otherRegions"/>
      <el-table-column label="流动人口状况" max-width="200px" min-width="120px" align="center"
                       prop="floatingPopulation"/>
      <el-table-column label="独生子女" align="center" prop="onlyChild">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.only_child" :value="scope.row.onlyChild"/>
        </template>
      </el-table-column>
      <el-table-column label="性质" align="center" prop="nature">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.student_nature" :value="scope.row.nature"/>
        </template>
      </el-table-column>
      <el-table-column label="接受资助状况" max-width="200px" min-width="120px" align="center" prop="support"/>
      <el-table-column label="家长姓名1" align="center" prop="parentName1"/>
      <el-table-column label="家长关系1" align="center" prop="relationship1">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.relationship" :value="scope.row.relationship1"/>
        </template>
      </el-table-column>
      <el-table-column label="家长工作单位1" max-width="200px" min-width="120px" align="center" prop="workAddress1"/>
      <el-table-column label="家长联系地址1" max-width="200px" min-width="120px" align="center" prop="contactAddress1"/>
      <el-table-column label="家长联系电话1" align="center" min-width="120px" prop="telephone1"/>
      <el-table-column label="家长邮政编码1" align="center" min-width="120px" prop="postalCode1"/>
      <el-table-column label="家长姓名2" align="center" prop="parentName2"/>
      <el-table-column label="家长关系2" align="center" prop="relationship2">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.relationship" :value="scope.row.relationship2"/>
        </template>
      </el-table-column>
      <el-table-column label="家长工作单位2" min-width="120px" align="center" prop="workAddress2"/>
      <el-table-column label="家长联系地址2" min-width="120px" align="center" prop="contactAddress2"/>
      <el-table-column label="家长联系电话2" min-width="120px" align="center" prop="telephone2"/>
      <el-table-column label="家长邮政编码2" min-width="120px" align="center" prop="postalCode2"/>
      <el-table-column label="操作" fixed="right" min-width="150" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button v-if="infoType==0" size="mini" type="text" icon="el-icon-edit"
                     @click="handleUpdate(scope.row)">修改
          </el-button>
          <el-button v-if="infoType==0" size="mini" type="text" icon="el-icon-delete"
                     @click="handleDelete(scope.row)">删除
          </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="dialogTitle" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="姓名" prop="studentName">
              <el-input v-model.trim="form.studentName" placeholder="请输入学生姓名"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="身份证号" prop="idCard">
              <el-input v-model.trim="form.idCard" @change="go" placeholder="请输入身份证号"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="注册序号" prop="schoolNo">
              <el-input v-model.trim="form.schoolNo" placeholder="请输入注册序号"/>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="性别" prop="sex">
              <el-select v-model="form.sex" disabled style="width: 100%" placeholder="请选择性别">
                <el-option
                  v-for="dict in dict.type.sys_user_sex"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value">
                </el-option>
              </el-select>

            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出生日期" prop="birthday">
              <el-date-picker clearable disabled v-model="form.birthday" style="width: 100%" type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择出生日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="民族" prop="nation">
              <el-select v-model="form.nation" style="width: 100%" placeholder="请选择民族">
                <el-option
                  v-for="item in Nations"
                  :key="item.label"
                  :label="item.label"
                  :value="item.label"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="省学籍辅号" prop="provincialNumber">
              <el-input v-model="form.provincialNumber" placeholder="请输入省学籍辅号"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="全国学籍号" prop="nationalNumber">
              <el-input v-model="form.nationalNumber" placeholder="请输入全国学籍号"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="联系电话" prop="stuTelephone">
              <el-input v-model="form.stuTelephone" placeholder="请输入联系电话"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="现住地址" prop="homeAddress">
              <el-input v-model="form.homeAddress" placeholder="请输入现住地址"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="通讯地址" prop="postalAddress">
              <el-input v-model="form.postalAddress" placeholder="请输入通讯地址"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="出生地" prop="birthAddress">
              <el-input v-model="form.birthAddress" placeholder="请输入出生地"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="邮政编码" prop="postalCode">
              <el-input v-model="form.postalCode" placeholder="请输入邮政编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="籍贯" prop="nativePlace">
              <el-input v-model="form.nativePlace" placeholder="请输入籍贯"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="户口所在地" prop="registeredAddress">
              <el-input v-model="form.registeredAddress" placeholder="请输入户口所在地"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="户口性质" prop="registeredType">
              <el-select v-model="form.registeredType" style="width: 100%" placeholder="请输入户口性质">
                <el-option
                  v-for="dict in dict.type.regist_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="初中学校" prop="juniorSchool">
              <el-input v-model="form.juniorSchool" placeholder="请输入初中学校"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="国家地区" prop="region">
              <el-input v-model="form.region" placeholder="请输入国家地区"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="外语语种" prop="foreignLanguages">
              <el-input v-model="form.foreignLanguages" placeholder="请输入外语语种"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="政治面貌" prop="appearance">
              <el-select v-model="form.appearance" style="width: 100%" placeholder="请选择政治面貌">
                <el-option v-for="dict in dict.type.politics_tatus" :key="dict.value" :label="dict.label"
                           :value="dict.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="血型" prop="bloodType">
              <el-input v-model="form.bloodType" placeholder="请输入血型"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="健康状况" prop="health">
              <el-input v-model="form.health" placeholder="请输入健康状况"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="港澳台侨" prop="otherRegions">
              <el-input v-model="form.otherRegions" placeholder="请输入港澳台侨"/>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="流动人口状况" prop="floatingPopulation">
              <el-input v-model="form.floatingPopulation" placeholder="请输入流动人口状况"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="独生子女" prop="onlyChild">
              <el-select v-model="form.onlyChild" style="width: 100%" placeholder="请选择独生子女状况">
                <el-option
                  v-for="dict in dict.type.only_child"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value">
                </el-option>
              </el-select>

            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="性质" prop="nature">
              <el-select v-model="form.nature" style="width: 100%" placeholder="请输入性质">
                <el-option
                  v-for="dict in dict.type.student_nature"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="接受资助状况" prop="support">
              <el-input v-model="form.support" placeholder="请输入接受资助状况"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="家长姓名1" prop="parentName1">
              <el-input v-model="form.parentName1" placeholder="请输入家长姓名"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="家长关系1 " prop="relationship1">
              <el-select v-model="form.relationship1" style="width: 100%" placeholder="请选择家长关系1">
                <el-option
                  v-for="dict in dict.type.relationship"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="家长工作单位1" prop="workAddress1">
              <el-input v-model="form.workAddress1" placeholder="请输入家长工作单位"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="家长联系地址1" prop="contactAddress1">
              <el-input v-model="form.contactAddress1" placeholder="请输入家长联系地址"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="家长联系电话1" prop="telephone1">
              <el-input v-model="form.telephone1" placeholder="请输入家长联系电话"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="家长邮政编码1" prop="postalCode1">
              <el-input v-model="form.postalCode1" placeholder="请输入家长邮政编码"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="家长姓名2" prop="parentName2">
              <el-input v-model="form.parentName2" placeholder="请输入家长姓名"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="家长关系2 " prop="relationship2">
              <el-select v-model="form.relationship2" style="width: 100%" placeholder="请选择家长关系2">
                <el-option
                  v-for="dict in dict.type.relationship"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="家长工作单位2" prop="workAddress2">
              <el-input v-model="form.workAddress2" placeholder="请输入家长工作单位"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="家长联系地址2" prop="contactAddress2">
              <el-input v-model="form.contactAddress2" placeholder="请输入家长联系地址"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="家长联系电话2" prop="telephone2">
              <el-input v-model="form.telephone2" placeholder="请输入家长联系电话"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="家长邮政编码2" prop="postalCode2">
              <el-input v-model="form.postalCode2" placeholder="请输入家长邮政编码"/>
            </el-form-item>
          </el-col>
        </el-row>
      </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 title="数据导入" :visible.sync="openUpload" width="400px" append-to-body>
      <el-upload
        ref="upload" :limit="1" accept=".xlsx, .xls"
        action="#"
        v-loading="uploadLoading"
        :on-progress="handleFileUploadProgress"
        :http-request="requestUpload"
        :on-remove="handleUploadDelete"
        :file-list="upLoadFileList"
        drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
                   @click="importTemplate">下载模板
          </el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitUpload">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listDetail,
  getDetail,
  delDetail,
  addDetail,
  updateDetail,
  detailImport,
  detailExport,
  detailTemplate,
} from "@/api/smartSchool/teachAffairAdministration/acquisition/detail.js";
import {Nations} from "@/enums/common";

export default {
  name: "TeachAffairAcquisitionDataView",
  dicts: ['sys_user_sex', 'student_nature', 'regist_type', 'politics_tatus', 'only_child', 'relationship'],
  data() {
    return {
      upLoadFileList: [],
      fileData: undefined,
      uploadLoading: false,
      infoId: "",
      infoType: "",
      Nations,
      //
      openUpload: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      detailList: [],
      // 弹出层标题
      title: "",
      dialogTitle: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        infoId: null,
        studentName: null,
        idCard: null,
        schoolNo: null,
        sex: null,
        birthday: null,
        nation: null,
        provincialNumber: null,
        nationalNumber: null,
        stuTelephone: null,
        homeAddress: null,
        postalAddress: null,
        birthAddress: null,
        postalCode: null,
        nativePlace: null,
        registeredAddress: null,
        registeredType: null,
        juniorSchool: null,
        region: null,
        foreignLanguages: null,
        appearance: null,
        bloodType: null,
        health: null,
        otherRegions: null,
        floatingPopulation: null,
        onlyChild: null,
        nature: null,
        support: null,
        parentName1: null,
        relationship1: null,
        workAddress1: null,
        contactAddress1: null,
        telephone1: null,
        postalCode1: null,
        parentName2: null,
        relationship2: null,
        workAddress2: null,
        contactAddress2: null,
        telephone2: null,
        postalCode2: null,
      },
      // 表单参数
      form: {},
      // area: {
      //   11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江",
      //   31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北",
      //   43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏",
      //   61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外"
      // },
      // 表单校验
      rules: {
        studentName: [
          {required: true, message: "学生姓名不能为空", trigger: "blur"}
        ],
        idCard: [
          {required: true, message: "身份证号不能为空", trigger: "blur"}
        ],
        schoolNo: [
          {required: true, message: "注册序号不能为空", trigger: "blur"}
        ],

      }
    };
  },
  created() {
    this.infoId = this.$route.query && this.$route.query.infoId
    this.infoType = this.$route.query && this.$route.query.infoType
    this.title = this.$route.query && this.$route.query.title
    this.getList();
  },
  activated() {
    this.infoId = this.$route.query && this.$route.query.infoId
    this.infoType = this.$route.query && this.$route.query.infoType
    this.title = this.$route.query && this.$route.query.title
    this.getList();
  },
  methods: {
    getList() {
      this.loading = false;
      this.loading = true;
      listDetail(this.queryParams, this.infoId).then(response => {
        this.detailList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    // 实现自动生成生日，性别，年龄
    go(val) {
      let iden = this.form.idCard;
      let sex = null;
      let birth = null;
      let myDate = new Date();
      let month = myDate.getMonth() + 1;
      let day = myDate.getDate();
      let age = 0;

      if (val.length === 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.length === 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 = '1';
      else
        sex = '0';
      this.form.sex = sex;
      // this.form.age = age;
      this.form.birthday = birth;
      // this.form.nativePlace = this.area[iden.substring(0, 2)];
    },


    // 取消按钮
    cancel() {
      this.open = false;
      this.openUpload = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        infoId: null,
        studentName: null,
        idCard: null,
        schoolNo: null,
        sex: null,
        birthday: null,
        nation: null,
        provincialNumber: null,
        nationalNumber: null,
        stuTelephone: null,
        homeAddress: null,
        postalAddress: null,
        birthAddress: null,
        postalCode: null,
        nativePlace: null,
        registeredAddress: null,
        registeredType: null,
        juniorSchool: null,
        region: null,
        foreignLanguages: null,
        appearance: null,
        bloodType: null,
        health: null,
        otherRegions: null,
        floatingPopulation: null,
        onlyChild: null,
        nature: null,
        support: null,
        parentName1: null,
        relationship1: null,
        workAddress1: null,
        contactAddress1: null,
        telephone1: null,
        postalCode1: null,
        parentName2: null,
        relationship2: null,
        workAddress2: null,
        contactAddress2: null,
        telephone2: null,
        postalCode2: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        delFlag: 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.dialogTitle = "添加";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getDetail(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.dialogTitle = "修改数据";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateDetail(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addDetail(this.form, this.infoId).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除所选的数据项？').then(function () {
        return delDetail(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('schoolInfo/export/' + this.infoId, {
        ...this.queryParams
      }, `信息发布详细数据${new Date().getTime()}.xlsx`)
    },
    // 下载模板
    importTemplate() {
      this.download(
        "/schoolInfo/importTemplate",
        {},
        `信息发布详细数据.xlsx`
      );
    },
    // 导入
    requestUpload(file) {
      this.fileData = file.file;
    },
    // 上传
    handleUpload() {
      // this.title = "上传文件"
      this.openUpload = true
    },
    /** 上传过程 */
    handleFileUploadProgress() {
      this.uploadLoading = true;
    },
    // 确定上传
    submitUpload() {
      const formData = new FormData();
      formData.append('file', this.fileData);
      this.uploadLoading = true;
      detailImport(formData, this.infoId).then(response => {
        this.uploadLoading = false;
        this.$modal.msgSuccess('上传成功');
        this.fileData = undefined
        this.upLoadFileList = []
        this.getList()
        this.openUpload = false
      }).catch(error => {
        this.uploadLoading = false;
      })
    },
    // 删除图片
    handleUploadDelete(file, fileList) {
      console.log(file, 88888888)
      console.log(fileList, 9999999999)
    },
  }
};
</script>
<style scoped lang="less">
.fixed-scroll-error {
  .el-table--scrollable-x .el-table__body-wrapper {
    z-index: 2;
  }
}


</style>
