item.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <div>
  3. <div v-if="props.items.length" class="d-flex align-center mb-1">
  4. <v-checkbox v-if="tab === 1" v-model="selectAll" :label="!selectAll ? $t('common.selectAll') : `已选中${selectList.length}条`" hide-details color="primary" @update:model-value="handleChangeSelectAll"></v-checkbox>
  5. <div v-if="tab === 1" class="ml-8">
  6. <v-btn :disabled="!selectAll" color="primary" variant="tonal" size="small" @click="handleAction(2, 'batch', {})">一键刷新</v-btn>
  7. <v-btn class="mx-3" :disabled="!selectAll" color="primary" variant="tonal" size="small" @click="handleAction(3, 'top', {})">{{ $t('common.topping') }}</v-btn>
  8. <!-- <v-btn class="mr-3" :disabled="!selectAll" color="primary" variant="tonal" size="small" @click="handleAction(4, 'top', {})">取消置顶</v-btn> -->
  9. <v-btn :disabled="!selectAll" color="primary" variant="tonal" size="small" @click="handleAction(0, 'close', {})">{{ $t('common.close') }}</v-btn>
  10. </div>
  11. <!-- <v-btn v-if="tab === 2" class="ml-8" :disabled="!selectAll" color="primary" variant="tonal" size="small" @click="handleAction(1, 'activation', {})">一键激活</v-btn> -->
  12. </div>
  13. <div v-for="val in items" :key="val.id" class="itemBox mb-3" style="height: 134px;">
  14. <div v-if="val.top && tab === 1" style="position: absolute;">
  15. <svg-icon name="top" size="50"></svg-icon>
  16. </div>
  17. <div class="d-flex justify-space-between" style="padding: 10px 20px;">
  18. <div class="position" :style="{'max-width': (val.status-0) === 99 && tab === 0 ? '70%' : '85%'}">
  19. <div class="item-select ml-5" v-if="tab === 1">
  20. <v-checkbox v-model="val.select" hide-details color="primary" @update:model-value="handleChangeSelect"></v-checkbox>
  21. </div>
  22. <div class="d-flex align-center" :class="{'cursor-pointer': tab === 1, 'ml-15': tab === 1}" @click="handleDetail(val)">
  23. <span class="position-name" v-ellipse-tooltip>{{ formatName(val.name) }}</span>
  24. </div>
  25. <div :class="['mt-3', 'other-info', 'ellipsis', {'ml-10': tab === 1}]">
  26. <span>{{ !val.areaId ? '全国' : val.area?.str }}</span>
  27. <span class="lines" v-if="val.eduName"></span>
  28. <span>{{ val.eduName }}</span>
  29. <span class="lines"></span>
  30. <span>{{ val.expName }}</span>
  31. <span class="lines" v-if="val.expName"></span>
  32. <span v-if="!val.payFrom && !val.payTo">面议</span>
  33. <span v-else>{{ val.payFrom ? val.payFrom + '-' : '' }}{{ val.payTo }}{{ val.payName ? '/' + val.payName : '' }}</span>
  34. <span class="lines" v-if="val.positionName"></span>
  35. <span>{{ val.positionName }}</span>
  36. </div>
  37. </div>
  38. <div v-if="tab !== 0" class="text-center color-primary d-flex flex-column justify-center cursor-pointer" @click="handleToResume(val)">
  39. <div class="font-weight-bold font-size-18">{{ val.count || 0 }}</div>
  40. <div class="font-size-14">已投递简历</div>
  41. </div>
  42. <div v-if="(val.status-0) === 99 && tab === 0" class="d-flex align-center">
  43. <v-chip color="warning" label>职位待发布,支付成功后自动发布</v-chip>
  44. </div>
  45. </div>
  46. <div class="bottom pa-5 d-flex justify-space-between align-center">
  47. <div v-if="val.hrName" class="d-flex align-center bottom-item">
  48. <v-avatar size="30">
  49. <v-img :src="getUserAvatar(val.hrHeadImg)" />
  50. </v-avatar>
  51. <div class="ml-3" v-ellipse-tooltip>{{ val.hrName }}</div>
  52. </div>
  53. <div class="bottom-item" v-ellipse-tooltip :style="{'text-align': val.hrName ? 'center' : 'start'}">
  54. <span>{{ $t('position.refreshTime') }} :{{ val.refreshTime ? timesTampChange(val.refreshTime, 'Y-M-D h:m') : '暂无' }}</span>
  55. </div>
  56. <div class="d-flex bottom-item justify-end">
  57. <div class="ml-10 d-flex">
  58. <div v-if="tab === 1">
  59. <span class="cursor-pointer actions" @click="handleAction(val.top ? 4 : 3, '', val)">{{ val.top ? '取消置顶' : $t('common.topping') }}</span>
  60. <span class="lines"></span>
  61. <span class="cursor-pointer actions" @click="handleAction(0, '', val)">{{ $t('common.close') }}</span>
  62. </div>
  63. <span v-if="jobNum && +jobNum > 0 && (val.status-0) === 99 && tab === 0">
  64. <span class="cursor-pointer color-primary" @click="handleRelease(val)">使用额度发布</span>
  65. <span class="lines"></span>
  66. </span>
  67. <span v-if="(val.status-0) === 99 && tab === 0" class="cursor-pointer color-primary" @click="toPay(val)">支付发布</span>
  68. <span class="lines" v-if="tab !== 2 && tab !== 3"></span>
  69. <span v-if="tab === 2" class="cursor-pointer actions" @click="handleAction(1, '', val, val)">激活</span>
  70. <span class="lines" v-if="tab === 2"></span>
  71. <span class="cursor-pointer actions" @click="handleDetail(val)">详情</span>
  72. <div v-if="tab !== 3">
  73. <span class="lines"></span>
  74. <span class="cursor-pointer" :class="{'actions': val.edit}" :style="{'color': val.edit ? '#333' : '#999'}" @click="handleEdit(val)">{{ $t('common.edit') }}</span>
  75. <v-tooltip v-if="!val.edit" activator="parent" location="top">职位发布时间超过24小时的不支持编辑</v-tooltip>
  76. </div>
  77. <span v-if="(val.status-0) === 99 && tab === 0">
  78. <span class="lines"></span>
  79. <span class="cursor-pointer actions color-error" @click="handleDelete(val)">删除</span>
  80. </span>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. <confirmPaymentDialog
  87. v-if="showConfirmPaymentDialog"
  88. :cost="39900"
  89. :spuId="spuId"
  90. :spuName="spuName"
  91. :showEnterpriseJump="true"
  92. :showOriginalPrice="true"
  93. :orderType="1"
  94. @paySuccess="paySuccess"
  95. @close="showConfirmPaymentDialog = false"
  96. ></confirmPaymentDialog>
  97. <Loading :visible="loading"></Loading>
  98. </template>
  99. <script setup>
  100. defineOptions({ name: 'enterprise-position-item'})
  101. import { ref, watch } from 'vue'
  102. import { useRouter } from 'vue-router'
  103. import { timesTampChange } from '@/utils/date'
  104. import { useI18n } from '@/hooks/web/useI18n'
  105. import { getEnterprisePubJobTypePermission } from '@/api/recruit/enterprise/position'
  106. import { closeJobAdvertised, enableJobAdvertised, refreshJobAdvertised, topJobAdvertised, topJobAdvertisedCancel, createTradeOrder } from '@/api/position'
  107. import Snackbar from '@/plugins/snackbar'
  108. import { useUserStore } from '@/store/user'
  109. import Confirm from '@/plugins/confirm'
  110. import { getUnpaidOrder } from '@/api/common'
  111. import { formatName } from '@/utils/getText'
  112. import { getUserAvatar } from '@/utils/avatar'
  113. import { updatePositionStatus, deletePosition } from '@/api/enterprise'
  114. const store = useUserStore()
  115. const { t } = useI18n()
  116. const emit = defineEmits(['refresh'])
  117. const props = defineProps({
  118. tab: {
  119. type: Number,
  120. default: 1
  121. },
  122. items: Array,
  123. jobNum: Number
  124. })
  125. const loading = ref(false)
  126. const selectAll = ref(false) // 全选
  127. const selectList = ref([]) // 选中列表
  128. const dealSelect = () => {
  129. selectList.value = props.items.filter(e => e.select).map(k => k.id)
  130. }
  131. // 全选
  132. const handleChangeSelectAll = () => {
  133. props.items.map(k => {
  134. k.select = selectAll.value
  135. return k
  136. })
  137. dealSelect()
  138. }
  139. // 单选
  140. const handleChangeSelect = () => {
  141. const length = props.items.filter(k => k.select).length
  142. selectAll.value = length > 0 ? true : false
  143. dealSelect()
  144. }
  145. // tab改变时清空选中的项
  146. watch(
  147. () => props.tab,
  148. () => {
  149. props.items.map(e => e.select = false)
  150. selectList.value = []
  151. selectAll.value = false
  152. },
  153. { immediate: true }
  154. )
  155. // 分页选中回显
  156. watch(
  157. () => props.items,
  158. (newVal) => {
  159. selectList.value.forEach(e => {
  160. const obj = newVal.find(k => k.id === e)
  161. if (obj) obj.select = true
  162. })
  163. },
  164. { immediate: true },
  165. { deep: true }
  166. )
  167. let baseInfo = ref(JSON.parse(localStorage.getItem('entBaseInfo')) || {})
  168. store.$subscribe((mutation, state) => {
  169. if (Object.keys(state.entBaseInfo).length) baseInfo.value = state.entBaseInfo
  170. })
  171. // 使用额度发布职位
  172. const handleRelease = async (val) => {
  173. if (!val.id) return
  174. try {
  175. await updatePositionStatus(val.id)
  176. Snackbar.success('发布成功')
  177. emit('refresh', 1)
  178. } catch {}
  179. }
  180. // 删除待支付职位
  181. const handleDelete = async (val) => {
  182. if (!val.id) return
  183. try {
  184. await deletePosition(val.id)
  185. Snackbar.success('删除成功')
  186. emit('refresh', 1)
  187. } catch {}
  188. }
  189. const showConfirmPaymentDialog = ref(false)
  190. const spuId = ref('')
  191. const spuName = ref('')
  192. const operateObj = ref({})
  193. // 支付
  194. const toPay = async (val) => {
  195. // 待发布且有额度的激活职位即可
  196. // if (baseInfo.value.entitlement?.publishJobCount > 0) {
  197. // await enableJobAdvertised([val.id])
  198. // Snackbar.success('发布成功')
  199. // emit('refresh', 1)
  200. // return
  201. // }
  202. operateObj.value = val
  203. spuId.value = val.id || ''
  204. spuName.value = val.name || ''
  205. showConfirmPaymentDialog.value = true
  206. }
  207. // 支付成功
  208. const paySuccess = async () => {
  209. showConfirmPaymentDialog.value = false
  210. setTimeout(() => {
  211. emit('refresh', 1)
  212. }, 1000)
  213. }
  214. const apiList = [closeJobAdvertised, enableJobAdvertised, refreshJobAdvertised, topJobAdvertised, topJobAdvertisedCancel]
  215. // 职位关闭、激活、刷新、置顶
  216. const handleAction = async (index, type, { id }, item) => {
  217. const ids = type ? props.items.filter(e => e.select).map(k => k.id) : [id]
  218. if (!ids.length && !index) return
  219. // 关闭职位提醒
  220. if (index === 0) {
  221. const text = baseInfo.value?.entitlement?.publishJobCount && baseInfo.value?.entitlement?.publishJobCount > 0 ? '将消耗一个发布点数' : '将重新收取费用'
  222. Confirm('系统提示', `是否确认关闭所选职位?关闭后再激活,${text}`).then(async () => {
  223. await apiList[index](ids)
  224. Snackbar.success(t('common.operationSuccessful'))
  225. // 清空选项
  226. selectList.value = []
  227. selectAll.value = false
  228. emit('refresh')
  229. })
  230. return
  231. }
  232. // 没有可发布额度激活职位需重新付款
  233. await store.getEnterpriseInfo(true)
  234. if (index === 1 && baseInfo.value?.entitlement.publishJobCount <= 0) {
  235. // 判断是否已有创建好的订单,有就直接跳转支付,没有就创建订单
  236. const data = await getUnpaidOrder({ spuId: id, type: 1 })
  237. if (!data) await createTradeOrder({ spuId: id, spuName: item.name, price: 39900, type: 1 })
  238. toPay(item)
  239. return
  240. }
  241. loading.value = true
  242. try {
  243. await apiList[index](ids)
  244. Snackbar.success(t('common.operationSuccessful'))
  245. // 清空选项
  246. selectList.value = []
  247. selectAll.value = false
  248. emit('refresh')
  249. } finally {
  250. loading.value = false
  251. }
  252. }
  253. const router = useRouter()
  254. // 职位编辑
  255. const handleEdit = async (val) => {
  256. if (!val.id || !val.edit) return
  257. const data = await getEnterprisePubJobTypePermission()
  258. if (!data || !data.length) return Snackbar.warning('没有该操作权限,请联系平台管理员升级后再试')
  259. router.push(`/recruit/enterprise/position/edit?id=${val.id}`)
  260. }
  261. // 职位详情
  262. const handleDetail = async (val) => {
  263. if (!val.id) return
  264. window.open(`/recruit/enterprise/position/details?id=${val.id}`)
  265. }
  266. // 查看职位投递简历
  267. const handleToResume = (val) => {
  268. let path = `/recruit/enterprise/resume?id=${val.id}`
  269. // if (val.bizId) path += `&jobFairId=${val.bizId}`
  270. router.push(path)
  271. }
  272. </script>
  273. <style scoped lang="scss">
  274. .itemBox {
  275. position: relative;
  276. border: 1px solid #e5e6eb;
  277. }
  278. .position-name {
  279. color: var(--color-333);
  280. font-size: 19px;
  281. }
  282. .position {
  283. position: relative;
  284. .item-select {
  285. position: absolute;
  286. left: -8px;
  287. top: -13px;
  288. }
  289. }
  290. .lines {
  291. display: inline-block;
  292. width: 1px;
  293. height: 17px;
  294. vertical-align: middle;
  295. background-color: #e0e0e0;
  296. margin: 0 10px;
  297. }
  298. .other-info {
  299. font-size: 15px;
  300. color: var(--color-666);
  301. }
  302. .bottom {
  303. position: absolute;
  304. bottom: 0;
  305. left: 0;
  306. width: 100%;
  307. height: 40px;
  308. background-color: #f7f8fa;
  309. font-size: 14px;
  310. color: var(--color-888);
  311. &-item {
  312. width: 33.3%;
  313. max-width: 33.3%;
  314. }
  315. }
  316. .actions:hover {
  317. color: var(--v-primary-base) !important;
  318. }
  319. </style>