details.vue 19 KB

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