<template>
  <el-table v-loading="loading" :data="tableData" :stripe="true" class="m-t-20px">
    <el-table-column label="学校名称" align="center" prop="schoolName" />
    <el-table-column label="专业名称" align="center" prop="major" />
    <el-table-column label="学历" align="center" prop="educationType">
      <template #default="scope">
        <dict-tag :type="DICT_TYPE.MENDUNER_EDUCATION_TYPE" :value="scope.row.educationType" />
      </template>
    </el-table-column>
    <el-table-column label="学制类型" align="center" prop="educationSystemType">
      <template #default="scope">
        <dict-tag :type="DICT_TYPE.MENDUNER_EDUCATION_SYSTEM_TYPE" :value="scope.row.educationSystemType" />
      </template>
    </el-table-column>
    <el-table-column
      label="在校开始日期"
      align="center"
      prop="startTime"
      :formatter="dateFormatter2"
      width="180px"
    />
    <el-table-column
      label="在校结束日期"
      align="center"
      prop="endTime"
      :formatter="dateFormatter2"
      width="180px"
    />
    <el-table-column label="在校经历" align="center" prop="content" :show-overflow-tooltip="true" />
  </el-table>

  <Pagination
    :total="total"
    v-model:page="queryParams.pageNo"
    v-model:limit="queryParams.pageSize"
    @pagination="getList"
  />
</template>

<script setup>
defineOptions({ name: 'PersonEduList'})
import { PersonInfoApi } from '@/api/menduner/system/person'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter2 } from '@/utils/formatTime'

const props = defineProps({
  userId: String
})

const loading = ref(false)
const tableData = ref([])
const total = ref(0)
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  userId: props.userId
})

const getList = async () => {
  loading.value = true
  try {
    const data = await PersonInfoApi.getPersonEduPage(queryParams)
    tableData.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}
getList()
</script>
