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();
}
}
};