|
|
@@ -60,6 +60,8 @@ export class StudyRecordsPageComponent implements OnInit {
|
|
|
readonly scheduleDateCounts = signal<Record<string, { planned: number; missed: number }>>({});
|
|
|
readonly overviewReadingRecord = signal<Item | null>(null);
|
|
|
readonly readingLoadingId = signal('');
|
|
|
+ readonly recordPage = signal(1);
|
|
|
+ readonly recordPageSize = 20;
|
|
|
readonly datePickerMonthLabel = computed(() => new Intl.DateTimeFormat('zh-CN', { year: 'numeric', month: 'long' }).format(this.datePickerMonth()));
|
|
|
readonly datePickerDays = computed<DatePickerDay[]>(() => {
|
|
|
const month = this.datePickerMonth();
|
|
|
@@ -91,6 +93,11 @@ export class StudyRecordsPageComponent implements OnInit {
|
|
|
if (!selectedDate) return this.items();
|
|
|
return this.items().filter((item) => this.dateKey(item['CreateTime'] ?? item['createTime'] ?? item['dqrq'] ?? item['date']) === selectedDate);
|
|
|
});
|
|
|
+ readonly recordPageCount = computed(() => Math.max(1, Math.ceil(this.visibleItems().length / this.recordPageSize)));
|
|
|
+ readonly paginatedItems = computed(() => {
|
|
|
+ const start = (this.recordPage() - 1) * this.recordPageSize;
|
|
|
+ return this.visibleItems().slice(start, start + this.recordPageSize);
|
|
|
+ });
|
|
|
readonly latestReadingRecord = computed(() => this.overviewReadingRecord() ?? this.items().find((item) => extractReadingWords(item['xxqs']).length > 0));
|
|
|
readonly latestReadingWordCount = computed(() => {
|
|
|
const item = this.latestReadingRecord();
|
|
|
@@ -157,6 +164,7 @@ export class StudyRecordsPageComponent implements OnInit {
|
|
|
this.studentId = Number(this.studentId || 0);
|
|
|
this.syncSelectedStudentContext();
|
|
|
this.selectedDate = this.dateKey(this.selectedDate);
|
|
|
+ this.recordPage.set(1);
|
|
|
this.syncDatePickerMonth();
|
|
|
this.syncHistoryState();
|
|
|
this.load();
|
|
|
@@ -164,6 +172,7 @@ export class StudyRecordsPageComponent implements OnInit {
|
|
|
|
|
|
showAllRecords(): void {
|
|
|
this.selectedDate = '';
|
|
|
+ this.recordPage.set(1);
|
|
|
this.syncHistoryState();
|
|
|
this.load();
|
|
|
}
|
|
|
@@ -183,6 +192,7 @@ export class StudyRecordsPageComponent implements OnInit {
|
|
|
|
|
|
selectDate(date: string): void {
|
|
|
this.selectedDate = date;
|
|
|
+ this.recordPage.set(1);
|
|
|
this.closeDatePicker();
|
|
|
this.syncHistoryState();
|
|
|
this.load();
|
|
|
@@ -196,6 +206,7 @@ export class StudyRecordsPageComponent implements OnInit {
|
|
|
|
|
|
clearDate(): void {
|
|
|
this.selectedDate = '';
|
|
|
+ this.recordPage.set(1);
|
|
|
this.closeDatePicker();
|
|
|
this.syncHistoryState();
|
|
|
this.load();
|
|
|
@@ -203,6 +214,10 @@ export class StudyRecordsPageComponent implements OnInit {
|
|
|
|
|
|
toggleCoursesExpanded(): void { this.coursesExpanded.update((expanded) => !expanded); }
|
|
|
|
|
|
+ goToRecordPage(page: number): void {
|
|
|
+ this.recordPage.set(Math.min(this.recordPageCount(), Math.max(1, page)));
|
|
|
+ }
|
|
|
+
|
|
|
selectedDateLabel(): string {
|
|
|
if (!this.selectedDate) return '全部日期';
|
|
|
const [year, month, day] = this.selectedDate.split('-').map(Number);
|
|
|
@@ -436,7 +451,9 @@ export class StudyRecordsPageComponent implements OnInit {
|
|
|
}).pipe(finalize(() => this.loading.set(false))).subscribe({
|
|
|
next: ({ result }) => {
|
|
|
const overview = result ?? {} as LearningOverview;
|
|
|
- this.items.set(Array.isArray(overview.records) ? overview.records : []);
|
|
|
+ const records = Array.isArray(overview.records) ? overview.records : [];
|
|
|
+ this.items.set(records);
|
|
|
+ this.recordPage.update((page) => Math.min(page, Math.max(1, Math.ceil(records.length / this.recordPageSize))));
|
|
|
this.overviewReadingRecord.set(overview.latestReadingRecord ?? null);
|
|
|
this.learningSchedules.set(Array.isArray(overview.schedules) ? overview.schedules : []);
|
|
|
this.recordDateCounts.set(overview.recordDateCounts ?? {});
|