details.vue 20 KB

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