<template>
  <el-table v-loading="loading" :data="tableData" :stripe="true" class="m-t-20px">
    <el-table-column label="期望职位" align="center" prop="positionName" />
    <el-table-column label="期望行业" align="center" prop="industryNameList">
      <template #default="scope">
        {{  scope.row.industryNameList && scope.row.industryNameList.length ? scope.row.industryNameList.join('，') : '' }}
      </template>
    </el-table-column>
    <el-table-column label="薪酬最低要求" align="center" prop="payFrom" />
    <el-table-column label="薪酬最高要求" align="center" prop="payTo" />
    <el-table-column label="求职类型" align="center" prop="jobType">
      <template #default="scope">
        <dict-tag :type="DICT_TYPE.MENDUNER_JOB_TYPE" :value="scope.row.jobType" />
      </template>
    </el-table-column>
    <el-table-column label="工作城市" align="center" prop="workAreaName" />
    <el-table-column label="其它感兴趣城市" align="center" prop="interestedAreaNameList">
      <template #default="scope">
        {{  scope.row.interestedAreaNameList && scope.row.interestedAreaNameList.length ? scope.row.interestedAreaNameList.join('，') : '' }}
      </template>
    </el-table-column>
    <el-table-column
      label="创建时间"
      align="center"
      prop="createTime"
      :formatter="dateFormatter"
      width="180px"
    />
  </el-table>

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

<script setup>
defineOptions({ name: 'PersonJobIntentionList'})
import { PersonInfoApi } from '@/api/menduner/system/person'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } 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.getPersonJobIntentionPage(queryParams)
    tableData.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}
getList()
</script>
