position.js 6.6 KB

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