table.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div>
  3. <CtTable
  4. class="mt-3"
  5. :items="items"
  6. :headers="headers"
  7. :loading="false"
  8. :elevation="0"
  9. height="60vh"
  10. :disableSort="true"
  11. :isTools="false"
  12. :showPage="true"
  13. :total="total"
  14. :page-info="pageInfo"
  15. itemKey="id"
  16. @pageHandleChange="e => emit('page', e)"
  17. >
  18. <template #name="{ item }">
  19. <div class="d-flex align-center cursor-pointer" @click="handleToPersonDetail(item)">
  20. <v-badge
  21. v-if="item?.person?.sex === '1' || item?.person?.sex === '2'"
  22. bordered
  23. offset-y="6"
  24. :color="badgeColor(item)"
  25. :icon="badgeIcon(item)">
  26. <v-avatar size="40" :image="getUserAvatar(item.person.avatar, item.person.sex)"></v-avatar>
  27. </v-badge>
  28. <v-avatar v-else size="40" :image="getUserAvatar(item.person.avatar, item.person.sex)"></v-avatar>
  29. <span class="defaultLink ml-3">{{ item?.person?.name }}</span>
  30. </div>
  31. </template>
  32. <template #status="{ item }">
  33. <span v-if="tab === 0">{{ item.status && item.status === '0' ? '未查看' : '已查看' }}</span>
  34. <span v-else>{{ item.status ? props.statusList.find(i => i.value === item.status)?.label : '' }}</span>
  35. </template>
  36. <template #actions="{ item }">
  37. <v-btn v-if="tab === 0" color="primary" variant="text" @click="handlePreviewResume(item)">查看附件</v-btn>
  38. <v-btn v-if="tab === 0" :color="item.jobClosed ? 'grey' : 'primary'" variant="text" @click="handleInterviewInvite(item)">邀请面试<v-tooltip v-if="item.jobClosed" activator="parent" location="top">职位已关闭</v-tooltip></v-btn>
  39. <v-btn v-if="tab === 0" :color="item.jobClosed ? 'grey' : 'primary'" variant="text" @click="handleToCommunicate(item)">立即沟通<v-tooltip v-if="item.jobClosed" activator="parent" location="top">职位已关闭</v-tooltip></v-btn>
  40. <v-btn v-if="tab === 0 || tab === 1" color="primary" variant="text" @click="handleEliminate(item)">不合适</v-btn>
  41. <v-btn v-if="!item.inTalentPool && (tab === 1 || tab === 2 || tab === 3)" color="primary" variant="text" @click="handleJoinToTalentPool(item)">加入储备</v-btn>
  42. <v-btn v-if="tab === 1 && (item.status === '3' || item.status === '4')" color="primary" variant="text" @click="handleEnterByEnterprise(item)">入职</v-btn>
  43. <v-btn v-if="tab === 4" color="primary" variant="text" @click="handleCancelEliminate(item)">取消不合适</v-btn>
  44. <v-btn v-if="tab === 2 && item?.job?.hire" color="primary" variant="text" @click="handleSettlement(item)">结算</v-btn>
  45. </template>
  46. </CtTable>
  47. <!-- 邀请面试 -->
  48. <CtDialog :visible="showInvite" :widthType="4" titleClass="text-h6" title="面试信息" @close="handleEditClose" @submit="handleEditSubmit">
  49. <InvitePage v-if="showInvite" ref="inviteRef" :itemData="itemData"></InvitePage>
  50. </CtDialog>
  51. <TipDialog :visible="showTip" icon="mdi-check-circle-outline" message="面试邀请发送成功" @close="showTip = false">
  52. <div class="color-primary text-decoration-underline cursor-pointer" @click="handleToInterviewManagement">点击到面试中查看。</div>
  53. </TipDialog>
  54. </div>
  55. </template>
  56. <script setup>
  57. defineOptions({ name: 'table-page'})
  58. import { ref, computed, watch } from 'vue'
  59. import { previewFile } from '@/utils'
  60. import { personJobCvLook, joinEliminate, personEntryByEnterprise, personCvUnfitCancel, joinToTalentPool } from '@/api/recruit/enterprise/personnel'
  61. import { saveInterviewInvite } from '@/api/recruit/enterprise/interview'
  62. import { hireJobCvRelSettlement } from '@/api/recruit/public/delivery'
  63. import { useI18n } from '@/hooks/web/useI18n'
  64. import { useUserStore } from '@/store/user'
  65. import Snackbar from '@/plugins/snackbar'
  66. import InvitePage from './invite.vue'
  67. import { getUserAvatar } from '@/utils/avatar'
  68. import { talkToUser, defaultTextEnt } from '@/hooks/web/useIM'
  69. import { useRouter } from 'vue-router'; const router = useRouter()
  70. const showTip = ref(false)
  71. const { t } = useI18n()
  72. const emit = defineEmits(['refresh'])
  73. const props = defineProps({
  74. tab: Number,
  75. items: Array,
  76. statusList: Array,
  77. pageInfo: Object,
  78. total: Number
  79. })
  80. const badgeColor = computed(() => (item) => {
  81. return (item.person && item.person.sex) ? (item.person.sex === '1' ? '#1867c0' : 'error') : 'error'
  82. })
  83. const badgeIcon = computed(() => (item) => {
  84. return (item.person && item.person.sex) ? (item.person.sex === '1' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'
  85. })
  86. const userStore = useUserStore()
  87. const inviteRef = ref()
  88. const showInvite = ref(false)
  89. const headers = ref([
  90. { title: '姓名', value: 'name', sortable: false },
  91. { title: '应聘职位', value: 'job.name', sortable: false },
  92. { title: '求职状态', key: 'person.jobStatusName', sortable: false },
  93. { title: '工作经验', key: 'person.expName', sortable: false },
  94. { title: '最高学历', key: 'person.eduName', sortable: false },
  95. { 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 },
  96. { title: '状态', key: 'status', sortable: false },
  97. { title: '操作', value: 'actions', sortable: false }
  98. ])
  99. const unfit = { title: '类型', key: 'unfitType', sortable: false, value: item => item.type && item.type === '0' ? '简历不适合' : '面试不适合' }
  100. const delivery = { title: '类型', key: 'deliveryType', sortable: false, value: item => item?.job?.hire ? '赏金职位' : '普通职位' }
  101. watch(
  102. () => props.tab,
  103. (val) => {
  104. const obj = val !== 4 ? delivery : unfit
  105. const index = headers.value.indexOf(obj)
  106. if (index === -1) headers.value.splice(-1, 0, obj)
  107. else headers.value.splice(index, 1)
  108. // 不合适不需要展示状态
  109. if (val === 4) {
  110. const obj = headers.value.find(e => e.key === 'status')
  111. const i = headers.value.indexOf(obj)
  112. if (i !== -1) headers.value.splice(i, 1)
  113. }
  114. },
  115. { immediate: true }
  116. )
  117. // 人才详情
  118. const handleToPersonDetail = ({ userId, id }) => {
  119. if (!userId || !id) return
  120. window.open(`/recruit/enterprise/talentPool/details/${userId}?id=${id}`)
  121. }
  122. // 加入人才库
  123. const handleJoinToTalentPool = async (item) => {
  124. if (!item.userId) return Snackbar.warning('数据异常')
  125. await joinToTalentPool(item.userId)
  126. Snackbar.success(t('common.operationSuccessful'))
  127. emit('refresh')
  128. }
  129. // 入职
  130. const handleEnterByEnterprise = async (item) => {
  131. if (!item.id) return
  132. await personEntryByEnterprise(item.id)
  133. Snackbar.success(t('common.operationSuccessful'))
  134. emit('refresh')
  135. }
  136. // 不合适
  137. const handleEliminate = async (item) => {
  138. if (!item.id || !item?.job?.id) return
  139. const query = {
  140. bizId: item.id,
  141. jobId: item.job.id,
  142. userId: item.userId,
  143. type: props.tab === 0 ? '0' : '1' // 投递简历0 已邀约1
  144. }
  145. await joinEliminate(query)
  146. Snackbar.success(t('common.operationSuccessful'))
  147. emit('refresh')
  148. }
  149. // 取消不合适
  150. const handleCancelEliminate = async (item) => {
  151. if (!item.id) return
  152. await personCvUnfitCancel(item.id)
  153. Snackbar.success(t('common.operationSuccessful'))
  154. emit('refresh')
  155. }
  156. // 查看简历
  157. const handlePreviewResume = async ({ url, id }) => {
  158. if (!url || !id) return
  159. try {
  160. const res = await personJobCvLook(id)
  161. if (res) {
  162. emit('refresh')
  163. previewFile(url)
  164. }
  165. } catch (err) {
  166. console.log(err)
  167. }
  168. }
  169. // 邀请面试
  170. const itemData = ref({})
  171. // const inviteType = ref(false)
  172. const handleInterviewInvite = (item) => {
  173. if (item?.jobClosed) return // 职位已关闭
  174. // if (item?.job?.hire) inviteType.value = true
  175. itemData.value = item
  176. showInvite.value = true
  177. }
  178. const handleToCommunicate = async (item) => {
  179. if (item?.jobClosed) return // 职位已关闭
  180. const userId = item.userId
  181. // const textObj = { text: defaultTextEnt }
  182. await talkToUser({userId, text: defaultTextEnt})
  183. let url = `/recruit/enterprise/chatTools?id=${userId}`
  184. router.push(url)
  185. }
  186. const handleEditClose = () => {
  187. showInvite.value = false
  188. // inviteType.value = false
  189. itemData.value = {}
  190. }
  191. const handleEditSubmit = async () => {
  192. const { valid } = await inviteRef.value.CtFormRef.formRef.validate()
  193. if (!valid) return
  194. const query = inviteRef.value.getQuery()
  195. if (!query?.time) return Snackbar.warning('请选择面试时间')
  196. await saveInterviewInvite(query)
  197. showTip.value = true
  198. handleEditClose()
  199. emit('refresh')
  200. }
  201. // 结算
  202. const handleSettlement = async (item) => {
  203. if (!item.id) return
  204. await hireJobCvRelSettlement(item.id)
  205. Snackbar.success(t('common.operationSuccessful'))
  206. emit('refresh')
  207. // 更新账户信息
  208. setTimeout(async () => {
  209. await userStore.getEnterpriseUserAccountInfo()
  210. }, 2000)
  211. }
  212. const handleToInterviewManagement = () => {
  213. router.push('/recruit/enterprise/interviewManagement')
  214. }
  215. </script>
  216. <style scoped lang="scss">
  217. :deep(.v-table > .v-table__wrapper > table > thead) {
  218. background-color: #f7f8fa !important;
  219. }
  220. :deep(.v-selection-control__input) {
  221. color: var(--v-primary-base) !important;
  222. }
  223. </style>