Authored by 邱骏

修改aay

... ... @@ -218,6 +218,23 @@ const activity = {
},
/**
*
* @param req
* @param res
*/
uploadExcelPage(req, res) {
const actId = req.query.actId || 23;
res.render('activity/upload-excel', {
actId,
date: moment().format('YYYY-MM-DD hh:mm:ss'),
bodyClass: 'nav-md',
module: 'admin',
page: 'activity'
});
},
/**
* y100活动文章创建页面
* @param req
* @param res
... ...
... ... @@ -19,6 +19,7 @@ router.get('/activity/article', activity.actArticleListPage);
router.get('/activity/createArticle', activity.createArticlePage);
router.get('/activity/createY100Article', activity.createY100ArticlePage);
router.get('/activity/y100Article', activity.actY100ArticleListPage);
router.get('/activity/upload_excel', activity.uploadExcelPage);
// 用户管理[page]
router.get('/user/list', user.userListPage);
... ...
<!-- page content -->
<div class="right_col" role="main">
<div class="">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title form-group">
<input id="up_excel" name="up_excel" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" style="display: inline-block; width: 80%;" type="file">
<button class="btn btn-primary btn-upload-excel" style="display: inline-block;" data-id="{{id}}">导入Y100列表</button>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr class="headings">
<th width="10%" class="column-title">ID</th>
<th width="15%" class="column-title">昵称</th>
<th width="15%" class="column-title">手机号</th>
<th width="30%" class="column-title">地址</th>
<th width="10%" class="column-title">鞋码</th>
<th width="20%" class="column-title">操作</th>
</tr>
</thead>
<tbody class="user-list">
</tbody>
</table>
</div>
<div class="table-pagination user-pagination pull-right"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /page content -->
... ...
... ... @@ -68,7 +68,7 @@ class Y100Model extends global.yoho.BaseModel {
SELECT
max(\`index\`) as maxIndex
FROM ${TABLE_ACT_ARTICLE_Y100} AAY
WHERE AAy.act_id = :actId`;
WHERE AAY.act_id = :actId`;
const maxResult = await mysqlCli.query(maxSql, params);
let maxIndex = maxResult[0].maxIndex;
... ...
... ... @@ -51,6 +51,7 @@
<ul class="nav child_menu">
<li><a href="/admin/activity/list">活动列表</a></li>
<li><a href="/admin/activity/create">活动创建</a></li>
<li><a href="/admin/activity/upload_excel">上传Y100excel</a></li>
</ul>
</li>
<li><a><i class="fa fa-users"></i> 用户管理 <span class="fa fa-chevron-down"></span></a>
... ...
require('admin/user.page.css');
require('bootpag/lib/jquery.bootpag.min');
const _ = require('lodash');
const moment = require('moment');
function bind_delete_user() {
const deleteFn = function() {
const userId = $(this).data('id');
$.ajax({
method: 'post',
url: '/admin/api/user/deleteInfoUser',
data: {
userId
}
})
.then(() => {
location.reload();
});
};
$(document).on('click', '.btn-delete-user', deleteFn);
}
function bind_export_user_list() {
let uploadFn = function() {
let file = $('#up_excel').files[0];
if (file) {
$.ajax({
url: '/api/excel/loady100',
data: {
file: file
},
success: function(res) {
console.log(res);
}
});
}
};
$('.btn-upload-excel').on('click', uploadFn);
}
function bind_table_pagination() {
const $ul = $('.user-list');
const $up = $('.user-pagination');
const fetchRender = (pageNo, pageSize) => {
$.ajax({
url: '/admin/api/user/users_list',
data: {
pageNo,
pageSize
}
})
.then(result => {
console.log(result);
const list = result.data;
const totalPage = result.totalPage;
let html = '';
_.each(list, item => {
item.userBirthday = moment(item.userBirthday).format('YYYY-MM-DD');
item.userGender = ['男', '女'][item.userGender];
html += `
<tr class="even pointer">
<td class="">${item.id}</td>
<td class="">${item.userName}</td>
<td class="">${item.userPhone}</td>
<td class="">${item.userEmail}</td>
<td class="">${item.userProvince}-${item.userCity}</td>
<td class="">${item.userBirthday}</td>
<td class="">${item.userGender}</td>
<td class="">
<button class="btn btn-danger btn-delete-user" data-id="${item.id}">删除用户
</button>
</td>
</tr>`;
});
$ul.html(html);
if (pageNo === 1) {
$up.bootpag({
total: totalPage,
page: 1,
maxVisible: 10,
}).on('page', function(event, num) {
fetchRender(num, 20);
});
}
});
};
fetchRender(1, 20);
}
(function() {
bind_delete_user();
bind_export_user_list();
bind_table_pagination();
}());
... ...