diff --git a/ruoyi-ui/src/views/ccdiEmployee/index.vue b/ruoyi-ui/src/views/ccdiEmployee/index.vue index 80bc7f2..ae2faab 100644 --- a/ruoyi-ui/src/views/ccdiEmployee/index.vue +++ b/ruoyi-ui/src/views/ccdiEmployee/index.vue @@ -425,6 +425,68 @@ export default { } }, methods: { + /** + * 保存导入任务到localStorage + * @param {Object} taskData - 任务数据 + */ + saveImportTaskToStorage(taskData) { + try { + const data = { + ...taskData, + saveTime: Date.now() + }; + localStorage.setItem('employee_import_last_task', JSON.stringify(data)); + } catch (error) { + console.error('保存导入任务状态失败:', error); + } + }, + /** + * 从localStorage读取导入任务 + * @returns {Object|null} 任务数据或null + */ + getImportTaskFromStorage() { + try { + const data = localStorage.getItem('employee_import_last_task'); + if (!data) return null; + + const task = JSON.parse(data); + + // 数据格式校验 + if (!task || !task.taskId) { + this.clearImportTaskFromStorage(); + return null; + } + + // 时间戳校验 + if (task.saveTime && typeof task.saveTime !== 'number') { + this.clearImportTaskFromStorage(); + return null; + } + + // 过期检查(7天) + const sevenDays = 7 * 24 * 60 * 60 * 1000; + if (Date.now() - task.saveTime > sevenDays) { + this.clearImportTaskFromStorage(); + return null; + } + + return task; + } catch (error) { + console.error('读取导入任务状态失败:', error); + this.clearImportTaskFromStorage(); + return null; + } + }, + /** + * 清除localStorage中的导入任务 + */ + clearImportTaskFromStorage() { + try { + localStorage.removeItem('employee_import_last_task'); + } catch (error) { + console.error('清除导入任务状态失败:', error); + } + }, /** 查询员工列表 */ getList() { this.loading = true;