index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <layout-page>
  3. <scroll-view class="scrollBox" style="position:relative;">
  4. <view class="box">
  5. <view v-if="loading" class="vertical80-center">{{ loadingText }}</view>
  6. <view v-else>
  7. <view class="mt-5" style="display: flex;">
  8. <!-- 赏金 -->
  9. <view v-if="info.hire && info.hirePrice" class="hirePrice ss-m-r-10 d-flex align-center">
  10. <view class="iconfont icon-a-1_zhaopin ss-m-r-10" style="color: #e03506; font-size: 20px;"></view>
  11. <view>{{ `赏金:${commissionCalculation(info.hirePrice / 100, 1)}元` }}</view>
  12. </view>
  13. <image v-if="isJobFair" src="/static/svg/jobFair.svg" class="ss-m-r-10" style="width: 30px; height: 30px;"></image>
  14. <!-- 职位名称 -->
  15. <h2 class="JobName" style="flex: 1;">
  16. {{ formatName(info.name) }}
  17. <span v-if="info?.status === '1'" class="color-error">(职位已关闭)</span>
  18. </h2>
  19. </view>
  20. <!-- 职位地区 -->
  21. <view class="d-flex justify-space-between mt-5 align-center">
  22. <view style="font-size: 14px; flex: 1; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; margin-right: 30px;">
  23. <span>
  24. <span>{{positionInfo?.area?.str ?? '全国' }}</span>
  25. <span class="viewider-mx" v-if="positionInfo?.eduName">|</span>
  26. <span>{{positionInfo?.eduName }}</span>
  27. <span class="viewider-mx" v-if="positionInfo?.expName">|</span>
  28. <span>{{positionInfo?.expName }}</span>
  29. </span>
  30. </view>
  31. </view>
  32. <view class="d-flex justify-space-between mt-5 align-center">
  33. <!-- 薪资 -->
  34. <view>
  35. <span v-if="!info.payFrom && !info.payTo" class="salary w-600">面议</span>
  36. <span v-else class="salary w-600">{{ info.payFrom }}-{{ info.payTo }}/{{ positionInfo.payName }}</span>
  37. </view>
  38. </view>
  39. <view class="font-size-13 color-999 ss-m-t-10" style="text-align: end;">更新时间:{{ timesTampChange(info?.refreshTime || info.updateTime, 'Y-M-D h:m') }}</view>
  40. <!-- 标签 -->
  41. <view class="tagList mt">
  42. <view class="tag" v-for="(tag,i) in info?.tagList || []" :key="'tagList' + i">
  43. {{ tag }}
  44. </view>
  45. </view>
  46. <!-- 岗位职责 -->
  47. <view class="topLine fs14 mt-5">
  48. <view class="fs15 w-600 my5">岗位职责</view>
  49. <view v-if="!info.content"></view>
  50. <rich-text v-else class="htmlCss" :nodes="cleanedHtml(info.content)"></rich-text>
  51. </view>
  52. <!-- 岗位要求 -->
  53. <view class="topLine mt-5">
  54. <view class="fs15 w-600 my5">岗位要求</view>
  55. <view v-if="!info.requirement"></view>
  56. <rich-text v-else class="htmlCss" :nodes="cleanedHtml(info.requirement)"></rich-text>
  57. </view>
  58. <!-- HR信息 -->
  59. <view class="topLine mt-5 d-flex align-center">
  60. <view class="avatarBox">
  61. <image style="width: 40px; height: 40px; border-radius: 50%;" :src="getUserAvatar(info?.contact?.avatar)"></image>
  62. </view>
  63. <view class="contact-name">{{ info.contact?.name }}</view>
  64. </view>
  65. <!-- 工作地址 -->
  66. <view class="topLine mt-5">
  67. <view class="fs15 w-600 my5">工作地址</view>
  68. <view class="my10">
  69. <uni-icons
  70. type="map-pin-ellipse"
  71. color="#00B760"
  72. class="mr"
  73. size="25"
  74. ></uni-icons>
  75. <span style="color: var(--color-666);font-size: 15px;line-height: 26px;">{{ info.address || '' }}</span>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </scroll-view>
  81. <view class="bottom-sticky" v-if="!loading && jobId">
  82. <view class="bottom-content">
  83. <button
  84. v-if="info?.status === '0'"
  85. class="buttons btnStyle ss-m-l-15"
  86. type="primary"
  87. @click="handleEdit"
  88. >编辑职位</button>
  89. </view>
  90. </view>
  91. </layout-page>
  92. </template>
  93. <script setup>
  94. import { commissionCalculation } from '@/utils/position'
  95. import { timesTampChange } from '@/utils/date'
  96. import layoutPage from '@/layout'
  97. import { ref, watch } from 'vue';
  98. import { getPositionDetails, getEnterprisePubJobTypePermission } from '@/api/position'
  99. import { dealDictObjData } from '@/utils/position'
  100. import { onLoad } from '@dcloudio/uni-app'
  101. import { userStore } from '@/store/user'
  102. import { formatName } from '@/utils/getText'
  103. import { getUserAvatar } from '@/utils/avatar'
  104. const useUserStore = userStore()
  105. const loading = ref(false)
  106. const loadingText = ref('加载中 . . . ')
  107. // 职位详情
  108. const info = ref({})
  109. const positionInfo = ref({})
  110. const beenLogin = ref(false)
  111. // 监听登录状态
  112. watch(() => useUserStore.refreshToken, (newVal) => {
  113. beenLogin.value = Boolean(newVal)
  114. }, { immediate: true }, { deep: true })
  115. let jobId = ''
  116. const isJobFair = ref(false)
  117. let obj = {}
  118. const isEdit = ref(false)
  119. const fairNoEdit = ref(false)
  120. onLoad(async (options) => {
  121. jobId = options?.id || options?.jobId || obj?.jobId || ''
  122. // 招聘会进入的岗位
  123. if (options?.jobFairId) isJobFair.value = true
  124. // 职位是否可编辑
  125. if (options?.isEdit && options?.isEdit === 'true') isEdit.value = true
  126. // 发布中的招聘会是否可编辑
  127. if (options?.fairNoEdit) fairNoEdit.value = true
  128. if (jobId) {
  129. loading.value = true
  130. loadingText.value = '加载中 . . . '
  131. getPositionDetail()
  132. } else {
  133. loadingText.value = '加载失败 . . . '
  134. }
  135. })
  136. // 富文本内容处理,去除多余的换行空格等
  137. const cleanedHtml = (text) => {
  138. const cleaned = text.replace(/\n/g, '<br>')
  139. .replace(/\s+/g, ' ')
  140. .replace(/(^|\s+)<\/p>(\s*<p>|$)/g, '</p><p>')
  141. .replace(/<p>\s*(<br>)\s*<\/p>/g, '')
  142. .replace(/<pre([^>]*)>/g, '<div$1>')
  143. .replace(/<\/pre>/g, '</div>')
  144. .replace(/<p>\s*(<\/br>)\s*<\/p>/g, '').trim()
  145. return cleaned
  146. }
  147. // 职位详情
  148. async function getPositionDetail () {
  149. try {
  150. loading.value = true
  151. const { data } = await getPositionDetails({ id: jobId })
  152. info.value = data
  153. positionInfo.value = { ...dealDictObjData({}, info.value), ...info.value, enterprise: dealDictObjData({}, data.enterprise) }
  154. loading.value = false
  155. } finally {
  156. }
  157. }
  158. // 职位编辑
  159. const handleEdit = async () => {
  160. if (!isJobFair.value && !isEdit.value) {
  161. uni.showToast({ title: '职位发布时间超过24小时的不支持编辑', icon: 'none', duration: 2000 })
  162. return
  163. }
  164. // 已关闭的招聘会职位不支持编辑
  165. // if (isJobFair.value && info.value.status === '1') {
  166. // uni.showToast({ title: '职位已关闭', icon: 'none', duration: 2000 })
  167. // return
  168. // }
  169. // 发布中的招聘会职位需进入招聘会中进行编辑
  170. if (fairNoEdit.value) {
  171. uni.showToast({ title: '该职位属于招聘会职位,请前往招聘会中进行编辑', icon: 'none', duration: 2000 })
  172. return
  173. }
  174. uni.showLoading({ title: '加载中 . . . ' })
  175. try {
  176. const res = await getEnterprisePubJobTypePermission()
  177. if (!res?.data?.length) {
  178. uni.showToast({ title: '没有该操作权限,请联系平台管理员升级后再试', icon: 'none', duration: 2000 })
  179. return
  180. }
  181. const url = isJobFair.value ? `/pagesB/jobFair/editJob?jobId=${jobId}&jobFairId=${info.value.bizId}` : `/pagesB/positionEdit/index?jobId=${jobId}`
  182. uni.navigateTo({ url })
  183. // 跳转编辑页面
  184. } finally {
  185. uni.hideLoading()
  186. }
  187. }
  188. </script>
  189. <style scoped lang="scss">
  190. @import '../../static/style/position/index.scss';
  191. .bottom-content {
  192. display: flex;
  193. justify-content: space-evenly;
  194. align-items: center;
  195. width: 100%;
  196. margin: 20rpx 0;
  197. .btnStyle {
  198. flex: 1;
  199. margin: 0 20rpx;
  200. }
  201. }
  202. </style>