batch.js
2.38 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
'use strict';
var $ = require('jquery'),
common = require('../common/common');
new common.dropDown({el:"#brandId",ajax:"brand",params:function(){
return {status:1}
}});
new common.dropDown({el:"#shopId",ajax:"sortbybrand",params:function(){
return {brandId:$("#brandId").val()}
}});
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>');
function batchExport(el, type) {
var loadModal = null;
return {
params: {
type: type,
brandId:common.util.__input("brandId"),
shopId:common.util.__input("shopId"),
supplierId:common.util.__input("supplierId"),
__type: "batch-import"
},
onStart: function(params) {
params.brandId=common.util.__input("brandId");
params.shopId=common.util.__input("shopId");
params.supplierId=common.util.__input("supplierId");
console.log("params",params);
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&&response.data.failFileReason.length==0) {
common.util.__tip(response.message, 'success');
return;
}
if(response.data&&response.data.failFileReason.length){
$("#message").html(response.data.failFileReason.join('/n'));
return false;
}
common.util.__tip(response.message, 'warning');
}
}
}
/*奥莱*/
common.edit.ajaxfileupload('#outletModify', batchExport('#sort-file', 'outletModify'));
/*补货*/
common.edit.ajaxfileupload('#supplyModify', batchExport('#brand-file', 'supplyModify'));
/*基础商品导入*/
$("#baseProduct").prop("disabled",true);
common.edit.ajaxfileupload('#baseProduct', batchExport('#sort-file', 'baseProduct'));
$(document).on("change","#brandId",function(){
if($(this).val()>0){
$("#baseProduct").prop("disabled",false);
}else{
$("#baseProduct").prop("disabled",true);
}
});