goods.basegoods.Batch.js
4.17 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
webpackJsonp([2],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var $ = __webpack_require__(1),
common = __webpack_require__(2);
new common.dropDown({el:"#brandId",ajax:"queryBrandByShopId",params:function(){
return {status:1}
}});
new common.dropDown({el:"#supplierId",ajax:"getjitSup",params:function(){
return {brandId:$("#brandId").val()}
}});
$('input[type="file"]').after('<div class="file-name btn btn-default">请选择文件</div>');
var loadModal = null;
function batchExport(el, type) {
return {
params: {
type: type,
brandId:common.util.__input("brandId"),
shopsId:common.util.__input("shopId"),
supplierId:common.util.__input("supplierId"),
__type: "batch-import"
},
onStart: function(params) {
params.brandId=common.util.__input("brandId");
params.shopsId=common.util.__input("shopId");
params.supplierId=common.util.__input("supplierId");
params.sellType=common.util.__input("sellType");
params.brandName=params.brandId?$("#brandId").find("option[value="+$("#brandId").val()+"]").text():"";
params.shopsName=common.util.__input("shopName");
params.supplierName=params.supplierId?$("#supplierId").find("option[value="+$("#supplierId").val()+"]").text():"";
console.log("params",params);
loadModal = common.dialog.load();
$("#message").html('');
//$(el).parents('td').find('.file-name').text($(el).val().replace("C:\\fakepath\\", ""));
},
onComplete: function(response) {
console.log("批量接口返回数据",response);
$("#message").html('');
if (response.code == 200&&response.data.taskId) {
__ajaxExeclById(response.data.taskId);
// common.util.__tip(response.message, 'success');
return;
}
if (loadModal) {
loadModal.close();
}
if(response.data&&response.data.failFileReason.length){
$("#message").html(response.data.failFileReason.join('<br/>'));
return false;
}
common.util.__tip(response.message, 'warning');
}
}
}
/*奥莱*/
common.edit.ajaxfileupload('#outletModify', batchExport('#sort-file', 'outletModify'));
/*补货*/
common.edit.ajaxfileupload('#supplyModify', batchExport('#brand-file', 'supplyModify'));
/*修改条码*/
common.edit.ajaxfileupload('#factoryCodeModify', batchExport('#brand-file', 'skuFactoryCodeModify'));
/*基础商品导入*/
$("#baseProduct").prop("disabled",true);
common.edit.ajaxfileupload('#baseProduct', batchExport('#sort-file', 'baseProduct'));
var isbrandId=false, issellType=false;
function jiekai(){
if(isbrandId && issellType){
$("#baseProduct").prop("disabled",false);
}else{
$("#baseProduct").prop("disabled",true);
}
}
$(document).on("change","#brandId",function(){
if($(this).val()>0){
isbrandId=true;
}else{
isbrandId=false;
}
jiekai();
$("#supplierId").val(-1).trigger("change");
});
$(document).on("change","#supplierId",function(){
$("#sellType").val(-1).trigger("change");
})
$(document).on("change","#sellType",function(){
if($(this).val() > 0){
issellType = true;
}else{
issellType = false;
}
jiekai();
})
function __ajaxExeclById(unquid){
var params={param:unquid};
common.util.__ajax({
url:'/product/queryBatchImportResult',
data:params
},function(res){
if(res.data.length){
//成功操作
if (loadModal) {
loadModal.close();
}
common.util.__tip(res.message, 'success');
}else{
setTimeout(function(){
__ajaxExeclById.call(null,unquid);
},5000);
}
$("#message").html(res.message);
},true);
}
// __ajaxExeclById("batchBasePrd1459835824928");
/***/ }
]);