operations.appEntranceIcon.Index.js
8.92 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
webpackJsonp([100],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var $ = __webpack_require__(1),
common = __webpack_require__(2);
////只能开启的入口
//var OPEN_ONLY_ENTRANCE = ['设置', '二维码', '站内信','订单-待收货','订单-待发货','订单-待评价','订单-退换货','首页','分类','逛','购物车','我的'];
//可以编辑、关闭的入口
var CAN_EDIT_CLOSE_ENTRANCE = ['地址管理','我的晒单','分享购','生日券','有货分期','学生认证','红包','服务与反馈','生日帽','专享折扣','购物返币','生日礼包','升级礼包','免邮服务','优享客服','7天退换货','极速发货','拼团'];
//只能关闭的入口
var CLOSE_ONLY_ENTRANCE = ['Yoho!Family','潮流口令'];
var ENUM = {
StatusEnum: {
0: '关闭',
1: '开启'
}
};
new common.dropDown({el: '#supplier-name', ajax: 'supplier'});
//下拉框
new common.dropDown({
el: '#sel-category',
ajax: 'selectAppEntranceIconCategory'
});
var g = new common.grid({
el: '#basicTable',
size: 10,
parms: function () {
return {
displayName: common.util.__input('sel-displayName'),
status: common.util.__input('sel-status'),
categoryId: common.util.__input('sel-category')
};
},
columns: [
{
display: '入口',
name: "entranceName"
},
{
display: '前端展示名称',
name: "displayName"
},
{
display: '分类',
name: "categoryName"
},
{
display: '状态',
name:"status",
render: function (item) {
return "<p>" + ENUM.StatusEnum[item.status] + "</p>";
}
},
{
display: '操作',
name: "",
render: function (items) {
var HtmArr = [];
var entranceName = items.entranceName;
if(!contains(CLOSE_ONLY_ENTRANCE,entranceName)){
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs info-modify">编辑</a>');
}
if(contains(CAN_EDIT_CLOSE_ENTRANCE,entranceName)||contains(CLOSE_ONLY_ENTRANCE,entranceName)){
if(items.status == 0){
HtmArr.push('<a onclick="changeStatus(1,'+items.id+')" href="javascript:;" class="btn btn-info btn-xs">开启</a>');
}else{
HtmArr.push('<a onclick="changeStatus(0,'+items.id+')" href="javascript:;" class="btn btn-danger btn-xs">关闭</a>');
}
}
return HtmArr.join('');
}
}]
});
g.init('/appEntranceIcon/queryList');
//==================== 按钮点击事件 =====================//
$("#filter-btn").click(function () {
g.reload(1);
});
/**
* 监听输入框变化
*/
$(document).on("change", ".observe", function () {
var $this = $(this);
var name = $this.data("field");
Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
obj[name1] = $this.val();
});
Bll.module.shopName = $('#shopId').find("option[value='" + Bll.module.shopId + "']").text();
});
/*验证*/
var edit = new common.edit2(".modal-body");
var Bll = {
module: null,
//弹框
toast: function (module, url) {
Bll.module = module;
var d = new common.dialog({
title: "入口名称",
content: common.util.__template2($("#template").html(), Bll.module),
width: '40%',
button: [
{
value: "保存",
callback: function () {
if (edit.validate()) {
common.util.__ajax2({
url: url,
data: Bll.module
}, function (res) {
if (res.code == '200') {
g.reload();
d.close();
}else{
common.util.__tip(res.message, "warning");
}
}, true);
}
return false;
},
css: "btn-primary"
},
{
"value": "取消",
"css": "btn-info"
}
]
});
Bll.__editRender();
},
__editRender: function () {
edit.init();
//new common.dropDown({
// el: "#sel-displayName",
// ajax: 'selectAppEntranceIconCategory'
//
//});
}
};
/**
* 编辑--点击事件
*/
$(document).on('click', '.info-modify', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax(
{
url: '/appEntranceIcon/queryById',
data: {
id: item.id,
}
}, function (res) {
//var item = res.data;
appEntranceIconOP( '/appEntranceIcon/update', res.data);
}, true);
});
//重发
$(document).on("click", "#uploadZip-btn", function () {
common.dialog.confirm("确认上传","是否确认上传zip?",function() {
common.util.__ajax2({
url: '/appEntranceIcon/uploadZip',
data: {}
}, function (res) {
if (res.code == '200') {
common.util.__tip("保存成功","success");
d.close();
}else{
common.util.__tip(res.message, "warning");
}
}, true);
});
});
// 图片上传
function uploadImage() {
common.edit.ajaxfileupload(".picfile", {
params: {
__type: "upload",
bucket: "plustar"
},
valid_extensions: ['png', 'jpg', 'jpeg'],
onComplete: function (response) {
if (response.status && response.code == 200) {
console.log("response", response);
if (response.data) {
imgArr.push(response.data);
rendBoList(imgArr);
}
}
else {
common.util.__tip(response.message, 'warning');
}
}
});
};
var imgArr = [];
function appEntranceIconOP( url, item) {
var a = new common.edit("#templete-top", {
"bucket": "plustar"
});
//a.on("validate", function () {
// if (imgArr.length == 0) {
// return "请上传banner图";
// }
//});
common.dialog.confirm('入口', common.util.__template2($("#template").html(), item), function () {
return a.submit(url, function (option) {
if (imgArr.length) {
option.data.bannerImg = imgArr.toString();
}
imgArr = [];
option.success = function (res) {
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);
}
});
});
$(".modal-dialog").css("width","800px");
/**
* 删除图片
*/
$(document).on("click", ".del-btn", function () {
var key = $(this).data('key');
var $parent = $(this).parent().parent();
$parent.find("input[type=file]").each(function(){
$(this).attr("value", "");
});
$parent.find(".upload-image-list .fileinput-button-icon").html('+');
});
a.init();
uploadImage();
rendBoList(imgArr);
}
function rendBoList(pictureBoList) {
$(".image-list").html('');
$("#addPic").append(common.util.__template2($("#imgeUpload").html(),
{
pictureBoList: pictureBoList
}
));
}
function contains(arr, obj) {
var i = arr.length;
while (i--) {
if (arr[i] === obj) {
return true;
}
}
return false;
}
window.changeStatus = changeStatus;
function changeStatus(status,id) {
var param = {
status: status,
id:id
};
common.dialog.confirm("警告",
"确认修改开启状态?",
function () {
common.util.__ajax({
url: '/appEntranceIcon/update',
data: param
}, function(res) {
g.reload();
});
});
}
/***/ }
]);