index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. const { t } = useI18n()
  42. const total = ref(0)
  43. const tipsText = ref(t('common.noData'))
  44. const query = ref({
  45. pageSize: 10,
  46. pageNo: 1,
  47. status: 0, // 0招聘中 1已关闭
  48. hasExpiredData: false, // true 到期职位
  49. hire: false // true 众聘岗位
  50. })
  51. const tab = ref(route.query?.hire ? 4: 1)
  52. if (route.query?.hire) router.replace({ path: route.path, query: { ...route.query, hire: false } })
  53. const tabList = [
  54. { label: t('position.recruitmentInProgress'), value: 1 },
  55. { label: t('position.closed'), value: 2 },
  56. { label: t('position.expiredPosition'), value: 3 },
  57. { label: t('position.publicRecruitment'), value: 4 }
  58. ]
  59. const items = ref([])
  60. const textItem = ref({
  61. type: 'text',
  62. width: 600,
  63. value: '',
  64. label: '请输入职位名称',
  65. clearable: true,
  66. appendInnerIcon: 'mdi-magnify'
  67. })
  68. const handleAdd = () => {
  69. router.push('/recruit/enterprise/position/add')
  70. }
  71. // 获取职位列表
  72. const getPositionList = async () => {
  73. query.value.hasExpiredData = tab.value === 3 ? true : false
  74. query.value.hire = tab.value === 4 ? true : false
  75. if (tab.value !== 3) {
  76. query.value.status = tab.value === 1 ? 0 : (tab.value === 2 ? 1 : null)
  77. } else delete query.value.status
  78. const { list, total: number } = await getJobAdvertisedList(query.value)
  79. if (!list.length) {
  80. if (query.value.name) tipsText.value = '暂无数据,请更换关键词后再试'
  81. }
  82. total.value = number
  83. items.value = list.length ? dealDictArrayData([], list) : []
  84. }
  85. getPositionList()
  86. const handleChangeTab = () => {
  87. query.value.pageNo = 1
  88. getPositionList()
  89. }
  90. const handleChangePage = (index) => {
  91. query.value.pageNo = index
  92. getPositionList()
  93. }
  94. // 职位名称检索
  95. const handleEnter = (e) => {
  96. query.value.name = e
  97. query.value.pageNo = 1
  98. getPositionList()
  99. }
  100. </script>
  101. <style scoped lang="scss">
  102. </style>