feat: 添加导入状态恢复和用户交互方法

- restoreImportState: 从localStorage恢复导入状态
- getLastImportTooltip: 获取导入时间提示信息
- clearImportHistory: 用户手动清除历史记录
- created(): 添加状态恢复调用

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
wkc
2026-02-06 12:19:32 +08:00
parent 3bb50077db
commit 8bf2792fd7

View File

@@ -416,6 +416,7 @@ export default {
created() { created() {
this.getList(); this.getList();
this.getDeptTree(); this.getDeptTree();
this.restoreImportState(); // 新增:恢复导入状态
}, },
beforeDestroy() { beforeDestroy() {
// 组件销毁时清除定时器 // 组件销毁时清除定时器
@@ -487,6 +488,55 @@ export default {
console.error('清除导入任务状态失败:', error); console.error('清除导入任务状态失败:', error);
} }
}, },
/**
* 恢复导入状态
* 在created()钩子中调用
*/
async restoreImportState() {
const savedTask = this.getImportTaskFromStorage();
if (!savedTask) {
this.showFailureButton = false;
this.currentTaskId = null;
return;
}
// 如果有失败记录,恢复按钮显示
if (savedTask.hasFailures && savedTask.taskId) {
this.currentTaskId = savedTask.taskId;
this.showFailureButton = true;
}
},
/**
* 获取上次导入的提示信息
* @returns {String} 提示文本
*/
getLastImportTooltip() {
const savedTask = this.getImportTaskFromStorage();
if (savedTask && savedTask.timestamp) {
const date = new Date(savedTask.timestamp);
const timeStr = this.parseTime(date, '{y}-{m}-{d} {h}:{i}');
return `上次导入: ${timeStr}`;
}
return '';
},
/**
* 清除导入历史记录
* 用户手动触发
*/
clearImportHistory() {
this.$confirm('确认清除上次导入记录?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.clearImportTaskFromStorage();
this.showFailureButton = false;
this.currentTaskId = null;
this.failureDialogVisible = false;
this.$message.success('已清除');
}).catch(() => {});
},
/** 查询员工列表 */ /** 查询员工列表 */
getList() { getList() {
this.loading = true; this.loading = true;