From 3b7526f6bd17af2ac7fc629ed3dfaea123478191 Mon Sep 17 00:00:00 2001 From: rdpnr_hemingxia Date: Fri, 11 Apr 2025 18:31:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/manage/delivery/import.html | 74 ++++++++++++++----- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/ruoyi-admin/src/main/resources/templates/manage/delivery/import.html b/ruoyi-admin/src/main/resources/templates/manage/delivery/import.html index 7d82de79..3870a2aa 100644 --- a/ruoyi-admin/src/main/resources/templates/manage/delivery/import.html +++ b/ruoyi-admin/src/main/resources/templates/manage/delivery/import.html @@ -4,18 +4,34 @@ -
- +
+ + + + -
+
@@ -30,7 +46,7 @@ url: prefix + "/list", showToggle:false, showPageGo:true, params:{ - deliveryId:'' + deliveryId:$('#bootstrap-table').attr('deliveryid') }, columns: [{ checkbox: false, @@ -74,22 +90,40 @@ $.table.init(options); } function importList(){ - + $('#uploadInput').click() } - // layui.use('upload',function(){ - // var upload = layui.upload; - // // 渲染 - // upload.render({ - // elem: '#uploadInput', - // url:prefix+'/importData', // 此处配置你自己的上传接口即可 - // auto: true, - // // multiple: true,', - // done: function(res){ - // layer.msg('上传成功'); - // console.log(res) - // } - // }); - // }); + + document.getElementById('uploadInput').addEventListener('change', function(event) { + const file = event.target.files[0]; + let data=new FormData() + data.append('file',file) + data.append('deliveryId',$('#bootstrap-table').attr('deliveryid')) + var xhr = new XMLHttpRequest(); // 创建XMLHttpRequest对象 + xhr.open('POST',prefix+'/importData', true); // 设置请求类型和URL + // 当请求完成时执行的回调函数 + xhr.onload = function (res) { + let data=JSON.parse(res.currentTarget.response) + if (data.code === 0) { + $.modal.msgSuccess('上传成功'); + } else { + $.modal.msgError(data.msg); + + } + $('#uploadInput').val('') + $.table.refresh(); + + }; + + // 当请求发生错误时执行的回调函数 + xhr.onerror = function () { + console.log('上传过程中发生错误'); + }; + // + // // 发送数据到服务器 + xhr.send(data); + + + });