<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sptg="http://www.thymeleaf.org">
    <head>
        <script th:replace="common/head"></script>
        <link rel="stylesheet" th:href="@{'/css/permission/account-detail.css'}" media="all">
    </head>
    <body style="position: absolute;top: 0;bottom: 0;left: 0;right: 0;">
        <div class="layui-fluid" >
            <!-- 下拉树 -->
            <div th:replace="common/org-tree"></div>
            <!-- 表格 -->
            <div class="x-body per-table">
                <div class="layui-card">
                    <!-- 查询条件 -->
                    <div class="layui-form layui-card-header layuiadmin-card-header-auto"  style="padding:0;">
                        <div class="layui-form-item border-b">
                            <!-- 登陆名 login_name -->
                            <div class="layui-inline">
                                <label for="login_name" class="layui-form-label">登录名</label>
                                <div class="layui-input-block">
                                    <input id="login_name" type="text" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <!-- 用户姓名 user_name -->
                            <div class="layui-inline">
                                <label for="user_name" class="layui-form-label">用户姓名</label>
                                <div class="layui-input-block">
                                    <input id="user_name" type="text" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <!-- 联系方式 user_mobile -->
                            <div class="layui-inline">
                                <label for="user_mobile" class="layui-form-label">联系方式</label>
                                <div class="layui-input-block">
                                    <input id="user_mobile" type="text" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <!-- 状态 is_enable -->
                            <div class="layui-inline">
                                <label for="is_enable" class="layui-form-label">状态</label>
                                <div class="layui-input-block">
                                    <select id="is_enable" class="layui-input">
                                        <option value="">全部</option>
                                        <option value="1">启用</option>
                                        <option value="2">禁用</option>
                                    </select>
                                </div>
                            </div>
                            <!-- 类型 -->
                            <div class="layui-inline">
                                <label for="role_id" class="layui-form-label">账号角色</label>
                                <div class="layui-input-block">
                                    <select id="role_id" class="layui-input">
                                        <option value="">全部</option>
                                        <option value="3">小区</option>
                                        <option value="10015">社区</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline"  style="margin-left: 38px;">
                                <button class="layui-btn layuiadmin-btn-useradmin"  lay-submit lay-filter="query">查询</button>
                                <button class="layui-btn  layui-btn-primary"  lay-submit lay-filter="reset">重置</button>
                            </div>
                        </div>

                        <!-- 表格+头部按钮 -->
                        <div class="layui-card-body" style="padding:0;">
                            <div style="padding-bottom: 10px;">
                                <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="add" sptg:security="account:add">添加账户</button>
                                <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="batchdel" sptg:security="account:delete">批量删除</button>
                            </div>
                            <table id="data_entity_table" lay-filter="data_table_event"></table>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 隐藏字段 -->
            <input id="fast_dfs_access_path" type="hidden" th:value="${fastDfsAccessPath}" />
            <!--/*@thymesVar id="onLineUser" type="com.sptg.permissions.api.entity.Account"*/-->
            <input id="user_id" type="hidden" th:value="${onLineUser.id}" />
            <input id="user_org_id" type="hidden" th:value="${onLineUser.orgId}" />
            <input type="hidden" id="showAd" value="true">
            <input id="isShowWeChatLogin" type="hidden"  sptg:security="account:is:we:chat:login" />
        </div>
    </body>

    <!-- 工具栏（编辑/删除） -->
    <script type="text/html" id="table-useradmin-webuser">
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="info">
            <span>详情</span>
        </a>
        {{# if(d.id != myId && d.openid == null){ }}
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit" sptg:security="account:update">
            <span>修改</span>
        </a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete" sptg:security="account:delete">
            <span>删除</span>
        </a>
        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="resetPwd" sptg:security="account:reset:password">
            <span>重置密码</span>
        </a>
        {{#  }else if(d.id != myId && d.openid != null){ }}
        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit" sptg:security="account:update">
            <span>修改</span>
        </a>
        <a class="layui-btn layui-btn-xs" data-dropdown="#dropUser{{d.LAY_INDEX}}" lay-event="more" no-shade="true">
            更多<i class="layui-icon layui-icon-drop" style="font-size: 12px;margin-right: 0;"></i></a>
        <!-- 下拉菜单 -->
        <ul class="dropdown-menu-nav dropdown-bottom-right layui-hide" id="dropUser{{d.LAY_INDEX}}">
            <div class="dropdown-anchor"></div>
            <li> <a lay-event="delete" sptg:security="account:delete">删除</a></li>
            <li> <a lay-event="untied" sptg:security="account:untied:we:chat">解绑微信</a></li>
        </ul>
        {{#  }else if(d.id == myId && d.openid != null){ }}
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="untied" sptg:security="account:untied:we:chat">
            <span>解绑微信</span>
        </a>
        {{# } }}
    </script>

    <!-- 用户详情 -->
    <script type="text/html" id="user_info">
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <div class="layui-form">

                                <div class="layui-form-item">
                                    <label class="layui-form-label">头像：</label>
                                    <div class="layui-input-inline avatar">
                                        <img src="{{ fastDfsAccessPath }}{{ d.userPortraitUri }}" />
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">归属机构：</label>
                                    <div class="layui-input-inline">
                                        <span class="detail-info">{{ d.orgName }}</span>
                                    </div>
                                    <label class="layui-form-label">姓名：</label>
                                    <div class="layui-input-inline">
                                        <span class="detail-info">{{ d.userName }}</span>
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">登录账户：</label>
                                    <div class="layui-input-inline">
                                        <span class="detail-info">{{ d.loginName }}</span>
                                    </div>
                                    <label class="layui-form-label">状态：</label>
                                    <div class="layui-input-inline">
                                        {{#  if(d.isEnable == 1){ }}
                                        <span class="detail-info">启用</span>
                                        {{#  } else { }}
                                        <span class="detail-info">禁用</span>
                                        {{#  } }}
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">联系电话：</label>
                                    <div class="layui-input-inline">
                                        <span class="detail-info">{{ d.userMobile }}</span>
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">用户角色：</label>
                                    <div class="layui-input-inline">
                                        {{#  d.roleList.forEach(function(item){ }}
                                            <span class="detail-info">{{ item.name }}</span>
                                        {{# }) }}
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">创建IP：</label>
                                    <div class="layui-input-inline">
                                        <span class="detail-info">{{ d.createIp ? d.createIp : '' }}</span>
                                    </div>
                                    <label class="layui-form-label">最后登录IP：</label>
                                    <div class="layui-input-inline">
                                        <span class="detail-info">{{ d.lastLoginIp ? d.lastLoginIp :'暂未登录' }}</span>
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">创建时间：</label>
                                    <div class="layui-input-inline">
                                        <span class="detail-info">{{ d.createDate ? d.createDate : '' }}</span>
                                    </div>
                                    <label class="layui-form-label">最后登录时间：</label>
                                    <div class="layui-input-inline">
                                        <span class="detail-info">{{ d.lastLoginDate ? d.lastLoginDate :'暂未登录' }}</span>
                                    </div>
                                </div>

                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">备注</label>
                                    <div class="layui-input-block">
                                        <textarea class="layui-textarea w500" disabled>{{ d.remark }}</textarea>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </script>

    <!-- 用户角色 -->
    <script type="text/html" id="user_role_list">
        {{#  layui.each(d.roleList, function(index,role){ }}
            <span>{{ role.name }}</span>
            {{# if(index < d.roleList.length - 1){ }}
                <span>,</span>
            {{# } }}
        {{#  }); }}
    </script>

    <!-- 状态 -->
    <script type="text/html" id="entity_is_enable">
        {{# if(d.id != myId){ }}
            <input type="checkbox" name="isEnable" lay-skin="switch" lay-filter="switch_is_enable"
                   data-json="{{ encodeURIComponent(JSON.stringify(d)) }}"
                   lay-text="启用|禁用" {{ d.isEnable == 1 ? 'checked' : '' }} />
        {{# }else { }}
            <input type="checkbox" name="isEnable" lay-skin="switch" disabled
                   lay-text="启用|禁用" {{ d.isEnable == 1 ? 'checked' : '' }} />
        {{# } }}
    </script>

    <!-- 开启小程序登录--实施小程序 -->
    <script type="text/html" id="is_we_chat_login">
        {{# if(d.id != myId){ }}
        <input type="checkbox" name="isWeChatLogin" lay-skin="switch" lay-filter="switch_is_we_chat_login"  sptg:security="account:is:we:chat:login"
               data-json="{{ encodeURIComponent(JSON.stringify(d)) }}"
               lay-text="启用|禁用" {{ d.isWeChatLogin == 1 ? 'checked' : '' }} />
        {{# }else { }}
        <input type="checkbox" name="isWeChatLogin" lay-skin="switch" disabled  sptg:security="account:is:we:chat:login"
               lay-text="启用|禁用" {{ d.isWeChatLogin == 1 ? 'checked' : '' }} />
        {{# } }}
    </script>

    <!-- javascript -->
    <script type="text/javascript" th:src="@{'/layui/layui.js'}"></script>
    <script type="text/javascript">
        layui.config({
            base: '/' //静态资源所在路径
        });
        //  文件服务器访问地址
        var fastDfsAccessPath = document.getElementById('fast_dfs_access_path').value;
        //  当前登陆用户Id
        var myId = document.getElementById('user_id').value;

    </script>
    <script type="text/javascript" th:src="@{'/js/permissions/account-manage.js'}"></script>

</html>