<template>
  <el-table v-loading="loading" :data="tableData" :stripe="true" class="m-t-20px">
    <el-table-column label="企业名称" align="center" prop="enterpriseName" />
    <el-table-column label="职位名称" align="center" prop="positionName" />
    <el-table-column label="在职时间范围" align="center" prop="startTime">
      <template #default="{ row }">
        {{ timesTampChange(row.startTime, 'Y-M') + ' 到 ' + (row.endTime ? timesTampChange(row.endTime, 'Y-M') : '至今') }}
      </template>
    </el-table-column>
    <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: 'PersonExpList'})
import { PersonInfoApi } from '@/api/menduner/system/person'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter2 } from '@/utils/formatTime'
import { timesTampChange } from '@/utils/transform/date'

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.getPersonExpPage(queryParams)
    tableData.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}
getList()
</script>
