9 changed files with 152 additions and 6 deletions
@ -0,0 +1,37 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\admin\controller\user; |
||||
|
|
||||
|
use app\common\controller\AdminController; |
||||
|
use app\admin\model\UserPointsLog as UserPointsLogModel; |
||||
|
use think\App; |
||||
|
|
||||
|
class Userpointslog extends AdminController |
||||
|
{ |
||||
|
|
||||
|
public function __construct(App $app) |
||||
|
{ |
||||
|
parent::__construct($app); |
||||
|
$this->model = new UserPointsLogModel(); |
||||
|
} |
||||
|
|
||||
|
public function index() |
||||
|
{ |
||||
|
if ($this->request->isAjax()) { |
||||
|
if (input('selectFields')) { |
||||
|
return $this->selectList(); |
||||
|
} |
||||
|
list($page, $limit, $where) = $this->buildTableParames(); |
||||
|
$param = ['page' => $page, 'limit' => $limit]; |
||||
|
$pageList = UserPointsLogModel::getPageList($param, $where, ''); |
||||
|
$data = [ |
||||
|
'code' => 0, |
||||
|
'msg' => '', |
||||
|
'count' => $pageList['count'], |
||||
|
'data' => $pageList['data'] |
||||
|
]; |
||||
|
return json($data); |
||||
|
} |
||||
|
return $this->fetch(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\admin\model; |
||||
|
|
||||
|
use app\common\model\TimeModel; |
||||
|
|
||||
|
class UserPointsLog extends TimeModel |
||||
|
{ |
||||
|
protected static function indexWhere(&$where) |
||||
|
{ |
||||
|
if ($where) { |
||||
|
foreach ($where as $key => $w) { |
||||
|
if ($w[0] == 'username') { |
||||
|
$uid = User::where('nick_name', $w[1], $w[2])->column('uid'); |
||||
|
$where[$key] = ['uid', 'in', $uid ?: [0]]; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static function getPageList(array $param = [], array $where = [], $field = '*'): array |
||||
|
{ |
||||
|
$page = $param['page'] ?? 1; |
||||
|
$limit = $param['limit'] ?? 10; |
||||
|
self::indexWhere($where); |
||||
|
$order = 'id desc'; |
||||
|
$count = self::where($where)->count(); |
||||
|
$list = self::where($where)->field($field)->order($order)->page($page, $limit)->select()->toArray(); |
||||
|
foreach ($list as &$item) { |
||||
|
$item['username'] = User::getUserValue($item['uid']); |
||||
|
$item['avatar'] = User::getUserValue($item['uid'], 'avatar'); |
||||
|
} |
||||
|
return ['data' => $list, 'count' => $count]; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
<div class="layuimini-container"> |
||||
|
<div class="layuimini-main"> |
||||
|
<table id="currentTable" class="layui-table layui-hide" |
||||
|
data-auth-add="{:auth('user.userpointslog/add')}" |
||||
|
data-auth-edit="{:auth('user.userpointslog/edit')}" |
||||
|
data-auth-delete="{:auth('user.userpointslog/delete')}" |
||||
|
lay-filter="currentTable"> |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
@ -0,0 +1,40 @@ |
|||||
|
define(["jquery", "easy-admin"], function ($, ea) { |
||||
|
|
||||
|
let init = { |
||||
|
table_elem: '#currentTable', |
||||
|
table_render_id: 'currentTableRenderId', |
||||
|
index_url: 'user.userpointslog/index', |
||||
|
}; |
||||
|
|
||||
|
let LogController = { |
||||
|
|
||||
|
index: function () { |
||||
|
|
||||
|
ea.table.render({ |
||||
|
init: init, |
||||
|
toolbar: [ |
||||
|
'refresh' |
||||
|
], |
||||
|
cols: [[ |
||||
|
{type: "checkbox"}, |
||||
|
{field: 'id', width: 80, title: 'ID'}, |
||||
|
{field: 'username', width: 100, title: '用户名'}, |
||||
|
{field: 'avatar', width: 140, title: '用户头像', search: false, templet: ea.table.image}, |
||||
|
{field: 'value', width: 120, title: '变动积分', templet: function (d) { |
||||
|
if (d.value > 0) { |
||||
|
return '<button type="button" class="layui-btn layui-btn-xs layui-btn-danger">+'+d.value+'</button>'; |
||||
|
} else { |
||||
|
return '<button type="button" class="layui-btn layui-btn-xs">'+d.value+'</button>'; |
||||
|
} |
||||
|
}}, |
||||
|
{field: 'create_time', width: 160, title: '创建时间', search: 'range'}, |
||||
|
{field: 'describe', minWidth: 80, title: '描述/说明', search: false}, |
||||
|
{field: 'remark', minWidth: 80, title: '备注', search: false} |
||||
|
]], |
||||
|
}); |
||||
|
|
||||
|
ea.listen(); |
||||
|
} |
||||
|
}; |
||||
|
return LogController; |
||||
|
}); |
||||
Loading…
Reference in new issue