item.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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">赏金:{{ commissionCalculation(val.hirePrice, 1) }}元</v-chip>
  25. </div>
  26. </div>
  27. <div class="d-flex align-center">
  28. <v-chip v-if="(val.status-0) === 99" color="warning" label>职位待发布,支付后成功后自动发布</v-chip>
  29. <v-chip v-if="val.status === '1' && tab === 2" color="error" class="cursor-pointer" label style="text-decoration: underline;" @click="toPay(val)">职位已关闭,点击激活职位</v-chip>
  30. </div>
  31. </div>
  32. <div class="bottom pa-5 d-flex justify-space-between align-center">
  33. <div>
  34. {{ $t('position.refreshTime') }} :{{ timesTampChange(val.updateTime, 'Y-M-D') }}
  35. <span v-if="val.expireTime">
  36. <span class="septal-line"></span>
  37. 到期时间:{{ timesTampChange(val.expireTime, 'Y-M-D') }}
  38. </span>
  39. </div>
  40. <div class="d-flex align-center">
  41. <span v-if="(val.status-0) === 99" class="cursor-pointer color-primary" @click="toPay(val)">去支付</span>
  42. <span v-if="(val.status - 0) !== 99 && val.status !== '1' && tab === 1" class="cursor-pointer actions" @click="handleAction(0, val)">{{ $t('common.close') }}</span>
  43. <span v-if="(val.status - 0) !== 99 && val.status !== '1' && tab === 1" class="lines"></span>
  44. <span v-if="tab === 1" class="cursor-pointer" @click="handleEdit(val)">编辑</span>
  45. <span v-if="tab === 3" class="cursor-pointer" @click="handleUpdateExpireTime(val)">修改到期时间</span>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <confirmPaymentDialog
  51. v-if="showConfirmPaymentDialog"
  52. :cost="cost"
  53. :spuId="spuId"
  54. :spuName="spuName"
  55. :orderType="2"
  56. @paySuccess="paySuccess"
  57. @close="showConfirmPaymentDialog = false"
  58. ></confirmPaymentDialog>
  59. <Loading :visible="loading"></Loading>
  60. <CtDialog :visible="showExpire" :widthType="2" titleClass="text-h6" title="修改职位到期时间" @close="showExpire = false; expireTimeId = null" @submit="handleSubmit">
  61. <CtForm v-if="showExpire" ref="CtFormRef" :items="formItem" style="height: 100px;"></CtForm>
  62. </CtDialog>
  63. </template>
  64. <script setup>
  65. import { commissionCalculation } from '@/utils/position'
  66. defineOptions({ name: 'enterprise-position-item'})
  67. import { ref } from 'vue'
  68. import { useRouter } from 'vue-router'
  69. import { timesTampChange } from '@/utils/date'
  70. import { useI18n } from '@/hooks/web/useI18n'
  71. import { closeJobAdvertised, enableJobAdvertised, updatePositionExpireTime } from '@/api/position'
  72. import Snackbar from '@/plugins/snackbar'
  73. import confirmPaymentDialog from '@/components/pay/confirmPaymentDialog.vue'
  74. const { t } = useI18n()
  75. const emit = defineEmits(['refresh'])
  76. const props = defineProps({
  77. items: Array,
  78. tab: Number
  79. })
  80. const loading = ref(false)
  81. const showConfirmPaymentDialog = ref(false)
  82. const cost = ref(0)
  83. const spuId = ref('')
  84. const spuName = ref('')
  85. const operateObj = ref({})
  86. const toPay = (val) => { // 已关闭的职位激活需要再次支付
  87. operateObj.value = val
  88. spuId.value = val.id || ''
  89. spuName.value = val.name || ''
  90. cost.value = val.hirePrice
  91. // 打开支付弹窗
  92. showConfirmPaymentDialog.value = true
  93. }
  94. // 支付成功
  95. const paySuccess = async () => {
  96. showConfirmPaymentDialog.value = false
  97. console.log(' operateObj.value?.status', operateObj.value?.status)
  98. if (operateObj.value?.status === '1') {
  99. handleAction(1, operateObj.value)
  100. }
  101. setTimeout(() => {
  102. emit('refresh')
  103. }, 1000)
  104. }
  105. const showExpire = ref(false)
  106. const CtFormRef = ref()
  107. const formItem = ref({
  108. options: [
  109. {
  110. type: 'datePicker',
  111. key: 'time',
  112. value: null,
  113. format: 'YYYY-MM-DD',
  114. label: '到期时间 *',
  115. labelWidth: 110,
  116. disabledDates: true
  117. }
  118. ]
  119. })
  120. const apiList = [ closeJobAdvertised, enableJobAdvertised ]
  121. // 职位关闭、激活
  122. const handleAction = async (index, { id }) => {
  123. const ids = [id]
  124. if (!ids.length && !index) return
  125. loading.value = true
  126. try {
  127. await apiList[index](ids)
  128. Snackbar.success(t('common.operationSuccessful'))
  129. emit('refresh')
  130. } finally {
  131. loading.value = false
  132. }
  133. }
  134. const router = useRouter()
  135. // 职位编辑
  136. const handleEdit = (val) => {
  137. if (props.tab !== 1) return
  138. router.push(`/recruit/enterprise/hirePosition/edit?id=${val.id}`)
  139. }
  140. // 职位过期时间修改
  141. const expireTimeId = ref('')
  142. const handleUpdateExpireTime = (item) => {
  143. expireTimeId.value = item.id
  144. showExpire.value = true
  145. }
  146. const handleSubmit = async () => {
  147. // const { valid } = await CtFormRef.value.formRef.validate()
  148. // if (!valid) return
  149. const time = formItem.value.options.find(e => e.key === 'time').value
  150. if (!time) return Snackbar.warning('请选择职位到期时间')
  151. await updatePositionExpireTime({ id: expireTimeId.value, time })
  152. expireTimeId.value = ''
  153. showExpire.value = false
  154. emit('refresh')
  155. }
  156. </script>
  157. <style scoped lang="scss">
  158. .itemBox {
  159. position: relative;
  160. border: 1px solid #e5e6eb;
  161. }
  162. .position-name {
  163. color: var(--color-333);
  164. font-size: 19px;
  165. }
  166. .position {
  167. max-width: 46%;
  168. position: relative;
  169. .item-select {
  170. position: absolute;
  171. left: -8px;
  172. top: -13px;
  173. }
  174. }
  175. .lines {
  176. display: inline-block;
  177. width: 1px;
  178. height: 17px;
  179. vertical-align: middle;
  180. background-color: #e0e0e0;
  181. margin: 0 10px;
  182. }
  183. .other-info {
  184. font-size: 15px;
  185. color: var(--color-666);
  186. }
  187. .bottom {
  188. position: absolute;
  189. bottom: 0;
  190. left: 0;
  191. width: 100%;
  192. height: 40px;
  193. background-color: #f7f8fa;
  194. font-size: 14px;
  195. color: var(--color-888);
  196. }
  197. .actions:hover {
  198. color: var(--v-primary-base);
  199. }
  200. </style>