item.vue 14 KB

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