| | |
| | | 搜索: |
| | | <select id="user-search-key"> |
| | | <option value="">-请选择-</option> |
| | | <option value="user_id">ID</option> |
| | | <option value="username">账号</option> |
| | | <option value="nick_name">用户名</option> |
| | | <option value="mobile">手机号</option> |
| | | </select>  |
| | | <input id="user-search-value" class="layui-input search-input" type="text" placeholder="输入关键字" />  |
| | | <button id="user-btn-search" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button> |
| | | <button id="user-btn-add" class="layui-btn icon-btn"><i class="layui-icon"></i>添加</button> |
| | | <button id="user-btn-export" class="layui-btn icon-btn"><i class="layui-icon"></i>导出</button> |
| | | <button type="button" class="layui-btn" id="user-btn-import"> |
| | | <i class="layui-icon"></i>导入 |
| | | </button> |
| | | <input id="user-search-value" class="layui-input search-input" type="text" placeholder="按关键字" />  |
| | | <button id="user-btn-search" class="layui-btn icon-btn"><i class="layui-icon" ></i>搜索</button> |
| | | <!-- <button id="user-btn-add" class="layui-btn icon-btn"><i class="layui-icon permissions" permissions="user-btn-add"></i>添加</button> --> |
| | | <!-- <button id="user-btn-export" class="layui-btn icon-btn"><i class="layui-icon permissions" permissions="user-btn-export"></i>导出</button>--> |
| | | <!-- <button type="button" class="layui-btn" id="user-btn-import">--> |
| | | <!-- <i class="layui-icon permissions" permissions="user-btn-import"></i>导入 --> |
| | | <!-- </button>--> |
| | | </div> |
| | | |
| | | <table class="layui-table" id="user-table" lay-filter="user-table"></table> |
| | |
| | | |
| | | <!-- 表格操作列 --> |
| | | <script type="text/html" id="user-table-bar"> |
| | | <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a> |
| | | <a class="layui-btn layui-btn-xs" lay-event="reset">重置密码</a> |
| | | <a class="layui-btn layui-btn-xs" lay-event="org">分配组织</a> |
| | | <a class="layui-btn layui-btn-xs" lay-event="del">删除</a> |
| | | <a class="layui-btn layui-btn-primary layui-btn-xs permissions" permissions="user-btn-add" lay-event="edit">修改</a> |
| | | <a class="layui-btn layui-btn-xs permissions" permissions="user-default-password" lay-event="reset">重置密码</a> |
| | | <!-- <a class="layui-btn layui-btn-xs permissions" permissions="userorg-save" lay-event="org">分配组织</a> --> |
| | | <!-- <a class="layui-btn layui-btn-xs permissions" permissions="user-del" lay-event="del">删除</a> --> |
| | | </script> |
| | | |
| | | <!-- 表格状态列 --> |
| | |
| | | elem: '#user-table', |
| | | url: config.base_server + 'api-user/users', |
| | | method: 'GET', |
| | | headers: { 'Authorization': 'Bearer ' + config.getToken().access_token }, |
| | | headers: { 'Authorization': 'Bearer ' + config.getToken().access_token}, |
| | | page: true, |
| | | cols: [[ |
| | | { field: 'id', sort: true, width: 200, title: '标识' }, |
| | | { field: 'username', sort: true, width: 100, title: '账号' }, |
| | | { field: 'nickname', sort: true, width: 200, title: '用户名' }, |
| | | { field: 'mobile', sort: true, width: 150, title: '手机号' }, |
| | | { field: 'username', width: "150",align: 'center', title: '账号' }, |
| | | { field: 'nickname', width: "150",align: 'center', title: '用户名' }, |
| | | { field: 'mobile', width: "150",align: 'center', title: '手机号' }, |
| | | { |
| | | sort: true, title: '性别', templet: function (d) { |
| | | return d.sex == 0 ? "男" : "女" |
| | | sort: true, width: "10%",align: 'center', title: '性别', templet: function (d) { |
| | | var value=""; |
| | | if(d.sex == 0){ |
| | | value="男"; |
| | | }else if(d.sex == 1){ |
| | | value="女"; |
| | | } |
| | | return value; |
| | | }, width: 100 |
| | | }, |
| | | { |
| | | sort: true, width: 200, templet: function (d) { |
| | | return util.toDateString(d.createTime); |
| | | }, title: '创建时间' |
| | | }, |
| | | { field: 'enabled', width: 100, sort: true, templet: '#user-tpl-state', title: '状态' }, |
| | | { fixed: 'right', align: 'center', toolbar: '#user-table-bar', title: '操作', width: 300 } |
| | | ]] |
| | | { field: 'createTime', width: "150",align: 'center', sort: true, title: '创建时间', templet: "<div>{{layui.util.toDateString(d.createTime, 'yyyy/MM/dd HH:mm')}}</div>" }, |
| | | { field: 'enabled', width: "10%",align: 'center', templet: '#user-tpl-state', title: '状态' }, |
| | | { fixed: 'right', width: "10%",align: 'center', toolbar: '#user-table-bar', title: '操作', width: 300 } |
| | | ]], |
| | | done:function(res){ |
| | | permissionsInput(res,config); |
| | | } |
| | | }); |
| | | |
| | | // 添加按钮点击事件 |
| | |
| | | admin.req('api-user/users/' + obj.data.id + '/password', {}, function (data) { |
| | | layer.closeAll('loading'); |
| | | if (data.code == 0) { |
| | | layer.msg(data.msg, { icon: 1, time: 500 }); |
| | | layer.msg(data.msg, { icon: 1, time: 2000 }); |
| | | layer.alert("密码重置为:"+data.data, {icon: 1}); |
| | | } else { |
| | | layer.msg(data.msg, { icon: 2, time: 500 }); |
| | | layer.msg(data.msg, { icon: 2, time: 2000 }); |
| | | } |
| | | }, 'PUT'); |
| | | }); |
| | |
| | | admin.req('api-user/users/' + obj.data.id, {}, function (data) { |
| | | layer.closeAll('loading'); |
| | | if (data.code == 0) { |
| | | layer.msg(data.msg, { icon: 1, time: 500 }); |
| | | layer.msg(data.msg, { icon: 1, time: 2000 }); |
| | | table.reload('user-table', {}); |
| | | } else { |
| | | layer.msg(data.msg, { icon: 2, time: 500 }); |
| | | layer.msg(data.msg, { icon: 2, time: 2000 }); |
| | | } |
| | | }, 'delete'); |
| | | }); |
| | |
| | | }, function (data) { |
| | | layer.closeAll('loading'); |
| | | if (data.code == 0) { |
| | | layer.msg(data.msg, { icon: 1, time: 500 }); |
| | | layer.msg(data.msg, { icon: 1, time: 2000 }); |
| | | //table.reload('table-user', {}); |
| | | } else { |
| | | layer.msg(data.msg, { icon: 2, time: 500 }); |
| | | layer.msg(data.msg, { icon: 2, time: 2000 }); |
| | | $(obj.elem).prop('checked', !obj.elem.checked); |
| | | form.render('checkbox'); |
| | | } |
| | |
| | | , headers: { "Authorization": "Bearer " + config.getToken().access_token } |
| | | , done: function (data) { |
| | | if (data.code == 0) { |
| | | layer.msg(data.msg, { icon: 1, time: 500 }); |
| | | layer.msg(data.msg, { icon: 1, time: 2000 }); |
| | | table.reload('user-table', {}); |
| | | } else { |
| | | layer.msg(data.msg, { icon: 2, time: 500 }); |
| | | layer.msg(data.msg, { icon: 2, time: 2000 }); |
| | | } |
| | | } |
| | | }); |