goods.cod.Upload.js
3.64 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
webpackJsonp([44],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by wangqianjun on 16/4/13.
*/
'use strict';
var $ = __webpack_require__(1),
common = __webpack_require__(2);
$('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'));
function batchExport1(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", response);
if (loadModal) {
loadModal.close();
}
if (response.code == 200) {
var failFileReason = response.data['failFileReason'];
var repeatFileReason = response.data['repeatFileReason'];
// 有数据导入失败
if (failFileReason.length || repeatFileReason.length) {
var htmlStr = [];
htmlStr[0] = htmlStr[1] = "";
for (var i = 0; i < failFileReason.length; i++) {
htmlStr[0] += '<p style="color:red;">"' + failFileReason[i] + '"</p>';
}
for (var i = 0; i < repeatFileReason.length; i++) {
htmlStr[1] += '<p style="color:red;">"' + repeatFileReason[i] + '"</p>';
}
htmlStr[2] = '<h2 style="color:red;">请修改后重新上传</h2>';
console.log(htmlStr);
$('.result1').html(htmlStr.join(""));
} else {
$('.result1').html("");
common.util.__tip(response.message, 'success');
}
} else {
common.util.__tip(response.message, 'warning');
}
}
}
}
common.edit.ajaxfileupload('#sort-file1', batchExport1('#sort-file1', 'refundExchangeModify'));
/***/ }
]);