table.vue 8.2 KB

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