From 233168e6962e7dc4661baceb47e5cf41b7af6711 Mon Sep 17 00:00:00 2001 From: zch Date: Thu, 12 Jun 2025 14:41:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(ems):=20=E4=BF=AE=E5=A4=8D=E7=9B=91?= =?UTF-8?q?=E7=9D=A3=E6=A3=80=E6=9F=A5=E6=B8=85=E5=8D=95=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E6=97=B6=20token=20=E8=BF=87=E6=9C=9F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 created 钩子中设置上传 headers 中的 token - 在打开导入对话框时重新设置最新的 token - 在提交上传文件前确保 token 是最新的 - 移除了初始化时不必要的 token 设置, --- src/views/ems/info/supervisionChecklist/index.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/views/ems/info/supervisionChecklist/index.vue b/src/views/ems/info/supervisionChecklist/index.vue index e47ce38..eec6341 100644 --- a/src/views/ems/info/supervisionChecklist/index.vue +++ b/src/views/ems/info/supervisionChecklist/index.vue @@ -586,9 +586,7 @@ url: "", updateSupport: false, isUploading: false, - headers: { - Authorization: "Bearer " + localStorage.getItem("token") - } + headers: {} }, // 详情抽屉 detailDrawer: false, @@ -605,6 +603,7 @@ created() { this.getList(); this.upload.url = process.env.VUE_APP_BASE_API + "/ems/info/supervisionChecklist/importData"; + this.upload.headers = { Authorization: "Bearer " + this.$store.getters.token }; }, mounted() { document.addEventListener('click', this.hideContextMenu); @@ -737,6 +736,8 @@ /** 导入按钮操作 */ handleImport() { this.upload.title = "导入动力能源部监督检查清单"; + // 确保在打开导入对话框时重新设置token + this.upload.headers = { Authorization: "Bearer " + this.$store.getters.token }; this.upload.open = true; }, /** 下载模板操作 */ @@ -758,6 +759,8 @@ }, // 提交上传文件 submitFileForm() { + // 在提交前确保token是最新的 + this.upload.headers = { Authorization: "Bearer " + this.$store.getters.token }; this.$refs.upload.submit(); }, // 查看详情