<%@page import="com.blueland.bpm.engine.config.model.*" %>
<%@page import="com.blueland.bpm.common.page.*" %>
<%@page import="java.util.*" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib tagdir="/WEB-INF/tags/simpletable" prefix="simpletable"%>
<%@ include file="/commons/taglibs.jsp" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@ include file="/commons/meta.jsp" %>
	<base href="<%=basePath%>">
	<title>角色管理列表</title>
	<link href="${ctx_js_plugins}/simpletable/simpletable.css" type="text/css" rel="stylesheet">
	<link href="${ctx}/resource/js/plugins/loadmask/jquery.loadmask.css" rel="stylesheet" type="text/css" />
	<script type='text/javascript' src='${ctx}/resource/js/plugins/loadmask/jquery.loadmask.js'></script>
	<script type="text/javascript" src="${ctx_js_plugins}/simpletable/simpletable.js"></script>
	<script type="text/javascript" >
		$(document).ready(function() {
			// 分页需要依赖的初始化动作
			window.simpleTable = new SimpleTable('queryForm',${page.thisPageNumber},${page.pageSize},'${pageRequest.sortColumns}');
		});

		function editRole(roleId){
			var url="";var title="";
			var title = "";
			if(null!=roleId && ""!=roleId){
				var url="${ctx}/role/edit.do?roleId="+roleId;
				title = "角色信息编辑";
			}else{
				var url="${ctx}/role/create.do";
				title="角色信息新增";
			}
			showDiaLog(url,title,'550px','420px');
		}
		function query(obj){
			$("#roleName").val($.trim($("#roleName").val()));
			getReferenceForm(obj).action='${ctx}/role/list.do';
			getReferenceForm(obj).submit();
		}
		function deleteRole(){
			batchDelete('${ctx}/role/delete.do','item',document.forms.queryForm);
			//增加遮罩层（系统正在处理请求，请稍后。。。）
			var item = document.getElementsByName("item");
			if(item.length > 0){
				for (var i = 0; i < item.length; i++) {
					if (item[i].checked == true) {
						setMask("main-container");
					}
				}
			}
		}
	</script>

</head>
<body>
<%@ include file="/commons/messages.jsp"%>
<form id="queryForm" name="queryForm"
	  action="${ctx}/role/list.do" method="get"
	  style="display: inline;">
	<div class="main-container" id="main-container">
		<div class="panel panel-primary">
			<div class="panel-heading">
				角色管理列表
			</div>
			<div class="panel-body" id="panel-body" style="padding:3px;">
				<div class="well well-sm" style="margin-bottom: 2px;">

					<table border="0" cellspacing="0" cellpadding="0" class="table-search">
						<tr>
							<td>角色名称：</td>
							<td>
								<input  class="input" value="${query.roleName}" id="roleName" name="roleName" maxlength="50"  />
							</td>
							<td>角色类型：</td>
							<td>
								<select name="roleType">
									<option value="">请选择</option>
									<option value="BIZ" ${query.roleType=="BIZ"?"selected":""}>业务角色</option>
									<option value="FLOW" ${query.roleType=="FLOW"?"selected":""}>流程角色</option>
									<c:if test="${ebpmAdmin}">
										<option value="GLOBAL" ${query.roleType=="GLOBAL"?"selected":""}>全局角色--${ebpmAdmin}</option>
									</c:if>
									<option value="SYS" ${query.roleType=="SYS"?"selected":""}>系统角色</option>
								</select>
							</td>
						</tr>

						<tr>
							<td colspan="7">
								<button type="button" onclick="query(this);" class="btn btn-xs btn-primary">
									查&nbsp;&nbsp;询
									<i class="ace-icon fa fa-search bigger-110"></i>
								</button>
								<button type="button" onclick="editRole();" class="btn btn-xs btn-success">
									新&nbsp;&nbsp;增
									<i class="ace-icon fa fa-plus bigger-110"></i>
								</button>
								<button type="button" class="btn btn-xs btn-danger" onclick="deleteRole()">
									删除
									<i class="ace-icon fa fa-trash-o bigger-110"></i>
								</button>
								<!-- <input value="查询"  type="submit" class="btn btn-xs btn-primary" onclick="query(this)"/>
								<input value="新增"  type="button" class="btn btn-xs btn-success" onclick="editRole();"/>
								<input value="删除"  type="button" class="btn btn-xs btn-danger" onclick="deleteRole()"/> -->
								<a href="${ctx}/role/export.do" class="btn btn-xs btn-orange">
									导&nbsp;&nbsp;出 <i class="ace-icon fa fa-cloud-download bigger-110"></i>
								</a>
							</td>
						</tr>
					</table>
				</div>

				<div class="row">
					<div class="col-xs-12">
						<div class="table-responsive">
							<table id="sample-table-1" class="table table-striped table-bordered table-hover">
								<thead>
								<tr>
									<th style="width: 20px"></th>
									<!-- 排序时为th增加sortColumn即可,new SimpleTable('sortColumns')会为tableHeader自动增加排序功能; -->
									<th sortColumn="roleName" >角色名称</th>
									<th sortColumn="roleId" >角色编码</th>
									<th sortColumn="roleSort" >排序号</th>
									<th sortColumn="roleType" >角色类型</th>
									<th sortColumn="roleAppId" >所属系统</th>
									<!--
                                    <th sortColumn="roleStatus" >角色状态</th>
                                     -->
									<th>操作</th>
								</tr>
								</thead>
								<tbody>

								<c:forEach items="${page.result}" var="item" varStatus="status">
									<tr class="${status.count % 2 == 0 ? 'odd' : 'even'}">
										<td>
											<input type="radio" name="item" readonly
											<c:choose>
											<c:when test="${'GLOBAL'==item.roleType &&!ebpmAdmin}">
												   disabled="disabled"
												   name="roleId"
											</c:when>
											<c:otherwise>
												   name="roleId"
											</c:otherwise>
											</c:choose>
												   value="${item.roleId}">
										</td>
										<td>${item.roleName}&nbsp;</td>
										<td>${item.roleId}&nbsp;</td>
										<td>${item.roleSort}&nbsp;</td>
										<td>${item.roleTypeVal}&nbsp;</td>
										<td>${item.roleAppName}&nbsp;</td>
										<!--
						<td>${item.roleStatusVal}&nbsp;</td>
						 -->
										<td style="font-size: 13px;">
											<c:if test="${'BIZ'==item.roleType ||'FLOW'==item.roleType|| ebpmAdmin}">
												<a href="javascript:void(0);" onclick="showDiaLog('${ctx}/pages/role_user_select.jsp?showTreeType=USER&roleId=${item.roleId}', '角色关联成员列表-${item.roleName}', '764px', '494px');">关联成员</a>
												&nbsp;&nbsp;
												<a href="javascript:void(0);" onclick="editRole('${item.roleId}');">修改</a>
											</c:if>
										</td>
									</tr>

								</c:forEach>
								</tbody>
							</table>
							<simpletable:pageToolbar page="${page}">
							</simpletable:pageToolbar>
						</div>
						<!-- /.table-responsive -->
					</div>
					<!-- /span -->
				</div>
			</div>
		</div>
	</div>
</form>
</body>
</html>	
