From 9aab7e0540964fcbd9cc36a781cbd313efe7c3d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=86=8A=E4=B8=BD=E5=90=9B?= <664953382@qq.com> Date: Wed, 23 Dec 2020 10:11:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=8C=BA=E8=BF=90=E7=BB=B4=E8=A7=92?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/hardware/device.js | 6 +++ src/api/system/role.js | 8 +++ src/views/hardware/device/list.vue | 86 ++++++++++++++++++++++++++---- src/views/system/area/index.vue | 26 ++++----- vue.config.js | 4 +- 5 files changed, 107 insertions(+), 23 deletions(-) diff --git a/src/api/hardware/device.js b/src/api/hardware/device.js index 5c07c23..8275fff 100644 --- a/src/api/hardware/device.js +++ b/src/api/hardware/device.js @@ -59,4 +59,10 @@ export function exportEquipment(params) { url: '/system/device/export', params }); +} +// 下载用户导入模板 +export function importTemplate() { + return request({ + url: '/system/device/importTemplate', + }) } \ No newline at end of file diff --git a/src/api/system/role.js b/src/api/system/role.js index 463501c..bb3b5ac 100644 --- a/src/api/system/role.js +++ b/src/api/system/role.js @@ -72,4 +72,12 @@ export function exportRole(query) { method: 'get', params: query }) +} + +// 获取角色下拉 +export function roleSelect(params) { + return request({ + url: '/system/role/select', + params + }) } \ No newline at end of file diff --git a/src/views/hardware/device/list.vue b/src/views/hardware/device/list.vue index 6ae18ea..7b9e9f2 100644 --- a/src/views/hardware/device/list.vue +++ b/src/views/hardware/device/list.vue @@ -23,20 +23,24 @@ - 增加 + 增加 批量删除 + v-hasPermi="['system:device:remove']">批量删除 - 导出 + 导入 + + + + 导出 @@ -75,14 +79,14 @@ --> @@ -203,6 +207,27 @@ 取 消 + + + + +
+ 将文件拖到此处,或 + 点击上传 +
+
+ 是否更新已经存在的用户数据 + 下载模板 +
+
提示:仅允许导入“xls”或“xlsx”格式文件!
+
+ +
@@ -215,7 +240,8 @@ import { update, del, saveDeviceFirmware, - exportEquipment + exportEquipment, + importTemplate } from "@/api/hardware/device"; // import { nodeList, addNode, nodeInfo, delNode, nodeSelect } from "@/api/system/device/node"; import { select as productSelect } from "@/api/hardware/product"; @@ -224,7 +250,7 @@ import { userSelect } from "@/api/system/user"; import { list as provinceList, getProvinceByParent } from "@/api/hardware/province"; import { productNodeList, productNodeSelect } from "@/api/hardware/productNode"; import { deviceNodeList, deviceNodeSave, deviceNodeInfo, deviceNodeDel, deviceNodeSelect } from "@/api/hardware/deviceNode"; - +import { getToken } from "@/utils/auth"; export default { name: "DeviceList", components: { @@ -282,6 +308,21 @@ export default { pageNum: 1, pageSize: 10, }, + // 用户导入参数 + upload: { + // 是否显示弹出层(用户导入) + open: false, + // 弹出层标题(用户导入) + title: "", + // 是否禁用上传 + isUploading: false, + // 是否更新已经存在的用户数据 + updateSupport: 0, + // 设置上传的请求头部 + headers: { Authorization: "Bearer " + getToken() }, + // 上传的地址 + url: process.env.VUE_APP_BASE_API + "/system/device/importData" + }, rules: { deviceId: [ { required: true, message: "设备SN不能为空", trigger: "blur" }, @@ -363,6 +404,33 @@ export default { this.download(response.msg); }) }, + /** 导入按钮操作 */ + handleImport () { + this.upload.title = "用户导入"; + this.upload.open = true; + }, + /** 下载模板操作 */ + importTemplate () { + importTemplate().then(response => { + this.download(response.msg); + }); + }, + // 文件上传中处理 + handleFileUploadProgress (event, file, fileList) { + this.upload.isUploading = true; + }, + // 文件上传成功处理 + handleFileSuccess (response, file, fileList) { + this.upload.open = false; + this.upload.isUploading = false; + this.$refs.upload.clearFiles(); + this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true }); + this.getList(); + }, + // 提交上传文件 + submitFileForm () { + this.$refs.upload.submit(); + }, getDeviceTypeLabel (deviceType) { let snap = ''; diff --git a/src/views/system/area/index.vue b/src/views/system/area/index.vue index 026cc0a..0b5a679 100644 --- a/src/views/system/area/index.vue +++ b/src/views/system/area/index.vue @@ -87,9 +87,9 @@ - - - + + + @@ -103,18 +103,13 @@