<template>
  <el-card shadow="never">
    <template #header>
      <CardTitle :title="props.title" />
    </template>
		<el-table v-loading="loading" :data="list" :stripe="true">
			<el-table-column label="投递人" align="center" prop="person.name" />
      <el-table-column label="投递职位" align="center" prop="name">
        <template #default="scope">{{ formatName(scope.row.job.name) }}</template>
      </el-table-column>
			<el-table-column label="职位发布企业" align="center" prop="enterpriseName">
        <template #default="scope">{{ formatName(scope.row.enterpriseName) }}</template>
      </el-table-column>
			<el-table-column label="投递简历名" align="center" prop="title" />
      <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"
		/>
  </el-card>
</template>

<script lang="ts" setup>
defineOptions({name: 'UserJobDelivery'})
import { dateFormatter } from '@/utils/formatTime'
import { JobFairManageApi } from '@/api/menduner/system/jobFair/manage'
import { formatName } from '@/utils'

const props = defineProps({
  title: {
    type: String,
    default: () => ''
  },
  query: {
    type: Object,
    default: () => {}
  }
})

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

const getList = async () => {
	const result = await JobFairManageApi.getUserJobCvRel(Object.assign(queryParams, props.query))

	list.value = result.list
	total.value = result.total
}

watch(() => props.query, () => {
	getList()
}, { deep: true, immediate: true })
</script>
