popularEnterprises.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div>
  3. <HotPromoted :items="items"></HotPromoted>
  4. <div class="text-center">
  5. <v-btn class="buttons" color="primary" to="/recruit/personal/company">{{ $t('enterprise.moreBtn') }}</v-btn>
  6. </div>
  7. </div>
  8. </template>
  9. <script setup name="popularEnterprises">
  10. import HotPromoted from '@/components/Enterprise/hotPromoted.vue'
  11. import { ref, reactive } from 'vue'
  12. import { getHotEnterprise } from '@/api/enterprise'
  13. import { getDict } from '@/hooks/web/useDictionaries'
  14. import { dealDictArrayData } from '@/views/recruit/personal/position/components/dict'
  15. const items = ref([])
  16. const dictObj = reactive({
  17. payUnit: [], // 薪资单位
  18. scale: [], // 规模
  19. industry: [], // 行业
  20. edu: [], // 学历
  21. exp: [], // 工作经验
  22. area: [], // 地区
  23. financing: [] // 融资类型
  24. })
  25. const dictList = ref([
  26. { type: 'menduner_pay_unit', value: 'payUnit', key: 'payUnit', label: 'payName' },
  27. { type: 'menduner_education_type', value: 'edu', key: 'eduType', label: 'eduName' },
  28. { type: 'menduner_exp_type', value: 'exp', key: 'expType', label: 'expName' },
  29. { type: 'menduner_area_type', value: 'area', key: 'areaId', label: 'areaName', params: {}, apiType: 'areaList', nameKey: 'name', valueKey: 'id' },
  30. { type: 'menduner_financing_status', value: 'financing', key: 'financingStatus', label: 'financingName', isEnter: true },
  31. { type: 'menduner_scale', value: 'scale', key: 'scale', label: 'scaleName', isEnter: true },
  32. { type: 'menduner_industry_type', value: 'industry', key: 'industryId', label: 'industryName', params: {}, apiType: 'industryList', nameKey: 'nameCn', valueKey: 'id', isEnter: true }
  33. ])
  34. // 热门企业
  35. const getHotEnterpriseList = async () => {
  36. const { list } = await getHotEnterprise({ pageNo: 1, pageSize: 9 })
  37. dictList.value.forEach(item => {
  38. items.value = list.map(e => {
  39. if (item.isEnter) {
  40. const valueKey = item.nameKey ? item.nameKey : 'label'
  41. const idKey = item.valueKey ? item.valueKey : 'value'
  42. const obj = dictObj[item.value].find(k => k[idKey] === e.enterprise[item.key])
  43. if (!obj) return
  44. e[item.label] = obj[valueKey]
  45. }
  46. const list = e.jobList
  47. if (!item.isEnter) {
  48. // 职位列表
  49. e.jobList = dealDictArrayData([], list).slice(0, 3)
  50. }
  51. return e
  52. })
  53. })
  54. }
  55. // 字典
  56. const getDictList = async () => {
  57. dictList.value.forEach(async (val) => {
  58. const { data } = await getDict(val.type, val.params, val.apiType)
  59. dictObj[val.value] = data
  60. })
  61. }
  62. const getData = async () => {
  63. await getDictList()
  64. getHotEnterpriseList()
  65. }
  66. getData()
  67. </script>