index.vue 3.7 KB

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