<div ng-controller="UserListCtrl" class="wrapper">
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="form-inline">
				<button ui-sref="userAdd" class="btn btn-default"><i class="glyphicon glyphicon-plus">添加用户</i></button>
				<div class="input-group col-sm-3">
				      	<div class="input-group-addon"><i class="glyphicon glyphicon-search"></i></div>
						<input type="text" placeholder="登录名" class="input-sm form-control" ng-model="search.loginName" ng-change="goPage(1)" />
				</div>
				</div>
			<table class="table table-striped">
				<thead>
					<tr>
						<th>序号</th>
						<th>登录名</th>
						<th>姓名</th>
						<th>角色</th>
						<th>状态</th>
						<th>操作</th>
					</tr>									
				</thead>
				<tbody>
				
					<tr ng-repeat="row in pageModel.array">
						<td>{{$index+1}}</td>
						<td>{{row.loginName}}</td>
						<td>{{row.name}}</td>
						<td>{{row.roleString}}</td>
						<td class="{{row.isEnabled ? 'text-success' : 'text-danger'}}">{{row.isEnabled | userStatus}}</td>
						<td>
							<a href="#userEdit/{{row.id}}" ng-show="row.isEnabled">
								<i class="glyphicon glyphicon-pencil">编辑</i>
							</a>
							
							<a href="#" ng-click="updateStatus(row.id, 'inactive')" ng-show="row.isEnabled" class="text-danger">
								&nbsp;&nbsp;<i class="glyphicon glyphicon-minus-sign">停用</i>
								
							</a>
							<a href="#" ng-click="resetPassword(row.id)" ng-show="row.isEnabled">
								&nbsp;&nbsp;<i class="glyphicon glyphicon-lock">重置密码</i>
							</a>
							
							<a href="#" ng-click="updateStatus(row.id, 'active')" ng-show="!row.isEnabled" class="text-success">
								<i class="glyphicon glyphicon-ok-sign">启用</i>
							</a>
						</td>
					</tr>
				</tbody>

			</table>
			<nav ng-if="pageModel.totalPage > 1">
				<ul class="pagination">
					<li class="{{pageModel.curPage == 1 ? 'disabled' : ''}}" ng-click="goPage(pageModel.curPage - 1)">
						<a aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
			      	</li>
				    <li ng-repeat="i in [9,8,7,6,5,4,3,2,1]" ng-if="pageModel.curPage - i > 0" ng-click="goPage(pageModel.curPage - i)">
				    	<a>{{pageModel.curPage - i}}</a>
			    	</li>
				    <li class="active"><a href="#">{{pageModel.curPage}}</a></li>
				    <li ng-repeat="i in [1,2,3,4,5,6,7,8,9]" ng-if="pageModel.curPage + i <= pageModel.totalPage" ng-click="goPage(pageModel.curPage + i)">
				    	<a>{{pageModel.curPage + i}}</a>
			    	</li>
				    <li class="{{pageModel.curPage == pageModel.totalPage ? 'disabled' : ''}}" ng-click="goPage(pageModel.curPage + 1)">
				      	<a aria-label="Next"><span aria-hidden="true">&raquo;</span></a>
				    </li>
				</ul>
			</div>
		</div>
	</div>
</div>