ShareOrderAudit.js
9.79 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
/**
* Created by wangqianjun on 16/5/4.
*/
var $ = require('jquery');
common = require('../../common/common');
datepicker = require('../../common/util/datepicker');
var ENUM = {
AuditEnum: {
'0': '待审核',
'1': '审核通过',
'2': '审核失败',
},
RecommendEnum: {
true: '已推荐',
false: '未推荐'
},
RewardEnum: {
false: '未发送奖励',
true: '奖励已发放'
}
};
//下拉框
new common.dropDown({
el: "#status"
});
new common.dropDown({
el: "#recomReward"
});
new common.dropDown({
el: "#hasImage"
});
//日期插件
$('.hasDatepicker').fdatepicker({
format: 'yyyy-mm-dd hh:ii:ss',
pickTime: true
});
/**
* 获取商品图片url
* @param item
*/
function goodsImg(item) {
var goods = item.goods;
var goodsImgUrl = "";
if (goods != null && goods.goodsImg != null && goods.goodsImg.length > 0) {
goodsImgUrl = goods.goodsImg[0].imageUrl;
}
return goodsImgUrl;
}
var g = new common.grid({
el: '#basicTable',
showtotalsize: true,
complete: function () {
$('#basicTable').poptrox({
usePopupCaption: true
});
},
parms: function () {
return {
status: $('#status').val(),
recomReward: $('#recomReward').val(),
hasImage: $('#hasImage').val(),
beginTime: common.util.__input('beginTime'),
endTime: common.util.__input('endTime'),
uid: common.util.__input('uid'),
productName: common.util.__input('productName'),
productSkn: common.util.__input('productSkn'),
orderCode: common.util.__input('orderCode')
};
},
columns: [{
display: '',
type: 'checkbox'
},{
display: '订单号',
name: "orderId"
}, {
display: '商品名称',
render: function (item) {
var goods = item.goods;
if (goods != null) {
productHref = "http://item.yohobuy.com/product/pro_" + item.productId + "_" + goods.goodsId + "/" + goods.cnAlphabet + ".html";
}
return '<a href="' + productHref + '">' + item.productName + '</a>';
}
}, {
display: '用户id',
name: "uid"
}, {
display: '商品图片',
render: function (item) {
var imgurl = goodsImg(item);
if (imgurl && imgurl != "") {
return ' <a class="pop" href="' + goodsImg(item) + '"> <img src="' + goodsImg(item) + '" title="' + item.productName + '" width="100" height="60"/> </a>';
}
}
}, {
display: "评价图片",
render: function (item) {
if (item.url && item.url != "") {
return '<a class="pop" href="' + item.url + '"><img src="' + item.url + '" " title="' + item.orderId + '" width="100" height="60"/> </a>'
}
}
}, {
display: '评价内容',
render: function (item) {
return encodeHtml(item.content);
},
style: "width:15%; word-break:break-all;"
}
, {
display: '评价星级',
name: "satisfied"
}, {
display: '审核状态',
render: function (item) {
return "<p>" + ENUM.AuditEnum[item.status] ? ENUM.AuditEnum[item.status] : "" + "</p>";
}
},
{
display: '审核返币',
render: function (item) {
return "<p>" + ENUM.RewardEnum[item.shareReward] ? ENUM.RewardEnum[item.shareReward] : "" + "</p>";
}
},
{
display: '推荐状态',
render: function (item) {
return "<p>" + ENUM.RecommendEnum[item.recomReward] ? ENUM.RecommendEnum[item.recomReward] : "" + "</p>";
}
}, {
display: "创建时间",
render: function (item) {
var t = new Date(item.createTime * 1000);
var formatted1 = common.util.__dateFormat(t, "yyyy-MM-dd");
var formatted2 = common.util.__dateFormat(t, "hh:mm:ss");
return "<p>" + formatted1 + "<br><font color='#999' style='font-size: 12px'>" + formatted2 + "</font></p>";
}
}, {
display: '备注',
name: "remark"
}, {
display: '审核操作',
//}
render: function (items) {
var HtmArr = [];
if (items.status == 0) {
HtmArr.push('<a style="margin-bottom:10px;" data-index="' + items.__index + '" data-type="pass" href="JavaScript:;" class="btn btn-success btn-xs aud">审核通过</a><br>');
HtmArr.push('<a data-index="' + items.__index + '" data-type="fail" href="JavaScript:;" class="btn btn-danger btn-xs aud">审核不通过</a>');
} else if (items.status == 1) {
HtmArr.push('<a data-index="' + items.__index + '" data-type="cancelpass" href="JavaScript:;" class="btn btn-warning btn-xs aud">取消审核通过</a>');
} else if (items.status == 2) {
HtmArr.push('<a data-index="' + items.__index + '" data-type="cancelpass" href="JavaScript:;" class="btn btn-warning btn-xs aud">取消审核不通过</a>');
}
return HtmArr.join('');
}
}, {
display: '推荐操作',
//}
render: function (items) {
var HtmArr = [];
if (items.recomReward == 0) {
HtmArr.push('<a data-index="' + items.__index + '" data-type="pass" href="JavaScript:;" class="btn btn-success btn-xs recomment">推荐</a>');
} else {
HtmArr.push('<a data-index="' + items.__index + '" data-type="cancelpass" href="JavaScript:;" class="btn btn-danger btn-xs recomment">取消推荐</a>');
}
return HtmArr.join('');
}
}
]
});
g.init('/shareOrder/shareOrderList');
// 审核
$(document).on('click', '.aud', function () {
var item = g.rows[$(this).data("index")];
var type = $(this).data('type');
var arr = [
{
commentId: item.id,
uid: item.uid
}
];
common.util.__ajax({
url: '/shareOrder/batchAud',
data: {
result: type,
shareOrderAudReqs: JSON.stringify(arr)
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('操作成功', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
});
// 推荐
$(document).on('click', '.recomment', function () {
var item = g.rows[$(this).data("index")];
var type = $(this).data('type');
common.util.__ajax({
url: '/shareOrder/recommend',
data: {
commentId: item.id,
recomReward: type,
uid: item.uid
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('操作成功', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
});
$(document).on('click', '#filter', function () {
g.reload();
});
//导出至excel,暂时只考虑筛选条件
$('#export-btn').on('click', function () {
var data = g.options.parms();
window.open("/ajax/down?queryConf=" + JSON.stringify(data) + "&type=sns");
});
// 只有"审核状态"为"待审核"时,才展示"批量审核通过"和"批量审核不通过"的按钮
$('#status').on('change', function (e) {
var valueSelected = this.value;
if(valueSelected === "0") {
$('#batch-audit-operation').show();
} else {
$('#batch-audit-operation').hide();
}
});
// 批量审核操作,处理勾选的结果
var Bll = {
toast: function(content, audResult) {
common.dialog.confirm("温馨提示", content, function() {
var selectedArr = g.selected;
var len = 0;
if(selectedArr) {
len = selectedArr.length;
}
if(len <= 0) {
common.util.__tip('请选择需要审核的晒单', 'warning');
return;
}
var options = [];
$.each(selectedArr, function (i, item) {
var data = {};
data.uid = item.uid;
data.commentId = item.id;
options.push(data);
});
console.log(JSON.stringify(options));
common.util.__ajax({
url: '/shareOrder/batchAud',
data: {
result: audResult,
shareOrderAudReqs: JSON.stringify(options)
}
}, function (res) {
if (res.code == 200) {
common.util.__tip('操作成功', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
}, function() {
// history.go(-1);
});
}
};
$('#batch-audit-pass').on('click', function () {
Bll.toast('批量审核通过?', 'pass');
});
$('#batch-audit-fail').on('click', function () {
Bll.toast('批量审核不通过?', 'fail');
});
// 对字符串中的特殊字符进行编码处理,防止js注入,形如 <script>alert(document.cookie)</script>
function encodeHtml(str, reg) {
return str ? str.replace(reg || /[&<">'](?:(amp|lt|quot|gt|#39|nbsp);)?/g, function(a, b) {
if (b) {
return a;
} else {
return {
'<': '<',
'&': '&',
'"': '"',
'>': '>',
"'": '''
}[a]
}
}) : '';
}