details.vue 20 KB

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