1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2025-12-08 13:49:37 +00:00

feat: 更新考勤管理逻辑,优化状态同步与自动保存功能

This commit is contained in:
Sunwuyuan 2025-11-29 15:18:21 +08:00
parent ca3d7c9dbf
commit 069f0a31c0
No known key found for this signature in database
GPG Key ID: A6A54CF66F56BB64

View File

@ -122,7 +122,7 @@
:attendance="state.boardData.attendance" :attendance="state.boardData.attendance"
:date-string="state.dateString" :date-string="state.dateString"
@save="saveAttendance" @save="saveAttendance"
@change="state.synced = false" @change="handleAttendanceChange"
/> />
<message-log ref="messageLog" /> <message-log ref="messageLog" />
@ -343,6 +343,7 @@ export default {
students: false, students: false,
}, },
debouncedUpload: null, debouncedUpload: null,
debouncedAttendanceSave: null,
throttledReflow: null, throttledReflow: null,
sortedItemsCache: { sortedItemsCache: {
key: "", key: "",
@ -615,10 +616,20 @@ export default {
}, },
deep: true, deep: true,
}, },
"state.attendanceDialog": {
handler(newValue) {
this.handleAttendanceDialogClose(newValue);
},
},
}, },
created() { created() {
this.debouncedUpload = debounce(this.uploadData, 2000); this.debouncedUpload = debounce(this.uploadData, 2000);
this.debouncedAttendanceSave = debounce(async () => {
if (this.autoSave) {
await this.trySave(true);
}
}, 2000);
this.throttledReflow = throttle(() => { this.throttledReflow = throttle(() => {
if (this.$refs.gridContainer) { if (this.$refs.gridContainer) {
this.optimizeGridLayout(this.sortedItems); this.optimizeGridLayout(this.sortedItems);
@ -1400,6 +1411,11 @@ export default {
return this.trySave(false); return this.trySave(false);
}, },
handleAttendanceChange() {
this.state.synced = false;
this.debouncedAttendanceSave();
},
async handleAttendanceDialogClose(newValue) { async handleAttendanceDialogClose(newValue) {
if (!newValue && !this.state.synced) { if (!newValue && !this.state.synced) {
await this.trySave(true); await this.trySave(true);