item.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div>
  3. <div v-for="val in items" :key="val.id" class="itemBox mb-3" style="height: 162px;">
  4. <div class="d-flex justify-space-between" style="padding: 10px 20px;">
  5. <div class="position">
  6. <div class="d-flex align-center" :class="{'cursor-pointer': tab !== 3 && val.edit}" @click="handleEdit(val)">
  7. <svg-icon class="mr-3" name="pin" size="25"></svg-icon>
  8. <span v-if="val.name.indexOf('style')" v-html="val.name" class="position-name"></span>
  9. <span v-else class="position-name">{{ val.name }}</span>
  10. </div>
  11. <div :class="['mt-3', 'other-info', 'ellipsis']">
  12. <span>{{ !val.areaId ? '全国' : val.area?.str }}</span>
  13. <span class="lines" v-if="val.eduName"></span>
  14. <span>{{ val.eduName }}</span>
  15. <span class="lines"></span>
  16. <span>{{ val.expName }}</span>
  17. <span class="lines"></span>
  18. <span v-if="!val.payFrom && !val.payTo">面议</span>
  19. <span v-else>{{ val.payFrom ? val.payFrom + '-' : '' }}{{ val.payTo }}{{ val.payName ? '/' + val.payName : '' }}</span>
  20. <span class="lines"></span>
  21. <span>{{ val.positionName }}</span>
  22. </div>
  23. <div v-if="val?.hire" class="mt-2">
  24. <v-chip v-if="val?.hirePrice && val.hirePrice > 0" class="mr-3" label color="primary" size="small">M豆:{{ commissionCalculation(val.hirePrice / 100, 1) }}个</v-chip>
  25. </div>
  26. </div>
  27. <div v-if="tab !== 0" class="text-center color-primary d-flex flex-column justify-center cursor-pointer" @click="handleToResume(val)">
  28. <div class="font-weight-bold font-size-18">{{ val.count || 0 }}</div>
  29. <div class="font-size-14">已投递简历</div>
  30. </div>
  31. <div v-if="(val.status-0) === 99 && tab === 0" class="d-flex align-center">
  32. <v-chip color="warning" label>职位待发布,支付成功后自动发布</v-chip>
  33. </div>
  34. </div>
  35. <div class="bottom pa-5 d-flex justify-space-between align-center">
  36. <div>
  37. {{ $t('position.refreshTime') }} :{{ timesTampChange(val.updateTime, 'Y-M-D') }}
  38. <span v-if="tab === 1">
  39. <span class="septal-line"></span>
  40. 到期时间:{{ val.expireTime ? timesTampChange(val.expireTime, 'Y-M-D') : '长期有效' }}
  41. </span>
  42. </div>
  43. <div class="d-flex align-center">
  44. <span v-if="val.status === '1' && tab === 2" class="cursor-pointer actions" @click="toPay(val)">职位已关闭,点击激活职位</span>
  45. <span v-if="(val.status-0) === 99 && tab === 0" class="cursor-pointer color-primary" @click="toPay(val)">发布</span>
  46. <span v-if="(val.status - 0) !== 99 && val.status !== '1' && tab === 1" class="cursor-pointer actions" @click="handleAction(0, val)">{{ $t('common.close') }}</span>
  47. <div v-if="tab !== 3">
  48. <span class="lines"></span>
  49. <span class="cursor-pointer" :class="{'actions': val.edit}" :style="{'color': val.edit ? '#333' : '#999'}" @click="handleEdit(val)">编辑</span>
  50. <v-tooltip v-if="!val.edit" activator="parent" location="top">职位发布时间超过24小时的不支持编辑</v-tooltip>
  51. </div>
  52. <!-- <span v-if="tab === 3" class="cursor-pointer actions" @click="handleUpdateExpireTime(val)">修改到期时间</span> -->
  53. <span class="lines" v-if="tab !== 3"></span>
  54. <span class="cursor-pointer actions" @click="handleDetail(val)">详情</span>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <confirmPaymentDialog
  60. v-if="showConfirmPaymentDialog"
  61. :cost="cost"
  62. :spuId="spuId"
  63. :spuName="spuName"
  64. :orderType="2"
  65. @paySuccess="paySuccess"
  66. @close="showConfirmPaymentDialog = false"
  67. ></confirmPaymentDialog>
  68. <Loading :visible="loading"></Loading>
  69. <CtDialog :visible="showExpire" :widthType="2" titleClass="text-h6" title="修改职位到期时间" @close="showExpire = false; expireTimeId = null" @submit="handleSubmit">
  70. <CtForm v-if="showExpire" ref="CtFormRef" :items="formItem" style="height: 100px;"></CtForm>
  71. </CtDialog>
  72. </template>
  73. <script setup>
  74. import { commissionCalculation } from '@/utils/position'
  75. defineOptions({ name: 'enterprise-position-item'})
  76. import { ref } from 'vue'
  77. import { useRouter } from 'vue-router'
  78. import { timesTampChange } from '@/utils/date'
  79. import { useI18n } from '@/hooks/web/useI18n'
  80. import { closeJobAdvertised, enableJobAdvertised, updatePositionExpireTime } from '@/api/position'
  81. import Snackbar from '@/plugins/snackbar'
  82. import confirmPaymentDialog from '@/components/pay/confirmPaymentDialog.vue'
  83. import { getEnterprisePubJobTypePermission } from '@/api/recruit/enterprise/position'
  84. const { t } = useI18n()
  85. const emit = defineEmits(['refresh'])
  86. const props = defineProps({
  87. items: Array,
  88. tab: Number
  89. })
  90. const loading = ref(false)
  91. const showConfirmPaymentDialog = ref(false)
  92. const cost = ref(0)
  93. const spuId = ref('')
  94. const spuName = ref('')
  95. const operateObj = ref({})
  96. const toPay = (val) => { // 已关闭的职位激活需要再次支付
  97. operateObj.value = val
  98. spuId.value = val.id || ''
  99. spuName.value = val.name || ''
  100. cost.value = val.hirePrice
  101. // 打开支付弹窗
  102. showConfirmPaymentDialog.value = true
  103. }
  104. // 支付成功
  105. const paySuccess = async () => {
  106. showConfirmPaymentDialog.value = false
  107. // console.log(' operateObj.value?.status', operateObj.value?.status)
  108. // if (operateObj.value?.status === '1') {
  109. // handleAction(1, operateObj.value)
  110. // }
  111. setTimeout(() => {
  112. emit('refresh', 1)
  113. }, 1000)
  114. }
  115. const showExpire = ref(false)
  116. const CtFormRef = ref()
  117. const formItem = ref({
  118. options: [
  119. {
  120. type: 'datePicker',
  121. key: 'time',
  122. value: null,
  123. format: 'YYYY-MM-DD',
  124. label: '到期时间 *',
  125. labelWidth: 110,
  126. disabledDate: true,
  127. teleported: true
  128. }
  129. ]
  130. })
  131. const apiList = [ closeJobAdvertised, enableJobAdvertised ]
  132. // 职位关闭、激活
  133. const handleAction = async (index, { id }) => {
  134. const ids = [id]
  135. if (!ids.length && !index) return
  136. loading.value = true
  137. try {
  138. await apiList[index](ids)
  139. Snackbar.success(t('common.operationSuccessful'))
  140. emit('refresh')
  141. } finally {
  142. loading.value = false
  143. }
  144. }
  145. const router = useRouter()
  146. // 职位编辑
  147. const handleEdit = async (val) => {
  148. if (!val.id || !val.edit) return
  149. const data = await getEnterprisePubJobTypePermission()
  150. if (!data || !data.length) return Snackbar.warning('没有该操作权限,请联系平台管理员升级后再试')
  151. router.push(`/recruit/enterprise/hirePosition/edit?id=${val.id}`)
  152. }
  153. // 职位过期时间修改
  154. const expireTimeId = ref('')
  155. const handleUpdateExpireTime = (item) => {
  156. expireTimeId.value = item.id
  157. showExpire.value = true
  158. }
  159. const handleSubmit = async () => {
  160. // const { valid } = await CtFormRef.value.formRef.validate()
  161. // if (!valid) return
  162. const time = formItem.value.options.find(e => e.key === 'time').value
  163. if (!time) return Snackbar.warning('请选择职位到期时间')
  164. await updatePositionExpireTime({ id: expireTimeId.value, time })
  165. expireTimeId.value = ''
  166. showExpire.value = false
  167. emit('refresh')
  168. }
  169. // 职位详情
  170. const handleDetail = async (val) => {
  171. if (!val.id) return
  172. window.open(`/recruit/enterprise/position/details?id=${val.id}`)
  173. }
  174. // 查看职位投递简历
  175. const handleToResume = (val) => {
  176. router.push(`/recruit/enterprise/invite/resume?id=${val.id}&hire=1`)
  177. }
  178. </script>
  179. <style scoped lang="scss">
  180. .itemBox {
  181. position: relative;
  182. border: 1px solid #e5e6eb;
  183. }
  184. .position-name {
  185. color: var(--color-333);
  186. font-size: 19px;
  187. }
  188. .position {
  189. position: relative;
  190. .item-select {
  191. position: absolute;
  192. left: -8px;
  193. top: -13px;
  194. }
  195. }
  196. .lines {
  197. display: inline-block;
  198. width: 1px;
  199. height: 17px;
  200. vertical-align: middle;
  201. background-color: #e0e0e0;
  202. margin: 0 10px;
  203. }
  204. .other-info {
  205. font-size: 15px;
  206. color: var(--color-666);
  207. }
  208. .bottom {
  209. position: absolute;
  210. bottom: 0;
  211. left: 0;
  212. width: 100%;
  213. height: 40px;
  214. background-color: #f7f8fa;
  215. font-size: 14px;
  216. color: var(--color-888);
  217. }
  218. .actions:hover {
  219. color: var(--v-primary-base) !important;
  220. }
  221. </style>