From 02d20b4552e7b8c4db832b2dfcfb9f572aa512a6 Mon Sep 17 00:00:00 2001 From: haozq <1611483981@qq.com> Date: Wed, 25 Dec 2024 10:48:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bns/html/device/equment/device.html | 4 +-- bns/js/device/device.js | 34 ++++++++++++++++++++- bns/js/projectInformation/projectDetails.js | 25 +++++++-------- bns/js/system/htmlpermission.js | 2 -- 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/bns/html/device/equment/device.html b/bns/html/device/equment/device.html index 29e36e6..5b2c320 100644 --- a/bns/html/device/equment/device.html +++ b/bns/html/device/equment/device.html @@ -111,8 +111,8 @@ - - + +
diff --git a/bns/js/device/device.js b/bns/js/device/device.js index 2317c10..6759249 100644 --- a/bns/js/device/device.js +++ b/bns/js/device/device.js @@ -64,8 +64,38 @@ layui.use(['layer', 'form', 'element','laypage'], function(){ exportData(); }) $("#downloadExcel").click(function(){ - window.open(dataUrl + 'proteam/pot/device/downloadExcel' + '?token=' + token); + downLoadExcelModel(); }) + + /*模板下载*/ + function downLoadExcelModel() { + let loadingMsg = layer.msg('模板下载中,请稍候...', {icon: 16, scrollbar: false, time: 0}); + let url = dataUrl + 'proteam/pot/device/downloadExcel' + '?token=' + token + let xhr = new XMLHttpRequest(); + xhr.open("get", url, true); + xhr.responseType = "blob"; // 转换流 + xhr.setRequestHeader("encrypt", + sm3(JSON.stringify({}))); + xhr.setRequestHeader('encryption','encryption'); + xhr.setRequestHeader('token',token); + xhr.onload = function () { + layer.close(loadingMsg); // 关闭提示层 + if (this.status === 200) { + let blob = this.response; + var a = document.createElement("a"); + var url = window.URL.createObjectURL(blob); + a.href = url; + a.download = "设备导入模板.xlsx"; // 文件名 + } else { + layer.msg('服务异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000}); + } + a.click() + window.URL.revokeObjectURL(url) + }; + xhr.send(); + } + + $(".layui-import").click(function(){ $("#import-excel").trigger('click'); }) @@ -94,6 +124,8 @@ layui.use(['layer', 'form', 'element','laypage'], function(){ } } }); + + $("#query").off().click(function(){ if(/^[a-zA-Z0-9\u4e80-\u9fa5\\s-]+$/.test($("#deviceName").val()) || ""==$("#deviceName").val()){ diff --git a/bns/js/projectInformation/projectDetails.js b/bns/js/projectInformation/projectDetails.js index 7e3465d..8117a6d 100644 --- a/bns/js/projectInformation/projectDetails.js +++ b/bns/js/projectInformation/projectDetails.js @@ -142,7 +142,6 @@ function pages(pageNum, pageSize) { url: dataUrl + 'proteam/pot/newPro/getProList?token=' + token, data: params, type: 'POST', - async: false, success: function (result) { if (result.code === 200) { console.log(result); @@ -399,9 +398,7 @@ function viewData(data) { function getOrgSelect() { let keys = []; $.ajax({ - headers: { - "encrypt": sm3(JSON.stringify({})) - }, + url: dataUrl + 'proteam/pot/team/getOrgSelected' + '?token=' + token, type: 'post', success: function (data) { @@ -425,14 +422,11 @@ function getOrgSelect() { function getProject() { let keys = []; $("#bidName").empty(); - Ajax().post({ - headers: { - "encrypt": sm3(JSON.stringify({ - currentUserId: user.userId, - isSup: user.isSup, - currentUserOrgId: user.orgId - })) - }, + $.ajax({ + type: 'post', + headers:{ + "encryption":"encryption" + }, url: dataUrl + 'proteam/pot/newPro/getProjectSelect', data: { currentUserId: user.userId, @@ -440,6 +434,8 @@ function getProject() { currentUserOrgId: user.orgId }, success: function (data) { + console.log("----44------>") + console.log(data) let obj = data.data; $.each(obj, function (index, item) { keys.push({ @@ -448,13 +444,14 @@ function getProject() { }); }); - formSelects.data('bidName', 'local', { arr: keys }); formSelects.btns('bidName',['remove']) form.render(); - } + },error:function(e){ + console.log("222") + } }); } diff --git a/bns/js/system/htmlpermission.js b/bns/js/system/htmlpermission.js index b5c3b9d..2157e8b 100644 --- a/bns/js/system/htmlpermission.js +++ b/bns/js/system/htmlpermission.js @@ -8,9 +8,7 @@ function getLocalpath(){ url[1]='/base/log/logManage.html'; } let yq=getHtmlPermission(usJosn.menus,url[1]); - console.log(yq) if(!yq){ - addLogs(url,url[1],usJosn.nickName); top.window.location.href = login_url; }