瀏覽代碼

feat: department filter

未来全栈 3 月之前
父節點
當前提交
b696944563
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5 5
      soul-app/src/app/page-psysurvey/page-psysurvey.component.ts

+ 5 - 5
soul-app/src/app/page-psysurvey/page-psysurvey.component.ts

@@ -6,7 +6,7 @@ import { IonHeader,IonButton, IonContent, IonIcon, IonItem, IonLabel, IonList,
   import { HttpClient } from '@angular/common/http';
   import { UserService } from '../user.service'; // 确保路径正确
   import { FormsModule } from '@angular/forms'; // 导入 FormsModule
-import { CloudQuery } from 'src/lib/ncloud';
+import { CloudQuery, CloudUser } from 'src/lib/ncloud';
 
 
   
@@ -37,9 +37,6 @@ export class PagePsysurveyComponent  implements OnInit {
    }
 
    ngOnInit() {
-    // 动态获取当前用户的学院信息
-    let user = this.userService.getCurrentUser()
-      this.userApartment = user.get("apartment"); // 从用户数据中获取学院
       this.getSurveys(); // 在获取到用户信息后获取问卷
   }
 
@@ -49,8 +46,11 @@ export class PagePsysurveyComponent  implements OnInit {
       this.filterSurveys(); // 过滤问卷
   }
   filterSurveys() {
+    let user = new CloudUser();
+    console.log(user)
     this.filteredSurveys = this.surveys.filter(survey => {
-      return survey.get("audience") === this.userApartment || survey.get("audience") === 'all';
+      console.log(survey.get("audience"), user.get("department"))
+      return (survey.get("audience") === user.get("department") || survey.get("audience") === 'all');
     });
   }