details.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <div style="position: relative;">
  3. <div class="default-width banner px-6" id="share">
  4. <div class="banner-title d-flex justify-space-between">
  5. <div class="d-flex align-center">
  6. <h1 class="ellipsis">{{ info.name }}</h1>
  7. <span class="salary">{{ info.payFrom }}-{{ info.payTo }}/{{ positionInfo.payName }}</span>
  8. <svg-icon v-if="info.hire" class="ml-5" name="pin" size="50"></svg-icon>
  9. </div>
  10. <span class="refresh-time">{{ timesTampChange(info.updateTime) }} {{ $t('common.refresh') }} <v-icon color="warning" size="20">mdi-alert-outline</v-icon></span>
  11. </div>
  12. <div class="banner-tags mt-4">
  13. <span v-for="k in desc" :key="k.mdi">
  14. <span v-if="positionInfo[k.value]" class="mr-10">
  15. <v-icon color="var(--color-666)" size="20">{{ k.mdi }}</v-icon>
  16. <span class="ml-1">{{ positionInfo[k.value] }}</span>
  17. </span>
  18. </span>
  19. </div>
  20. <div class="banner-tools my-4">
  21. <v-chip size="small" label v-for="(k, i) in info.tagList" :key="i" class="mr-1" color="primary">{{ k }}</v-chip>
  22. </div>
  23. <div class="d-flex justify-space-between mb-5">
  24. <div>
  25. <div>
  26. <v-chip v-if="info.hire && info.hirePrice && info.hirePrice > 0" label color="primary">赏金:{{ commissionCalculation(info.hirePrice, 1) }}元</v-chip>
  27. <v-chip v-if="info.hire && info.hirePoint && info.hirePoint > 0" label color="primary" class="ml-1">积分:{{ commissionCalculation(info.hirePoint, 1) }}点</v-chip>
  28. </div>
  29. <div v-if="info?.hire" class="font-size-14 mt-3 color-error">推荐好友入职成功即可获得赏金</div>
  30. </div>
  31. <div class="banner-tools-btns">
  32. <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>
  33. <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>
  34. <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>
  35. <v-btn class="button-item mx-2 radius" color="success" variant="outlined" @click="toDetails(info)">{{ $t('position.communicate') }}</v-btn>
  36. <v-btn class="button-item radius" :disabled="delivery" color="primary" variant="outlined" @click="handleDelivery">{{ delivery ? $t('position.delivered') : $t('position.submitResume') }}</v-btn>
  37. </div>
  38. </div>
  39. <v-divider></v-divider>
  40. <div class="d-flex">
  41. <div class="content-left">
  42. <div v-if="Object.keys(info).length">
  43. <div>{{ $t('position.jobResponsibilities') }}:</div>
  44. <div v-if="info.content" class="requirement" v-html="info.content.replace(/\n/g, '</br>')"></div>
  45. <div v-else>暂无</div>
  46. <div class="mt-3">{{ $t('position.jobRequirements') }}:</div>
  47. <div v-if="info.requirement" class="requirement" v-html="info.requirement.replace(/\n/g, '</br>')"></div>
  48. <div v-else>暂无</div>
  49. </div>
  50. <v-divider class="my-3"></v-divider>
  51. <div class="contact" v-if="Object.keys(info).length">
  52. <div class="float-left d-flex align-center">
  53. <v-img :src="getUserAvatar(info.contact.avatar, info.contact.sex)" :width="45" style="height: 45px;"></v-img>
  54. <div class="ml-2">
  55. <div class="contact-name">{{ info.contact.name }}</div>
  56. <div class="contact-info">
  57. {{ info.enterprise.name }}
  58. <span v-if="info?.enterprise?.name && info?.contact?.postNameCn">·</span>
  59. {{ info.contact.postNameCn }}</div>
  60. </div>
  61. </div>
  62. </div>
  63. <v-divider class="my-3"></v-divider>
  64. <div>
  65. <h4>{{ $t('position.address') }}</h4>
  66. <div class="mt-1">
  67. <v-icon size="25" color="primary">mdi-map-marker</v-icon>
  68. <span style="color: var(--color-666);font-size: 15px;">{{ info.address }}</span>
  69. </div>
  70. </div>
  71. <div class="mt-3 text-center">
  72. <v-btn
  73. class="mr-2 radius button-item"
  74. color="success"
  75. variant="outlined"
  76. @click="toDetails(info)"
  77. >
  78. {{ $t('position.communicate') }}
  79. </v-btn>
  80. <v-btn class="radius button-item" :disabled="delivery" color="primary" @click="handleDelivery">{{ delivery ? $t('position.delivered') : $t('position.submitResume') }}</v-btn>
  81. </div>
  82. </div>
  83. <div class="content-right" v-if="Object.keys(info).length">
  84. <!-- 公司信息 -->
  85. <EnterpriseInfo :info="{ ...info, position: { ...positionInfo } }"></EnterpriseInfo>
  86. <!-- 相似职位 -->
  87. <similarPositions v-if="similarList.length" class="mt-3" :list="similarList" :info="info"></similarPositions>
  88. </div>
  89. </div>
  90. </div>
  91. <!-- 简历上传 -->
  92. <File ref="uploadFile" @success="handleUploadResume"></File>
  93. <!-- 选择简历 -->
  94. <selectResumeDialog v-model="showResume" :list="resumeList" @submit="handleSubmit" @close="handleClose"></selectResumeDialog>
  95. <!-- 职位分享 -->
  96. <Dialog
  97. :visible="shareDialog" :widthType="2" :footer="false" titleClass="text-h6"
  98. :title="$t('position.rewardsShared')"
  99. @close="shareDialog = false"
  100. >
  101. <div>
  102. <div class="mb-3">微信分享:保存图片分享给好友</div>
  103. <!-- <div class="mb-3">方式一:保存图片分享给好友</div> -->
  104. <div class="d-flex align-center flex-column">
  105. <v-img :src="previewSrc" width="200" height="250"></v-img>
  106. <div class="mt-5">
  107. <v-btn color="primary" variant="outlined" prepend-icon="mdi-eye-outline" @click="showPreview = true">预览</v-btn>
  108. <v-btn class="ml-3" color="primary" variant="outlined" prepend-icon="mdi-arrow-down-bold-box-outline" @click="handleDownloadImage">保存到本地</v-btn>
  109. </div>
  110. </div>
  111. </div>
  112. <!-- <div class="mt-10">
  113. <div class="mb-3">方式二:复制以下链接分享给好友</div>
  114. <div class="pa-4" style="background-color: #f0f0f0; border-radius: 8px;">{{ shareUrlTxt }}</div>
  115. <div class="text-center">
  116. <v-btn class="mt-5 ml-3" color="primary" variant="outlined" v-clipboard="() => shareUrlTxt" @click="copyText">点击复制分享链接</v-btn>
  117. </div>
  118. </div> -->
  119. <template #footer>
  120. <v-divider></v-divider>
  121. <div>
  122. <v-btn class="float-right ma-2" color="primary" variant="text" @click="shareDialog = false">{{ $t('common.close') }}</v-btn>
  123. </div>
  124. </template>
  125. </Dialog>
  126. <PreviewImg v-if="showPreview" :list="[previewSrc]" @close="showPreview = false" :isImage="true"></PreviewImg>
  127. <Loading :visible="loading"></Loading>
  128. <div style="position: absolute; left: -9999px; bottom: 0">
  129. <PosterPage :jobId="id" ref="share"></PosterPage>
  130. </div>
  131. <!-- 快速登录 -->
  132. <login-page v-if="showLogin" @loginSuccess="loginSuccess" @close="loginClose"></login-page>
  133. </div>
  134. </template>
  135. <script setup>
  136. defineOptions({ name: 'position-details' })
  137. import { commissionCalculation } from '@/utils/position'
  138. import { computed, ref } from 'vue'
  139. import { useRouter } from 'vue-router'
  140. import { timesTampChange } from '@/utils/date'
  141. import { getPersonResumeCv, savePersonResumeCv } from '@/api/recruit/personal/resume'
  142. import { useI18n } from '@/hooks/web/useI18n'
  143. import { getPositionDetails, getSimilarPosition, getJobFavoriteCheck, getPersonJobFavorite, getPersonJobUnfavorite, jobCvRelCheckSend, jobCvRelSend } from '@/api/position'
  144. import { dealDictObjData, dealDictArrayData } from '@/utils/position'
  145. import similarPositions from '@/components/Position/similarPositions.vue'
  146. import EnterpriseInfo from '@/components/Enterprise/info.vue'
  147. import Snackbar from '@/plugins/snackbar'
  148. import Dialog from '@/components/CtDialog'
  149. import selectResumeDialog from './jobDetails/selectResumeDialog'
  150. import { getToken } from '@/utils/auth'
  151. import { prologue, defaultText } from '@/hooks/web/useIM'
  152. import { getUserAvatar } from '@/utils/avatar'
  153. import PosterPage from './poster.vue'
  154. import html2canvas from 'html2canvas'
  155. import { downloadBase64, DPR } from '@/utils'
  156. import loginPage from '@/views/common/loginDialog.vue'
  157. const { t } = useI18n()
  158. const router = useRouter()
  159. const { id } = router.currentRoute.value.params
  160. const delivery = ref(false) // 是否已投递简历
  161. const loading = ref(false)
  162. const showLogin = ref(false)
  163. const previewSrc = ref('')
  164. const showPreview = ref(false)
  165. const share = ref()
  166. // 生成图片
  167. const generateAndDownloadImage = async () => {
  168. if (!share.value) return
  169. loading.value = true
  170. try {
  171. const canvas = await html2canvas(share.value.$el, { scale: DPR(), useCORS: true })
  172. const image = canvas.toDataURL().replace(/^data:image\/(png|jpg);base64,/, '')
  173. previewSrc.value = `data:image/png;base64,${image}`
  174. loading.value = false
  175. } catch (error) {
  176. console.error('Error generating image:', error)
  177. Snackbar.error('图片生成失败')
  178. }
  179. }
  180. // 保存图片到本地
  181. const handleDownloadImage = () => {
  182. const { name, areaName, payFrom, payTo } = info.value
  183. downloadBase64(previewSrc.value, `${name}_${areaName}_${payFrom}-${payTo}-${positionInfo.value.payName}`)
  184. }
  185. // 快速登录
  186. const loginSuccess = () => {
  187. showLogin.value = false
  188. Snackbar.success('登录成功')
  189. userInfo.value = localStorage.getItem('userInfo') ? JSON.parse(localStorage.getItem('userInfo')) : {}
  190. shareUrl.value = '/shareJob?' + new URLSearchParams({
  191. jobId: id,
  192. sharedById: userInfo.value?.id,
  193. }).toString()
  194. shareDialog.value = true
  195. generateAndDownloadImage()
  196. }
  197. const loginClose = () => {
  198. showLogin.value = false
  199. Snackbar.warning('您已取消登录,无法分享职位给好友')
  200. }
  201. // 相似职位
  202. const similarList = ref([])
  203. const getSimilarPositionList = async () => {
  204. if (!Object.keys(positionInfo).length) return
  205. const { list } = await getSimilarPosition({ pageNo: 1, pageSize: 4, positionId: positionInfo.value.positionId, expType: positionInfo.value.expType, eduType: positionInfo.value.eduType })
  206. const items = list.splice(0, 4)
  207. similarList.value = dealDictArrayData([], items)
  208. }
  209. // 职位详情
  210. const info = ref({})
  211. const positionInfo = ref({})
  212. const getPositionDetail = async () => {
  213. const data = await getPositionDetails({ id })
  214. info.value = data
  215. positionInfo.value = { ...dealDictObjData({}, info.value), ...info.value }
  216. getSimilarPositionList()
  217. }
  218. getPositionDetail()
  219. // 效验是否有投递过简历
  220. const deliveryCheck = async () => {
  221. const data = await jobCvRelCheckSend({ jobId: id })
  222. if (data) delivery.value = true
  223. }
  224. if (getToken()) deliveryCheck()
  225. const desc = [
  226. { mdi: 'mdi-map-marker-outline', value: 'areaName' },
  227. { mdi: 'mdi-school-outline', value: 'eduName' },
  228. { mdi: 'mdi-clock-time-ten-outline', value: 'expName' }
  229. ]
  230. // 效验求职者是否有收藏该职位
  231. const isCollection = ref(true)
  232. const getCollectionStatus = async () => {
  233. if (!getToken()) return isCollection.value = false
  234. const data = await getJobFavoriteCheck({ jobId: id })
  235. isCollection.value = data
  236. }
  237. getCollectionStatus()
  238. // 分享有礼
  239. const shareDialog = ref(false)
  240. const shareUrl = ref('')
  241. const userInfo = ref(localStorage.getItem('userInfo') ? JSON.parse(localStorage.getItem('userInfo')) : {})
  242. const handleShare = async () => {
  243. // 分享链接携带参数: 用户id、职位id
  244. if (!getToken()) {
  245. Snackbar.warning('您还未登录,请先登录后再试')
  246. showLogin.value = true
  247. return
  248. }
  249. generateAndDownloadImage()
  250. shareUrl.value = '/shareJob?' + new URLSearchParams({
  251. jobId: id,
  252. sharedById: userInfo.value?.id,
  253. }).toString()
  254. shareDialog.value = true
  255. }
  256. // 复制分享链接
  257. const accessUrl = import.meta.env.VITE_ACCESS_BASE_URL
  258. const shareUrlTxt = computed(() => {
  259. return accessUrl + shareUrl.value
  260. })
  261. // const copyText = () => {
  262. // Snackbar.success('复制成功')
  263. // }
  264. // 收藏&取消收藏职位
  265. const handleCollection = async () => {
  266. const api = isCollection.value ? getPersonJobUnfavorite : getPersonJobFavorite
  267. await api(isCollection.value ? id : { jobId: id })
  268. await getCollectionStatus()
  269. }
  270. // 投递简历时,若当前用户没有简历列表则弹窗上传简历以及投递
  271. const uploadFile = ref()
  272. const handleUploadResume = async (url, title) => {
  273. if (!url || !title) return
  274. // 简历上传
  275. await savePersonResumeCv({ title, url })
  276. // 简历投递
  277. await jobCvRelSend({ jobId: id, title, url, type: info.value.hire ? 1 : 0 })
  278. setTimeout(() => {
  279. Snackbar.success(t('resume.deliverySuccess'))
  280. deliveryCheck()
  281. }, 3000)
  282. }
  283. const showResume = ref(false)
  284. // 效验是否有投递简历
  285. const resumeList = ref([])
  286. const selectResume = ref()
  287. const handleDelivery = async () => {
  288. if (delivery.value) return Snackbar.warning(t('resume.alreadyResume'))
  289. const result = await getPersonResumeCv()
  290. resumeList.value = result
  291. // 没有上传过简历的先去上传
  292. if (!result.length) {
  293. Snackbar.warning('您还未上传过简历,请先上传简历')
  294. uploadFile.value.trigger()
  295. return
  296. }
  297. showResume.value = true
  298. }
  299. // 简历投递
  300. const handleClose = () => {
  301. showResume.value = false
  302. selectResume.value = null
  303. }
  304. const handleSubmit = async (val) =>{
  305. selectResume.value = val
  306. if (!selectResume.value) return Snackbar.warning(t('resume.selectResumeToSubmit'))
  307. const obj = resumeList.value.find(e => e.id === selectResume.value)
  308. if (!obj) return Snackbar.warning(t('resume.selectedResumeNotExist'))
  309. handleClose()
  310. loading.value = true
  311. await jobCvRelSend({ jobId: id, title: obj.title, url: obj.url, type: info.value.hire ? 1 : 0 })
  312. setTimeout(async () => {
  313. Snackbar.success(t('resume.deliverySuccess'))
  314. await deliveryCheck()
  315. loading.value = false
  316. }, 3000)
  317. }
  318. // 沟通
  319. const toDetails = async (info) => {
  320. const userId = info.contact.userId
  321. const enterpriseId = info.contact.enterpriseId
  322. const textObj = {
  323. text: defaultText,
  324. positionInfo: positionInfo.value
  325. }
  326. await prologue({userId, enterpriseId, text: JSON.stringify(textObj)})
  327. let url = `/recruit/personal/message?id=${info.id}`
  328. if (info.contact.enterpriseId) {
  329. url += `&enterprise=${info.contact.enterpriseId}`
  330. }
  331. router.push(url)
  332. }
  333. </script>
  334. <style lang="scss" scoped>
  335. @import '@/styles/recruit/position/index.scss'
  336. </style>