|
@@ -5,7 +5,8 @@ |
|
@@ -5,7 +5,8 @@ |
5
|
var $ = require('jquery'),
|
5
|
var $ = require('jquery'),
|
6
|
common = require('../../../common/common');
|
6
|
common = require('../../../common/common');
|
7
|
|
7
|
|
8
|
-
|
8
|
+var enum_switch_val={yes:"Y", no:"N"};
|
|
|
9
|
+var enum_switch_name={open:"开启", close:"关闭"};
|
9
|
//下拉框
|
10
|
//下拉框
|
10
|
|
11
|
|
11
|
new common.dropDown({
|
12
|
new common.dropDown({
|
|
@@ -13,7 +14,9 @@ new common.dropDown({ |
|
@@ -13,7 +14,9 @@ new common.dropDown({ |
13
|
ajax: 'brand'
|
14
|
ajax: 'brand'
|
14
|
});
|
15
|
});
|
15
|
|
16
|
|
16
|
-
|
17
|
+var buildOperateHtml=function(_index,_class,_name) {
|
|
|
18
|
+ return '<a data-index="' + _index + '" href="JavaScript:;" class="btn btn-warning btn-xs '+ _class +'">'+ _name +'</a>'
|
|
|
19
|
+ };
|
17
|
|
20
|
|
18
|
var g = new common.grid({
|
21
|
var g = new common.grid({
|
19
|
el: '#basicTable',
|
22
|
el: '#basicTable',
|
|
@@ -49,17 +52,17 @@ var g = new common.grid({ |
|
@@ -49,17 +52,17 @@ var g = new common.grid({ |
49
|
render: function(items) {
|
52
|
render: function(items) {
|
50
|
var HtmArr = [];
|
53
|
var HtmArr = [];
|
51
|
|
54
|
|
52
|
- if (items.isNew === "N") {
|
|
|
53
|
- HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-warning btn-xs open-isNew">NEW</a>');
|
55
|
+ if (items.isNew === enum_switch_val.no) {
|
|
|
56
|
+ HtmArr.push(buildOperateHtml(items.__index,'open-isNew','NEW'));
|
54
|
}
|
57
|
}
|
55
|
- if (items.isNew === "Y") {
|
|
|
56
|
- HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs close-isNew">取消NEW</a>');
|
58
|
+ if (items.isNew === enum_switch_val.yes) {
|
|
|
59
|
+ HtmArr.push(buildOperateHtml(items.__index,'close-isNew','取消NEW'));
|
57
|
}
|
60
|
}
|
58
|
- if (items.isHot === "N") {
|
|
|
59
|
- HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-warning btn-xs open-isHot">HOT</a>');
|
61
|
+ if (items.isHot === enum_switch_val.no) {
|
|
|
62
|
+ HtmArr.push(buildOperateHtml(items.__index,'open-isHot','HOT'));
|
60
|
}
|
63
|
}
|
61
|
- if (items.isHot === "Y") {
|
|
|
62
|
- HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs close-isHot">取消HOT</a>');
|
64
|
+ if (items.isHot === enum_switch_val.yes) {
|
|
|
65
|
+ HtmArr.push(buildOperateHtml(items.__index,'close-isHot','取消HOT'));
|
63
|
}
|
66
|
}
|
64
|
HtmArr.push('<a href="/erpproduct/brands/edit/' + items.id + '"" class="btn btn-info btn-xs">编辑</a>');
|
67
|
HtmArr.push('<a href="/erpproduct/brands/edit/' + items.id + '"" class="btn btn-info btn-xs">编辑</a>');
|
65
|
return HtmArr.join('');
|
68
|
return HtmArr.join('');
|
|
@@ -71,16 +74,7 @@ g.init('/brand/getBrandDecorateList'); |
|
@@ -71,16 +74,7 @@ g.init('/brand/getBrandDecorateList'); |
71
|
$("#filter-btn").click(function() {
|
74
|
$("#filter-btn").click(function() {
|
72
|
g.reload(1);
|
75
|
g.reload(1);
|
73
|
});
|
76
|
});
|
74
|
-var callBack=function(res,operateName) {
|
|
|
75
|
- if (res.code == 200) {
|
|
|
76
|
- common.util.__tip(operateName+'成功', 'success');
|
|
|
77
|
- g.reload();
|
|
|
78
|
- } else {
|
|
|
79
|
- common.util.__tip(res.message);
|
|
|
80
|
- }
|
|
|
81
|
- };
|
|
|
82
|
-var enum_switch_val={yes:"Y", no:"N"};
|
|
|
83
|
-var enum_switch_name={open:"开启", close:"关闭"};
|
77
|
+
|
84
|
//品牌isHot
|
78
|
//品牌isHot
|
85
|
$('tbody').on('click', '.close-isHot', function() {
|
79
|
$('tbody').on('click', '.close-isHot', function() {
|
86
|
var item = g.rows[$(this).data("index")];
|
80
|
var item = g.rows[$(this).data("index")];
|
|
@@ -90,7 +84,14 @@ $('tbody').on('click', '.close-isHot', function() { |
|
@@ -90,7 +84,14 @@ $('tbody').on('click', '.close-isHot', function() { |
90
|
id: item.id,
|
84
|
id: item.id,
|
91
|
isHot: enum_switch_val.no
|
85
|
isHot: enum_switch_val.no
|
92
|
}
|
86
|
}
|
93
|
- }, callBack(res,enum_switch_name.close), true);
|
87
|
+ }, function(res){
|
|
|
88
|
+ if (res.code == 200) {
|
|
|
89
|
+ common.util.__tip(enum_switch_name.close+'成功', 'success');
|
|
|
90
|
+ g.reload();
|
|
|
91
|
+ } else {
|
|
|
92
|
+ common.util.__tip(res.message);
|
|
|
93
|
+ }
|
|
|
94
|
+ }, true);
|
94
|
});
|
95
|
});
|
95
|
|
96
|
|
96
|
$('tbody').on('click', '.open-isHot', function(){
|
97
|
$('tbody').on('click', '.open-isHot', function(){
|
|
@@ -101,7 +102,14 @@ $('tbody').on('click', '.open-isHot', function(){ |
|
@@ -101,7 +102,14 @@ $('tbody').on('click', '.open-isHot', function(){ |
101
|
id: item.id,
|
102
|
id: item.id,
|
102
|
isHot: enum_switch_val.yes
|
103
|
isHot: enum_switch_val.yes
|
103
|
}
|
104
|
}
|
104
|
- }, callBack(res,enum_switch_name.open), true)
|
105
|
+ }, function(res){
|
|
|
106
|
+ if (res.code == 200) {
|
|
|
107
|
+ common.util.__tip(enum_switch_name.open+'成功', 'success');
|
|
|
108
|
+ g.reload();
|
|
|
109
|
+ } else {
|
|
|
110
|
+ common.util.__tip(res.message);
|
|
|
111
|
+ }
|
|
|
112
|
+ }, true)
|
105
|
});
|
113
|
});
|
106
|
|
114
|
|
107
|
//品牌isNew
|
115
|
//品牌isNew
|
|
@@ -113,7 +121,14 @@ $('tbody').on('click', '.close-isNew', function() { |
|
@@ -113,7 +121,14 @@ $('tbody').on('click', '.close-isNew', function() { |
113
|
id: item.id,
|
121
|
id: item.id,
|
114
|
isNew: enum_switch_val.no
|
122
|
isNew: enum_switch_val.no
|
115
|
}
|
123
|
}
|
116
|
- }, callBack(res,enum_switch_name.close), true);
|
124
|
+ }, function(res){
|
|
|
125
|
+ if (res.code == 200) {
|
|
|
126
|
+ common.util.__tip(enum_switch_name.close+'成功', 'success');
|
|
|
127
|
+ g.reload();
|
|
|
128
|
+ } else {
|
|
|
129
|
+ common.util.__tip(res.message);
|
|
|
130
|
+ }
|
|
|
131
|
+ }, true);
|
117
|
});
|
132
|
});
|
118
|
|
133
|
|
119
|
$('tbody').on('click', '.open-isNew', function() {
|
134
|
$('tbody').on('click', '.open-isNew', function() {
|
|
@@ -124,5 +139,12 @@ $('tbody').on('click', '.open-isNew', function() { |
|
@@ -124,5 +139,12 @@ $('tbody').on('click', '.open-isNew', function() { |
124
|
id: item.id,
|
139
|
id: item.id,
|
125
|
isNew: enum_switch_val.yes
|
140
|
isNew: enum_switch_val.yes
|
126
|
}
|
141
|
}
|
127
|
- }, callBack(res,enum_switch_name.open), true);
|
142
|
+ }, function(res){
|
|
|
143
|
+ if (res.code == 200) {
|
|
|
144
|
+ common.util.__tip(enum_switch_name.open+'成功', 'success');
|
|
|
145
|
+ g.reload();
|
|
|
146
|
+ } else {
|
|
|
147
|
+ common.util.__tip(res.message);
|
|
|
148
|
+ }
|
|
|
149
|
+ }, true);
|
128
|
}); |
150
|
}); |