guang.info.Index.js
10.9 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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
webpackJsonp([63],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by wangqianjun on 16/3/22.
*/
var $ = __webpack_require__(1);
common = __webpack_require__(2);
datepicker = __webpack_require__(9);
var ENUM = {
GenderEnum: {
'1': '男',
'2': '女',
'3': '通用'
},
StatusEnum: {
'-1': '已关闭',
0: '未发布',
1: '已发布'
},
BLKEnum: {
0: '否',
1: '是'
}
};
//下拉框
new common.dropDown({
el: "#articleGender"
});
new common.dropDown({
el: "#authorId",
ajax: 'guangGetAuthorList'
});
new common.dropDown({
el: "#maxSortId",
ajax: 'guangGetSortList',
params: function () {
return {
parentId: 0
};
}
});
new common.dropDown({
el: "#status"
});
new common.dropDown({
el: '#orderBy'
});
//日期插件
$.timepicker.dateRange($('#starttime'), $('#endtime'));
var Timmer = {
toast: function (content, fn) {
common.dialog.confirm("定时发布", content, function () {
//console.log("fn()",fn());
common.util.__ajax({
url: '/guang/article/timmer',
data: fn()
}, function (res) {
if (res.code == '200') {
g.reload();
}
});
});
}
};
var g = new common.grid({
el: '#basicTable',
size: 10,
parms: function () {
return {
articleTitle: common.util.__input('articleTitle'),
articleGender: common.util.__input('articleGender'),
authorId: common.util.__input('authorId'),
maxSortId: common.util.__input('maxSortId'),
status: $('#status').val(),//common.util.__input('status'),
orderBy: common.util.__input('orderBy'),
startTime: common.util.__input('starttime'),
endTime: common.util.__input('endtime'),
appType: common.util.__input('appType')
};
},
columns: [{
display: 'ID',
name: "id"
}, {
display: "缩略图",
render: function (item) {
item.coverImage = common.util.__template(item.coverImage, {mode: 2, width: 100, height: 100});
return '<img src="' + item.coverImage + '" width="100" />'
}
}, {
display: '文章标题',
name: "articleTitle",
width: '15%',
/**render: function (item) {
// return '<span class="text-overflow"">' + item.articleTitle + '</span>'
}*/
}, {
display: '分类',
name: "maxSortName"
}, {
display: '性别',
render: function (item) {
return "<p>" + ENUM.GenderEnum[item.articleGender] + "</p>";
}
}, {
display: '作者',
name: "authorName"
}, {
display: '状态',
render: function (item) {
var sta = ENUM.StatusEnum[item.status];
if(item.status == 1 && common.util.__compareDate(Date.now(), item.publishTime * 1000)) {
//检查是否为定时发布,当未到达所设定时间时,即使status为1,也显示‘未发布’
sta = "未发布";
} else {
}
return "<p>" + sta + "</p>";
}
}, {
display: '创建人',
name: "createUser"
}, {
display: "创建时间",
render: function (item) {
if (item.createTime && item.createTime !== 0) {
var t = new Date(item.createTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
return "<p>" + formatted + "</p>";
}
else {
return "";
}
}
}, {
display: '发布人',
name: "publishUser"
}, {
display: "发布时间",
render: function (item) {
//console.log(item.publishTime);
if (item.publishTime && item.publishTime !== 0) {
var t = new Date(item.publishTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
return "<p>" + formatted + "</p>";
}
else {
return "";
}
}
}, {
display: 'BLK',
render: function (item) {
return "<p>" + ENUM.BLKEnum[item.appType] + "</p>";
}
},{
display: '操作',
//}
name: "status",
render: function (items) {
var HtmArr = [];
HtmArr.push('<a data-index="' + items.__index + '" href="/guang/article/contentEdit/' + items.id + '" class="btn btn-info btn-xs info-modify">编辑</a>');
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs info-time">定时</a>');
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs info-del">删除</a>');
if (items.status == 1) {
if(common.util.__compareDate(Date.now(), items.publishTime * 1000)) {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-success btn-xs info-open">发布</a>');
} else {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-warning btn-xs info-close">关闭</a>');
}
} else {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-success btn-xs info-open">发布</a>');
}
if (items.isRecommend == 1) {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-warning btn-xs info-recommend-cancel">取消推荐</a>');
} else {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-success btn-xs info-recommend">推荐</a>');
}
if (items.isTop == 1) {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-warning btn-xs info-sticky-cancel">取消置顶</a>');
} else {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-success btn-xs info-sticky">置顶</a>');
}
return HtmArr.join('');
}
}]
});
g.init('/guang/article/list');
//==================== 按钮点击事件 =====================//
$("#filter-btn").click(function () {
g.reload(1);
});
//关闭资讯
$(document).on('click', '.info-close', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: '/guang/article/operation',
data: {
id: item.id,
status: -1
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('关闭资讯成功', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
});
//打开资讯
$(document).on('click', '.info-open', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: '/guang/article/operation',
data: {
id: item.id,
status: 1
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('开启资讯成功', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
});
//推荐
$(document).on('click', '.info-recommend', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: '/guang/article/operation',
data: {
id: item.id,
isRecommend: 1
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('成功推荐', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
});
//取消推荐
$(document).on('click', '.info-recommend-cancel', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: '/guang/article/operation',
data: {
id: item.id,
isRecommend: 0
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('成功取消推荐', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
});
//置顶
$(document).on('click', '.info-sticky', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: '/guang/article/operation',
data: {
id: item.id,
isTop: 1
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('成功置顶', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
});
});
//取消置顶
$(document).on('click', '.info-sticky-cancel', function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: '/guang/article/operation',
data: {
id: item.id,
isTop: 0
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('成功取消置顶', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
});
});
//定时
$(document).on("click", ".info-time", function () {
var item = g.rows[$(this).data("index")];
var item1= $.extend(true,{},item);
if(item.publishTime&&item.publishTime!=0){
var t = new Date(item.publishTime * 1000);
item1.publishTime= common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
}
else{
item1.publishTime="yyyy-MM-dd hh:mm"
}
var data = function () {
var dateString = common.util.__input('datepicker');
if (dateString === '' || $.trim(dateString) === '') {
return "请填写时间";
}
return {
publishTime: dateString,
id: item.id
};
};
Timmer.toast(common.util.__template2($("#template").html(), item1), data);
$('#datepicker').datetimepicker({
timeFormat: 'HH:mm',
showSecond: false
});
});
// 删除
$(document).on("click", ".info-del", function () {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("温馨提示", "您确定要删除吗?", function () {
common.util.__ajax({
url: '/guang/article/del',
data: {
id: item.id
}
}, function () {
g.reload();
});
});
});
/***/ }
]);