brandModels.js
4.54 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/**
* Created by wangqianjun on 16/3/7.
* 【商品基础规则】->【品牌款型系列】
*/
var $ = require('jquery'),
common = require('../common/common');
var TypeEnum = {
enum: {
1:"品牌款型",
2:"品牌系列",
"":""
}
}
var StatusEnum = {
enum: {
1:"开启",
0:"关闭",
"":""
}
}
new common.dropDown({el: "#models-type"});
new common.dropDown({el: "#status"});
new common.dropDown({
el:"#shop",
ajax:"queryShopPass"
});
new common.dropDown({
el:"#brand",
ajax:"brand"
});
var BUCKET={
"bucket" : "brandBanner"
};
var e = new common.edit('#form-base',BUCKET);
e.init();
var g = new common.grid({
el: "#basicTable",
parms: function() {
return {
seriesName: common.util.__input("models-name"),
shopsId: common.util.__input("shop"),
brandId: common.util.__input("brand"),
type: common.util.__input("models-type"),
status: common.util.__input("status"),
bannarImg: common.util.__input("bannarImg"),
id: common.util.__input("id")
};
},
columns: [{
display: '',
type: 'checkbox'
}, {
display: 'ID',
name: 'id',
}, {
display: '店铺',
name: 'shopsName'
}, {
display: '品牌',
name: 'brandName',
}, {
display: '款型系列名称',
name: 'seriesName'
}, {
display: '类型',
render: function(item) {
return '<p>'+TypeEnum.enum[item.type] +'<p>';
}
}, {
display: 'banner图片',
render: function(item) {
return '<img src="' + item.bannarImg + '" style="width:200px; height:100px">';
}
}, {
display: '排序',
name: 'orderBy'
}, {
display: '状态',
render: function(item) {
return '<p>'+StatusEnum.enum[item.status] +'<p>';
}
}, {
display: '操作',
render: function(items) {
var HtmArr = [];
HtmArr.push('<a data-index="'+ items.__index+ '" href="JavaScript:;" class="btn btn-info btn-xs edit-class-btn">编辑</a>');
if (items.status === 0) {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-warning btn-xs open-brand">开启</a>');
}
if (items.status === 1) {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs close-brand">关闭</a>');
}
return HtmArr.join('');
}
}]
});
g.init("/erpproduct/brandfolder/list");
//全部
$("#filter-btn").click(function(){
g.reload();
});
$("#add-btn").click(function(){
attributeOp("新建", '/erpproduct/brandfolder/add', {});
});
$(document).on('click', '.edit-class-btn', function () {
var item = g.rows[$(this).data('index')];
console.log(item);
attributeOp("修改", '/erpproduct/brandfolder/update', item);
});
function attributeOp(prefix, url, item) {
var a = new common.edit(".confirm",BUCKET);
common.dialog.confirm(prefix + "款型系列", common.util.__template2($("#template").html(), item), function () {
return a.submit(url, function (option) {
option.data.categoryId = item.categoryId;
option.data.attributeId = item.attributeId;
option.success = function (res) {
res = res.data;
if (res.code == "200") {
a.$tip("提交成功", function () {
g.reload();
}, 'growl-success');
} else {
a.$tip(res.message);
}
return false;
},
option.error = function (res) {
a.$tip(res.message);
}
});
});
new common.dropDown({
el:"#shopsId",
ajax:"queryShopPass"
});
new common.dropDown({
el:"#brandId",
ajax:"brand"
});
a.init();
}
//关闭
$('tbody').on('click', '.close-brand', function() {
var item=g.rows[$(this).data("index")];
common.util.__ajax({
url:'/erpproduct/brandfolder/close',
data:{id:item.id}
},function(){
g.reload();
});
});
//开启
$('tbody').on('click', '.open-brand', function() {
var item=g.rows[$(this).data("index")];
common.util.__ajax({
url:'/erpproduct/brandfolder/open',
data:{id:item.id}
},function(){
g.reload();
});
});