文件上传基本完成
parent
f81830743d
commit
3b7526f6bd
|
@ -4,18 +4,34 @@
|
||||||
<th:block th:include="include :: header('发货清单列表')" />
|
<th:block th:include="include :: header('发货清单列表')" />
|
||||||
</head>
|
</head>
|
||||||
<body class="gray-bg">
|
<body class="gray-bg">
|
||||||
<div class="col-sm-12 select-table table-striped" th:deliveryId="${deliveryId}">
|
<div class="col-sm-12 select-table table-striped" >
|
||||||
<input id="uploadInput" type="hidden">
|
<input id="uploadInput" type="file" accept=".xls,.xlsx" style="display: none">
|
||||||
|
<div class="col-sm-12 search-collapse" style="display: none" onchange="upLoadFile">
|
||||||
|
<form id="formId">
|
||||||
|
<div class="select-list">
|
||||||
|
<ul>
|
||||||
|
|
||||||
|
<li style="display: none">
|
||||||
|
<label>id:</label>
|
||||||
|
<input th:value="${orderDelivery.id}" type="text" name="deliveryId">
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="btn-group-sm" id="toolbar" role="group">
|
<div class="btn-group-sm" id="toolbar" role="group">
|
||||||
<a class="btn btn-success" onclick="downloadTem()" shiro:hasPermission="manage:delivery:add">
|
<a class="btn btn-success" onclick="downloadTem()" shiro:hasPermission="manage:delivery:add">
|
||||||
<i class="fa fa-download"></i> 下载模板
|
<i class="fa fa-download"></i> 下载模板
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-primary" shiro:hasPermission="manage:delivery:edit" id="upload">
|
<a class="btn btn-primary" onclick="importList()" shiro:hasPermission="manage:delivery:edit" id="upload">
|
||||||
<i class="fa fa-upload"></i> 导入清单
|
<i class="fa fa-upload"></i> 导入清单
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<table id="bootstrap-table"></table>
|
<table id="bootstrap-table" th:deliveryId="${orderDelivery.id}"></table>
|
||||||
</div>
|
</div>
|
||||||
<th:block th:include="include :: footer" />
|
<th:block th:include="include :: footer" />
|
||||||
|
|
||||||
|
@ -30,7 +46,7 @@ url: prefix + "/list",
|
||||||
showToggle:false,
|
showToggle:false,
|
||||||
showPageGo:true,
|
showPageGo:true,
|
||||||
params:{
|
params:{
|
||||||
deliveryId:''
|
deliveryId:$('#bootstrap-table').attr('deliveryid')
|
||||||
},
|
},
|
||||||
columns: [{
|
columns: [{
|
||||||
checkbox: false,
|
checkbox: false,
|
||||||
|
@ -74,22 +90,40 @@ $.table.init(options);
|
||||||
|
|
||||||
}
|
}
|
||||||
function importList(){
|
function importList(){
|
||||||
|
$('#uploadInput').click()
|
||||||
}
|
}
|
||||||
// layui.use('upload',function(){
|
|
||||||
// var upload = layui.upload;
|
document.getElementById('uploadInput').addEventListener('change', function(event) {
|
||||||
// // 渲染
|
const file = event.target.files[0];
|
||||||
// upload.render({
|
let data=new FormData()
|
||||||
// elem: '#uploadInput',
|
data.append('file',file)
|
||||||
// url:prefix+'/importData', // 此处配置你自己的上传接口即可
|
data.append('deliveryId',$('#bootstrap-table').attr('deliveryid'))
|
||||||
// auto: true,
|
var xhr = new XMLHttpRequest(); // 创建XMLHttpRequest对象
|
||||||
// // multiple: true,',
|
xhr.open('POST',prefix+'/importData', true); // 设置请求类型和URL
|
||||||
// done: function(res){
|
// 当请求完成时执行的回调函数
|
||||||
// layer.msg('上传成功');
|
xhr.onload = function (res) {
|
||||||
// console.log(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);
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue