operations.hotsuggest.Index.js
11.2 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
webpackJsonp([108],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by ty on 2016/6/16.
* 热门意见
*/
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var status = "-1";
var quick_select = {};
var statusArr = ["未编辑","已编辑", "已发布"];
var HotSuggestBean = {
"status": 1,
"coverImage": "",
"orderBy": "",
"content": "",
"replyContent": "",
};
var module = {};
var edit = new common.edit2("#edit-content", {bucket: "suggest"});
$.timepicker.dateRange($("#startTime"), $("#endTime"));
/**
* 搜索控件初始化
*/
new common.dropDown({
el: "#status-filter"
});
new common.dropDown({
el: "#clientType-filter"
});
new common.edit("#radios-select").init();
var g = new common.grid({
el: '#content-list',
callback: function (res) {
if (res && res.data) {
quick_select = {
uneditCount: res.data.uneditCount,
editedCount: res.data.editedCount,
publishCount: res.data.publishCount,
status: status
};
}
$("#quick").html(common.util.__template2($("#status-search").html(), {quick_select: quick_select}));
return res.data;
},
parms: function () {
return {
startTime: common.util.__input('startTime'),
endTime: common.util.__input('endTime'),
status: status,
clientType: common.util.__input('clientType-filter'),
hasImage: common.util.__input('hasImage'),
isReliable: common.util.__input('isReliable')
};
},
columns: [
{
display: '',
type: 'checkbox'
},
{
display: "来源",
name: "clientType",
render: function (item) {
return item.clientType == "custom" ? "自定义" : item.clientType;
}
},
{
display: '反馈内容',
name: "content",
style:"width:20%;word-break:break-all;"
},
{
display: '回复内容',
name: "replyContent",
style:"width:20%; word-break:break-all;"
},
{
display: '封面图',
render: function (item) {
if(item.imageUrl) {
return '<a href="'+ item.imageUrl +'"target="_blank"><img style="max-height: 150px" src="'+item.imageUrl+'"/></a>';
}
}
},
{
display: '时间',
name: "createTime"
},
{
display: '排序',
render: function (item) {
var arr = [];
arr.push('<input class="form-control" style="width: 50px;display: inline-block" id="order_by_'+ item.__index +'" value="'+ item.orderBy +'">');
arr.push('<a data-index="'+ item.__index +'" class="btn btn-info btn-xs updateOrder">更新</a>');
return arr.join("");
}
},
{
display: "状态",
render: function (item) {
return "<p>" + statusArr[item.status] + "</p>";
}
},
{
display: '靠谱',
name: "reliable"
},
{
display: '不靠谱',
name: "unreliable"
},
{
display: '操作',
render: function (item) {
var HtmArr = [];
//status 0 : 编辑、取消热门(删除操作) status 1:编辑、发布、取消热门(删除操作) status 2: 撤回(更新为已编辑状态)
if (item.status == 0) {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs edit">编辑</a>');
if(!item.suggestId) {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs setHot">删除</a>');
} else {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs setHot">取消热门</a>');
}
} else if (item.status == 1) {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs edit">编辑</a>');
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-success btn-xs publish">发布</a>');
if(!item.suggestId) {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs setHot">删除</a>');
} else {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs setHot">取消热门</a>');
}
} else if (item.status == 2) {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-warning btn-xs publish">撤回</a>');
}
return HtmArr.join('');
}
}]
});
g.init('/suggest/suggestHot/getSuggestHotList');
var Bll = {
toast: function (item, url, title) {
var dialog = common.dialog({
title: title,
content: common.util.__template2($("#edit-template").html(), item),
width: "60%",
button: [
{
value: '取消',
css: "btn btn-default"
},
{
value: '保存',
css: "btn btn-primary",
callback: function () {
if(edit.validate() && Bll.__checkLength()) {
module.status = 1;
common.util.__ajax({
url: url,
data: item
}, function () {
dialog.close();
g.reload();
});
}
return false;
}
},
{
value: '发布',
css: "btn btn-success",
callback: function () {
if(edit.validate() && Bll.__checkLength()) {
module.status = 2;
common.util.__ajax({
url: url,
data: item
}, function () {
dialog.close();
g.reload();
});
}
return false;
}
}
]
})
edit.init();
edit.on("file_onComplete", function (obj) {
module[obj.field] = obj.data;
});
},
__render: function () {
$(".modal-body").html(common.util.__template2($("#edit-template").html(), module));
edit.init();
edit.on("file_onComplete", function (obj) {
module[obj.field] = obj.data;
});
},
batch:function(url, hint) {
var ids = [];
$.each(g.selected,function (i, value) {
ids.push(value.id);
});
if(ids.length) {
common.dialog.confirm("发送确认", "是否确认发送?", function () {
common.util.__ajax({
url: url,
data: {
id: ids.join(",")
}
}, function () {
g.reload();
});
});
} else {
common.util.__tip(hint,"warning");
}
},
__checkLength: function () {//校验长度
var contentLength = 0;
for(var i = 0; i < module.content.length; i++) {
if(/[\u4e00-\u9fa5]/i.test(module.content.charAt(i))) {
contentLength += 1;
} else {
contentLength += 0.5;
}
};
if(contentLength > 27) {
common.util.__tip("标题长度为:" + contentLength + ",超过了最大长度", "warning");
return false;
}
var replyLength = 0;
for(var i = 0; i < module.replyContent.length; i++) {
if(/[\u4e00-\u9fa5]/i.test(module.replyContent.charAt(i))) {
replyLength += 1;
} else {
replyLength += 0.5;
}
};
if(replyLength > 80) {
common.util.__tip("回复内容长度为:" + replyLength + ",超过了最大长度", "warning");
return false;
}
return true;
}
};
//新增修改
$(document).on("click", ".edit", function () {
module = $.extend(true, {}, g.rows[$(this).data("index")]);
Bll.toast(module, "/suggest/suggestHot/updateSuggestHot", "修改热门反馈");
});
$(document).on("click", "#add", function () {
module = $.extend(true, {}, HotSuggestBean);
Bll.toast(module, "/suggest/suggestHot/addSuggestHot", "添加热门反馈");
});
$(document).on("change", ".observe", function () {
module[$(this).data("field")] = $(this).val();
});
//删除图片
$(document).on("click", "#delImage", function () {
module["coverImage"] = "";
Bll.__render();
});
//筛选
$(document).on("click", "input[name='quick_select']", function () {
status = $(this).val();
g.reload(1);
$(this).attr("checked", "");
$(this).parent().siblings().find("input[name='quick_select']").removeAttr('checked');
});
$(document).on("click", "#filter-info", function () {
status = common.util.__input('status-filter');
g.reload(1);
});
//发布/撤回
$(document).on("click", ".publish", function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: "/suggest/suggestHot/publishSuggestHot",
data: {id: item.id, status: 3-item.status}
}, function () {
g.reload();
});
});
//取消热门
$(document).on("click", ".setHot", function () {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: "/suggest/suggestHot/deleteSuggestHot",
data: {id: item.id}
}, function () {
g.reload();
});
});
//更新排序
$(document).on("click", ".updateOrder", function () {
var index = $(this).data("index");
if(!/^[0-9]*$/.test($("#order_by_" + index).val())) {
common.util.__tip("排序只能是数字!");
return;
}
var item = g.rows[index];
item.orderBy = $("#order_by_" + index).val();
common.util.__ajax({
url: "/suggest/suggestHot/updateSuggestHot",
data: item
}, function () {
g.reload();
});
});
$(document).on("click", "#batchPublish", function () {
Bll.batch("/suggest/suggestHot/batchPublishSuggestHot", "请选择要发布的反馈");
});
/***/ }
]);