details.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <div style="position: relative;">
  3. <div class="banner px-6" id="share" :class="{'default-width': defaultWidth}">
  4. <div class="banner-title d-flex justify-space-between align-center">
  5. <div class="d-flex align-center justify-between">
  6. <svg-icon v-if="info?.hire" class="ml-5" name="pin" size="50"></svg-icon>
  7. <svg-icon v-if="(info.source === '2' && info.bizId) || jobFairId" name="jobFair" class="mr-1" size="35"></svg-icon>
  8. <h1>{{ formatName(info.name) }}</h1>
  9. </div>
  10. <v-btn v-if="showContentRight && !jobFairId" color="primary" variant="text" size="large" @click.stop="handleReturn" prepend-icon="mdi-chevron-triple-left">返回上一页</v-btn>
  11. </div>
  12. <div class="d-flex mt-1 justify-space-between align-center">
  13. <div class="banner-tags">
  14. <span v-for="k in desc" :key="k.mdi">
  15. <span v-if="positionInfo[k.value] || k.value === 'areaName'" class="mr-10">
  16. <v-icon color="var(--color-666)" size="20">{{ k.mdi }}</v-icon>
  17. <span class="ml-1">
  18. {{ k.value === 'areaName' ? !positionInfo.areaId ? '全国' : positionInfo.area?.str : positionInfo[k.value] }}
  19. <!-- {{ (k.value === 'areaName' && !positionInfo.areaId) ? '全国' : positionInfo[k.value] }} -->
  20. </span>
  21. </span>
  22. </span>
  23. </div>
  24. <div>
  25. <span v-if="!info.payFrom && !info.payTo" class="salary font-size-20">面议</span>
  26. <span v-else class="salary font-size-20">{{ info.payFrom ? info.payFrom + '-' : ''}}{{ info.payTo }}{{ positionInfo.payName ? '/' + positionInfo.payName : '' }}</span>
  27. </div>
  28. </div>
  29. <div class="refresh-time text-end">{{ timesTampChange(info.refreshTime || info.updateTime) }} {{ $t('common.refresh') }} <v-icon color="primary" size="20">mdi-circle-medium</v-icon></div>
  30. <div class="banner-tools my-4">
  31. <v-chip size="small" label v-for="(k, i) in info.tagList" :key="i" class="mr-1" color="primary">{{ k }}</v-chip>
  32. </div>
  33. <div class="d-flex justify-space-between mb-5">
  34. <div>
  35. <div>
  36. <v-chip v-if="info.hire && info.hirePrice && info.hirePrice > 0" label color="primary">赏金:{{ commissionCalculation(info.hirePrice / 100, 1) }}元</v-chip>
  37. <v-chip v-if="info.hire && info.hirePoint && info.hirePoint > 0" label color="primary" class="ml-1">积分:{{ commissionCalculation(info.hirePoint / 100, 1) }}点</v-chip>
  38. </div>
  39. <div v-if="info?.hire" class="font-size-14 mt-3 color-error">推荐好友入职成功即可获得赏金</div>
  40. </div>
  41. <div class="banner-tools-btns" v-if="props.showOperateBtn">
  42. <v-btn v-if="info?.hire" class="radius mr-2 button-item" variant="outlined" color="error" prepend-icon="mdi-share-outline" @click="handleShare">我要赏金</v-btn>
  43. <v-btn v-else class="radius mr-2 button-item" variant="outlined" color="error" prepend-icon="mdi-share-outline" @click="handleShare">{{ $t('position.rewardsShared') }}</v-btn>
  44. <v-btn class="button-item radius" color="warning" variant="outlined" :prepend-icon="isCollection ? 'mdi-heart' : 'mdi-heart-outline'" @click="handleCollection">{{ isCollection ? $t('position.cancelFavorite') : $t('position.collection') }}</v-btn>
  45. <v-btn class="button-item mx-2 radius" color="success" variant="outlined" @click="toDetails(info)">{{ $t('position.communicate') }}</v-btn>
  46. <v-btn class="button-item radius" :disabled="delivery" color="primary" variant="outlined" @click="handleDelivery">{{ delivery ? $t('position.delivered') : $t('position.submitResume') }}</v-btn>
  47. </div>
  48. </div>
  49. <v-divider></v-divider>
  50. <div class="d-flex">
  51. <div class="content-left">
  52. <div v-if="Object.keys(info).length">
  53. <div>
  54. <div class="resume-header">
  55. <div class="resume-title">{{ $t('position.jobResponsibilities') }}:</div>
  56. </div>
  57. <div v-if="info.content" class="requirement" v-html="cleanedHtml(info.content)"></div>
  58. <div v-else>暂无</div>
  59. </div>
  60. <div class="mt-3">
  61. <div class="resume-header">
  62. <div class="resume-title">{{ $t('position.jobRequirements') }}:</div>
  63. </div>
  64. <div v-if="info.requirement" class="requirement" v-html="cleanedHtml(info.requirement)"></div>
  65. <div v-else>暂无</div>
  66. </div>
  67. </div>
  68. <v-divider class="my-3"></v-divider>
  69. <div class="contact" v-if="Object.keys(info).length">
  70. <div class="float-left d-flex align-center">
  71. <v-img :src="getUserAvatar(info.contact.avatar, info.contact.sex)" :width="45" rounded contain style="height: 45px;"></v-img>
  72. <div class="ml-2">
  73. <div class="contact-name">{{ info.contact.name }}</div>
  74. <div class="contact-info">
  75. {{ formatName(info.enterprise.anotherName || info.enterprise.name) }}
  76. <span v-if="info?.enterprise?.anotherName && info?.contact?.postNameCn">·</span>
  77. {{ info.contact.postNameCn }}</div>
  78. </div>
  79. </div>
  80. </div>
  81. <v-divider class="my-3"></v-divider>
  82. <div>
  83. <h4>{{ $t('position.address') }}</h4>
  84. <div class="mt-1">
  85. <v-icon size="25" color="primary">mdi-map-marker</v-icon>
  86. <span style="color: var(--color-666);font-size: 15px;">{{ info.address ? info.address : '未知' }}</span>
  87. </div>
  88. </div>
  89. <div class="mt-3 text-center" v-if="props.showOperateBtn">
  90. <v-btn
  91. class="mr-2 radius button-item"
  92. color="success"
  93. variant="outlined"
  94. @click="toDetails(info)"
  95. >
  96. {{ $t('position.communicate') }}
  97. </v-btn>
  98. <v-btn class="radius button-item" :disabled="delivery" color="primary" @click="handleDelivery">{{ delivery ? $t('position.delivered') : $t('position.submitResume') }}</v-btn>
  99. </div>
  100. </div>
  101. <div class="content-right" v-if="Object.keys(info).length && props.showContentRight">
  102. <!-- 公司信息 -->
  103. <EnterpriseInfo :info="{ ...info, position: { ...positionInfo } }"></EnterpriseInfo>
  104. <!-- 相似职位 -->
  105. <similarPositions v-if="similarList.length" class="mt-3" :list="similarList" :info="info"></similarPositions>
  106. </div>
  107. </div>
  108. </div>
  109. <!-- 简历上传 -->
  110. <CtDialog
  111. :visible="showUploadDialog"
  112. :widthType="2"
  113. :footer="true"
  114. title="附件简历上传"
  115. titleClass="text-h6"
  116. @close="showUploadDialog = false"
  117. @submit="handleUploadSubmit"
  118. >
  119. <CtForm ref="CtFormRef" :items="formItems">
  120. <template #uploadFile="{ item }">
  121. <TextInput v-model="item.value" :item="item" @click="openFileInput"></TextInput>
  122. <File ref="uploadFile" @success="handleUploadResume"></File>
  123. </template>
  124. </CtForm>
  125. <div class="color-666" style="font-size: 13px;">* 仅支持.doc, .docx, .pdf文件且大小不能超过20MB</div>
  126. </CtDialog>
  127. <!-- 选择简历 -->
  128. <selectResumeDialog v-model="showResume" :list="resumeList" @submit="handleSubmit" @close="handleClose"></selectResumeDialog>
  129. <!-- 图片预览 -->
  130. <PreviewImage v-if="showPreview" :urlList="[previewSrc]" :fileName="fileName" @close="showPreview = !showPreview" />
  131. <Loading :visible="loading"></Loading>
  132. <div v-if="Object.keys(info).length && Object.keys(positionInfo).length" style="position: absolute; left: -9999px; bottom: 0">
  133. <PosterPage :id="id" :jobFairId="jobFairId" :info="info" :positionInfo="positionInfo" ref="share"></PosterPage>
  134. </div>
  135. <!-- 快速登录 -->
  136. <loginPage v-if="showLogin" @loginSuccess="loginSuccess" @close="loginClose"></loginPage>
  137. </div>
  138. </template>
  139. <script setup>
  140. defineOptions({ name: 'position-details' })
  141. import { ref, computed } from 'vue'
  142. import { useRouter, useRoute } from 'vue-router'
  143. import Snackbar from '@/plugins/snackbar'
  144. import html2canvas from 'html2canvas'
  145. import { useI18n } from '@/hooks/web/useI18n'
  146. import { prologue, defaultText } from '@/hooks/web/useIM'
  147. import PosterPage from './poster.vue'
  148. import selectResumeDialog from './jobDetails/selectResumeDialog'
  149. import similarPositions from '@/components/Position/similarPositions.vue'
  150. import EnterpriseInfo from '@/components/Enterprise/info.vue'
  151. import loginPage from '@/views/common/loginDialog.vue'
  152. import {
  153. getPositionDetails,
  154. getSimilarPosition,
  155. getJobFavoriteCheck,
  156. getPersonJobFavorite,
  157. getPersonJobUnfavorite,
  158. jobCvRelCheckSend,
  159. jobCvRelSend
  160. } from '@/api/position'
  161. import { getPersonResumeCv, savePersonResumeCv } from '@/api/recruit/personal/resume'
  162. import { DPR } from '@/utils'
  163. import { timesTampChange } from '@/utils/date'
  164. import { dealDictObjData, dealDictArrayData, commissionCalculation } from '@/utils/position'
  165. import { getToken } from '@/utils/auth'
  166. import { getUserAvatar } from '@/utils/avatar'
  167. import { checkPersonBaseInfo } from '@/utils/check'
  168. import dialogExtend from '@/plugins/dialogExtend'
  169. import { formatName } from '@/utils/getText'
  170. import { jobFairPositionDeliveryCheck } from '@/api/recruit/personal/jobFair'
  171. const emit = defineEmits(['preview'])
  172. const props = defineProps({
  173. defaultWidth: {
  174. type: Boolean,
  175. default: true
  176. },
  177. showOperateBtn: {
  178. type: Boolean,
  179. default: true
  180. },
  181. showContentRight: {
  182. type: Boolean,
  183. default: true
  184. },
  185. propJobId: {
  186. type: [String, Number],
  187. default: ''
  188. },
  189. // 是否为推荐职位引用
  190. isRecommend: {
  191. type: Boolean,
  192. default: false
  193. }
  194. })
  195. const { t } = useI18n()
  196. const router = useRouter()
  197. const route = useRoute()
  198. let { id } = props.propJobId ? { id: props.propJobId } : router.currentRoute.value.params
  199. if (id) id = id.toString()
  200. const delivery = ref(false) // 是否已投递简历
  201. const loading = ref(false)
  202. const showLogin = ref(false)
  203. const previewSrc = ref('')
  204. const showPreview = ref(false)
  205. // 附件简历上传
  206. const CtFormRef = ref()
  207. const showUploadDialog = ref(false)
  208. const formItems = ref({
  209. options: [
  210. {
  211. type: 'text',
  212. key: 'title',
  213. value: '',
  214. label: '附件简历名称 *',
  215. rules: [v => !!v || '请输入附件简历名称']
  216. },
  217. {
  218. slotName: 'uploadFile',
  219. key: 'url',
  220. value: '',
  221. truthValue: '',
  222. label: '点击上传附件简历 *',
  223. outline: true,
  224. accept: '.doc, .docx, .pdf',
  225. prependInnerIcon: 'mdi-file-document-outline',
  226. rules: [v => !!v || '请上传您的附件简历']
  227. }
  228. ]
  229. })
  230. // 招聘会id
  231. const jobFairId = ref(route?.query?.jobFairId)
  232. const nextFunc = ref(null) // 登录成功或强制填写个人信息成功后回调
  233. let loginCloseWarningWord = ''
  234. // 快速登录
  235. const loginSuccess = () => {
  236. showLogin.value = false
  237. Snackbar.success('登录成功')
  238. if (nextFunc.value) nextFunc.value()
  239. }
  240. const loginClose = () => {
  241. showLogin.value = false
  242. Snackbar.warning(loginCloseWarningWord)
  243. }
  244. // 返回上一页
  245. const handleReturn = () => {
  246. if (window.history.state.back) {
  247. router.back()
  248. } else router.push('/recruitHome')
  249. }
  250. // 富文本内容处理,去除多余的换行空格等
  251. const cleanedHtml = (text) => {
  252. let cleaned = text.replace(/\n/g, '</br>')
  253. cleaned = cleaned.replace(/\s+/g, ' ').trim()
  254. cleaned = cleaned.replace(/(^|\s+)<\/p>(\s*<p>|$)/g, '</p><p>').trim()
  255. cleaned = cleaned.replace(/<p>\s*(<br>)\s*<\/p>/g, '')
  256. cleaned = cleaned.replace(/<p>\s*(<\/br>)\s*<\/p>/g, '')
  257. return cleaned
  258. }
  259. // 职位详情分享图片下载文件名
  260. const fileName = computed(() => {
  261. const { name, areaName, payFrom, payTo } = info.value
  262. const salary = payFrom && payTo ? `${payFrom ? '_' + payFrom + '-' : ''}${payTo}` : '-面议'
  263. return `${name}${areaName ? '_' + areaName : ''}${salary}${positionInfo.value.payName ? '-' + positionInfo.value.payName : ''}`
  264. })
  265. const share = ref()
  266. // 生成图片
  267. const generateAndDownloadImage = async () => {
  268. if (!share.value) return
  269. loading.value = true
  270. try {
  271. const canvas = await html2canvas(share.value.$el, { scale: DPR(), useCORS: true })
  272. const image = canvas.toDataURL().replace(/^data:image\/(png|jpg);base64,/, '')
  273. previewSrc.value = `data:image/png;base64,${image}`
  274. loading.value = false
  275. if (props.isRecommend) {
  276. emit('preview', previewSrc.value, fileName.value)
  277. return
  278. }
  279. showPreview.value = true
  280. } catch (error) {
  281. console.error('Error generating image:', error)
  282. Snackbar.error('图片生成失败')
  283. }
  284. }
  285. // 相似职位
  286. const similarList = ref([])
  287. const getSimilarPositionList = async () => {
  288. if (!Object.keys(positionInfo).length) return
  289. const { list } = await getSimilarPosition({ pageNo: 1, pageSize: 4, id })
  290. if (!list.length) return
  291. const items = list.splice(0, 4)
  292. similarList.value = dealDictArrayData([], items)
  293. }
  294. // 职位详情
  295. const info = ref({})
  296. const positionInfo = ref({})
  297. const getPositionDetail = async () => {
  298. const data = await getPositionDetails({ id })
  299. info.value = data
  300. positionInfo.value = { ...dealDictObjData({}, info.value), ...info.value }
  301. if (props.type !=='recommendShow') getSimilarPositionList()
  302. }
  303. getPositionDetail()
  304. // 效验是否有投递过简历
  305. const deliveryCheck = async () => {
  306. // 区分招聘会职位与普通职位
  307. const api = jobFairId.value ? jobFairPositionDeliveryCheck : jobCvRelCheckSend
  308. const params = jobFairId.value ? { jobFairId: jobFairId.value, jobId: id } : { jobId: id }
  309. const data = await api(params)
  310. if (data) delivery.value = true
  311. }
  312. if (getToken()) deliveryCheck()
  313. const desc = [
  314. { mdi: 'mdi-map-marker-outline', value: 'areaName' },
  315. { mdi: 'mdi-school-outline', value: 'eduName' },
  316. { mdi: 'mdi-clock-time-ten-outline', value: 'expName' }
  317. ]
  318. // 效验求职者是否有收藏该职位
  319. const isCollection = ref(true)
  320. const getCollectionStatus = async () => {
  321. if (!getToken()) return isCollection.value = false
  322. const data = await getJobFavoriteCheck({ jobId: id })
  323. isCollection.value = data
  324. }
  325. getCollectionStatus()
  326. // 分享有礼
  327. const handleShare = async () => {
  328. nextFunc.value = handleShare // 登录成功或强制填写个人信息成功后回调
  329. if (!getToken()) {
  330. showLogin.value = true // 打开快速登录弹窗
  331. Snackbar.warning('您还未登录,请先登录后再试')
  332. //
  333. loginCloseWarningWord = '您已取消登录,无法分享职位给好友' // 取消登录提示语
  334. return
  335. }
  336. if (!checkPersonBaseInfo()) { // 强制填写个人信息
  337. dialogExtend('necessaryInfoDialog').then(() => {
  338. if (nextFunc.value) nextFunc.value()
  339. })
  340. return
  341. }
  342. generateAndDownloadImage() // 生成海报
  343. }
  344. // 收藏&取消收藏职位
  345. const handleCollection = async () => {
  346. nextFunc.value = handleCollection // 登录成功或强制填写个人信息成功后回调
  347. if (!getToken()) {
  348. showLogin.value = true // 打开快速登录弹窗
  349. Snackbar.warning('您还未登录,请先登录后再试')
  350. //
  351. loginCloseWarningWord = '您已取消登录,无法收藏职位' // 取消登录提示语
  352. return
  353. }
  354. if (!checkPersonBaseInfo()) { // 强制填写个人信息
  355. dialogExtend('necessaryInfoDialog').then(() => {
  356. if (nextFunc.value) nextFunc.value()
  357. })
  358. return
  359. }
  360. const api = isCollection.value ? getPersonJobUnfavorite : getPersonJobFavorite
  361. await api(isCollection.value ? id : { jobId: id })
  362. await getCollectionStatus()
  363. }
  364. // 选择文件
  365. const uploadFile = ref()
  366. const openFileInput = () => {
  367. uploadFile.value.trigger()
  368. }
  369. // 上传附件
  370. const handleUploadResume = async (url, title, filename) => {
  371. const obj = formItems.value.options.find(e => e.key === 'url')
  372. obj.value = filename
  373. obj.truthValue = url
  374. }
  375. // 上传附件
  376. const handleUploadSubmit = async () => {
  377. const { valid } = await CtFormRef.value.formRef.validate()
  378. if (!valid) return
  379. const obj = {}
  380. formItems.value.options.forEach(e => {
  381. obj[e.key] = e.truthValue || e.value
  382. })
  383. if (!obj.title || !obj.url) return
  384. loading.value = true
  385. await savePersonResumeCv(obj)
  386. const params = {
  387. jobId: id,
  388. title: obj.title,
  389. url: obj.url,
  390. type: info.value.hire ? 1 : 0
  391. }
  392. // 如果是参与招聘会的职位,则传招聘会id
  393. if (jobFairId.value) params.jobFairId = jobFairId.value
  394. await jobCvRelSend(params)
  395. showUploadDialog.value = false
  396. setTimeout(() => {
  397. Snackbar.success(t('resume.deliverySuccess'))
  398. deliveryCheck()
  399. loading.value = false
  400. }, 1000)
  401. }
  402. const showResume = ref(false)
  403. // 效验是否有投递简历
  404. const resumeList = ref([])
  405. const selectResume = ref()
  406. const handleDelivery = async () => {
  407. nextFunc.value = handleDelivery // 登录成功或强制填写个人信息成功后回调
  408. if (!getToken()) {
  409. showLogin.value = true // 打开快速登录弹窗
  410. Snackbar.warning('您还未登录,请先登录后再试')
  411. //
  412. loginCloseWarningWord = '您已取消登录,无法投递简历' // 取消登录提示语
  413. return
  414. }
  415. if (delivery.value) return Snackbar.warning(t('resume.alreadyResume'))
  416. if (!checkPersonBaseInfo()) { // 强制填写个人信息
  417. dialogExtend('necessaryInfoDialog').then(() => {
  418. if (nextFunc.value) nextFunc.value()
  419. })
  420. return
  421. }
  422. const result = await getPersonResumeCv()
  423. resumeList.value = result
  424. // 没有上传过简历的先去上传
  425. if (!result.length) {
  426. Snackbar.warning('您还未上传过简历,请先上传简历')
  427. showUploadDialog.value = true
  428. return
  429. }
  430. showResume.value = true
  431. }
  432. // 简历投递
  433. const handleClose = () => {
  434. showResume.value = false
  435. selectResume.value = null
  436. }
  437. const handleSubmit = async (val) =>{
  438. selectResume.value = val
  439. if (!selectResume.value) return Snackbar.warning(t('resume.selectResumeToSubmit'))
  440. const obj = resumeList.value.find(e => e.id === selectResume.value)
  441. if (!obj) return Snackbar.warning(t('resume.selectedResumeNotExist'))
  442. handleClose()
  443. loading.value = true
  444. const params = {
  445. jobId: id,
  446. title: obj.title,
  447. url: obj.url,
  448. type: info.value.hire ? 1 : 0
  449. }
  450. // 如果是参与招聘会的职位,则传招聘会id
  451. if (jobFairId.value) params.jobFairId = jobFairId.value
  452. await jobCvRelSend(params)
  453. setTimeout(async () => {
  454. Snackbar.success(t('resume.deliverySuccess'))
  455. await deliveryCheck()
  456. loading.value = false
  457. }, 3000)
  458. }
  459. let toDetailsInfo = {}
  460. // 沟通
  461. const toDetails = async (info) => {
  462. nextFunc.value = toDetails // 登录成功或强制填写个人信息成功后回调
  463. if (info) toDetailsInfo = info // 快速登录弹窗回调使用
  464. else info = toDetailsInfo
  465. if (!getToken()) {
  466. showLogin.value = true // 打开快速登录弹窗
  467. Snackbar.warning('您还未登录,请先登录后再试')
  468. //
  469. loginCloseWarningWord = '您已取消登录,无法对职位进行沟通' // 取消登录提示语
  470. return
  471. }
  472. try {
  473. const userId = info.contact.userId
  474. const enterpriseId = info.contact.enterpriseId
  475. const textObj = {
  476. text: defaultText,
  477. positionInfo: positionInfo.value
  478. }
  479. await prologue({userId, enterpriseId, text: JSON.stringify(textObj)})
  480. let url = `/recruit/personal/message?id=${info.id}`
  481. if (info.contact.enterpriseId) {
  482. url += `&enterprise=${info.contact.enterpriseId}`
  483. }
  484. window.open(url)
  485. } catch (error) {
  486. console.log(error)
  487. }
  488. }
  489. </script>
  490. <style lang="scss" scoped>
  491. @import '@/styles/recruit/position/index.scss'
  492. </style>