entry-ai-detail.vue 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <view class="page-content h-screen">
  3. <mx-nav-bar :title="prevData.name" border/>
  4. <scroll-view scroll-y class="list-container">
  5. <view class="p-20 fx-col gap-20">
  6. <voluntary-card :data="prevData"/>
  7. <voluntary-major v-for="u in prevData.details" :data="u" hide-btn default-expand disable-summary/>
  8. </view>
  9. </scroll-view>
  10. <view class="h-[60px] fx-row fx-cen-cen px-30 bg-white mx-shadow-up z-10">
  11. <uv-button v-bind="gradientBtnBinding" text="生成志愿报告" @click="goReport"/>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import {computed} from 'vue';
  17. import {getVoluntary} from "@/api/webApi/ie-voluntary";
  18. import {universityDetail} from "@/api/webApi/collegemajor";
  19. import VoluntaryCard from "../components/card/voluntary-card.vue";
  20. import VoluntaryMajor from "../components/card/voluntary-major.vue";
  21. import AIFormCommonStyle from "@/pages/ie/components/AIFormCommonStyle";
  22. import {useTransfer} from "@/hooks/useTransfer";
  23. import {useProvideMajorTreeService} from "@/pages/ie/hooks/useMajorTreeInjection";
  24. import {useCacheStore} from "@/hooks/useCacheStore";
  25. import {useProvideUserSnapshot} from "@/pages/ie/hooks/useUserSnapshotInjection";
  26. export default {
  27. mixins: [AIFormCommonStyle],
  28. components: {VoluntaryCard, VoluntaryMajor},
  29. setup() {
  30. const {usingCacheTransfer, prevData, transferTo} = useTransfer()
  31. const {dispatchCache} = useCacheStore()
  32. const snapshot = computed(() => prevData.value?.userSnapshot)
  33. useProvideMajorTreeService()
  34. useProvideUserSnapshot(snapshot)
  35. return {
  36. usingCacheTransfer,
  37. prevData,
  38. transferTo,
  39. dispatchCache
  40. }
  41. },
  42. async mounted() {
  43. if (!this.usingCacheTransfer && this.prevData.id) {
  44. // this scene is from ai-form page
  45. // reload voluntary then assign to `prevData`, make it the same as cache mode from list-page
  46. const {data} = await getVoluntary(this.prevData)
  47. // noinspection ES6MissingAwait
  48. const tasks = data.details?.map(async u => {
  49. // fill university info by need.
  50. if (!u.university?.name && u.university?.code) {
  51. const payload = {code: u.university.code}
  52. const {data} = await this.dispatchCache(universityDetail, payload)
  53. u.university = data.baseInfo
  54. }
  55. })
  56. // 因为vue3不会自动深度监听,所以要确保university在prevData之前赋值
  57. await Promise.all(tasks)
  58. this.prevData = data
  59. }
  60. },
  61. methods: {
  62. goReport() {
  63. const path = '/pages/ie/entry-ai-report/entry-ai-report'
  64. this.transferTo(path, this.prevData, null, true)
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .list-container {
  71. height: calc(100vh - 44px - 60px - var(--window-bottom));
  72. }
  73. </style>