table.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div>
  3. <v-data-table
  4. class="mt-3"
  5. :items="items"
  6. :headers="headers"
  7. hover
  8. :disable-sort="true"
  9. height="60vh"
  10. no-data-text="暂无数据"
  11. item-value="id"
  12. >
  13. <template #bottom></template>
  14. <template v-slot:item.name="{ item }">
  15. <div class="d-flex align-center cursor-pointer" @click="handleToPersonDetail(item)">
  16. <v-badge
  17. v-if="item?.person?.sex === '1' || item?.person?.sex === '2'"
  18. bordered
  19. offset-y="6"
  20. :color="badgeColor(item)"
  21. :icon="badgeIcon(item)">
  22. <v-avatar size="40" :image="item.person.avatar || 'https://minio.citupro.com/dev/menduner/7.png'"></v-avatar>
  23. </v-badge>
  24. <v-avatar v-else size="40" :image="item.person.avatar || 'https://minio.citupro.com/dev/menduner/7.png'"></v-avatar>
  25. <span class="defaultLink ml-3">{{ item?.person?.name }}</span>
  26. </div>
  27. </template>
  28. <template v-slot:item.actions="{ item }">
  29. <div v-if="tab === 0">
  30. <v-btn color="primary" variant="text" @click="handlePreviewResume(item)">查看附件</v-btn>
  31. <v-btn color="primary" variant="text" @click="handleInterviewInvite(item)">邀请面试</v-btn>
  32. </div>
  33. <v-btn v-if="tab === 0 || tab === 1" color="primary" variant="text" @click="handleEliminate(item)">不合适</v-btn>
  34. <div v-if="tab === 1">
  35. <v-btn color="primary" variant="text" @click="handleEnterByEnterprise(item)">入职</v-btn>
  36. </div>
  37. <v-btn v-if="tab === 3" color="primary" variant="text" @click="handleCancelEliminate(item)">取消不合适</v-btn>
  38. </template>
  39. </v-data-table>
  40. <!-- 邀请面试 -->
  41. <CtDialog :visible="showInvite" :widthType="2" titleClass="text-h6" title="面试信息" @close="handleEditClose" @submit="handleEditSubmit">
  42. <InvitePage v-if="showInvite" ref="inviteRef" :itemData="itemData"></InvitePage>
  43. </CtDialog>
  44. </div>
  45. </template>
  46. <script setup>
  47. defineOptions({ name: 'table-page'})
  48. import { ref, computed, watch } from 'vue'
  49. import { previewFile } from '@/utils'
  50. import { personJobCvLook, joinEliminate, personEntryByEnterprise, personCvUnfitCancel } from '@/api/recruit/enterprise/personnel'
  51. import { saveInterviewInvite } from '@/api/recruit/enterprise/interview'
  52. import { useI18n } from '@/hooks/web/useI18n'
  53. import Snackbar from '@/plugins/snackbar'
  54. import InvitePage from './invite.vue'
  55. const { t } = useI18n()
  56. const emit = defineEmits(['refresh'])
  57. const props = defineProps({
  58. tab: Number,
  59. items: Array,
  60. statusList: Array
  61. })
  62. const badgeColor = computed(() => (item) => {
  63. return (item.person && item.person.sex) ? (item.person.sex === '1' ? '#1867c0' : 'error') : 'error'
  64. })
  65. const badgeIcon = computed(() => (item) => {
  66. return (item.person && item.person.sex) ? (item.person.sex === '1' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'
  67. })
  68. const inviteRef = ref()
  69. const showInvite = ref(false)
  70. const headers = ref([
  71. { title: '姓名', value: 'name', sortable: false },
  72. { title: '应聘职位', value: 'job.name', sortable: false },
  73. { title: '求职状态', key: 'person.jobStatusName', sortable: false },
  74. { title: '工作经验', key: 'person.expName', sortable: false },
  75. { title: '最高学历', key: 'person.eduName', sortable: false },
  76. { title: '岗位薪资', key: 'job', value: item => item.job.payFrom && item.job.payTo ? `${item.job.payFrom ? item.job.payFrom + '-' : ''}${item.job.payTo}${item.job.payName ? '/' + item.job.payName : ''}` : '面议', sortable: false },
  77. { title: '状态', key: 'status', sortable: false, value: item => item.status ? props.statusList.find(i => i.value === item.status).label : '' },
  78. { title: '操作', value: 'actions', sortable: false }
  79. ])
  80. const unfit = { title: '类型', key: 'unfitType', sortable: false, value: item => item.type === '0' ? '简历不合适' : '面试不合适' }
  81. const delivery = { title: '类型', key: 'deliveryType', sortable: false, value: item => item.status === '0' ? '新投递' : '已查看' }
  82. const list = [0, 3]
  83. watch(
  84. () => props.tab,
  85. (val) => {
  86. if (list.indexOf(val) !== -1) {
  87. headers.value.splice(-1, 0, val === 0 ? delivery : unfit)
  88. } else {
  89. const index = headers.value.indexOf(item => item.key === val === 0 ? 'deliveryType' : 'unfitType')
  90. if (index !== -1) headers.value.splice(index, 1)
  91. }
  92. },
  93. { immediate: true }
  94. )
  95. // 人才详情
  96. const handleToPersonDetail = ({ userId, id }) => {
  97. if (!userId || !id) return
  98. window.open(`/recruit/enterprise/talentPool/details/${userId}?id=${id}`)
  99. }
  100. // 入职
  101. const handleEnterByEnterprise = async (item) => {
  102. if (!item.id) return
  103. await personEntryByEnterprise(item.id)
  104. Snackbar.success(t('common.operationSuccessful'))
  105. emit('refresh')
  106. }
  107. // 不合适
  108. const handleEliminate = async (item) => {
  109. if (!item.id || !item?.job?.id) return
  110. const query = {
  111. bizId: item.id,
  112. jobId: item.job.id,
  113. userId: item.userId,
  114. type: props.tab === 0 ? '0' : '1' // 投递简历0 已邀约1
  115. }
  116. await joinEliminate(query)
  117. Snackbar.success(t('common.operationSuccessful'))
  118. emit('refresh')
  119. }
  120. // 取消不合适
  121. const handleCancelEliminate = async (item) => {
  122. if (!item.id) return
  123. await personCvUnfitCancel(item.id)
  124. Snackbar.success(t('common.operationSuccessful'))
  125. emit('refresh')
  126. }
  127. // 查看简历
  128. const handlePreviewResume = async ({ url, id }) => {
  129. if (!url || !id) return
  130. await personJobCvLook(id)
  131. previewFile(url)
  132. }
  133. // 邀请面试
  134. const itemData = ref({})
  135. const handleInterviewInvite = (item) => {
  136. itemData.value = item
  137. showInvite.value = true
  138. }
  139. const handleEditClose = () => {
  140. showInvite.value = false
  141. itemData.value = {}
  142. }
  143. const handleEditSubmit = async () => {
  144. const { valid } = await inviteRef.value.CtFormRef.formRef.validate()
  145. if (!valid) return
  146. const query = inviteRef.value.getQuery()
  147. if (!query?.time) return Snackbar.warning('请选择面试时间')
  148. await saveInterviewInvite(query)
  149. Snackbar.success(t('common.operationSuccessful'))
  150. handleEditClose()
  151. emit('refresh')
  152. }
  153. </script>
  154. <style scoped lang="scss">
  155. :deep(.v-table > .v-table__wrapper > table > thead) {
  156. background-color: #f7f8fa !important;
  157. }
  158. :deep(.v-selection-control__input) {
  159. color: var(--v-primary-base) !important;
  160. }
  161. </style>