From 977ed5975c03074e4c41e70aa16b901e3a4321a1 Mon Sep 17 00:00:00 2001 From: "zangch@mesnac.com" Date: Thu, 4 Dec 2025 13:20:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(deviceParam):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=8F=82=E6=95=B0=E5=AF=BC=E5=85=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增导入按钮,支持xlsx和xls格式文件上传 - 实现设备参数导入弹窗及拖拽上传区域 - 支持上传时是否更新已存在的设备参数数据 - 完成文件上传的进度、成功和失败处理逻辑 - 提供导入模板下载功能,便于格式规范 - 上传请求携带Token认证,确保接口安全 - 导入完成后刷新列表并显示导入结果提示 --- src/views/base/deviceParam/index.vue | 94 ++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/src/views/base/deviceParam/index.vue b/src/views/base/deviceParam/index.vue index 251b9e3..e6f4f58 100644 --- a/src/views/base/deviceParam/index.vue +++ b/src/views/base/deviceParam/index.vue @@ -76,6 +76,16 @@ v-hasPermi="['base:deviceParam:remove']" >删除 + + 导入 + 取 消 + + + + + +
将文件拖到此处,或点击上传
+
+
+ 是否更新已经存在的设备参数数据 +
+ 仅允许导入xls、xlsx格式文件。 + 下载模板 +
+
+ +
@@ -209,6 +250,7 @@ import { listDeviceParam, getDeviceParam, delDeviceParam, addDeviceParam, updateDeviceParam } from "@/api/base/deviceParam"; import { getDeviceLedgerList } from '@//api/base/deviceLedger' import { findFactoryList } from '@//api/base/factory' +import { getToken } from "@/utils/auth" export default { name: "DeviceParam", @@ -274,6 +316,21 @@ export default { ], // 设备下拉框 deviceLedgerList: [], + // 设备参数导入参数 + upload: { + // 是否显示弹出层(设备参数导入) + open: false, + // 弹出层标题(设备参数导入) + title: "", + // 是否禁用上传 + isUploading: false, + // 是否更新已经存在的设备参数数据 + updateSupport: 0, + // 设置上传的请求头部 + headers: { Authorization: "Bearer " + getToken() }, + // 上传的地址 + url: process.env.VUE_APP_BASE_API + "/base/deviceParam/importData" + }, }; }, created() { @@ -406,6 +463,43 @@ export default { this.download('base/deviceParam/export', { ...this.queryParams }, `deviceParam_${new Date().getTime()}.xlsx`) + }, + /** 导入按钮操作 */ + handleImport() { + this.upload.title = "设备参数导入"; + this.upload.open = true; + }, + /** 下载模板操作 */ + importTemplate() { + this.download('base/deviceParam/importTemplate', { + }, `deviceParam_template_${new Date().getTime()}.xlsx`) + }, + // 文件上传中处理 + handleFileUploadProgress(event, file, fileList) { + this.upload.isUploading = true; + }, + // 文件上传成功处理 + handleFileSuccess(response, file, fileList) { + this.upload.open = false; + this.upload.isUploading = false; + this.$refs.upload.clearFiles(); + if (response.code === 200) { + this.$alert("
" + response.msg + "
", "导入结果", { dangerouslyUseHTMLString: true }); + this.getList(); + } else { + this.$modal.msgError(response.msg || "导入失败"); + } + }, + // 文件上传失败处理 + handleFileError(err, file, fileList) { + this.upload.open = false; + this.upload.isUploading = false; + this.$refs.upload.clearFiles(); + this.$modal.msgError("文件上传失败,请重试"); + }, + // 提交上传文件 + submitFileForm() { + this.$refs.upload.submit(); } } };