position.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. const result = dictObj[data.value].find(val => val[idKey] === item[e])
  48. if (!result) return
  49. item[data.label] = result[valueKey] || ''
  50. })
  51. return { ...item, active: false, select: false }
  52. })
  53. return res
  54. }
  55. export const dealDictObjData = (res, obj) => {
  56. res = obj
  57. Object.keys(obj).map(e => {
  58. const data = dictList.value.find(k => k.key === e)
  59. if (!data) return
  60. const valueKey = data.nameKey ? data.nameKey : 'label'
  61. const idKey = data.valueKey ? data.valueKey : 'value'
  62. const result = dictObj[data.value]?.find(val => val[idKey] === obj[e])
  63. if (!result) return
  64. res[data.label] = result[valueKey]
  65. res = { ...obj, ...res }
  66. })
  67. return res
  68. }
  69. // 计算众聘佣金
  70. let data
  71. const list = ['headhuntRate', 'recommendRate', 'cvRate'] // 平台、推荐人、投递人
  72. const getRation = async () => {
  73. data = await getPublicRatio()
  74. }
  75. getRation()
  76. export const rechargeRatio = () => { return 10 }
  77. export const commissionCalculation = (count, type) => {
  78. if (!data || !Object.keys(data).length) return
  79. // 所占的百分比
  80. const ratio = parseFloat(data[list[type]]) / 10 // 所占的百分比-> 50%变为0.5 (不能改)
  81. // 积分变成金额
  82. const value = count * ratio / rechargeRatio()
  83. return value % 1 === 0 ? Math.floor(value) : value.toFixed(2)
  84. }
  85. // "分"和"元" 转化。 type-> toCent:提交给后端需要乘以100; toYuan:回显需要除以100)
  86. export const FenYuanTransform = (count, type='toYuan') => {
  87. if ((count - 0) === 0) return 0
  88. if (!count) return ''
  89. const Magnification = type === 'toCent' ? 100 : 1/100
  90. return type === 'toCent' ? (count - 0)*Magnification : ((count - 0)*Magnification).toFixed(2)
  91. }
  92. // 跳转企业详情(有优选集团页面则跳转集团页面,没有则跳转企业详情页面)
  93. import router from '@/router'
  94. import { getWebContent } from '@/api/common'
  95. const preferred = ref({})
  96. const getSystemWebContent = async () => {
  97. const data = await getWebContent()
  98. // 优选集团
  99. preferred.value = data.appPreferredGroup
  100. }
  101. export const jumpToEnterpriseDetail = async (id, isOpenWindow = false, tabKey = 0) => {
  102. if (!preferred.value || !Object.keys(preferred.value).length) await getSystemWebContent()
  103. // 跳转集团页面
  104. if (preferred.value[id] && Object.keys(preferred.value[id]).length > 0) return window.open(`/recruit/personal/advertisement/${id}`)
  105. // 不在优选集团中跳转企业详情
  106. const key = tabKey ? 'recruitmentPositions' : 'briefIntroduction'
  107. if (isOpenWindow) {
  108. window.open(`/recruit/personal/company/details/${id}?key=${key}`)
  109. } else {
  110. await router.push(`/recruit/personal/company/details/${id}?key=${key}`)
  111. await nextTick()
  112. }
  113. }