<form class="formadd formadd1" target="frame1" enctype="multipart/form-data" method="post" action="">
<input type="submit" class="submitaddbtn" value="批量领取导入" />
<input type="file" name="file" val="1" class="fileinp fileinp1" id="fileinp1"/>
</form>
//批量领取导入
$(".main").on("change",".fileinp1",function(){
var formData = new FormData();
formData.append("fileExcel",$("#fileinp1")[0].files[0]);
$.ajax({
url: url+"dilatation/setReceiveDilatations",
type : 'POST',
async : false,
data : formData,
// 告诉jQuery不要去处理发送的数据
processData : false,
// 告诉jQuery不要去设置Content-Type请求头
contentType : false,
beforeSend:function(){
layer.msg("正在导入",{icon:0,time:2000});
},
success : function(data) {
console.log(data.dataList[1]);
if(data.code==0){
console.log();
if(data.dataList=='上传文件格式不正确'){
layer.msg("上传文件格式不正确",{icon:0,time:2000});
}else if(data.dataList=='导入失败(第2行,账期为空)' || data.dataList!= ''){
layer.msg("导入失败",{icon:0,time:2000});
}else if(data.dataList[1] == 1){
layer.msg("导入成功",{icon:6,time:2000});
$("#fileinp1").val('');
}
}
}
});
})