popularEnterprises.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div>
  3. <HotPromoted :items="items"></HotPromoted>
  4. <div class="text-center">
  5. <v-btn class="buttons" color="primary">{{ $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 { dealDictData } from '@/views/recruit/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 = [
  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.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. e[item.label] = dictObj[item.value].find(k => Number(k[idKey]) === e[item.key])[valueKey]
  43. }
  44. const list = e.jobList
  45. if (!item.isEnter) {
  46. // 职位列表
  47. e.jobList = dealDictData(e.jobList, list)
  48. }
  49. return e
  50. })
  51. })
  52. }
  53. // 字典
  54. const getDictList = async () => {
  55. dictList.forEach(async (val) => {
  56. const { data } = await getDict(val.type, val.params, val.apiType)
  57. dictObj[val.value] = data
  58. })
  59. }
  60. const getData = async () => {
  61. await getDictList()
  62. getHotEnterpriseList()
  63. }
  64. getData()
  65. </script>