item.vue 11 KB

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