...
|
...
|
@@ -9,6 +9,7 @@ const excelExport = require('excel-export'); |
|
|
const UserModel = require('../models/user');
|
|
|
|
|
|
const DO_SUCCESS = '操作成功';
|
|
|
const GET_SUCCESS = '获取成功';
|
|
|
|
|
|
const timeFmt = (time) => {
|
|
|
if (_.isNumber(time)) {
|
...
|
...
|
@@ -23,26 +24,51 @@ const userController = { |
|
|
* 用户列表页
|
|
|
* @param req
|
|
|
* @param res
|
|
|
*/
|
|
|
userListPage(req, res) {
|
|
|
res.render('user/list', {
|
|
|
bodyClass: 'nav-md',
|
|
|
module: 'admin',
|
|
|
page: 'user'
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户列表
|
|
|
* @param req
|
|
|
* @param res
|
|
|
* @param next
|
|
|
*/
|
|
|
userListPage(req, res, next) {
|
|
|
req.ctx(UserModel).userList()
|
|
|
.then(result => {
|
|
|
userList(req, res, next) {
|
|
|
const pageNo = req.query.pageNo || 1;
|
|
|
const pageSize = req.query.pageSize || 20;
|
|
|
|
|
|
_.map(result, item => {
|
|
|
item.createTime = timeFmt(
|
|
|
item.createTime
|
|
|
);
|
|
|
});
|
|
|
req.ctx(UserModel).userList({
|
|
|
pageNo,
|
|
|
pageSize
|
|
|
})
|
|
|
.then(list => {
|
|
|
_.each(list, item => {
|
|
|
item.createTime = timeFmt(item.createTime);
|
|
|
});
|
|
|
|
|
|
res.render('user/list', {
|
|
|
bodyClass: 'nav-md',
|
|
|
userList: result,
|
|
|
module: 'admin',
|
|
|
page: 'user'
|
|
|
return list;
|
|
|
})
|
|
|
.then(list => {
|
|
|
req.ctx(UserModel).allUsersNum()
|
|
|
.then(totalCount => {
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
data: list,
|
|
|
pageNo: +pageNo,
|
|
|
pageSize: +pageSize,
|
|
|
totalCount,
|
|
|
totalPage: Math.ceil(totalCount / pageSize),
|
|
|
message: GET_SUCCESS
|
|
|
});
|
|
|
});
|
|
|
})
|
|
|
.catch(next);
|
|
|
})
|
|
|
.catch(next);
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -94,7 +120,7 @@ const userController = { |
|
|
rows: []
|
|
|
};
|
|
|
|
|
|
req.ctx(UserModel).userList()
|
|
|
req.ctx(UserModel).exportUserList()
|
|
|
.then(result => {
|
|
|
let temp = [];
|
|
|
|
...
|
...
|
|