From 3bb50077dbfa17acd330281eec9739e6e7b8e645 Mon Sep 17 00:00:00 2001 From: wkc <978997012@qq.com> Date: Fri, 6 Feb 2026 12:15:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0localStorage=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=96=B9=E6=B3=95=E7=94=A8=E4=BA=8E=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=8C=81=E4=B9=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - saveImportTaskToStorage: 保存导入任务到localStorage - getImportTaskFromStorage: 读取并校验导入任务数据 - clearImportTaskFromStorage: 清除localStorage数据 Co-Authored-By: Claude Sonnet 4.5 --- ruoyi-ui/src/views/ccdiEmployee/index.vue | 62 +++++++++++++++++++++++ 1 file changed, 62 insertions(+) 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;