index.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <slot name="header"></slot>
  3. <view class="content">
  4. <view v-for="(item,index) in items" :key="item.label" class="content-box">
  5. <view class="content-box-value">
  6. {{ item.count }}
  7. </view>
  8. <view class="content-box-title">
  9. {{ item.label }}
  10. </view>
  11. </view>
  12. </view>
  13. </template>
  14. <script setup>
  15. import { ref } from 'vue';
  16. import { getRecommendCount } from '@/api/position.js'
  17. import { getDict } from '@/hooks/useDictionaries.js'
  18. const props = defineProps({
  19. type: {
  20. type: String,
  21. default: 'menduner_hire_job_cv_status'
  22. }
  23. })
  24. const items = ref([])
  25. // 获取状态
  26. async function recommendCount () {
  27. try {
  28. const { data: dict } = await getDict(props.type)
  29. items.value = dict.data.map(e => {
  30. return {
  31. ...e,
  32. count: 0
  33. }
  34. })
  35. console.log(items)
  36. const { data } = await getRecommendCount()
  37. if (!data) {
  38. return
  39. }
  40. items.value.forEach(e => {
  41. e.count = data.find(_e => _e.key === e.value)?.value || 0
  42. })
  43. } catch (error) {
  44. console.log(error)
  45. }
  46. }
  47. recommendCount()
  48. </script>
  49. <style scoped lang="scss">
  50. .content {
  51. display: flex;
  52. justify-content: space-around;
  53. padding: 36rpx 12rpx;
  54. &-box {
  55. font-size: 20rpx;
  56. color: #999;
  57. text-align: center;
  58. &-value {
  59. font-size: 1.8em;
  60. color: #000;
  61. }
  62. }
  63. }
  64. </style>