details.vue 17 KB

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