Просмотр исходного кода

fix: 修复学习记录学员下拉显示

彭峰 2 месяцев назад
Родитель
Сommit
e0bd75cf46

+ 1 - 1
src/app/features/study-records/study-records-page.component.html

@@ -1,6 +1,6 @@
 <section class="records-page">
   @if (meta.path === 'pages/his/his') {
-    <form class="filter-row" (change)="onFilterChange()">@if (session.groupId() === 3) { <label><span>学员</span><select name="student" [(ngModel)]="studentId"><option [ngValue]="0">选择学员</option>@for (student of students(); track $index) { <option [ngValue]="student['szyh']">{{ student['honeyname'] || student['HoneyName'] }}</option> }</select></label> }<label><span>日期</span><input name="date" type="date" [(ngModel)]="selectedDate" /></label></form>
+    <form class="filter-row" (change)="onFilterChange()">@if (session.groupId() === 3) { <label><span>学员</span><select name="student" [(ngModel)]="studentId"><option [ngValue]="0">选择学员</option>@for (student of students(); track studentValue(student) || $index) { <option [ngValue]="studentValue(student)">{{ studentName(student) }}</option> }</select></label> }<label><span>日期</span><input name="date" type="date" [(ngModel)]="selectedDate" /></label></form>
   }
   @if (meta.path === 'pages/his/his') {
     <section class="ai-reading-feature" aria-labelledby="ai-reading-title">

+ 11 - 0
src/app/features/study-records/study-records-page.component.ts

@@ -178,6 +178,17 @@ export class StudyRecordsPageComponent implements OnInit {
     return `${Math.floor(seconds / 3600)}小时${Math.floor((seconds % 3600) / 60)}分`;
   }
 
+  studentValue(student: Item): number {
+    return Number(student['szyh'] ?? student['UserID'] ?? student['UserId'] ?? student['userId'] ?? student['ID'] ?? 0);
+  }
+
+  studentName(student: Item): string {
+    const name = String(student['honeyname'] ?? student['HoneyName'] ?? student['honeyName'] ?? student['UserName'] ?? student['username'] ?? '').trim();
+    if (name) return name;
+    const mobile = String(student['Mobile'] ?? student['mobile'] ?? '').trim();
+    return mobile || `学员 ${this.studentValue(student)}`;
+  }
+
   private loadLearningHistory(uid: number): void {
     const targetUid = this.session.groupId() === 3 ? this.studentId : uid;
     if (!targetUid) {