table.vue 7.7 KB

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