<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="家长姓名" prop="parentName">
        <el-input
          v-model="queryParams.parentName"
          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="telephone">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.telephone"-->
      <!--          placeholder="请输入电话"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="家长身份证号" prop="idCard">
        <el-input
          v-model="queryParams.idCard"
          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-table v-loading="loading" :data="parentList">
      <el-table-column label="序号" align="center" type="index"/>
      <el-table-column label="家长姓名" align="center" prop="parentName"/>
      <el-table-column label="电话号码" align="center" prop="telephone"/>
      <el-table-column label="身份证号" align="center" prop="idCard" min-width="120"/>
      <el-table-column label="关系" align="center" prop="relationship">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.relationship" :value="scope.row.relationship"/>
        </template>
      </el-table-column>
      <el-table-column label="学生姓名" align="center" prop="studentName"/>
      <el-table-column label="学生身份证号" align="center" min-width="120" prop="stuIdCard"/>
      <el-table-column label="学生班级" align="center" prop="classAlias"/>
      <el-table-column label="工作地址" align="center" prop="workAddress" min-width="120"/>
      <el-table-column label="联系地址" align="center" prop="contactAddress" min-width="120"/>
      <el-table-column label="邮政编码" align="center" prop="postalCode" min-width="120"/>
    </el-table>

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

<script>
import {
  listParent
} from "@/api/smartSchool/teachAffairAdministration/affairParentInformtion";

export default {
  name: "index",
  dicts: ["relationship"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 学生家长信息表格数据
      parentList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        parentName: null,
        idCard: null,
        studentName: null,
        stuIdCard: null,
        // telephone: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询学生家长信息列表 */
    getList() {
      this.loading = true;
      listParent(this.queryParams).then(response => {
        this.parentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/parent/export', {
        ...this.queryParams
      }, `parent_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
