table.vue 6.0 KB

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