index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 class="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 :value="1"> {{ $t('position.recruitmentInProgress') }}</v-tab>
  13. <v-tab :value="2"> {{ $t('position.closed') }}</v-tab>
  14. <v-tab :value="3"> {{ $t('position.expiredPosition') }}</v-tab>
  15. </v-tabs>
  16. <v-window v-model="tab" class="mt-1">
  17. <v-window-item :value="1">
  18. <PositionItem v-if="items.length" :tab="tab" :items="items" @refresh="getPositionList"></PositionItem>
  19. </v-window-item>
  20. <v-window-item :value="2">
  21. <PositionItem v-if="items.length" :tab="tab" :items="items" @refresh="getPositionList"></PositionItem>
  22. </v-window-item>
  23. <v-window-item :value="3">
  24. <PositionItem v-if="items.length" :tab="tab" :items="items"></PositionItem>
  25. </v-window-item>
  26. </v-window>
  27. <Empty v-if="!items.length" :message="tipsText" :elevation="false"></Empty>
  28. <CtPagination
  29. v-else
  30. :total="total"
  31. :page="query.pageNo"
  32. :limit="query.pageSize"
  33. @handleChange="handleChangePage"
  34. ></CtPagination>
  35. </div>
  36. </v-card>
  37. </div>
  38. </template>
  39. <script setup>
  40. defineOptions({ name: 'enterprise-position-list'})
  41. import { ref } from 'vue'
  42. import TextUI from '@/components/FormUI/TextInput'
  43. import PositionItem from './components/item.vue'
  44. import { useRouter } from 'vue-router'
  45. import { getJobAdvertisedList } from '@/api/position'
  46. import { dealDictArrayData } from '@/views/recruit/position/components/dict'
  47. const router = useRouter()
  48. const tab = ref(1)
  49. const total = ref(0)
  50. const tipsText = ref('暂无数据')
  51. const query = ref({
  52. pageSize: 10,
  53. pageNo: 1
  54. })
  55. const items = ref([])
  56. const textItem = ref({
  57. type: 'text',
  58. width: 600,
  59. value: '',
  60. label: '请输入职位名称',
  61. appendInnerIcon: 'mdi-magnify'
  62. })
  63. const handleAdd = () => {
  64. router.push('/enterprise/position/add')
  65. }
  66. // 获取职位列表
  67. const getPositionList = async () => {
  68. query.value.hasExpiredData = tab.value === 3 ? true : false
  69. if (tab.value === 2) query.value.status = 1
  70. else delete query.value.status
  71. const { list, total: number } = await getJobAdvertisedList(query.value)
  72. if (!list.length) {
  73. if (query.value.name) tipsText.value = '暂无数据,请更换关键词后再试'
  74. }
  75. total.value = number
  76. items.value = list.length ? dealDictArrayData([], list) : []
  77. }
  78. getPositionList()
  79. const handleChangeTab = () => {
  80. query.value.pageNo = 1
  81. getPositionList()
  82. }
  83. const handleChangePage = (index) => {
  84. query.value.pageNo = index
  85. getPositionList()
  86. }
  87. // 职位名称检索
  88. const handleEnter = (e) => {
  89. query.value.name = e
  90. query.value.pageNo = 1
  91. getPositionList()
  92. }
  93. </script>
  94. <style scoped lang="scss">
  95. .card-box {
  96. width: 100%;
  97. height: 100%;
  98. }
  99. .btn {
  100. width: 116px;
  101. }
  102. </style>