<table border="0" align="center" cellpadding="0" cellspacing="0" ms-controller="Users" id="nobgmian">
    <tbody>
        <tr>
            <!--左侧-->
            <td style="vertical-align: top; width: 245px;">
                <div class="boxTitle full_screen_height" style='width: 245px;'>
                    <h2 style="margin-bottom: 0px;">按部门检索</h2>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td>
                                    <ul ms-widget='groupTree,groupTree,groupTreeOpts' class='ztree'></ul>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </td>
            <!--左侧END-->

            <!--中间主体-->
            <td style="vertical-align: top; padding: 0 15px;">
                <!--Top-->
                <div class="boxTitle">
                    <h2>分类检索</h2>
                    <table width="99%" border="0" cellspacing="0" cellpadding="0" class="seacrhTable" id="seacrhTable">
                        <tbody>
                            <tr>
                                <td width="320" class="searchico">
                                    <div class="input-append" style="margin-bottom: 0px;">
                                        <input type="text" id="keyword" ms-duplex="query1.data.key.val" class="span4" placeholder="输入账号、姓名等关键词" ms-enter="toSearch">
                                        <button class="add-on ibtsearch" style="height: 28px; font-size: 12px; padding: 3px 12px;" ms-click="toSearch">搜索</button>
                                        <button class="add-on ibtsearch" style="height: 28px; font-size: 12px; padding: 3px 12px;" ms-click="query1.clearQuery">显示全部</button>
                                    </div>
                                </td>
                                <td class="fgray">{{lang.SearchHistory}}
                                   <span class="bindSearchHistory" ms-repeat-h='query1.history'>
                                       <a href="javascript:void(0)" ms-click='query1.addQuery(h.name,h.val,h.label)' ms-title='h.label'>{{h.label|truncate(5)}}</a>
                                   </span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0" class="seacrhField">
                        <tbody>
                            <tr class="quickword" ms-repeat="query1.data" ms-if-loop="$val.items">
                                <td colspan="2"><span>{{$val.label}}</span>
                                    <div style="display: inline;">
                                        <a ms-repeat-r='$val.items' href="javascript:void(0)" ms-click='query1.addQuery($key,r.val,r.label)' ms-class-1="selected:r.curr" ms-html='r.label'></a>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" class="seabox">
                                    <span class="first" ms-html='lang.CurrSearchCondition'></span>
                                    <div style="display: inline; float: left;" ms-repeat="query1.data">
                                        <span class="searchItem" ms-if-loop='$val.valLabel'>{{$val.valLabel}}
                                        <i><a href="javascript:void(0)" ms-click='query1.removeQuery($key)'></a></i>
                                        </span>
                                    </div>
                                    <span class="last" ms-visible='query1.hasQuery' ms-click='query1.clearQuery'><a href="javascript:void(0)" ms-html='lang.ClearAll'></a></span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>

                <!--Bottom-->
                <table width="100%" border="0" cellspacing="1" cellpadding="0" class="top10">
                    <tbody>
                        <tr>
                            <td width="356" valign="top">
                                <div class="boxTitlenob">
                                    <h2>用户列表
                                        <!--<span class="rseachbox">
                                            <input id="appendedInput" type="text" style="margin-bottom:0px;">
                                            <button class="inputbt" id="qSearch"></button>
                                        </span>-->
                                    </h2>
                                </div>
                                <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tableList">
                                    <thead>
                                        <tr class="dobtn">
                                            <td colspan="9">
                                                <a href="javascript:void(0)" ms-if="ADD" ms-click="doadd" class="doadd">新增</a>
                                                <a href="javascript:void(0)" ms-if="DELETE" ms-click="grid1.removeAll" class="doalldel">批量删除</a>
                                                <a ms-if="LOCK" href="javascript:void(0)" class="dolock" style="background-position: -503px -48px; padding-bottom: 1px;" ms-click="setAvailable(null,false)">批量禁用</a>
                                                <a ms-if="UNLOCK" href="javascript:void(0)" class="dounlock" style="background-position: -503px -101px" ms-click="setAvailable(null,true)">批量启用</a>
                                                <a href="javascript:void(0)" class="docontact" style="background-position: -300px -108px" ms-click="setContact(true)">批量加入通讯录</a>
                                                <a href="javascript:void(0)" class="docontact" style="background-position: -300px -371px" ms-click="setContact(false)">批量移出通讯录</a>
                                            </td>
                                        </tr>
                                        <tr class="head">
                                            <th style="width: 5%;">
                                                <input type="checkbox" ms-duplex-radio='grid1.checkall'>
                                            </th>
                                            <th style="width: 18%;">帐号</th>
                                            <th style="width: 10%;">主角色</th>
                                            <th style="width: 10%;">姓名</th>
                                            <th style="width: 12%;">部门</th>
                                            <th style="width: 10%;">职位</th>
                                            <th>状态/通讯录</th>
                                            <th style="width: 10%;">创建时间</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr class="gridmsg" ms-if="grid1.gridmsg">
                                            <td colspan="9">{{grid1.gridmsg|html}}</td>
                                        </tr>
                                        <tr class="dobody" ms-repeat-item="grid1.list" ms-class-1="selected:item.checked">
                                            <td>
                                                <input type="checkbox" name="checkbox" ms-duplex-radio='item.checked'></td>
                                            <td  style="text-align:left;">
                                                <a href="javascript:void(0)" ms-click="doview(item.Id)" ms-widget='userCard' ms-data-userid="item.Id">{{item.UserName}}</a>
                                            </td>
                                            <td style="text-align:left;">{{item.Role.Name}}</td>
                                            <td style="text-align:left;">{{item.FullName}}</td>
                                            <td>{{item.Group.Name}}</td>
                                            <td>{{item.PositionName}}</td>
                                            <td>
                                                <span style="color: green;" ms-visible="item.IsAvailable">{{lang.Enable}}</span>
                                                <span style="color: red;" ms-visible="!item.IsAvailable">{{lang.Disabled}}</span>
                                                | {{item.IsJoin?'是':'否'}}
                                            </td>
                                            <td>{{item.AddTime|truncate(10,'')}}</td>
                                            <td>
                                                <a href="javascript:void(0)" ms-click="doview(item.Id)"  class="doview" title="查看"></a>
                                                <a href="javascript:void(0)" ms-if="item.EDIT" ms-click="doedit(item.Id)" class="doedit" title="编辑"></a>
                                                <a href="javascript:void(0)" ms-if="!item.EDIT" title="非常抱歉，您没有编辑的权限" class="noedit"></a>
                                                <a href="javascript:void(0)" ms-if="item.DELETE" ms-click="grid1.remove(item,$index)" class="dodel" title="删除"></a>
                                                <a href="javascript:void(0)" ms-if="!item.DELETE" title="非常抱歉，您没有删除的权限" class="nodelete"></a>
                                                <a ms-if="item.UNLOCK && !item.IsAvailable" href="javascript:void(0)" class="dounlock" title="启用" ms-live-click='setAvailable(item.Id,true)'></a>
                                                <a ms-if="item.LOCK && item.IsAvailable" href="javascript:void(0)" class="dolock" title="禁用" ms-live-click='setAvailable(item.Id,false)'></a>
                                            </td>
                                        </tr>
                                    </tbody>
                                    <tfoot>
                                        <tr style="background-color: #fff;">
                                            <td colspan="9" ms-widget='paging' data-gridid="grid1"></td>
                                        </tr>
                                    </tfoot>
                                </table>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
            <!--中间主体END-->

            <!--右侧-->
            <td style="vertical-align: top; width: 215px; overflow-y: auto;" ms-widget='roleList,roleList,roleListOpts'></td>
            <!--右侧END-->
        </tr>
    </tbody>
