index.js
10.1 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
/**
* Created by jiangmin on 2016/5/9.
* 反馈管理
*/
var $ = require('jquery');
common = require('../common/common');
datepicker = require('../util/datepicker');
var ENUM = {
//发送状态
StatusEnum1: {
'0': '未发送',
'1': '未发送',
'2': '已发送'
},
//状态
StatusEnum2: {
'0': '未回复',
'1': '已回复',
'2': '已回复'
}
};
/**
* 下拉框
*/
new common.dropDown({
el: "#isHot-filter"
});
new common.dropDown({
el: "#status-filter"
});
new common.dropDown({
el: "#clientType-filter"
});
/**
* 日期插件
*/
$('.hasDatepicker').fdatepicker({
format: 'yyyy-mm-dd'
});
var appVersion = {};
var replyPersonName = {};
var quick_select = {};
var status = "-1";
/**
* 列表
* @type {common.grid}
*/
var g = new common.grid({
el: '#content-list',
callback: function (data) {
if (data && data.data) {
quick_select = {
replyTotal: data.data.replyTotal,
unReplyTotal: data.data.unReplyTotal,
status: status
};
}
$("#quick").html(common.util.__template2($("#quick-search").html(), {quick_select: quick_select}));
return data.data;
},
parms: function () {
if (common.util.__input('status-filter')) {
status = common.util.__input('status-filter');
}
return {
uid: common.util.__input('uid-filter'),
startTime: common.util.__input('startTime'),
endTime: common.util.__input('endTime'),
isHot: common.util.__input('isHot-filter'),
status: status,
clientType: common.util.__input('clientType-filter'),
appVersion: common.util.__input('choose-appVersion'),
replyPersonId: common.util.__input('choose-replyPersonName')
};
},
columns: [
{
display: '',
type: 'checkbox'
}, {
display: "UID",
name: "uid"
}, {
display: "来源",
name: "clientType"
}, {
display: '版本号',
name: "appVersion"
}, {
display: '图片',
render: function (item) {
var a = item.imageUrl.split('?');
return '<a href="' + a[0] + '" target="_blank"><img src="' + item.imageUrl + '"></a>'
}
}, {
display: '反馈内容',
name: "content",
style:"width:20%;word-break:break-all;"
}, {
display: '回复内容',
name: "replyContent",
style:"width:20%; word-break:break-all;"
}, {
display: '回复人',
name: "replyPersonName",
render: function (item) {
if (item.status == '0') {
return "";
}
else {
return item.replyPersonName
}
}
}, {
display: '时间',
name: "createTime"
}, {
display: "发送状态",
render: function (item) {
return "<p>" + ENUM.StatusEnum1[item.status] + "</p>";
}
}, {
display: "回复状态",
name: 'status',
render: function (item) {
return "<p>" + ENUM.StatusEnum2[item.status] + "</p>";
}
}, {
display: '操作',
render: function (item) {
var HtmArr = [];
//已发送,已回复,uid为0,则不可再“回”、“发”
if (item.status == 2 || item.uid == '0') {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs reply" disabled="true">回</a>');
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-success btn-xs publish" disabled="true">发</a>');
}
else if (item.status == 0) {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs reply">回</a>');
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-success btn-xs publish" disabled="true">发</a>');
}
else {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs reply">回</a>');
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-success btn-xs publish">发</a>');
}
if (item.isHot == 1) {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs setHot" disabled="false">热</a>');
}
else {
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs setHot">热</a>');
}
HtmArr.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-dark btn-xs delete">删</a>');
return HtmArr.join('');
}
}]
});
g.init('/suggest/suggest/getSuggestList');
$(document).on("click", "input[name='quick_select']", function () {
status = $(this).val();
g.reload();
$(this).attr("checked", "");
$(this).parent().siblings().find("input[name='quick_select']").removeAttr('checked');
});
var Bll = {
dropDown: function (url, title, data) {
common.util.__ajax({
url: url,//获取所有版本号
data: {}
}, function (res) {
$("#" + title + "-content").html(common.util.__template2($("#search-" + title).html(), res));
new common.dropDown({el: "#choose-" + title});
data = res.data;
}, true);
},
toast: function (url, item, content) {
common.dialog.confirm("",
content,
function () {
common.util.__ajax({
url: url,
data: item
}, function () {
g.reload();
});
});
},
toastBatch: function (url, id, content) {
common.dialog.confirm("", content,
function () {
common.util.__ajax({
url: url,
data: {
id: id
}
}, function (res) {
//console.log(res);
g.reload(1);
});
});
}
};
Bll.dropDown("/suggest/suggest/getAllAppVersions", "appVersion", appVersion);
Bll.dropDown("/suggest/suggest/findAllReplyInfo", "replyPersonName", replyPersonName);
/**
* 查询按钮点击时间
*/
$("#filter-btn").click(function () {
g.reload(1);
});
/**
* 回
*/
$(document).on('click', '.reply', function () {
var item = g.rows[$(this).data("index")];
common.dialog({
title: "回答反馈内容",
content: common.util.__template2($("#replyTemplate").html(), item),
button: [
{
value: "保存",
callback: function () {
common.util.__ajax({
url: "/suggest/suggest/replySuggest",
data: {
id: item.id,
replyContent: $("#replyContent").val()
}
}, function (res) {
if (res.code == '200') {
g.reload();
}
})
},
css: "btn btn-info"
}, {
value: "取消"
}
]
});
});
/**
* 发
*/
$(document).on('click', '.publish', function () {
var item = g.rows[$(this).data("index")];
item = {
id: item.id
};
Bll.toast('/suggest/suggest/publishSuggest', item, "是否确认发送?");
});
/**
* 热
*/
$(document).on('click', '.setHot', function () {
var item = g.rows[$(this).data("index")];
item = {
id: item.id,
isHot: 1
};
Bll.toast('/suggest/suggest/setHotSuggest', item, "是否确认设置热门?");
});
/**
* 删除
*/
$(document).on('click', '.delete', function () {
var item = g.rows[$(this).data("index")];
Bll.toast('/suggest/suggest/deleteSuggest', item, "是否确认删除?");
});
//批量发送
$(document).on('click', '#batchPublish', function () {
var selectedArr = g.selected,
len = selectedArr.length,
idList = [],
idstatus0 = [],
idstatus2 = [];
var msg = "";
var msgs = [];
if (len <= 0) {
common.util.__tip('请选择反馈', 'warning');
return;
}
$.each(selectedArr, function (i, value) {
idList.push(value['id']);
if (value['status'] == 0) {
idstatus0.push(value['uid']);
}
if (value['status'] == 2) {
idstatus2.push(value['uid']);
}
});
var msg1 = idstatus0.length + '条反馈还没有回复,不可发送!';
var msg2 = idstatus2.length + '条反馈已发送,不可重复发送!';
if (idstatus0.length > 0) {
msgs.push(msg1);
}
if (idstatus2.length > 0) {
msgs.push(msg2);
}
if (msgs.length > 0) {
for (var i = 0; i < msgs.length; i++) {
msg = msg + '<p>' + msgs[i] + '</p>'
}
common.util.__tip(msg, 'warning');
return;
}
Bll.toastBatch("/suggest/suggest/batchPublishSuggest", idList.join(","), "确定批量发送吗?");
});
/**
* 批量导出
*/
$(document).on('click', '#batchExport', function () {
var selectedArr = g.selected,
len = selectedArr.length,
idList = [];
if (len <= 0) {
common.util.__tip('请选择反馈', 'warning');
return;
}
$.each(selectedArr, function (i, value) {
idList.push(value['id']);
});
var data = {
id: idList.join(",")
};
window.open("/ajax/down?queryConf=" + JSON.stringify(data) + "&type=suggestExport");
});