<template>
  <div class="app-container">
    <el-table :data="parentList" style="width: 100%">
      <el-table-column prop="parentName" label="家长姓名"></el-table-column>
      <el-table-column prop="telephone" label="电话号码"></el-table-column>
      <el-table-column prop="relationship" label="关系">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.relationship" :value="scope.row.relationship"/>
        </template>
      </el-table-column>
      <el-table-column prop="idCard" label="身份证号"></el-table-column>
      <el-table-column align="center" prop="workAddress" label="工作地址"/>
      <el-table-column align="center" prop="contactAddress" label="联系地址"/>
      <el-table-column align="center" prop="postalCode" label="邮政编码"/>
    </el-table>
  </div>
</template>

<script>
import {getParentInfo} from '@/api/smartSchool/gradeWork/classView'

export default {
  name: 'index',
  dicts: ['relationship'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 学生家长信息表格数据
      parentList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      id: undefined
    }
  },
  created() {
    this.id = this.$route.query && this.$route.query.studentId
    this.getList()
  },
  activated() {
    this.id = this.$route.query && this.$route.query.studentId
    this.getList()
  },

  methods: {
    /** 查询学生家长信息列表 */
    getList() {
      this.loading = true
      getParentInfo(this.id).then(response => {
        this.parentList = response.rows
        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>
