item.vue 11 KB

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