index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div>
  3. <v-card class="card-box pa-5">
  4. <div class="d-flex justify-center mt-3">
  5. <TextUI :item="textItem" @enter="handleEnter" @appendInnerClick="handleEnter"></TextUI>
  6. </div>
  7. <div class="text-end">
  8. <v-btn prepend-icon="mdi-plus" color="primary" @click="handleAdd">{{ $t('position.newPositionsAdded') }}</v-btn>
  9. </div>
  10. <div class="mt-3">
  11. <v-tabs v-model="tab" align-tabs="start" color="primary" bg-color="#f7f8fa" @update:model-value="handleChangeTab">
  12. <v-tab v-for="val in tabList" :key="val.value" :value="val.value"> {{ val.label }}</v-tab>
  13. </v-tabs>
  14. <v-window v-model="tab" class="mt-1">
  15. <v-window-item v-for="val in tabList" :key="val.value" :value="val.value">
  16. <PositionItem v-if="items.length" :tab="val.value" :items="items" @refresh="getPositionList"></PositionItem>
  17. </v-window-item>
  18. </v-window>
  19. <Empty v-if="!items.length" :message="tipsText" :elevation="false"></Empty>
  20. <CtPagination
  21. v-else
  22. :total="total"
  23. :page="query.pageNo"
  24. :limit="query.pageSize"
  25. @handleChange="handleChangePage"
  26. ></CtPagination>
  27. </div>
  28. </v-card>
  29. </div>
  30. </template>
  31. <script setup>
  32. defineOptions({ name: 'enterprise-position-list'})
  33. import { ref } from 'vue'
  34. import TextUI from '@/components/FormUI/TextInput'
  35. import PositionItem from './components/item.vue'
  36. import { useRoute } from 'vue-router'; const route = useRoute()
  37. import { useRouter } from 'vue-router'; const router = useRouter()
  38. import { getJobAdvertisedList } from '@/api/position'
  39. import { dealDictArrayData } from '@/utils/position'
  40. import { useI18n } from '@/hooks/web/useI18n'
  41. import { useUserStore } from '@/store/user'
  42. const store = useUserStore()
  43. const { t } = useI18n()
  44. const total = ref(0)
  45. const tipsText = ref(t('common.noData'))
  46. const query = ref({
  47. pageSize: 10,
  48. pageNo: 1,
  49. status: 0, // 0招聘中 1已关闭
  50. // hasExpiredData: false, // true 到期职位
  51. hire: false // true 众聘岗位
  52. })
  53. const showHire = (route.query?.hire - 0) || 0
  54. const tab = ref(showHire ? 4: 1)
  55. // if (showHire) history.replaceState({ ...route.query, hire: 0 }, '', route.path) // 更新浏览器历史记录,不触发页面重新加载 ( 目的:去除目标参数 )
  56. const tabList = [
  57. { label: t('position.recruitmentInProgress'), value: 1 },
  58. { label: t('position.closed'), value: 2 },
  59. // { label: t('position.expiredPosition'), value: 3 },
  60. { label: t('position.publicRecruitment'), value: 4 }
  61. ]
  62. const items = ref([])
  63. const textItem = ref({
  64. type: 'text',
  65. width: 600,
  66. value: '',
  67. label: '请输入职位名称',
  68. clearable: true,
  69. appendInnerIcon: 'mdi-magnify'
  70. })
  71. const handleAdd = async () => {
  72. router.push('/recruit/enterprise/position/add')
  73. await store.getEnterpriseUserAccountInfo()
  74. }
  75. // 获取职位列表
  76. const getPositionList = async () => {
  77. // query.value.hasExpiredData = tab.value === 4 ? true : false
  78. query.value.hire = tab.value === 4 ? true : false
  79. if (tab.value !== 3) {
  80. query.value.status = tab.value === 1 ? 0 : (tab.value === 2 ? 1 : null)
  81. }
  82. const { list, total: number } = await getJobAdvertisedList(query.value)
  83. if (!list.length) {
  84. if (query.value.name) tipsText.value = '暂无数据,请更换关键词后再试'
  85. }
  86. total.value = number
  87. items.value = list.length ? dealDictArrayData([], list) : []
  88. }
  89. getPositionList()
  90. const handleChangeTab = () => {
  91. query.value.pageNo = 1
  92. getPositionList()
  93. }
  94. const handleChangePage = (index) => {
  95. query.value.pageNo = index
  96. getPositionList()
  97. }
  98. // 职位名称检索
  99. const handleEnter = (e) => {
  100. query.value.name = e
  101. query.value.pageNo = 1
  102. getPositionList()
  103. }
  104. </script>
  105. <style scoped lang="scss">
  106. </style>