item.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div>
  3. <div v-if="props.items.length" class="d-flex align-center mb-1">
  4. <v-checkbox v-if="tab !== 3 && tab !== 4" 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', {})">{{ $t('common.refresh') }}</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 :disabled="!selectAll" color="primary" variant="tonal" size="small" @click="handleAction(0, 'close', {})">{{ $t('common.close') }}</v-btn>
  9. </div>
  10. <v-btn v-if="tab === 2" class="ml-8" :disabled="!selectAll" color="primary" variant="tonal" size="small" @click="handleAction(1, 'activation', {})">{{ $t('common.activation') }}</v-btn>
  11. </div>
  12. <div v-for="val in items" :key="val.id" class="itemBox mb-3" :style="{'height': val?.hire ? '162px' : '134px'}">
  13. <div class="d-flex justify-space-between" style="padding: 10px 20px;">
  14. <div class="position">
  15. <div v-if="tab !== 3 && tab !== 4" class="item-select">
  16. <v-checkbox v-model="val.select" hide-details color="primary" @update:model-value="handleChangeSelect"></v-checkbox>
  17. </div>
  18. <div :class="[{'ml-10': tab !== 3 && tab !== 4} ,'d-flex' ,'align-center']">
  19. <span v-if="val.name.indexOf('style')" v-html="val.name" class="position-name" @click="handleDetails(val)"></span>
  20. <span v-else class="position-name" @click="handleDetails(val)">{{ val.name }}</span>
  21. <svg-icon v-if="tab === 4" class="ml-3" name="pin" size="25"></svg-icon>
  22. </div>
  23. <div :class="['mt-3', 'other-info', 'ellipsis', {'ml-10': tab !== 3 && tab !== 4}]">
  24. <span>{{ val.areaName }}</span>
  25. <span class="lines" v-if="val.areaName && val.eduName"></span>
  26. <span>{{ val.eduName }}</span>
  27. <span class="lines"></span>
  28. <span>{{ val.expName }}</span>
  29. <span class="lines"></span>
  30. <span>{{ val.payFrom }}-{{ val.payTo }}/{{ val.payName }}</span>
  31. <span class="lines"></span>
  32. <span>{{ val.positionName }}</span>
  33. </div>
  34. <div v-if="val?.hire" class="mt-2">
  35. <v-chip v-if="val?.hirePrice && val.hirePrice > 0" class="mr-3" label color="primary" size="small">赏金:{{ commissionCalculation(val.hirePrice, 1) }}元</v-chip>
  36. <v-chip v-if="val?.hirePoint && val.hirePoint > 0" label color="primary" size="small">积分:{{ commissionCalculation(val.hirePoint, 1) }}点</v-chip>
  37. </div>
  38. </div>
  39. <div class="d-flex align-center">
  40. <div v-if="tab === 1">
  41. <!-- <v-btn color="primary" variant="tonal">{{ $t('position.talentSearch') }}</v-btn> -->
  42. <v-btn class="ml-3" color="primary" @click="handleAction(2, '', val)">{{ $t('common.refresh') + $t('common.position') }}</v-btn>
  43. </div>
  44. <div v-if="tab === 2">
  45. <v-btn color="primary" @click="handleAction(1, '', val)">{{ $t('common.activatePosition') }}</v-btn>
  46. </div>
  47. </div>
  48. </div>
  49. <div class="bottom pa-5 d-flex justify-space-between align-center">
  50. <div>{{ $t('position.refreshTime') }} :{{ timesTampChange(val.updateTime, 'Y-M-D') }} {{ val.expireDay && Number(val.expireDay) >= 1 ? `(${ val.expireDay }天后到期)` : '' }}</div>
  51. <div class="d-flex">
  52. <div class="ml-10 d-flex">
  53. <div v-if="tab === 4 && (val.status-0) === 99">
  54. <span class="cursor-pointer defaultLink" style="color: primary;" @click="toPay(val)">去支付</span>
  55. <span class="lines"></span>
  56. </div>
  57. <div v-if="tab === 1">
  58. <span class="cursor-pointer" @click="handleAction(3, '', val)">{{ $t('common.topping') }}</span>
  59. <span class="lines"></span>
  60. <span class="cursor-pointer" @click="handleAction(0, '', val)">{{ $t('common.close') }}</span>
  61. <span class="lines"></span>
  62. </div>
  63. <span class="cursor-pointer" @click="handleToStatistics">{{ $t('position.recruitmentStatistics') }}</span>
  64. <div v-if="tab !== 3">
  65. <span class="lines"></span>
  66. <span class="cursor-pointer" @click="handleEdit(val)">{{ $t('common.edit') }}</span>
  67. </div>
  68. <!-- <div v-if="tab === 4">
  69. <span class="lines"></span>
  70. <span class="cursor-pointer">{{ $t('common.close') }}</span>
  71. </div> -->
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <confirmPaymentDialog
  78. v-if="showConfirmPaymentDialog"
  79. :cost="cost"
  80. :spuId="spuId"
  81. :spuName="spuName"
  82. :type="2"
  83. returnUrl="/recruit/enterprise/position?hire=1"
  84. @close="showConfirmPaymentDialog = false"
  85. ></confirmPaymentDialog>
  86. </template>
  87. <script setup>
  88. import { commissionCalculation } from '@/utils/position'
  89. defineOptions({ name: 'enterprise-position-item'})
  90. import { ref, watch } from 'vue'
  91. import { useRouter } from 'vue-router'
  92. import { timesTampChange } from '@/utils/date'
  93. import { useI18n } from '@/hooks/web/useI18n'
  94. import { closeJobAdvertised, enableJobAdvertised, refreshJobAdvertised, topJobAdvertised } from '@/api/position'
  95. import Snackbar from '@/plugins/snackbar'
  96. import confirmPaymentDialog from '@/components/pay/confirmPaymentDialog.vue'
  97. const { t } = useI18n()
  98. const emit = defineEmits(['refresh'])
  99. const props = defineProps({
  100. tab: {
  101. type: Number,
  102. default: 1
  103. },
  104. items: Array
  105. })
  106. const showConfirmPaymentDialog = ref(false)
  107. const cost = ref(0)
  108. const spuId = ref('')
  109. const spuName = ref('')
  110. const toPay = (val) => {
  111. spuId.value = val.id || ''
  112. spuName.value = val.name || ''
  113. cost.value = (val.hirePrice - 0) || 0
  114. // 打开支付弹窗
  115. showConfirmPaymentDialog.value = true
  116. }
  117. const selectAll = ref(false) // 全选
  118. const selectList = ref([]) // 选中列表
  119. const dealSelect = () => {
  120. selectList.value = props.items.filter(e => e.select).map(k => k.id)
  121. }
  122. // 全选
  123. const handleChangeSelectAll = () => {
  124. props.items.map(k => {
  125. k.select = selectAll.value
  126. return k
  127. })
  128. dealSelect()
  129. }
  130. // 单选
  131. const handleChangeSelect = () => {
  132. const length = props.items.filter(k => k.select).length
  133. selectAll.value = length > 0 ? true : false
  134. dealSelect()
  135. }
  136. // tab改变时清空选中的项
  137. watch(
  138. () => props.tab,
  139. () => {
  140. props.items.map(e => e.select = false)
  141. selectList.value = []
  142. selectAll.value = false
  143. },
  144. { immediate: true }
  145. )
  146. // 分页选中回显
  147. watch(
  148. () => props.items,
  149. (newVal) => {
  150. selectList.value.forEach(e => {
  151. const obj = newVal.find(k => k.id === e)
  152. if (obj) obj.select = true
  153. })
  154. },
  155. { immediate: true },
  156. { deep: true }
  157. )
  158. const apiList = [ closeJobAdvertised, enableJobAdvertised, refreshJobAdvertised, topJobAdvertised ]
  159. // 职位关闭、激活、刷新、置顶
  160. const handleAction = async (index, type, { id }) => {
  161. const ids = type ? props.items.filter(e => e.select).map(k => k.id) : [id]
  162. if (!ids.length && !index) return
  163. await apiList[index](ids)
  164. Snackbar.success(t('common.operationSuccessful'))
  165. // 清空选项
  166. selectList.value = []
  167. selectAll.value = false
  168. emit('refresh')
  169. }
  170. const router = useRouter()
  171. // 职位编辑
  172. const handleEdit = (val) => {
  173. router.push(`/recruit/enterprise/position/edit?id=${val.id}`)
  174. }
  175. // 职位详情
  176. const handleDetails = (val) => {
  177. window.open(`/recruit/enterprise/position/details/${val.id}`)
  178. }
  179. // 跳转招聘统计
  180. const handleToStatistics = () => {
  181. router.push('/recruit/enterprise/statistics/overallAnalysis')
  182. }
  183. </script>
  184. <style scoped lang="scss">
  185. .itemBox {
  186. position: relative;
  187. border: 1px solid #e5e6eb;
  188. }
  189. .position-name {
  190. color: var(--color-333);
  191. font-size: 19px;
  192. cursor: pointer;
  193. &:hover {
  194. color: var(--v-primary-base);
  195. }
  196. }
  197. .position {
  198. max-width: 46%;
  199. position: relative;
  200. .item-select {
  201. position: absolute;
  202. left: -8px;
  203. top: -13px;
  204. }
  205. }
  206. .lines {
  207. display: inline-block;
  208. width: 1px;
  209. height: 17px;
  210. vertical-align: middle;
  211. background-color: #e0e0e0;
  212. margin: 0 10px;
  213. }
  214. .other-info {
  215. font-size: 15px;
  216. color: var(--color-666);
  217. }
  218. .bottom {
  219. position: absolute;
  220. bottom: 0;
  221. left: 0;
  222. width: 100%;
  223. height: 40px;
  224. background-color: #f7f8fa;
  225. font-size: 14px;
  226. color: var(--color-888);
  227. }
  228. .resume {
  229. display: flex;
  230. font-size: 13px;
  231. flex-direction: column;
  232. align-items: center;
  233. color: var(--color-888);
  234. margin-right: 100px;
  235. cursor: pointer;
  236. }
  237. .resume-number {
  238. font-size: 20px;
  239. font-weight: 700;
  240. color: var(--color-999);
  241. }
  242. </style>