Commit 0b98ff16 authored by strong's avatar strong

Merge branch 'bugfix_1019_comment_export'

parents 9f3a0a0f a61352d0
...@@ -1123,7 +1123,7 @@ router.get('/thread/:tid/exportComments', function(req, res, next) { ...@@ -1123,7 +1123,7 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
{caption:'发帖人', type:'string'}, {caption:'发帖人', type:'string'},
{caption:'openId', type:'string'}, {caption:'openId', type:'string'},
{caption:'内容', type:'string'}, {caption:'内容', type:'string'},
{caption:'评论数', type:'number'}, {caption:'评论数', type:'string'},
{caption:'转发数', type:'string'}, {caption:'转发数', type:'string'},
{caption:'点赞数', type:'string'}, {caption:'点赞数', type:'string'},
{caption:'点赞人', type:'string'}, {caption:'点赞人', type:'string'},
...@@ -1137,9 +1137,19 @@ router.get('/thread/:tid/exportComments', function(req, res, next) { ...@@ -1137,9 +1137,19 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
t_from_openId = thread.from?thread.from.uid:'', t_from_openId = thread.from?thread.from.uid:'',
t_praiseNames = thread.praiseNames, t_praiseNames = thread.praiseNames,
t_praiseOpenIds = thread.praiseOpenIds; t_praiseOpenIds = thread.praiseOpenIds;
rows.push([t_title,t_time,t_from,t_from_openId,thread.content,thread.comment_count,thread.share_count.toString(),thread.praise_count.toString(),t_praiseNames,t_praiseOpenIds]); rows.push([
t_title,
t_time,
t_from,
t_from_openId,
thread.content,
thread.comment_count.toString(),
thread.share_count.toString(),
thread.praise_count.toString(),
t_praiseNames,
t_praiseOpenIds]);
rows.push(['','','','','','','','','','']); rows.push(['','','','','','','','','','']);
rows.push(['楼层','发布时间','openId','会员名', '内容','点赞数','点赞人','点赞人openId','','']); rows.push(['楼层','发布时间','openId','会员名', '内容','点赞数','点赞人','点赞人openId',null,null]);
for (var i = items.length - 1; i >= 0; i--) { for (var i = items.length - 1; i >= 0; i--) {
var comment = items[i]; var comment = items[i];
var floor = comment.floor, var floor = comment.floor,
...@@ -1159,7 +1169,7 @@ router.get('/thread/:tid/exportComments', function(req, res, next) { ...@@ -1159,7 +1169,7 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
nickName = comment.from.nickName || '游客'; nickName = comment.from.nickName || '游客';
} }
var this_row = [floor + '', time,openId, nickName, content, praiseCount, praiseNames,praiseOpenIds,null,null]; var this_row = [floor + '', time,openId, nickName, encode(content,'utf-8'), praiseCount.toString(), praiseNames,praiseOpenIds,null,null];
rows.push(this_row); rows.push(this_row);
if(comment.comments.length > 0){ if(comment.comments.length > 0){
for (var k = 0; k < comment.comments.length; k++) { for (var k = 0; k < comment.comments.length; k++) {
...@@ -1184,7 +1194,8 @@ router.get('/thread/:tid/exportComments', function(req, res, next) { ...@@ -1184,7 +1194,8 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
}; };
conf.rows = rows; conf.rows = rows;
var result = nodeExcel.execute(conf); var result = nodeExcel.execute(conf);
res.setHeader('Content-Type', 'application/vnd.ms-excel'); res.charset = 'utf-8';
res.setHeader('Content-Type', 'application/vnd.openxmlformats');
res.setHeader('Content-Disposition', 'attachment; filename=commentsReport.xlsx'); res.setHeader('Content-Disposition', 'attachment; filename=commentsReport.xlsx');
res.end(result, 'binary'); res.end(result, 'binary');
}).fail(function(cont,err){ }).fail(function(cont,err){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment