brand-cooperation.js
3.16 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
'use strict';
var $ = require('jquery'),
common=require('../common/common');
var ENUM={
cooperateTypeId:{0:'未设置',1:'代销',2:'经销',3:'自主'}
}
new common.dropDown({el:'#brandCooperation'});
new common.dropDown({el:'#brandCooperationSet'});
var g = new common.grid({
el:"#basicTable",
parms:function(){
return {
brandName:common.util.__input("brand"),
cooperateTypeId: common.util.__input("brandCooperation"),
setFlag: common.util.__input("brandCooperationSet")
};
},
columns:[
{display: 'ID', name: 'brandId'},
{display: '品牌', name:'brandName'},
{display: '合作模式', render: function(item) {
return ENUM.cooperateTypeId[item.cooperateTypeId];
}},
{display: '是否设置', name: 'cooperateTypeName'},
{display: '操作信息', render: function(item) {
var html = '';
if (item.addUserName) {
html += '<p>' + item.addUserName + '</p>';
}
if (item.updateTime) {
html += '<p>' + item.updateTime + '</p>';
}
return html;
}},
{display: '操作', render:function(item){
var htmlArr = [];
if (item.cooperateTypeId != 1) {
htmlArr.push('<a href="javascript:;" class="btn btn-info btn-xs cooperate-type" data-brandid="' + item.brandId + '" data-id="' + item.id + '" data-type="1">代销</a>');
}
if (item.cooperateTypeId != 2) {
htmlArr.push('<a href="javascript:;" class="btn btn-info btn-xs cooperate-type" data-brandid="' + item.brandId + '" data-id="' + item.id + '" data-type="2">经销</a>');
}
if (item.cooperateTypeId != 3) {
htmlArr.push('<a href="javascript:;" class="btn btn-info btn-xs cooperate-type" data-brandid="' + item.brandId + '" data-id="' + item.id + '" data-type="3">自主</a>');
}
return htmlArr.join('');
}}
]
});
g.init($("#gridurl").val());
$('#basicTable').on('click', '.cooperate-type', function() {
var $brandId = $(this).data('brandid'),
$id = $(this).data('id'),
brandType = $(this).data('type');
common.util.__ajax({
url:'/goods/brandCooperation/update',
data:{
brandId: $brandId,
id: $id,
cooperateTypeId: brandType
}
},function(res){
g.reload();
});
});
//筛选
$("#filter-btn").click(function(){
g.reload(1);
});
//批量导入按钮点击事件
$('#import-btn').on('click', function() {
$('#basicTable, .bulk-import').toggle();
});
$(' #sure-change, .priceTable-wrap').hide();
common.edit.ajaxfileupload("#upload-input",{
params:{type:"brandCooperation",__type:"batch-import"},
onStart: function() {
$('.load-modal').show();
},
onComplete:function(response){
console.log(response);
var li = '';
$('.load-modal').hide();
$.each(response.data.failFileReason, function(i, value) {
li += '<li>' + value + '</li>';
});
$('#error-msg').html(li);
}
});