<template>
  <div>
    <div v-if="items.length">
      <LongStrip :items="items" :showCancelBtn="true" @refresh="getPositionList"></LongStrip>
      <CtPagination
        :total="total"
        :page="page.pageNo"
        :limit="page.pageSize"
        @handleChange="handleChangePage"
      ></CtPagination>
    </div>
    <Empty v-else></Empty>
  </div>
</template>

<script setup>
// 感兴趣-职位收藏
defineOptions({ name: 'position-collection' })
import { ref } from 'vue'
import { dealDictObjData } from '@/views/recruit/position/components/dict'
import { getJobFavoriteList } from '@/api/position'

const total = ref(0)
const items = ref([])
const page = ref({
  pageNo: 1,
  pageSize: 10
})


// 获取收藏职位列表
const getPositionList = async () => {
  const { list, total: number } = await getJobFavoriteList(page.value)
  items.value = list.map(e => {
    e.job = { ...e.job, ...dealDictObjData({}, e.job) }
    e.enterprise = { ...e.enterprise, ...dealDictObjData({}, e.enterprise)}
    e.active = false
    return e
  })
  total.value = number
}
getPositionList()

const handleChangePage = (index) => {
  page.value.pageNo = index
  getPositionList()
}
</script>

<style scoped lang="scss">

</style>
