index.vue 6.9 KB

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