item.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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 === 1}" @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.areaName }}</span>
  13. <span class="lines" v-if="val.areaName && 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" 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" 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. <span v-if="tab !== 3 && val.edit" class="lines"></span>
  48. <span v-if="tab !== 3 && val.edit" class="cursor-pointer actions" @click="handleEdit(val)">编辑</span>
  49. <!-- <span v-if="tab === 3" class="cursor-pointer actions" @click="handleUpdateExpireTime(val)">修改到期时间</span> -->
  50. <span class="lines" v-if="tab !== 3"></span>
  51. <span class="cursor-pointer actions" @click="handleDetail(val)">详情</span>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. <confirmPaymentDialog
  57. v-if="showConfirmPaymentDialog"
  58. :cost="cost"
  59. :spuId="spuId"
  60. :spuName="spuName"
  61. :orderType="2"
  62. @paySuccess="paySuccess"
  63. @close="showConfirmPaymentDialog = false"
  64. ></confirmPaymentDialog>
  65. <Loading :visible="loading"></Loading>
  66. <CtDialog :visible="showExpire" :widthType="2" titleClass="text-h6" title="修改职位到期时间" @close="showExpire = false; expireTimeId = null" @submit="handleSubmit">
  67. <CtForm v-if="showExpire" ref="CtFormRef" :items="formItem" style="height: 100px;"></CtForm>
  68. </CtDialog>
  69. </template>
  70. <script setup>
  71. import { commissionCalculation } from '@/utils/position'
  72. defineOptions({ name: 'enterprise-position-item'})
  73. import { ref } from 'vue'
  74. import { useRouter } from 'vue-router'
  75. import { timesTampChange } from '@/utils/date'
  76. import { useI18n } from '@/hooks/web/useI18n'
  77. import { closeJobAdvertised, enableJobAdvertised, updatePositionExpireTime } from '@/api/position'
  78. import Snackbar from '@/plugins/snackbar'
  79. import confirmPaymentDialog from '@/components/pay/confirmPaymentDialog.vue'
  80. import { getEnterprisePubJobTypePermission } from '@/api/recruit/enterprise/position'
  81. const { t } = useI18n()
  82. const emit = defineEmits(['refresh'])
  83. const props = defineProps({
  84. items: Array,
  85. tab: Number
  86. })
  87. const loading = ref(false)
  88. const showConfirmPaymentDialog = ref(false)
  89. const cost = ref(0)
  90. const spuId = ref('')
  91. const spuName = ref('')
  92. const operateObj = ref({})
  93. const toPay = (val) => { // 已关闭的职位激活需要再次支付
  94. operateObj.value = val
  95. spuId.value = val.id || ''
  96. spuName.value = val.name || ''
  97. cost.value = val.hirePrice
  98. // 打开支付弹窗
  99. showConfirmPaymentDialog.value = true
  100. }
  101. // 支付成功
  102. const paySuccess = async () => {
  103. showConfirmPaymentDialog.value = false
  104. // console.log(' operateObj.value?.status', operateObj.value?.status)
  105. // if (operateObj.value?.status === '1') {
  106. // handleAction(1, operateObj.value)
  107. // }
  108. setTimeout(() => {
  109. emit('refresh')
  110. }, 1000)
  111. }
  112. const showExpire = ref(false)
  113. const CtFormRef = ref()
  114. const formItem = ref({
  115. options: [
  116. {
  117. type: 'datePicker',
  118. key: 'time',
  119. value: null,
  120. format: 'YYYY-MM-DD',
  121. label: '到期时间 *',
  122. labelWidth: 110,
  123. disabledDate: true,
  124. teleported: true
  125. }
  126. ]
  127. })
  128. const apiList = [ closeJobAdvertised, enableJobAdvertised ]
  129. // 职位关闭、激活
  130. const handleAction = async (index, { id }) => {
  131. const ids = [id]
  132. if (!ids.length && !index) return
  133. loading.value = true
  134. try {
  135. await apiList[index](ids)
  136. Snackbar.success(t('common.operationSuccessful'))
  137. emit('refresh')
  138. } finally {
  139. loading.value = false
  140. }
  141. }
  142. const router = useRouter()
  143. // 职位编辑
  144. const handleEdit = async (val) => {
  145. if (props.tab !== 1) return
  146. const data = await getEnterprisePubJobTypePermission()
  147. if (!data || !data.length) return Snackbar.warning('没有该操作权限,请联系平台管理员升级后再试')
  148. router.push(`/recruit/enterprise/hirePosition/edit?id=${val.id}`)
  149. }
  150. // 职位过期时间修改
  151. const expireTimeId = ref('')
  152. const handleUpdateExpireTime = (item) => {
  153. expireTimeId.value = item.id
  154. showExpire.value = true
  155. }
  156. const handleSubmit = async () => {
  157. // const { valid } = await CtFormRef.value.formRef.validate()
  158. // if (!valid) return
  159. const time = formItem.value.options.find(e => e.key === 'time').value
  160. if (!time) return Snackbar.warning('请选择职位到期时间')
  161. await updatePositionExpireTime({ id: expireTimeId.value, time })
  162. expireTimeId.value = ''
  163. showExpire.value = false
  164. emit('refresh')
  165. }
  166. // 职位详情
  167. const handleDetail = async (val) => {
  168. if (!val.id) return
  169. window.open(`/recruit/enterprise/position/details?id=${val.id}`)
  170. }
  171. // 查看职位投递简历
  172. const handleToResume = (val) => {
  173. router.push(`/recruit/enterprise/resume?id=${val.id}&hire=1`)
  174. }
  175. </script>
  176. <style scoped lang="scss">
  177. .itemBox {
  178. position: relative;
  179. border: 1px solid #e5e6eb;
  180. }
  181. .position-name {
  182. color: var(--color-333);
  183. font-size: 19px;
  184. }
  185. .position {
  186. position: relative;
  187. .item-select {
  188. position: absolute;
  189. left: -8px;
  190. top: -13px;
  191. }
  192. }
  193. .lines {
  194. display: inline-block;
  195. width: 1px;
  196. height: 17px;
  197. vertical-align: middle;
  198. background-color: #e0e0e0;
  199. margin: 0 10px;
  200. }
  201. .other-info {
  202. font-size: 15px;
  203. color: var(--color-666);
  204. }
  205. .bottom {
  206. position: absolute;
  207. bottom: 0;
  208. left: 0;
  209. width: 100%;
  210. height: 40px;
  211. background-color: #f7f8fa;
  212. font-size: 14px;
  213. color: var(--color-888);
  214. }
  215. .actions:hover {
  216. color: var(--v-primary-base);
  217. }
  218. </style>