| <div class="layui-fluid layui-anim febs-anim" id="febs-user" lay-title="代理商列表"> | 
|     <div class="layui-row febs-container"> | 
|         <div class="layui-col-md12"> | 
|             <div class="layui-card"> | 
|                 <div class="layui-card-body febs-table-full"> | 
|                     <form class="layui-form layui-table-form" lay-filter="user-table-form"> | 
|                         <div class="layui-row"> | 
|                             <div class="layui-col-md10"> | 
|                                 <div class="layui-form-item"> | 
|                                     <div class="layui-inline"> | 
|                                         <div class="layui-input-inline"> | 
|                                             <input type="text" placeholder="手机号/邮箱/邀请码" name="account" autocomplete="off" class="layui-input"> | 
|                                         </div> | 
|                                     </div> | 
|                                     <div class="layui-inline"> | 
|                                         <label class="layui-form-label layui-form-label-sm">创建时间</label> | 
|                                         <div class="layui-input-inline"> | 
|                                             <input type="text" name="createTime" id="user-createTime" class="layui-input"> | 
|                                         </div> | 
|                                     </div> | 
|                                     <div class="layui-inline"> | 
|                                         <label class="layui-form-label layui-form-label-sm">账号类型</label> | 
|                                         <div class="layui-input-inline"> | 
|                                             <select name="accountType"> | 
|                                                 <option value=""></option> | 
|                                                 <option value="1">测试账号</option> | 
|                                                 <option value="2">正常账号</option> | 
|                                             </select> | 
|                                         </div> | 
|                                     </div> | 
|                                     <div class="layui-inline"> | 
|                                         <label class="layui-form-label layui-form-label-sm">账号状态</label> | 
|                                         <div class="layui-input-inline"> | 
|                                             <select name="accountStatus"> | 
|                                                 <option value=""></option> | 
|                                                 <option value="0">禁用</option> | 
|                                                 <option value="1">正常</option> | 
|                                             </select> | 
|                                         </div> | 
|                                     </div> | 
|                                     <div class="layui-inline"> | 
|                                         <label class="layui-form-label layui-form-label-sm">实名状态</label> | 
|                                         <div class="layui-input-inline"> | 
|                                             <select name="certifyStatus"> | 
|                                                 <option value=""></option> | 
|                                                 <option value="0">未通过</option> | 
|                                                 <option value="1">审核中</option> | 
|                                                 <option value="2">审核通过</option> | 
|                                                 <option value="2">未实名</option> | 
|                                             </select> | 
|                                         </div> | 
|                                     </div> | 
|                                 </div> | 
|                             </div> | 
|                             <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area"> | 
|                                 <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query"> | 
|                                     <i class="layui-icon"></i> | 
|                                 </div> | 
|                                 <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset"> | 
|                                     <i class="layui-icon"></i> | 
|                                 </div> | 
|                                 <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-cyan-plain table-action" id="add" shiro:hasPermission="agent:add"> | 
|                                     <i class="layui-icon"></i> | 
|                                 </div> | 
| <!--                                <div class="layui-btn layui-btn-sm layui-btn-primary table-action action-more"--> | 
| <!--                                     shiro:hasAnyPermissions="agent:add,agent:edit">--> | 
| <!--                                    <i class="layui-icon"></i>--> | 
| <!--                                </div>--> | 
|                             </div> | 
|                         </div> | 
|                     </form> | 
|                     <table lay-filter="userTable" lay-data="{id: 'userTable'}"></table> | 
|                 </div> | 
|             </div> | 
|         </div> | 
|     </div> | 
| </div> | 
| <!-- 表格字段状态格式化 start --> | 
| <script type="text/html" id="certify-status"> | 
|     {{# | 
|     var certifyStatus = { | 
|     0: {title: '未实名', color: 'blue'}, | 
|     1: {title: '未实名', color: 'blue'}, | 
|     2: {title: '审核通过', color: 'green'}, | 
|     3: {title: '未实名', color: 'blue'} | 
|     }[d.certifyStatus]; | 
|     }} | 
|     <span class="layui-badge febs-tag-{{certifyStatus.color}}">{{ certifyStatus.title }}</span> | 
| </script> | 
| <script type="text/html" id="account-status"> | 
|     {{# | 
|     var accountStatus = { | 
|     1: {title: '正常', color : 'blue'}, | 
|     0: {title: '禁用', color : 'red'} | 
|     }[d.status]; | 
|     }} | 
|     <span class="layui-badge febs-bg-{{accountStatus.color}}">{{ accountStatus.title }}</span> | 
| </script> | 
| <!-- 表格字段状态格式化 start --> | 
|   | 
| <!-- 表格操作栏 start --> | 
| <script type="text/html" id="user-option"> | 
|     <span shiro:lacksPermission="agent:edit,agent:del"> | 
|         <span class="layui-badge-dot febs-bg-orange"></span> 无权限 | 
|     </span> | 
|     <a lay-event="reset" title="重置密码" shiro:hasPermission="agent:password:reset"><i class="layui-icon febs-edit-area febs-blue"></i></a> | 
|     <a lay-event="edit" title="编辑" shiro:hasPermission="agent:edit"><i class="layui-icon febs-edit-area febs-blue"></i></a> | 
| <!--    <a lay-event="del" title="删除" shiro:hasPermission="agent:del"><i class="layui-icon febs-edit-area febs-red"></i></a>--> | 
| </script> | 
| <!-- 表格操作栏 end --> | 
| <script data-th-inline="none" type="text/javascript"> | 
|     // 引入组件并初始化 | 
|     layui.use(['dropdown', 'jquery', 'laydate', 'form', 'table', 'febs', 'treeSelect'], function () { | 
|         var $ = layui.jquery, | 
|             laydate = layui.laydate, | 
|             febs = layui.febs, | 
|             form = layui.form, | 
|             table = layui.table, | 
|             dropdown = layui.dropdown, | 
|             $view = $('#febs-user'), | 
|             $query = $view.find('#query'), | 
|             $reset = $view.find('#reset'), | 
|             $add = $view.find('#add'), | 
|             $searchForm = $view.find('form'), | 
|             sortObject = {field: 'createTime', type: null}, | 
|             tableIns, | 
|             createTimeFrom, | 
|             createTimeTo; | 
|   | 
|         form.render(); | 
|   | 
|         // 表格初始化 | 
|         initTable(); | 
|   | 
|         // 时间组件 | 
|         laydate.render({ | 
|             elem: '#user-createTime', | 
|             range: true, | 
|             trigger: 'click' | 
|         }); | 
|   | 
|         // 新增下拉组件 | 
|         dropdown.render({ | 
|             elem: $view.find('.action-more'), | 
|             click: function (name, elem, event) { | 
|                 var checkStatus = table.checkStatus('userTable'); | 
|                 if (name === 'add') { | 
|                     febs.modal.open('新增用户', 'agent/agentAdd', { | 
|                         btn: ['提交', '重置'], | 
|                         area: $(window).width() <= 750 ? '95%' : '50%', | 
|                         offset: '30px', | 
|                         yes: function (index, layero) { | 
|                             $('#user-add').find('#submit').trigger('click'); | 
|                         }, | 
|                         btn2: function () { | 
|                             $('#user-add').find('#reset').trigger('click'); | 
|                             return false; | 
|                         } | 
|                     }); | 
|                 } | 
|                 if (name === 'delete') { | 
|                     if (!checkStatus.data.length) { | 
|                         febs.alert.warn('请选择需要删除的用户'); | 
|                     } else { | 
|                         febs.modal.confirm('删除用户', '确定删除该用户?', function () { | 
|                             var userIds = []; | 
|                             layui.each(checkStatus.data, function (key, item) { | 
|                                 userIds.push(item.userId) | 
|                             }); | 
|                             deleteUsers(userIds.join(',')); | 
|                         }); | 
|                     } | 
|                 } | 
|                 // if (name === 'reset') { | 
|                 //     if (!checkStatus.data.length) { | 
|                 //         febs.alert.warn('请选择需要重置密码的用户'); | 
|                 //     } else { | 
|                 //         var usernames = []; | 
|                 //         layui.each(checkStatus.data, function (key, item) { | 
|                 //             usernames.push(item.username) | 
|                 //         }); | 
|                 //         febs.post(ctx + 'user/password/reset/' + usernames.join(','), null, function () { | 
|                 //             febs.alert.success('所选用户密码已重置为1234qwer'); | 
|                 //         }); | 
|                 //     } | 
|                 // } | 
|             }, | 
|             options: [{ | 
|                 name: 'add', | 
|                 title: '新增代理商', | 
|                 perms: 'agent:add' | 
|             }] | 
|         }); | 
|   | 
|         // 初始化表格操作栏各个按钮功能 | 
|         table.on('tool(userTable)', function (obj) { | 
|             var data = obj.data, | 
|                 layEvent = obj.event; | 
|             if (layEvent === 'reset') { | 
|                 febs.modal.confirm('重置密码', '确定重置该用户密码?', function () { | 
|                     febs.post(ctx + 'agent/reset/' + data.id, null, function () { | 
|                         febs.alert.success('所选用户密码已重置为1234qwer'); | 
|                     }); | 
|                 }); | 
|             } | 
|             if (layEvent === 'del') { | 
|                 febs.modal.confirm('删除用户', '确定删除该用户?', function () { | 
|                     deleteUsers(data.id); | 
|                 }); | 
|             } | 
|             if (layEvent === 'edit') { | 
|                 febs.modal.open('修改用户', '/agent/agentEdit/' + data.id, { | 
|                     area: $(window).width() <= 750 ? '90%' : '50%', | 
|                     offset: '30px', | 
|                     btn: ['提交', '取消'], | 
|                     yes: function (index, layero) { | 
|                         $('#user-update').find('#submit').trigger('click'); | 
|                     }, | 
|                     btn2: function () { | 
|                         layer.closeAll(); | 
|                     } | 
|                 }); | 
|             } | 
|         }); | 
|   | 
|         // 查询按钮 | 
|         $query.on('click', function () { | 
|             var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type}); | 
|             tableIns.reload({where: params, page: {curr: 1}}); | 
|         }); | 
|   | 
|         // 刷新按钮 | 
|         $reset.on('click', function () { | 
|             $searchForm[0].reset(); | 
|             sortObject.type = 'null'; | 
|             createTimeTo = null; | 
|             createTimeFrom = null; | 
|             tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject}); | 
|         }); | 
|   | 
|         $add.on('click', function() { | 
|             febs.modal.open('新增用户', 'agent/agentAdd', { | 
|                 btn: ['提交', '重置'], | 
|                 area: $(window).width() <= 750 ? '95%' : '50%', | 
|                 offset: '30px', | 
|                 yes: function (index, layero) { | 
|                     $('#user-add').find('#submit').trigger('click'); | 
|                     tableIns.reload({where: params, page: {curr: 1}}); | 
|                 }, | 
|                 btn2: function () { | 
|                     $('#user-add').find('#reset').trigger('click'); | 
|                     return false; | 
|                 } | 
|             }); | 
|         }); | 
|   | 
|         function initTable() { | 
|             tableIns = febs.table.init({ | 
|                 elem: $view.find('table'), | 
|                 id: 'userTable', | 
|                 url: ctx + 'agent/getList', | 
|                 cols: [[ | 
|                     {type: 'checkbox'}, | 
|                     {field: 'name', title: '代理姓名', minWidth: 100, align: 'center'}, | 
|                     {field: 'account', title: '代理账号', minWidth: 100, align: 'center'}, | 
|                     {field: 'inviteId', title: '代理UID', minWidth: 100, align: 'center'}, | 
|                     {field: 'telphone', title: '联系方式', minWidth: 130, align: 'center'}, | 
|                     // {field: 'email', title: '邮箱', minWidth: 180, align: 'center'}, | 
|                     {field: 'refererId', title: '上级UID', minWidth: 100, align: 'center'}, | 
|                     {title: '是否实名', templet: '#certify-status', minWidth: 100, align: 'center'}, | 
|                     {field: 'childCnt', title: '发展代理数', minWidth: 100, align: 'center'}, | 
|                     {field: 'chargeTotal', title: '充值总额', minWidth: 100, align: 'center'}, | 
|                     {field: 'cashOutTotal', title: '提现总额', minWidth: 100, align: 'center'}, | 
|                     {field: 'returnTotal', title: '佣金返现', minWidth: 100, align: 'center'}, | 
|                     {field: 'returnRatio', title: '返佣比例', minWidth: 100, align: 'center'}, | 
|                     {title: '状态', templet: '#account-status', align: 'center'}, | 
|                     {field: 'createTime', title: '创建时间', minWidth: 140, align: 'center'}, | 
|                     {title: '操作', toolbar: '#user-option', minWidth: 140, fixed : 'right', align: 'center'} | 
|                 ]] | 
|             }); | 
|         } | 
|   | 
|         // 获取查询参数 | 
|         function getQueryParams() { | 
|             var createTime = $searchForm.find('input[name="createTime"]').val(); | 
|             if (createTime) { | 
|                 createTimeFrom = createTime.split(' - ')[0]; | 
|                 createTimeTo = createTime.split(' - ')[1]; | 
|             } | 
|             return { | 
|                 startTime: createTimeFrom, | 
|                 endTime: createTimeTo, | 
|                 account: $searchForm.find('input[name="account"]').val().trim(), | 
|                 accountStatus: $searchForm.find("select[name='accountStatus']").val(), | 
|                 accountType: $searchForm.find("select[name='accountType']").val(), | 
|                 certifyStatus: $searchForm.find("select[name='certifyStatus']").val(), | 
|                 invalidate_ie_cache: new Date() | 
|             }; | 
|         } | 
|   | 
|         function deleteUsers(userIds) { | 
|             var currentUserId = currentUser.userId + ''; | 
|             if (('' + userIds).split(',').indexOf(currentUserId) !== -1) { | 
|                 febs.alert.warn('所选用户包含当前登录用户,无法删除'); | 
|                 return; | 
|             } | 
|             febs.get(ctx + 'agent/del/' + userIds, null, function () { | 
|                 febs.alert.success('删除用户成功'); | 
|                 $query.click(); | 
|             }); | 
|         } | 
|     }) | 
| </script> |