123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- {extend name="common/base"/}
- <!-- 主体 -->
- {block name="body"}
- <div class="p-3">
- <form class="layui-form gg-form-bar border-t border-x">
- <div class="layui-input-inline" style="width:300px;">
- <input type="text" name="keywords" placeholder="昵称/真实姓名/手机号" class="layui-input" autocomplete="off" />
- </div>
- <div class="layui-input-inline" style="width:120px;">
- <input type="text" class="layui-input" id="start_time" readonly placeholder="注册开始时间" name="start_time">
- </div>
- ~
- <div class="layui-input-inline" style="width:120px;">
- <input type="text" class="layui-input" id="end_time" readonly placeholder="注册结束时间" name="end_time">
- </div>
- <div class="layui-input-inline">
- <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
- </div>
- </form>
- <table class="layui-hide" id="user" lay-filter="user"></table>
- </div>
- <script type="text/html" id="status">
- <i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
- </script>
- {/block}
- <!-- /主体 -->
- <!-- 脚本 -->
- {block name="script"}
- <script>
- const moduleInit = ['tool'];
- function gouguInit() {
- var tool = layui.tool, table = layui.table, laydate = layui.laydate, form = layui.form;
- laydate.render({
- elem: '#start_time',
- type: 'date'
- });
- laydate.render({
- elem: '#end_time',
- type: 'date'
- });
- layui.pageTable = table.render({
- elem: '#user',
- title: '用户列表',
- toolbar: '#toolbarDemo',
- url: '/admin/user/index', //数据接口
- page: true, //开启分页
- limit: 20,
- cols: [
- [ //表头
- {
- field: 'id',
- title: 'ID号',
- align: 'center',
- width: 90
- }, {
- field: 'headimgurl',
- title: '头像',
- align: 'center',
- width: 60,
- templet: function (d) {
- var html = '';
- var delBtn = '<img src="' + d.headimgurl + '" width="28" height="28"/>';
- return delBtn;
- }
- }, {
- field: 'username',
- title: '用户名',
- align: 'center',
- width: 100
- }, {
- field: 'level_name',
- title: '会员等级',
- align: 'center',
- width: 90
- }, {
- field: 'sex',
- title: '性别',
- align: 'center',
- width: 60,
- templet: function (d) {
- var html = '-';
- if (d.sex == 1) {
- html = '男'
- } else if (d.sex == 2) {
- html = '女'
- }
- return html;
- }
- }, {
- field: 'nickname',
- title: '昵称',
- align: 'center',
- width: 100
- }, {
- field: 'name',
- title: '真实姓名',
- align: 'center',
- width: 100
- }, {
- field: 'mobile',
- title: '手机号码',
- align: 'center',
- width: 120
- }, {
- field: 'email',
- title: '电子邮箱',
- align: 'center',
- minWidth: 150
- }, {
- field: 'register_time',
- title: '注册时间',
- align: 'center',
- width: 150
- }, {
- field: 'status',
- title: '状态',
- toolbar: '#status',
- align: 'center',
- width: 60
- }, {
- field: 'right',
- fixed: 'right',
- title: '操作',
- align: 'center',
- width: 136,
- templet:function(d){
- let btn1 = '<span class="layui-btn layui-btn-xs layui-btn-normal" lay-event="view">详情</span><span class="layui-btn layui-btn-xs" lay-event="edit">编辑</span>';
- let btn2 = '<span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">禁用</span>';
- let btn3 = '<span class="layui-btn layui-btn-normal layui-btn-xs" lay-event="open">启用</span>';
- if(d.status == 1){
- return '<div class="layui-btn-group">'+btn1+btn2+'</div>';
- }else{
- return '<div class="layui-btn-group">'+btn1+btn3+'</div>';
- }
- }
- }
- ]
- ]
- });
- //监听行工具事件
- table.on('tool(user)', function (obj) {
- var data = obj.data;
- if (obj.event === 'view') {
- tool.side('/admin/user/view?id=' + data.id);
- return;
- }
- else if (obj.event === 'edit') {
- tool.side('/admin/user/edit?id=' + data.id);
- return;
- }
- else if (obj.event === 'del') {
- layer.confirm('您确定要禁用该用户', {
- icon: 3,
- title: '提示'
- }, function (index) {
- let callback = function (e) {
- layer.msg(e.msg);
- if (e.code == 0) {
- layer.close(index);
- layui.pageTable.reload()
- }
- }
- tool.post("/admin/user/disable", { id: data.id, status: 0 }, callback);
- layer.close(index);
- });
- } else if (obj.event === 'open') {
- layer.confirm('您确定要启用该用户', {
- icon: 3,
- title: '提示'
- }, function (index) {
- let callback = function (e) {
- layer.msg(e.msg);
- if (e.code == 0) {
- layer.close(index);
- layui.pageTable.reload()
- }
- }
- tool.post("/admin/user/disable", { id: data.id, status: 1 }, callback);
- layer.close(index);
- });
- }
- });
- //监听搜索提交
- form.on('submit(webform)', function (data) {
- layui.pageTable.reload({
- where: {
- keywords: data.field.keywords,
- attach: data.field.attach,
- start_time: data.field.start_time,
- end_time: data.field.end_time
- },
- page: {
- curr: 1
- }
- });
- return false;
- });
- }
- </script>
- {/block}
- <!-- /脚本 -->
|