//上传文件 upload: function () { layui.use('upload', function () { var upload = layui.upload; //执行实例 var uploadInst = upload.render({ elem: '#upload' //绑定元素 , url: QUERY_BATCH_UPLOAD //上传接口 ,auto: false //选择文件后不自动上传 , accept: 'file' , exts: 'xlsx|xls' //只允许上传Excel文件 , size: 5000 //限制文件大小,单位 KB ,choose: function(obj){ // 确定导入文件并进行线上合规验证吗? //确认框 layer.confirm('确定导入文件吗?', {icon: 3, title:'提示'}, function(index){ //读取本地文件 obj.preview(function(index, file, result){ //单个重传 obj.upload(index, file); }); layer.close(index); }); } , done: function (res) { var code = res.code; if(code && code==0){ //上传完毕回调 layer.msg("文件已经成功上传!"); }else{ var msg = res.msg; layer.alert(msg); return; } } , error: function () { //请求异常回调 } }); }); },