commentManager.js
6.45 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
/**
* Created by wangqianjun on 16/3/22.
*/
var $ = require('jquery'),
common = require('../common/common');
/**
* Created by wangqianjun on 16/3/22.
*/
'use strict';
var $ = require('jquery'),
common = require('../common/common');
var STATUS = 0;
var ENUM = {
HotEnum: {
'1': '是',
'0': '否',
},
StatusEnum: {
'-1':'屏蔽',
0:'待审核',
1:'通过',
},
}
new common.dropDown({
el: "#condNum",
ajax: 'guangCommentGetFilterItems',
});
var g = new common.grid({
el: '#basicTable',
parms: function () {
return {
status: STATUS,
condNum: common.util.__input('condNum'),
condContent: common.util.__input('condContent'),
};
},
columns: [
{
display: '',
type: 'checkbox'
},
{display: "ID", name: "id"},
{display: "用户/id", render:function(item){
var value = item.username +'/'+ item.uid;
return "<p>" + value + "</p>";
}},
{
display: "回复时间",
render: function (item) {
var t = new Date(item.createTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
return "<p>" + formatted + "</p>";
}
},
{
display: "回复内容",
name: "content",
width:'15%',
},
{display: "回复文章", name: "articleTitle", width:'15%',},
{display: "编辑", name: "editorName"},
{
display: '状态',
render: function (item) {
return "<p>" + ENUM.StatusEnum[item.auditStatus] + "</p>";
}
},
{
display: "操作时间",
hidden: true,
render: function (item) {
var t = new Date(item.operationTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
return "<p>" + formatted + "</p>";
}
},
{
display: '操作',
//}
name: "status",
render: function (items) {
var HtmArr = [];
if(items.auditStatus == 0) {
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs comment-pass">通过</a>');
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs comment-mask">屏蔽</a>');
}
return HtmArr.join('');
}
}
]
});
g.init('/guang/comment/getList');
var BllPass = {
toast: function (content, fn) {
common.dialog.confirm("温馨提示", content, function () {
common.util.__ajax({
url: '/guang/comment/audit',
data: fn()
}, function () {
g.reload();
});
});
}
}
//==================== 按钮点击事件 =====================//
//批量通过
$(document).on('click', '#batch-pass-btn', function() {
var selectedArr = g.selected,
len = selectedArr.length,
idList = [];
if (len <= 0) {
common.util.__tip('请选择评论', 'warning');
return;
}
var data = function () {
$.each(selectedArr, function (i, value) {
idList.push(value['id']);
});
return {
id: idList.toString(),
status:1
};
}
BllPass.toast("确定要通过该申请吗?", data);
g.reload();
});
//批量屏蔽
$(document).on('click', '#mask-btn', function() {
var selectedArr = g.selected,
len = selectedArr.length,
idList = [];
if (len <= 0) {
common.util.__tip('请选择评论', 'warning');
return;
}
var data = function () {
$.each(selectedArr, function (i, value) {
idList.push(value['id']);
});
return {
id: idList.toString(),
status:-1
};
}
BllPass.toast("确定要通过该申请吗?", data);
g.reload();
});
//单个通过
$(document).on('click', '.comment-pass', function() {
var item = g.rows[$(this).data("index")];
var data = function () {
return {
id: item.id,
status:1
};
}
BllPass.toast("确定要通过该评论吗?", data);
g.reload();
});
//单个屏蔽
$(document).on('click', '.comment-mask', function() {
var item = g.rows[$(this).data("index")];
var data = function () {
return {
id: item.id,
status:-1
};
}
BllPass.toast("确定要屏蔽该评论吗?", data);
g.reload();
});
//待审核
$(document).on('click', '#check-btn', function() {
//articleCategoryOP("新增", '/guang/author/addAuthor', {});
STATUS = 0;
$('#filter-div').hide();
g.options.columns[9].hidden = false;
g.options.columns[8].hidden = true;
g.init('/guang/comment/getList');
});
//已审核
$(document).on('click', '#pass-btn', function() {
//articleCategoryOP("新增", '/guang/author/addAuthor', {});
STATUS = 1;
g.options.columns[9].hidden = true;
g.options.columns[8].hidden = false;
$('#filter-div').hide();
g.init('/guang/comment/getList');
//g.distroy
});
//全部
$(document).on('click', '#all-btn', function() {
$('#filter-div').show();
STATUS = '';
g.options.columns[9].hidden = false;
g.options.columns[8].hidden = true;
g.init('/guang/comment/getList');
});
//筛选
$(document).on('click', '#filter-btn', function() {
g.reload();
});
function commentOP(prefix, url, item) {
var a =new common.edit(".confirm", {
"bucket" : "color"
});
common.dialog.confirm(prefix+'作者', common.util.__template2($("#template").html(), item), function () {
//
return a.submit(url,function(option){
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);
}
});
});
a.init();
}