table.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <div>
  3. <CtTable
  4. class="mt-3"
  5. :items="items"
  6. :headers="headers"
  7. :loading="false"
  8. :elevation="0"
  9. :disableSort="true"
  10. :isTools="false"
  11. height="calc(100vh - 360px)"
  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 || item?.phone }}</span>
  30. </div>
  31. </template>
  32. <template #jobName="{item}">
  33. <svg-icon v-if="item.jobFairId" name="jobFair" size="20"></svg-icon>
  34. {{ formatName(item.job.name) }}
  35. </template>
  36. <template #status="{ item }">
  37. <span v-if="tab === 0">{{ item.status && item.status === '0' ? '未查看' : '已查看' }}</span>
  38. <span v-else>{{ item.status ? props.statusList.find(i => i.value === item.status)?.label : '' }}</span>
  39. </template>
  40. <template #actions="{ item }">
  41. <!-- <v-btn color="primary" variant="text" @click="handlePreviewResume(item)">查看附件</v-btn>
  42. <v-menu v-if="actionItems(item).length">
  43. <template v-slot:activator="{ props }">
  44. <v-icon v-bind="props" class="mx-3" size="20" color="primary">mdi-dots-horizontal</v-icon>
  45. </template>
  46. <v-list>
  47. <v-list-item
  48. v-for="(k, index) in actionItems(item)"
  49. :key="index"
  50. :value="index"
  51. color="primary"
  52. @click="k.click(item)"
  53. >
  54. <v-list-item-title>
  55. <span :class="{'disabledItem': tab === 0 && ['邀请面试', '立即沟通'].includes(k.title) && item.jobClosed}">{{ k.title }}</span>
  56. <v-tooltip v-if="tab === 0 && ['邀请面试', '立即沟通'].includes(k.title) && item.jobClosed" activator="parent" location="top">职位已关闭</v-tooltip>
  57. </v-list-item-title>
  58. </v-list-item>
  59. </v-list>
  60. </v-menu> -->
  61. <v-btn icon variant="text" v-for="(k, index) in actionItems(item)" :key="index" @click.stop="k.click(item)">
  62. <v-icon :color="k?.disabled ? '#ccc' : k.color">{{ k.icon }}</v-icon>
  63. <v-tooltip :text="k.title" location="top" activator="parent">
  64. <span>{{ k.title }}</span>
  65. </v-tooltip>
  66. </v-btn>
  67. </template>
  68. </CtTable>
  69. <!-- 邀请面试 -->
  70. <CtDialog :visible="showInvite" :widthType="4" titleClass="text-h6" title="面试信息" @close="handleEditClose" @submit="handleEditSubmit">
  71. <InvitePage v-if="showInvite" ref="inviteRef" :itemData="itemData"></InvitePage>
  72. </CtDialog>
  73. <TipDialog :visible="showTip" icon="mdi-check-circle-outline" message="面试邀请发送成功" @close="showTip = false">
  74. <div class="color-primary text-decoration-underline cursor-pointer" @click="handleToInterviewManagement">点击到面试中查看。</div>
  75. </TipDialog>
  76. <Loading :visible="formLoading" />
  77. </div>
  78. </template>
  79. <script setup>
  80. defineOptions({ name: 'table-page'})
  81. import { ref, computed, watch } from 'vue'
  82. import { previewFile } from '@/utils'
  83. import { personJobCvLook, joinEliminate, personEntryByEnterprise, personCvUnfitCancel, joinToTalentPool } from '@/api/recruit/enterprise/personnel'
  84. import { saveInterviewInvite } from '@/api/recruit/enterprise/interview'
  85. import { hireJobCvRelSettlement } from '@/api/recruit/public/delivery'
  86. import { useI18n } from '@/hooks/web/useI18n'
  87. import { useUserStore } from '@/store/user'
  88. import Snackbar from '@/plugins/snackbar'
  89. import Confirm from '@/plugins/confirm'
  90. import InvitePage from './invite.vue'
  91. import { getUserAvatar } from '@/utils/avatar'
  92. import { getBlob, saveAs } from '@/utils'
  93. import { talkToUser, defaultTextEnt } from '@/hooks/web/useIM'
  94. import { useRouter } from 'vue-router'; const router = useRouter()
  95. import { formatName } from '@/utils/getText'
  96. const showTip = ref(false)
  97. const { t } = useI18n()
  98. const emit = defineEmits(['refresh', 'page'])
  99. const props = defineProps({
  100. tab: Number,
  101. items: Array,
  102. statusList: Array,
  103. pageInfo: Object,
  104. total: Number
  105. })
  106. const badgeColor = computed(() => (item) => {
  107. return (item.person && item.person.sex) ? (item.person.sex === '1' ? '#1867c0' : 'error') : 'error'
  108. })
  109. const badgeIcon = computed(() => (item) => {
  110. return (item.person && item.person.sex) ? (item.person.sex === '1' ? 'mdi-gender-male' : 'mdi-gender-female') : 'mdi-gender-female'
  111. })
  112. const formLoading = ref(false)
  113. const userStore = useUserStore()
  114. const inviteRef = ref()
  115. const showInvite = ref(false)
  116. const headers = ref([
  117. { title: '姓名', value: 'name', sortable: false },
  118. { title: '人才类型', key: 'person.type', sortable: false, value: item => item.person?.type ? item.person.type === '1' ? '在校学生' : '职场人士' : '' },
  119. { title: '求职状态', key: 'person.jobStatusName', sortable: false },
  120. { title: '工作经验', key: 'person.expName', sortable: false },
  121. { title: '最高学历', key: 'person.eduName', sortable: false },
  122. { title: '应聘职位', key: 'jobName', sortable: false },
  123. { title: '操作时间', key: 'createTime', sortable: false },
  124. { title: '状态', key: 'status', sortable: false },
  125. { title: '操作', value: 'actions', sortable: false }
  126. ])
  127. let baseInfo = ref(JSON.parse(localStorage.getItem('entBaseInfo')) || {})
  128. userStore.$subscribe((mutation, state) => {
  129. if (Object.keys(state.entBaseInfo).length) baseInfo.value = state.entBaseInfo
  130. })
  131. watch(
  132. () => props.tab,
  133. (val) => {
  134. // 不合适不需要展示状态
  135. if (val === 4) {
  136. const obj = headers.value.find(e => e.key === 'status')
  137. const i = headers.value.indexOf(obj)
  138. if (i !== -1) headers.value.splice(i, 1)
  139. }
  140. },
  141. { immediate: true }
  142. )
  143. // 人才详情
  144. const handleToPersonDetail = async (item) => {
  145. const userId = item.userId
  146. const id = props.tab === 0 ? item.id : item.cvRel.id
  147. if (!userId || !id) return
  148. // 改变状态
  149. try {
  150. const res = await personJobCvLook(id)
  151. if (res) {
  152. emit('refresh')
  153. }
  154. } catch (err) {
  155. console.log(err)
  156. }
  157. window.open(`/recruit/enterprise/talentPool/details/${userId}`)
  158. }
  159. // 加入人才库
  160. const handleJoinToTalentPool = async (item) => {
  161. if (!item.userId) return Snackbar.warning('数据异常')
  162. Confirm('系统提示', '是否确认将此求职者加入人才库?').then(async () => {
  163. await joinToTalentPool(item.userId)
  164. Snackbar.success(t('common.operationSuccessful'))
  165. emit('refresh')
  166. })
  167. }
  168. // 入职
  169. const handleEnterByEnterprise = async (item) => {
  170. if (!item.id) return
  171. Confirm('系统提示', '是否确认将此求职者操作入职?').then(async () => {
  172. await personEntryByEnterprise(item.id)
  173. Snackbar.success(t('common.operationSuccessful'))
  174. emit('refresh')
  175. })
  176. }
  177. // 不合适
  178. const handleEliminate = async (item) => {
  179. if (!item.id || !item?.job?.id) return
  180. Confirm('系统提示', '是否确认加入不合适?').then(async () => {
  181. const query = {
  182. bizId: item.id,
  183. jobId: item.job.id,
  184. userId: item.userId,
  185. jobCvRelId: props.tab === 0 ? item.id : item.cvRel?.id,
  186. type: props.tab === 0 ? '0' : '1' // 投递简历0 已邀约1
  187. }
  188. // 招聘会职位则带id
  189. if (item?.jobFairId) query.jobFairId = item.jobFairId
  190. await joinEliminate(query)
  191. Snackbar.success(t('common.operationSuccessful'))
  192. emit('refresh')
  193. })
  194. }
  195. // 取消不合适
  196. const handleCancelEliminate = async (item) => {
  197. if (!item.id) return
  198. Confirm('系统提示', '是否确认取消不合适?').then(async () => {
  199. await personCvUnfitCancel(item.id)
  200. Snackbar.success(t('common.operationSuccessful'))
  201. emit('refresh')
  202. })
  203. }
  204. // 查看简历
  205. const handlePreviewResume = async (item) => {
  206. // 招聘会收到的简历不需要效验
  207. if (!item.jobFairId) {
  208. // 效验企业是否有查看简历次数
  209. await userStore.getEnterpriseInfo(true)
  210. if (baseInfo.value?.entitlement?.lookCvCount <= 0) return Snackbar.warning('您的查看简历次数已用完,请联系平台管理员!')
  211. }
  212. const url = props.tab === 0 ? item.url : item.cvRel.url
  213. const id = props.tab === 0 ? item.id : item.cvRel.id
  214. if (!url || !id) return Snackbar.warning('简历不存在')
  215. try {
  216. const res = await personJobCvLook(id)
  217. if (res) {
  218. emit('refresh')
  219. previewFile(url)
  220. }
  221. } catch (err) {
  222. console.log(err)
  223. }
  224. }
  225. // 邀请面试
  226. const itemData = ref({})
  227. const handleInterviewInvite = (item) => {
  228. if (item.handleStatus) return
  229. if (item?.jobClosed) return // 职位已关闭
  230. itemData.value = item
  231. showInvite.value = true
  232. }
  233. const handleToCommunicate = async (item) => {
  234. if (item?.jobClosed) return // 职位已关闭
  235. const userId = item.userId
  236. await talkToUser({userId, text: defaultTextEnt})
  237. let url = `/recruit/enterprise/chatTools?id=${userId}`
  238. router.push(url)
  239. }
  240. const handleEditClose = () => {
  241. showInvite.value = false
  242. itemData.value = {}
  243. }
  244. const handleEditSubmit = async () => {
  245. const { valid } = await inviteRef.value.CtFormRef.formRef.validate()
  246. if (!valid) return
  247. const query = inviteRef.value.getQuery()
  248. if (!query?.time) return Snackbar.warning('请选择面试时间')
  249. query.jobCvRelId = itemData.value.id
  250. formLoading.value = true
  251. try {
  252. await saveInterviewInvite(query)
  253. showTip.value = true
  254. handleEditClose()
  255. emit('refresh')
  256. } finally {
  257. formLoading.value = false
  258. }
  259. }
  260. // 结算
  261. const handleSettlement = async (item) => {
  262. if (!item.id) return
  263. Confirm('系统提示', '是否确认结算?').then(async () => {
  264. await hireJobCvRelSettlement(item.id)
  265. Snackbar.success(t('common.operationSuccessful'))
  266. emit('refresh')
  267. // 更新账户信息
  268. setTimeout(async () => {
  269. await userStore.getEnterpriseUserAccountInfo()
  270. }, 2000)
  271. })
  272. }
  273. const handleToInterviewManagement = () => {
  274. router.push('/recruit/enterprise/interviewManagement')
  275. }
  276. // 下载附件
  277. const handleDownloadAttachment = async (k) => {
  278. // 招聘会收到的简历不需要效验
  279. if (!k.jobFairId) {
  280. // 效验企业是否有下载简历次数
  281. await userStore.getEnterpriseInfo(true)
  282. if (baseInfo.value?.entitlement?.lookCvCount <= 0) return Snackbar.warning('您的下载简历次数已用完,请联系平台管理员!')
  283. }
  284. const url = props.tab === 0 ? k.url : k.cvRel?.url
  285. if (!url) return
  286. getBlob(url).then(blob => {
  287. saveAs(blob, props.tab === 0 ? k.title : k.cvRel?.title)
  288. })
  289. }
  290. const actionItems = (item) => {
  291. const arr = []
  292. // 有返回简历信息的才展示查看简历&下载简历
  293. if ((props.tab === 0 && item.url) || (props.tab !== 0 && item?.cvRel && item.cvRel?.url)) arr.push(
  294. { title: '查看附件', color: 'warning', click: handlePreviewResume, icon: 'mdi-eye-outline' },
  295. { title: '下载附件', color: 'error', click: handleDownloadAttachment, icon: 'mdi-arrow-down-bold-circle-outline' }
  296. )
  297. if (props.tab === 0) {
  298. arr.push(
  299. {
  300. title: item?.jobClosed ? '邀请面试(职位已关闭)' : (item.handleStatus ? '邀请面试(已邀面试)' : '邀请面试'),
  301. disabled: item?.jobClosed || item.handleStatus,
  302. color: 'success',
  303. click: handleInterviewInvite,
  304. icon: 'mdi-account-clock-outline'
  305. },
  306. {
  307. title: item?.jobClosed ? '立即沟通(职位已关闭)' : '立即沟通',
  308. color: 'primary',
  309. disabled: item?.jobClosed,
  310. click: handleToCommunicate,
  311. icon: 'mdi-comment-processing-outline'
  312. }
  313. )
  314. }
  315. if ([0, 1].includes(props.tab)) arr.push({ title: '不合适', color: 'indigo', click: handleEliminate, icon: 'mdi-account-remove-outline' })
  316. if (props.tab === 4) arr.push({ title: '取消不合适', color: 'light-blue', click: handleCancelEliminate, icon: 'mdi-account-check-outline' })
  317. if (props.tab === 2 && item?.job?.hire) arr.push({ title: '结算', click: handleSettlement, icon: 'mdi-currency-cny' })
  318. if (props.tab === 1 && ['3', '4'].includes(item.status)) arr.push({ title: '入职', click: handleEnterByEnterprise, icon: 'mdi-account-arrow-right-outline' })
  319. // 面试后才能够加入储备
  320. if ([1, 2, 3].includes(props.tab) && !item.inTalentPool) arr.push({ title: '加入储备', color: '#00897B', click: handleJoinToTalentPool, icon: 'mdi-account-star-outline' })
  321. return arr
  322. }
  323. </script>
  324. <style scoped lang="scss">
  325. :deep(.v-table > .v-table__wrapper > table > thead) {
  326. background-color: #f7f8fa !important;
  327. }
  328. :deep(.v-selection-control__input) {
  329. color: var(--v-primary-base) !important;
  330. }
  331. .disabledItem {
  332. cursor: auto;
  333. opacity: .5;
  334. }
  335. </style>