table.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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="getUserAvatar(item.person.avatar, item.person.sex)"></v-avatar>
  21. </v-badge>
  22. <span class="defaultLink ml-3">{{ item?.person?.name }}</span>
  23. </div>
  24. </template>
  25. <template v-slot:item.status="{ item }">
  26. <span v-if="tab === 0">{{ item.status && item.status === '0' ? '未查看' : '已查看' }}</span>
  27. <span v-else>{{ item.status ? props.statusList.find(i => i.value === item.status).label : '' }}</span>
  28. </template>
  29. <template v-slot:item.actions="{ item }">
  30. <v-btn v-if="tab === 0" color="primary" variant="text" @click="handlePreviewResume(item)">查看附件</v-btn>
  31. <!-- <v-btn v-if="tab === 0" color="primary" variant="text" @click="handleInterviewInvite(item)">邀请面试</v-btn> -->
  32. <v-btn v-if="tab === 0 || tab === 1" color="primary" variant="text" @click="handleEliminate(item)">不合适</v-btn>
  33. <v-btn v-if="tab === 1 && (item.status === '3' || item.status === '4')" color="primary" variant="text" @click="handleEnterByEnterprise(item)">入职</v-btn>
  34. <v-btn v-if="tab === 4" color="primary" variant="text" @click="handleCancelEliminate(item)">取消不合适</v-btn>
  35. <v-btn v-if="tab === 2 && item?.job?.hire" color="primary" variant="text" @click="handleSettlement(item)">结算</v-btn>
  36. </template>
  37. </v-data-table>
  38. <!-- 邀请面试 -->
  39. <CtDialog :visible="showInvite" :widthType="2" titleClass="text-h6" title="面试信息" @close="handleEditClose" @submit="handleEditSubmit">
  40. <InvitePage v-if="showInvite" ref="inviteRef" :itemData="itemData"></InvitePage>
  41. <!-- <PublicPage v-if="showInvite && inviteType" ref="publicRef" :item-data="itemData"></PublicPage> -->
  42. </CtDialog>
  43. </div>
  44. </template>
  45. <script setup>
  46. defineOptions({ name: 'table-page'})
  47. import { ref, computed, watch } from 'vue'
  48. import { previewFile } from '@/utils'
  49. import { personJobCvLook, joinEliminate, personEntryByEnterprise, personCvUnfitCancel } from '@/api/recruit/enterprise/personnel'
  50. import { saveInterviewInvite } from '@/api/recruit/enterprise/interview'
  51. import { hireJobCvRelSettlement } from '@/api/recruit/public/delivery'
  52. import { useI18n } from '@/hooks/web/useI18n'
  53. import { useUserStore } from '@/store/user'
  54. import Snackbar from '@/plugins/snackbar'
  55. import InvitePage from './invite.vue'
  56. import { getUserAvatar } from '@/utils/avatar'
  57. // import PublicPage from './public.vue'
  58. const { t } = useI18n()
  59. const emit = defineEmits(['refresh'])
  60. const props = defineProps({
  61. tab: Number,
  62. items: Array,
  63. statusList: Array
  64. })
  65. const badgeColor = computed(() => (item) => {
  66. return (item.person && item.person.sex) ? (item.person.sex === '1' ? '#1867c0' : 'error') : 'error'
  67. })
  68. const badgeIcon = computed(() => (item) => {
  69. return (item.person && item.person.sex) ? (item.person.sex === '1' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'
  70. })
  71. const userStore = useUserStore()
  72. const inviteRef = ref()
  73. // const publicRef = ref()
  74. const showInvite = ref(false)
  75. const headers = ref([
  76. { title: '姓名', value: 'name', sortable: false },
  77. { title: '应聘职位', value: 'job.name', sortable: false },
  78. { title: '求职状态', key: 'person.jobStatusName', sortable: false },
  79. { title: '工作经验', key: 'person.expName', sortable: false },
  80. { title: '最高学历', key: 'person.eduName', sortable: false },
  81. { title: '岗位薪资', key: 'job', value: item => `${item.job.payFrom}-${item.job.payTo}/${item.job.payName}`, sortable: false },
  82. { title: '状态', key: 'status', sortable: false },
  83. { title: '操作', value: 'actions', sortable: false }
  84. ])
  85. const unfit = { title: '类型', key: 'unfitType', sortable: false, value: item => item.type === '0' ? '简历不适合' : '面试不适合' }
  86. const delivery = { title: '类型', key: 'deliveryType', sortable: false, value: item => item.type === '0' ? '普通职位' : '赏金职位' }
  87. const list = [0, 4]
  88. watch(
  89. () => props.tab,
  90. (val) => {
  91. if (list.indexOf(val) !== -1) {
  92. headers.value.splice(-1, 0, val === 0 ? delivery : unfit)
  93. } else {
  94. const index = headers.value.indexOf(item => item.key === val === 0 ? 'deliveryType' : 'unfitType')
  95. if (index !== -1) headers.value.splice(index, 1)
  96. }
  97. // 不合适不需要展示状态
  98. if (val === 4) {
  99. const obj = headers.value.find(e => e.key === 'status')
  100. const i = headers.value.indexOf(obj)
  101. if (i !== -1) headers.value.splice(i, 1)
  102. }
  103. },
  104. { immediate: true }
  105. )
  106. // 人才详情
  107. const handleToPersonDetail = ({ userId, id }) => {
  108. if (!userId || !id) return
  109. window.open(`/recruit/enterprise/talentPool/details/${userId}?id=${id}`)
  110. }
  111. // 入职
  112. const handleEnterByEnterprise = async (item) => {
  113. if (!item.id) return
  114. await personEntryByEnterprise(item.id)
  115. Snackbar.success(t('common.operationSuccessful'))
  116. emit('refresh')
  117. }
  118. // 不合适
  119. const handleEliminate = async (item) => {
  120. if (!item.id || !item?.job?.id) return
  121. const query = {
  122. bizId: item.id,
  123. jobId: item.job.id,
  124. userId: item.userId,
  125. type: props.tab === 0 ? '0' : '1' // 投递简历0 已邀约1
  126. }
  127. await joinEliminate(query)
  128. Snackbar.success(t('common.operationSuccessful'))
  129. emit('refresh')
  130. }
  131. // 取消不合适
  132. const handleCancelEliminate = async (item) => {
  133. if (!item.id) return
  134. await personCvUnfitCancel(item.id)
  135. Snackbar.success(t('common.operationSuccessful'))
  136. emit('refresh')
  137. }
  138. // 查看简历
  139. const handlePreviewResume = async ({ url, id }) => {
  140. if (!url || !id) return
  141. await personJobCvLook(id)
  142. previewFile(url)
  143. }
  144. // 邀请面试
  145. const itemData = ref({})
  146. // const inviteType = ref(false)
  147. // const handleInterviewInvite = (item) => {
  148. // // if (item?.job?.hire) inviteType.value = true
  149. // itemData.value = item
  150. // showInvite.value = true
  151. // }
  152. const handleEditClose = () => {
  153. showInvite.value = false
  154. // inviteType.value = false
  155. itemData.value = {}
  156. }
  157. const handleEditSubmit = async () => {
  158. // if (inviteType.value) return
  159. const { valid } = await inviteRef.value.CtFormRef.formRef.validate()
  160. if (!valid) return
  161. const query = inviteRef.value.getQuery()
  162. if (!query?.time) return Snackbar.warning('请选择面试时间')
  163. await saveInterviewInvite(query)
  164. Snackbar.success(t('common.operationSuccessful'))
  165. handleEditClose()
  166. emit('refresh')
  167. }
  168. // 结算
  169. const handleSettlement = async (item) => {
  170. if (!item.id) return
  171. await hireJobCvRelSettlement(item.id)
  172. Snackbar.success(t('common.operationSuccessful'))
  173. emit('refresh')
  174. // 更新账户信息
  175. setTimeout(async () => {
  176. await userStore.getEnterpriseUserAccountInfo()
  177. }, 2000)
  178. }
  179. </script>
  180. <style scoped lang="scss">
  181. :deep(.v-table > .v-table__wrapper > table > thead) {
  182. background-color: #f7f8fa !important;
  183. }
  184. :deep(.v-selection-control__input) {
  185. color: var(--v-primary-base) !important;
  186. }
  187. </style>