index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view class="box defaultBgc">
  3. <view style="background-color: #fff;">
  4. <uni-segmented-control
  5. :current="current"
  6. :values="tabList.map(e => e.label)"
  7. @clickItem="changeControl"
  8. styleType="text"
  9. activeColor="#00B760"
  10. ></uni-segmented-control>
  11. <!-- 条件搜索 -->
  12. <view style="margin: 20rpx;">
  13. <uni-data-select
  14. v-model="query.jobId"
  15. :clear="true"
  16. :localdata="jobList"
  17. @change="handleChangeJob"
  18. placeholder="招聘职位"
  19. ></uni-data-select>
  20. </view>
  21. </view>
  22. <scroll-view class="scrollBox" :scroll-y="true" @scrolltolower="loadingMore" style="position:relative;">
  23. <CardItem v-if="items?.length" :items="items" :statusList="tabList" @refresh="handleRefresh" />
  24. <uni-load-more :status="more" />
  25. </scroll-view>
  26. </view>
  27. </template>
  28. <script setup>
  29. import { ref } from 'vue'
  30. import CardItem from './components/item.vue'
  31. import { getInterviewInvitePage } from '@/api/interview'
  32. import { getJobAdvertised } from '@/api/search'
  33. import { onShow, onLoad } from '@dcloudio/uni-app'
  34. import { getDict } from '@/hooks/useDictionaries'
  35. import { formatName } from '@/utils/getText'
  36. const current = ref(0)
  37. const tabList = ref([])
  38. const more = ref('more')
  39. const total = ref(0)
  40. const items = ref([])
  41. const query = ref({
  42. pageNo: 1,
  43. pageSize: 10,
  44. status: null,
  45. jobId: null
  46. })
  47. // 职位列表
  48. const jobList = ref([])
  49. const getJobList = async () => {
  50. const { data } = await getJobAdvertised()
  51. if (data.length) {
  52. jobList.value = data.map(e => {
  53. return { text: `${formatName(e.name)}_${e.status === '1' ? '已关闭' : '招聘中'}`, value: e.id }
  54. })
  55. }
  56. }
  57. onLoad(() => {
  58. getDict('menduner_interview_invite_status').then(({ data }) => {
  59. tabList.value = data.data ?? []
  60. if (!tabList.value.length) return
  61. query.value.pageNo = 1
  62. getList()
  63. })
  64. getJobList()
  65. })
  66. // 获取面试列表
  67. const getList = async () => {
  68. more.value = 'loading'
  69. query.value.status = tabList.value[current.value].value
  70. try {
  71. const { data } = await getInterviewInvitePage(query.value)
  72. const { list, total: number } = data
  73. if (!list.length) {
  74. more.value = 'noMore'
  75. return
  76. }
  77. total.value = number
  78. items.value = items.value.concat(list)
  79. if (items.value.length === +number) {
  80. more.value = 'noMore'
  81. return
  82. }
  83. } catch {
  84. query.value.pageNo--
  85. more.value = 'more'
  86. }
  87. }
  88. onShow(() => {
  89. if (!tabList.value.length) return
  90. items.value = []
  91. query.value.pageNo = 1
  92. getList()
  93. })
  94. // 选择招聘中职位
  95. const handleChangeJob = () => {
  96. query.value.pageNo = 1
  97. items.value = []
  98. total.value = 0
  99. getList()
  100. }
  101. const handleRefresh = () => {
  102. items.value = []
  103. total.value = 0
  104. query.value.pageNo = 1
  105. getList()
  106. }
  107. const changeControl = (e) => {
  108. current.value = e.currentIndex
  109. handleRefresh()
  110. }
  111. // 加载更多
  112. const loadingMore = () => {
  113. if (more.value === 'noMore') return
  114. more.value = 'loading'
  115. query.value.pageNo++
  116. getList()
  117. }
  118. </script>
  119. <style scoped lang="scss">
  120. .box {
  121. height: 100vh;
  122. overflow: hidden;
  123. box-sizing: border-box;
  124. display: flex;
  125. flex-direction: column;
  126. }
  127. .scrollBox{
  128. flex: 1;
  129. padding-bottom: 24rpx;
  130. box-sizing: border-box;
  131. height: 0 !important;
  132. }
  133. :deep(.segmented-control) {
  134. overflow: auto;
  135. }
  136. :deep(.segmented-control__item) {
  137. white-space: nowrap !important;
  138. padding: 0 20rpx;
  139. }
  140. :deep(.uni-select__selector-item) {
  141. display: block !important;
  142. text-align: left !important;
  143. max-width: 100% !important;
  144. white-space: nowrap !important;
  145. text-overflow: ellipsis !important;
  146. overflow: hidden !important;
  147. }
  148. </style>