index.vue 4.2 KB

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