extends /apps/entim/include/layout.pug

block content
    #containter.clearfix
        .group-left
            .group-icon
                img(src='/images/imgroup.png')
            .group-name
                | #{imGroup.name}
            .group-btn
                a.layui-btn.layui-btn-normal.layui-btn-small(href='/ent/im/group.html?id=#{imGroup.id}') 发消息
                if user.id = imGroup.creater
                    a.layui-btn.layui-btn-danger.layui-btn-small(data-toggle="tip", data-title="解散动作无法恢复，请确认是否解散该群？", href="/ent/im/rmgroup.html?id=#{imGroup.id}") 解散群
        .group-rig
            .layui-tab.layui-tab-brief(style='margin:0px;height: 100%')
                ul.layui-tab-title
                    li.layui-this 群成员
                .layui-tab-content(style='height: calc(100% - 60px)')
                    .layui-tab-item.layui-show(style='height: 100%;width: 100%;overflow-y: auto')
                        form.layui-form
                            ul
                                if organList
                                    for organ in organList
                                        li.ukefu-entim-organ-open
                                            h5.ukefu-entim-organ(lay-filter="spread", lay-type="true")
                                                i.layui-icon 
                                                span= organ.name
                                                - var curusers = 0
                                                if userList
                                                    for entimuser in userList
                                                        if entimuser.organs && entimuser.id != user.id && entimuser.organs[organ.id]
                                                            - curusers = curusers+1
                                                em
                                                    cite.layim-count
                                                        | (#{curusers})
                                            ul.ukefu-user-list
                                                if userList
                                                    for entimuser in userList
                                                        if entimuser.organs && entimuser.id != user.id && entimuser.organs[organ.id]
                                                            li(id="user_#{entimuser.id}")
                                                                img(src="/images/user-pc.png")
                                                                span= entimuser.uname
                                                                p
                                                                    | 最近登陆:#{pugHelper.formatDate('yyyy-MM-dd HH:mm:ss', entimuser.lastlogintime)}
                                                                if user.id = imGroup.creater
                                                                    .ukefu-group-join
                                                                        - var useringroup = false
                                                                        if imGroupUserList
                                                                            for imGroupUser in imGroupUserList
                                                                                if imGroupUser.user && imGroupUser.user.id == entimuser.id
                                                                                    - useringroup = true
                                                                        input(type="checkbox", name="user", title="加入", value="#{entimuser.id}", lay-filter="save", checked=useringroup == true)
    script.
        layui.use('element', function () {
            var element = layui.element();
        });
        layui.use('form', function () {
            var form = layui.form();
            form.on("checkbox(save)", function (data) {
                if (data.elem.checked) {
                    loadURL('/ent/im/group/seluser.html?id=#{imGroup.id}&user=' + data.value)
                } else {
                    loadURL('/ent/im/group/rmuser.html?id=#{imGroup.id}&user=' + data.value)
                }
            });
        });
        $('.ukefu-entim-organ').click(function () {
            if ($(this).parent().hasClass('ukefu-entim-organ-open')) {
                $(this).parent().removeClass('ukefu-entim-organ-open');
                $(this).children().first().html('&#xe602;');
            } else {
                $(this).parent().addClass('ukefu-entim-organ-open')
                $(this).children().first().html('&#xe61a;');
            }
        });

