position.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import { reactive, ref, nextTick } from 'vue'
  2. import { getDict } from '@/hooks/web/useDictionaries'
  3. import { getPublicRatio } from '@/api/recruit/enterprise/position'
  4. const dictObj = reactive({
  5. payUnit: [], // 薪资单位
  6. scale: [], // 规模
  7. industry: [], // 行业
  8. edu: [], // 学历
  9. exp: [], // 工作经验
  10. sex: [],
  11. area: [], // 地区
  12. jobStatus: [], // 求职状态
  13. marital: [], // 婚姻状态
  14. })
  15. const dictList = ref([
  16. { type: 'menduner_pay_unit', value: 'payUnit', key: 'payUnit', label: 'payName' },
  17. { type: 'menduner_scale', value: 'scale', key: 'scale', label: 'scaleName' },
  18. { type: 'menduner_job_seek_status', value: 'jobStatus', key: 'jobStatus', label: 'jobStatusName' },
  19. { type: 'menduner_marital_status', value: 'marital', key: 'maritalStatus', label: 'maritalStatusName' },
  20. { type: 'menduner_sex', value: 'sex', key: 'sex', label: 'sexName' },
  21. { type: 'menduner_industry_type', value: 'industry', key: 'industryId', label: 'industryName', params: {}, apiType: 'industryList', nameKey: 'nameCn', valueKey: 'id' },
  22. { type: 'menduner_education_type', value: 'edu', key: 'eduType', label: 'eduName' },
  23. { type: 'menduner_exp_type', value: 'exp', key: 'expType', label: 'expName' },
  24. { type: 'menduner_area_type', value: 'area', key: 'areaId', label: 'areaName', params: {}, apiType: 'areaList', nameKey: 'name', valueKey: 'id' },
  25. { type: 'menduner_area_type', value: 'reg', key: 'regId', label: 'regName', params: {}, apiType: 'areaList', nameKey: 'name', valueKey: 'id' },
  26. { type: 'positionData', value: 'position', key: 'positionId', label: 'positionName', params: {}, apiType: 'positionData', nameKey: 'nameCn', valueKey: 'id' }
  27. ])
  28. // 字典
  29. const getDictList = async () => {
  30. dictList.value.forEach(async (val) => {
  31. const { data } = await getDict(val.type, val.params, val.apiType)
  32. dictObj[val.value] = data
  33. })
  34. }
  35. export const getDictListData = async () => {
  36. await getDictList()
  37. }
  38. getDictListData()
  39. export const dealDictArrayData = (res, list) => {
  40. res = list.map(item => {
  41. Object.keys(item).map(e => {
  42. const data = dictList.value.find(k => k.key === e)
  43. if (!data) return
  44. const valueKey = data.nameKey ? data.nameKey : 'label'
  45. const idKey = data.valueKey ? data.valueKey : 'value'
  46. if (!dictObj[data.value] || !Object.keys(dictObj[data.value]).length) return
  47. // 工作经验、学历为null则是不限
  48. const result = ['expType', 'eduType'].includes(e) && !item[e] ? { label: `${e === 'expType' ? '工作经验' : '学历' }不限` } : dictObj[data.value].find(val => val[idKey] === item[e])
  49. if (!result) return
  50. item[data.label] = result[valueKey] || ''
  51. })
  52. return { ...item, active: false, select: false }
  53. })
  54. return res
  55. }
  56. export const dealDictObjData = (res, obj) => {
  57. res = obj
  58. Object.keys(obj).map(e => {
  59. const data = dictList.value.find(k => k.key === e)
  60. if (!data) return
  61. const valueKey = data.nameKey ? data.nameKey : 'label'
  62. const idKey = data.valueKey ? data.valueKey : 'value'
  63. // 工作经验、学历为null则是不限
  64. const result = ['expType', 'eduType'].includes(e) && !obj[e] ? { label: `${e === 'expType' ? '工作经验' : '学历' }不限` } : dictObj[data.value]?.find(val => val[idKey] === obj[e])
  65. if (!result) return
  66. res[data.label] = result[valueKey]
  67. res = { ...obj, ...res }
  68. })
  69. return res
  70. }
  71. // 计算众聘佣金
  72. let data
  73. const list = ['headhuntRate', 'recommendRate', 'cvRate'] // 平台、推荐人、投递人
  74. const getRation = async () => {
  75. data = await getPublicRatio()
  76. }
  77. getRation()
  78. export const rechargeRatio = () => { return 10 }
  79. export const commissionCalculation = (count, type) => {
  80. if (!data || !Object.keys(data).length) return
  81. // 所占的百分比
  82. const ratio = parseFloat(data[list[type]]) / 10 // 所占的百分比-> 50%变为0.5 (不能改)
  83. // 积分变成金额
  84. const value = count * ratio / rechargeRatio()
  85. return value % 1 === 0 ? Math.floor(value) : value.toFixed(2)
  86. }
  87. // "分"和"元" 转化。 type-> toCent:提交给后端需要乘以100; toYuan:回显需要除以100)
  88. export const FenYuanTransform = (count, type='toYuan') => {
  89. if ((count - 0) === 0) return 0
  90. if (!count) return ''
  91. const Magnification = type === 'toCent' ? 100 : 1/100
  92. return type === 'toCent' ? (count - 0)*Magnification : ((count - 0)*Magnification).toFixed(2)
  93. }
  94. // 跳转企业详情(有优选集团页面则跳转集团页面,没有则跳转企业详情页面)
  95. import router from '@/router'
  96. import { getWebContent } from '@/api/common'
  97. const preferred = ref({})
  98. const getSystemWebContent = async () => {
  99. const data = await getWebContent()
  100. // 优选集团
  101. preferred.value = data.appPreferredGroup
  102. }
  103. export const jumpToEnterpriseDetail = async (id, isOpenWindow = false, tabKey = 0) => {
  104. if (!preferred.value || !Object.keys(preferred.value).length) await getSystemWebContent()
  105. // 跳转集团页面
  106. if (preferred.value[id] && Object.keys(preferred.value[id]).length > 0) return window.open(`/recruit/personal/advertisement/${id}`)
  107. // 不在优选集团中跳转企业详情
  108. const key = tabKey ? 'recruitmentPositions' : 'briefIntroduction'
  109. const url = `/recruit/personal/company/details/${id}?key=${key}`
  110. if (isOpenWindow) {
  111. window.open(url)
  112. } else {
  113. router.push({ path: url })
  114. }
  115. }