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

refine(admin): remove obsolete learning sync status from reports

彭峰 3 дней назад
Родитель
Сommit
758b409ef4

+ 1 - 2
projects/xiaoshu-admin/src/app/pages/operations-learning-reports.component.html

@@ -1,4 +1,4 @@
-<header class="page-header report-header"><div><p>LEARNING REPORTS</p><h1>单词学习报表</h1><span>集中查看学生每次学习结果,生成可下载的专业 PDF 报表</span></div><button class="ui-button refresh-action" type="button" (click)="load(true)" [disabled]="refreshing()"><lucide-icon [img]="icons.RefreshCw" [size]="17" [class.spin]="refreshing()" />{{ refreshing() ? '正在同步' : '刷新最新数据' }}</button></header>
+<header class="page-header report-header"><div><p>LEARNING REPORTS</p><h1>单词学习报表</h1><span>集中查看学生每次学习结果,生成可下载的专业 PDF 报表</span></div><button class="ui-button refresh-action" type="button" (click)="load(true)" [disabled]="refreshing()"><lucide-icon [img]="icons.RefreshCw" [size]="17" [class.spin]="refreshing()" />{{ refreshing() ? '正在刷新' : '刷新最新数据' }}</button></header>
 
 @if (message()) { <p class="notice" role="status">{{ message() }}</p> }
 @if (error()) { <p class="notice error" role="alert">{{ error() }}</p> }
@@ -28,7 +28,6 @@
 <ng-template #dateCalendar><div class="calendar-popover day-popover" role="dialog" aria-label="选择日期" (click)="$event.stopPropagation()"><header><button type="button" aria-label="上一月" (click)="shiftCalendar(-1,$event)"><lucide-icon [img]="icons.ChevronLeft" [size]="17" /></button><strong>{{ calendarTitle() }}</strong><button type="button" aria-label="下一月" (click)="shiftCalendar(1,$event)"><lucide-icon [img]="icons.ChevronRight" [size]="17" /></button></header><div class="week-grid" aria-hidden="true">@for(day of weekDays;track day){<span>{{ day }}</span>}</div><div class="day-grid">@for(day of calendarDays();track $index){@if(day){<button type="button" [class.today]="day.date===(today | date:'yyyy-MM-dd')" [class.selected]="day.date===selectedDate()" [attr.aria-label]="day.date" [attr.aria-current]="day.date===selectedDate()?'date':null" (click)="selectDate(day.date)">{{ day.day }}</button>}@else{<span></span>}}</div></div></ng-template>
 
 @if (data(); as pageData) {
-  <div class="source-line" [class.delayed]="pageData.sourceStatus.state !== 'synced'" role="status"><i></i><strong>{{ pageData.sourceStatus.label }}</strong><span>{{ pageData.sourceStatus.message }}</span>@if (pageData.sourceStatus.lastSuccessAt) { <time>{{ pageData.sourceStatus.lastSuccessAt | date:'MM-dd HH:mm:ss' }}</time> }</div>
   <section class="report-metrics" aria-label="学习报表摘要">
     <article><span>学习报表</span><strong>{{ pageData.summary.reportCount }}</strong><small>当前筛选范围</small></article>
     <article><span>学习学员</span><strong>{{ pageData.summary.studentCount }}</strong><small>去重学员人数</small></article>

+ 0 - 39
projects/xiaoshu-admin/src/app/pages/operations-learning-reports.component.scss

@@ -157,38 +157,6 @@
 .query-action {
   min-width: 112px;
 }
-.source-line {
-  display: flex;
-  align-items: center;
-  gap: 8px;
-  margin: 0 0 16px;
-  padding: 10px 14px;
-  border: 1px solid #cfe5dc;
-  border-radius: 13px;
-  background: #eff8f4;
-  color: #2c6654;
-  font-size: 12px;
-}
-.source-line i {
-  width: 8px;
-  height: 8px;
-  border-radius: 50%;
-  background: #26966f;
-}
-.source-line span {
-  color: #70807a;
-}
-.source-line time {
-  margin-left: auto;
-}
-.source-line.delayed {
-  border-color: #efd7ac;
-  background: #fff8e9;
-  color: #956018;
-}
-.source-line.delayed i {
-  background: #dc9228;
-}
 .member-scope {
   display: flex;
   align-items: center;
@@ -558,13 +526,6 @@
   .report-metrics {
     grid-template-columns: 1fr 1fr;
   }
-  .source-line {
-    align-items: flex-start;
-    flex-wrap: wrap;
-  }
-  .source-line time {
-    margin-left: 0;
-  }
   .pdf-sheet {
     transform-origin: top left;
   }

+ 19 - 0
projects/xiaoshu-admin/src/app/pages/operations-learning-reports.component.spec.ts

@@ -39,6 +39,25 @@ describe('OperationsLearningReportsComponent', () => {
     expect(element.textContent).toContain('66.7%');
   });
 
+  it('refreshes the current report data without invoking legacy sync or showing its old status', async () => {
+    const component = fixture.componentInstance;
+    const currentPage = component.data()!;
+    operations.learningReports.and.resolveTo({
+      ...currentPage,
+      sourceStatus: { ...sourceStatus, state: 'delayed', label: '学习记录同步延迟', message: '旧系统 19108 条,新数据库 19111 条' },
+    });
+    operations.learningReports.calls.reset();
+
+    await component.load(true);
+    fixture.detectChanges();
+
+    expect(operations.learningReports).toHaveBeenCalledWith(1, 20, '', jasmine.objectContaining({ studentObjectId: 'student-1' }), false);
+    const text = (fixture.nativeElement as HTMLElement).textContent || '';
+    expect(text).toContain('学习报表已刷新');
+    expect(text).not.toContain('学习记录同步延迟');
+    expect(text).not.toContain('旧系统 19108 条');
+  });
+
   it('opens the complete word report through the detail cloud operation', async () => {
     await fixture.componentInstance.open('study-common-1');
     fixture.detectChanges();

+ 2 - 2
projects/xiaoshu-admin/src/app/pages/operations-learning-reports.component.ts

@@ -121,10 +121,10 @@ export class OperationsLearningReportsComponent implements OnInit, OnDestroy {
     if (!background) { if (refresh) this.refreshing.set(true); else this.loading.set(true); }
     this.error.set(''); this.message.set('');
     try {
-      const page = await this.operations.learningReports(this.page(), this.pageSize, this.search(), this.filters(), refresh);
+      const page = await this.operations.learningReports(this.page(), this.pageSize, this.search(), this.filters(), false);
       if (request !== this.loadRequest) return;
       this.data.set(page);
-      if (refresh) this.message.set(page.sourceStatus.state === 'synced' ? '学习记录已同步到最新水位' : page.sourceStatus.message);
+      if (refresh) this.message.set('学习报表已刷新');
     } catch (error) {
       if (request === this.loadRequest) this.error.set(error instanceof Error ? error.message : '学习报表加载失败');
     } finally {