</table>

<!--新增和编辑模板-->
<noscript type="text/avalon" id="userTemplate">
    <table width="98%" border="0" cellspacing="0" cellpadding="0" class="titbox" style="margin-bottom: 10px; height: 30px;">
        <tr>
            <td width="68" height="30" class="tit">用户信息</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    <table width="800" cellspacing="0" cellpadding="0" border="0" class="commontable">
        <tbody>
            <tr>
                <th>账号：</th>
                <td style="width: 40%">
                    <input type="text" width="200" ms-duplex="userEntity.UserName" /><span class="must">*</span></td>
                <th>密码：</th>
                <td>
                    <input type="password" width="200" ms-duplex="userEntity.Password" ms-focus="pwdFocus" ms-blur="pwdBlur" />
                    <span class="must">*</span>
                </td>
            </tr>
            <tr>
                <th>姓名：</th>
                <td>
                    <input type="text" width="200" ms-duplex="userEntity.FullName" /><span class="must">*</span></td>
                <th>性别：</th>
                <td>
                    <label style="padding-right: 20px;">
                        <input type="radio" ms-duplex-text="userEntity.Sex" name="sex" value="0" />
                        男</label>
                    <label>
                        <input type="radio" ms-duplex-text="userEntity.Sex" name="sex" value="1" />
                        女</label>
                </td>
            </tr>
            <tr>
                <th>部门：</th>
                <td>
                    <input type="text" width="200" readonly="readonly" ms-duplex="userEntity.Group.Name" />
                    <button class="myfbt" ms-widget='dropDownGroupTree,setGroup,postGroupTreeOpts'><i class="bm"></i></button>
                    <span class="must">*</span>
                </td>
                <th>职位：</th>
                <td>
                    <select ms-each-opt="posts" ms-duplex-text="userEntity.PositionId">
                        <option ms-value="opt.Id" ms-text="opt.Name"></option>
                    </select>
                    <span class="must">*</span><span class="helptip"> <a href="#" data-toggle="tooltip" data-placement="top" title='选择职位前请先选择部门'>&nbsp;&nbsp; </a></span>
                </td>
            </tr>
            <tr>
                <th>手机：</th>
                <td>
                    <input type="text" width="200" ms-duplex="userEntity.Phone" ms-readonly="userEntity.DeviceSn" />
                    <span class="must">*</span>
                    <span class="helptip" title="已经绑定手机APP的，需要在用户详情面板解绑后才能修改手机号码。">&nbsp;</span>
                </td>
                <th>电子邮箱：</th>
                <td>
                    <input type="text" width="200" ms-duplex="userEntity.Email" /></td>
            </tr>
            <tr>
                <th>电话：</th>
                <td>
                    <input type="text" width="200" ms-duplex="userEntity.Tel" /></td>
                <th>QQ：</th>
                <td>
                    <input type="text" width="200" ms-duplex="userEntity.QQ" /></td>
            </tr>
            <tr>
                <th>状态：</th>
                <td>
                    <label style="padding-right: 20px;">
                        <input type="radio" ms-duplex-bool="userEntity.IsAvailable" name="enable" value="true" />
                        启用</label>
                    <label>
                        <input type="radio" ms-duplex-bool="userEntity.IsAvailable" name="enable" value="false" />
                        禁用</label>
                </td>
                <th>加入通讯录：</th>
                <td>
                    <label style="padding-right: 20px;">
                        <input type="radio" ms-duplex-bool="userEntity.IsJoin" name="join" value="true" />
                        是</label>
                    <label>
                        <input type="radio" ms-duplex-bool="userEntity.IsJoin" name="join" value="false" />
                        否</label>
                </td>
            </tr>

        </tbody>
    </table>

    <table width="98%" border="0" cellspacing="0" cellpadding="0" class="titbox" style="margin-bottom: 10px; height: 30px;">
        <tr>
            <td width="68" height="30" class="tit">角色分配</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    <div style="height: 250px; overflow-y: scroll; width:98%; margin:auto;">
        <table width="780" border="0" cellspacing="1" cellpadding="0" class="tableList" style="margin:auto;">
            <thead>
                <tr class="head">
                    <th style="width: 5%; text-align: center;">选择角色
                    </th>
                    <th style="width: 15%; text-align: center;">角色名称</th>
                    <th style="width: 8%; text-align: center;">默认角色</th>
                    <th style="width: 30%; text-align: center;">角色说明</th>
                </tr>
            </thead>
            <tbody>
                <tr class="dobody" ms-repeat-item="roleList" ms-class-1="selected:item.checked">
                    <td>
                        <input type="checkbox"  ms-duplex-radio="item.checked" ms-change="roleChange(item)" /></td>
                    <td>{{item.Name}}</td>
                    <td>
                        <input type="radio" name="default" ms-duplex-text="userEntity.Role.Id"  ms-value="item.Id" ms-change="defRoleChange($index)" /></td>
                    <td style="text-align: left;">{{item.Description}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</noscript>
<!--查看模板-->
<noscript type="text/avalon" id="detailTemplate">
    <table width="98%" border="0" cellspacing="0" cellpadding="0" class="titbox" style="margin-bottom: 10px; height: 30px;">
        <tr>
            <td width="68" height="30" class="tit">用户信息</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    <table width="800" cellspacing="1" cellpadding="0" border="0" class="tablecInfo">
        <tbody>
            <tr>
                <td>账号：</td>
                <td colspan="3">
                    {{userEntity.UserName}}
                </td>
            </tr>
            <tr>
                <td style="width: 80px;">姓名：</td>
                <td style="width: 300px;">
                    {{userEntity.FullName}}
                </td>
                <td style="width: 80px;">性别：</td>
                <td>
                    {{userEntity.Sex?"男":"女"}}
                </td>
            </tr>
            <tr>
                <td>部门：</td>
                <td>
                    {{userEntity.Group?userEntity.Group.Name:""}}
                </td>
                <td>职位：</td>
                <td>
                    {{userEntity.PositionName}}
                </td>
            </tr>
            <tr>
                <td>手机：</td>
                <td>
                    {{userEntity.Phone}}
                </td>
                <td>电子邮箱：</td>
                <td>
                    {{userEntity.Email}}

                </td>
            </tr>
            <tr>
                <td>电话：</td>
                <td>
                    {{userEntity.Tel}}

                </td>
                <td>QQ：</td>
                <td>
                    {{userEntity.QQ}}
                </td>
            </tr>
            <tr>
                <td>状态：</td>
                <td>
                    {{userEntity.IsAvailable?"启用":"禁用"}}
                </td>
                <td>加入通讯录：</td>
                <td>
                    {{userEntity.IsJoin?"是":"否"}}
                </td>
            </tr>

        </tbody>
    </table>

    <table width="98%" border="0" cellspacing="0" cellpadding="0" class="titbox" style="margin-bottom: 10px; height: 30px;">
        <tr>
            <td width="80" height="30" class="tit">APP设备绑定</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    <div style="max-height:150px; overflow-y: auto;">
        <table width="780" border="0" cellspacing="1" cellpadding="0" class="tableList" style="margin:auto;">
            <thead>
                <tr class="head">
                    <th style="width: 5%; text-align: center;">序号
                    </th>
                    <th style="width: 40%; text-align: center;">设备名称</th>
                    <th style="width: 50%; text-align: center;">设备序列号</th>
                    <th style="width: 5%; text-align: center;">操作</th>
                </tr>
            </thead>
            <tbody>
                <tr class="dobody" ms-repeat-item="userEntity.DeviceSnList">
                    <td>
                        {{$index+1}}</td>
                    <td>{{item.Value}}</td>
                    <td>
                        {{item.Key}}
                    </td>
                    <td>
                        <a href="javascript:void(0)" ms-if="userEntity.DELETE" ms-click="unbindAppUser(userEntity.Id, item,$index)" class="dodel" title="解除此设备绑定"></a>
                    </td>
                </tr>
                <tr ms-if="userEntity.DeviceSnList.length==0">
                    <td colspan="4" class="gridmsg">暂无绑定设备</td>
                </tr>
            </tbody>
        </table>
    </div>
    <table width="98%" border="0" cellspacing="0" cellpadding="0" class="titbox" style="margin-bottom: 10px; height: 30px;">
        <tr>
            <td width="68" height="30" class="tit">角色分配</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    <div style="height: 250px; overflow-y: auto;">
        <table width="780" border="0" cellspacing="1" cellpadding="0" class="tableList" style="margin:auto;">
            <thead>
                <tr class="head">
                    <th style="width: 5%; text-align: center;">序号
                    </th>
                    <th style="width: 15%; text-align: center;">角色名称</th>
                    <th style="width: 8%; text-align: center;">默认角色</th>
                    <th style="width: 30%; text-align: center;">角色说明</th>
                </tr>
            </thead>
            <tbody>
                <tr class="dobody" ms-repeat-item="userEntity.roleList" ms-class-1="selected:userEntity.Role.Id==item.Id">
                    <td>
                        {{$index+1}}</td>
                    <td>{{item.Name}}</td>
                    <td>
                        <input ms-if="userEntity.Role.Id==item.Id" type="radio" checked="checked" />
                    </td>
                    <td style="text-align: left;">{{item.Description}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</noscript>

