diff --git a/offer_backend/apps/organizations/views.py b/offer_backend/apps/organizations/views.py index f1c6c7c..8144a01 100644 --- a/offer_backend/apps/organizations/views.py +++ b/offer_backend/apps/organizations/views.py @@ -7,8 +7,14 @@ from apps.accounts.permissions import IsSuperAdmin class OrganizationPublicViewSet(viewsets.ReadOnlyModelViewSet): """公开只读:门户展示用,返回顶级组织(集团)及其子公司树""" - queryset = Organization.objects.filter(is_active=True, parent__isnull=True) + queryset = Organization.objects.filter(is_active=True) serializer_class = OrganizationTreeSerializer + + def get_queryset(self): + # 列表只返回顶级,详情可查任意 + if self.action == 'list': + return Organization.objects.filter(is_active=True, parent__isnull=True) + return Organization.objects.filter(is_active=True) permission_classes = [AllowAny] diff --git a/offer_frontend/src/views/portal/CompanyDetailView.vue b/offer_frontend/src/views/portal/CompanyDetailView.vue index 6cecc34..67bcbe7 100644 --- a/offer_frontend/src/views/portal/CompanyDetailView.vue +++ b/offer_frontend/src/views/portal/CompanyDetailView.vue @@ -21,11 +21,15 @@ const route = useRoute() const org = ref(null) const jobs = ref([]) onMounted(async () => { - const [orgRes, jobRes] = await Promise.all([ - getOrganization(route.params.id), - getJobs({ organization: route.params.id }) - ]) - org.value = orgRes.data - jobs.value = jobRes.data.results + try { + const [orgRes, jobRes] = await Promise.all([ + getOrganization(route.params.id), + getJobs({ organization: route.params.id }) + ]) + org.value = orgRes.data + jobs.value = jobRes.data.results ?? [] + } catch (e) { + console.error('加载公司详情失败', e) + } }) diff --git a/offer_frontend/src/views/portal/CompanyListView.vue b/offer_frontend/src/views/portal/CompanyListView.vue index cffbe62..8c86ce5 100644 --- a/offer_frontend/src/views/portal/CompanyListView.vue +++ b/offer_frontend/src/views/portal/CompanyListView.vue @@ -47,13 +47,10 @@