cod-upload.js
1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Created by wangqianjun on 16/4/13.
*/
'use strict';
var $ = require('jquery'),
common = require('../common/common');
$('input[type="file"]').after('<div class="file-name btn btn-default">请选择文件</div>');
function batchExport(el, type) {
var loadModal = null;
return {
params: {
type: type,
__type: "batch-import"
},
onStart: function() {
loadModal = common.dialog.load();
$(el).parents('td').find('.file-name').text($(el).val().replace("C:\\fakepath\\", ""));
},
onComplete: function(response) {
console.log(response);
if (loadModal) {
loadModal.close();
}
if (response.code == 200) {
var failFileReason = response.data['failFileReason'];
// 有数据导入失败
if(failFileReason.length) {
var htmlStr = "";
//for(var item in failFileReason) {
for(var i = 0; i < failFileReason.length; i++){
htmlStr += '<p style="color:red;">"'+failFileReason[i]+'"</p>';
}
htmlStr += '<h2 style="color:red;">请修改后重新上传</h2>';
$('.result').html(htmlStr);
} else {
$('.result').html("");
common.util.__tip(response.message, 'success');
}
} else {
common.util.__tip(response.message, 'warning');
}
}
}
}
common.edit.ajaxfileupload('#sort-file', batchExport('#sort-file', 'payDeliveryModify'));