|
@@ -8,9 +8,70 @@
|
|
|
function importExcel(url, fn) {
|
|
|
var importForm =$("#importForm")[0];
|
|
|
jp.loading(' 正在导入,请稍等...');
|
|
|
- jp.uploadFile(importForm, url,function (data) {
|
|
|
- fn(data);
|
|
|
- })
|
|
|
+ // jp.uploadFile(importForm, url,function (data) {
|
|
|
+ // fn(data);
|
|
|
+ // })
|
|
|
+ var data = new FormData(importForm);
|
|
|
+ // data.append("CustomField", "This is some extra data, testing");//如果要添加参数
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ enctype: 'multipart/form-data',
|
|
|
+ url: url,
|
|
|
+ data: data,
|
|
|
+ processData: false, //prevent jQuery from automatically transforming the data into a query string
|
|
|
+ contentType: false,
|
|
|
+ cache: false,
|
|
|
+ timeout: 600000,
|
|
|
+ success: function (result) {
|
|
|
+ if(result.success && result.errorCode === '-1'){
|
|
|
+ jp.confirm('该项目已存在,确定覆盖嘛?', function(){
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ enctype: 'multipart/form-data',
|
|
|
+ url: '${ctx}/managementcenter/materialinfo/import',
|
|
|
+ data: data,
|
|
|
+ processData: false, //prevent jQuery from automatically transforming the data into a query string
|
|
|
+ contentType: false,
|
|
|
+ cache: false,
|
|
|
+ timeout: 600000,
|
|
|
+ success: function (result) {
|
|
|
+ fn(result);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }else if((result.success && result.errorCode === '0')){
|
|
|
+ fn(result)
|
|
|
+ }
|
|
|
+ // fn(result);
|
|
|
+ },
|
|
|
+ error:function(xhr, textStatus){
|
|
|
+ if(xhr.status == 0){
|
|
|
+ jp.info("连接失败,请检查网络!")
|
|
|
+ }else if(xhr.status == 404){
|
|
|
+ var errDetail ="<font color='red'>404,请求地址不存在!</font>";
|
|
|
+ top.layer.alert(errDetail , {
|
|
|
+ icon: 2,
|
|
|
+ area:['auto','auto'],
|
|
|
+ title:"请求出错"
|
|
|
+ })
|
|
|
+ }else if(xhr.status && xhr.responseText){
|
|
|
+ var errDetail ="<font color='red'>"+ xhr.responseText.replace(/[\r\n]/g,"<br>").replace(/[\r]/g,"<br>").replace(/[\n]/g,"<br>")+"</font>";
|
|
|
+ top.layer.alert(errDetail , {
|
|
|
+ icon: 2,
|
|
|
+ area:['80%','70%'],
|
|
|
+ title:xhr.status+"错误"
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ var errDetail =xhr.responseText=="<font color='red'>未知错误!</font>";
|
|
|
+ top.layer.alert(errDetail , {
|
|
|
+ icon: 2,
|
|
|
+ area:['auto','auto'],
|
|
|
+ title:"真悲剧,后台抛出异常了"
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
</script>
|
|
|
</head>
|
|
@@ -19,19 +80,10 @@
|
|
|
<div id="importBox" >
|
|
|
<form id="importForm" action="${url}" method="post" enctype="multipart/form-data"
|
|
|
style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入,请稍等...');">
|
|
|
- <div>
|
|
|
- <label class="label-item single-overflow pull-left" title="选择文件:">选择文件:</label>
|
|
|
<input id="uploadFile" name="file" type="file" class="form-control" style="width:300px"/>
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- <label class="label-item single-overflow pull-left" title="选择物料库:">选择物料库:</label>
|
|
|
- <select name="batch" class="form-control simple-select" style="width:300px">
|
|
|
- <option value="" label=""/>
|
|
|
- <c:forEach var="item" items="${batch}">
|
|
|
- <option value="${item.suppliesBatch}" label="${item.suppliesBatch}"/>
|
|
|
- </c:forEach>
|
|
|
- </select>
|
|
|
- </div>
|
|
|
+ <br/>
|
|
|
+ 导入文件不能超过5M,仅允许导入“xls”或“xlsx”格式文件!
|
|
|
+
|
|
|
</form>
|
|
|
</div>
|
|
|
</div>
|