item.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. @close="showConfirmPaymentDialog = false"
  84. ></confirmPaymentDialog>
  85. </template>
  86. <script setup>
  87. import { commissionCalculation } from '@/utils/position'
  88. defineOptions({ name: 'enterprise-position-item'})
  89. import { ref, watch } from 'vue'
  90. import { useRouter } from 'vue-router'
  91. import { timesTampChange } from '@/utils/date'
  92. import { useI18n } from '@/hooks/web/useI18n'
  93. import { closeJobAdvertised, enableJobAdvertised, refreshJobAdvertised, topJobAdvertised } from '@/api/position'
  94. import Snackbar from '@/plugins/snackbar'
  95. import confirmPaymentDialog from '@/components/pay/confirmPaymentDialog.vue'
  96. const { t } = useI18n()
  97. const emit = defineEmits(['refresh'])
  98. const props = defineProps({
  99. tab: {
  100. type: Number,
  101. default: 1
  102. },
  103. items: Array
  104. })
  105. const showConfirmPaymentDialog = ref(false)
  106. const cost = ref(0)
  107. const spuId = ref('')
  108. const spuName = ref('')
  109. const toPay = (val) => {
  110. console.log('1', val)
  111. //
  112. spuId.value = val.id || ''
  113. spuName.value = val.name || ''
  114. cost.value = (val.hirePrice - 0) || 0
  115. // 打开支付弹窗
  116. showConfirmPaymentDialog.value = true
  117. }
  118. const selectAll = ref(false) // 全选
  119. const selectList = ref([]) // 选中列表
  120. const dealSelect = () => {
  121. selectList.value = props.items.filter(e => e.select).map(k => k.id)
  122. }
  123. // 全选
  124. const handleChangeSelectAll = () => {
  125. props.items.map(k => {
  126. k.select = selectAll.value
  127. return k
  128. })
  129. dealSelect()
  130. }
  131. // 单选
  132. const handleChangeSelect = () => {
  133. const length = props.items.filter(k => k.select).length
  134. selectAll.value = length > 0 ? true : false
  135. dealSelect()
  136. }
  137. // tab改变时清空选中的项
  138. watch(
  139. () => props.tab,
  140. () => {
  141. props.items.map(e => e.select = false)
  142. selectList.value = []
  143. selectAll.value = false
  144. },
  145. { immediate: true }
  146. )
  147. // 分页选中回显
  148. watch(
  149. () => props.items,
  150. (newVal) => {
  151. selectList.value.forEach(e => {
  152. const obj = newVal.find(k => k.id === e)
  153. if (obj) obj.select = true
  154. })
  155. },
  156. { immediate: true },
  157. { deep: true }
  158. )
  159. const apiList = [ closeJobAdvertised, enableJobAdvertised, refreshJobAdvertised, topJobAdvertised ]
  160. // 职位关闭、激活、刷新、置顶
  161. const handleAction = async (index, type, { id }) => {
  162. const ids = type ? props.items.filter(e => e.select).map(k => k.id) : [id]
  163. if (!ids.length && !index) return
  164. await apiList[index](ids)
  165. Snackbar.success(t('common.operationSuccessful'))
  166. // 清空选项
  167. selectList.value = []
  168. selectAll.value = false
  169. emit('refresh')
  170. }
  171. const router = useRouter()
  172. // 职位编辑
  173. const handleEdit = (val) => {
  174. router.push(`/recruit/enterprise/position/edit?id=${val.id}`)
  175. }
  176. // 职位详情
  177. const handleDetails = (val) => {
  178. window.open(`/recruit/enterprise/position/details/${val.id}`)
  179. }
  180. // 跳转招聘统计
  181. const handleToStatistics = () => {
  182. router.push('/recruit/enterprise/statistics/overallAnalysis')
  183. }
  184. </script>
  185. <style scoped lang="scss">
  186. .itemBox {
  187. position: relative;
  188. border: 1px solid #e5e6eb;
  189. }
  190. .position-name {
  191. color: var(--color-333);
  192. font-size: 19px;
  193. cursor: pointer;
  194. &:hover {
  195. color: var(--v-primary-base);
  196. }
  197. }
  198. .position {
  199. max-width: 46%;
  200. position: relative;
  201. .item-select {
  202. position: absolute;
  203. left: -8px;
  204. top: -13px;
  205. }
  206. }
  207. .lines {
  208. display: inline-block;
  209. width: 1px;
  210. height: 17px;
  211. vertical-align: middle;
  212. background-color: #e0e0e0;
  213. margin: 0 10px;
  214. }
  215. .other-info {
  216. font-size: 15px;
  217. color: var(--color-666);
  218. }
  219. .bottom {
  220. position: absolute;
  221. bottom: 0;
  222. left: 0;
  223. width: 100%;
  224. height: 40px;
  225. background-color: #f7f8fa;
  226. font-size: 14px;
  227. color: var(--color-888);
  228. }
  229. .resume {
  230. display: flex;
  231. font-size: 13px;
  232. flex-direction: column;
  233. align-items: center;
  234. color: var(--color-888);
  235. margin-right: 100px;
  236. cursor: pointer;
  237. }
  238. .resume-number {
  239. font-size: 20px;
  240. font-weight: 700;
  241. color: var(--color-999);
  242. }
  243. </style>