position.js 6.1 KB

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