系统日志导出

This commit is contained in:
Anyon 2020-11-07 23:15:55 +08:00
parent 55a6831d01
commit 543a5f4093
2 changed files with 24 additions and 5 deletions

View File

@ -44,9 +44,13 @@ class Oplog extends Controller
{
$this->title = '系统日志管理';
$this->isSupper = AdminService::instance()->isSuper();
$query = $this->_query($this->table);
$query->like('action,node,content,username,geoip');
$query->dateBetween('create_at')->order('id desc')->page();
$query = $this->_query($this->table)->order('id desc');
$query->like('action,node,content,username,geoip')->dateBetween('create_at');
if (input('output') === 'json') {
$this->success('获取数据成功', $query->page(true, false));
} else {
$query->page();
}
}
/**

View File

@ -47,10 +47,25 @@
</div>
<div class="layui-form-item layui-inline">
<button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
<button type="submit" class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
<button type="button" data-form-export="{:url('index')}?type={$type|default=''}" class="layui-btn layui-btn-primary">
<i class="layui-icon layui-icon-export"></i> 导 出
</button>
</div>
</form>
</fieldset>
<script>form.render()</script>
<script>
window.form.render();
require(['excel'], function (excel) {
excel.bind(function (data) {
data.forEach(function (item, index) {
data[index] = [item.username, item.node, item.geoip, item.action, item.create_at];
});
data.unshift(['操作账号', '访问节点', '访问IP地址', '访问操作', '访问时间']);
return data;
}, '访问日志');
});
</script>