<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>流程模块管理</title>
	<meta name="decorator" content="default"/>
	<%@include file="/webpage/include/treetable.jsp" %>
	<script type="text/javascript">
        $(document).ready(function() {
            $("th").css('text-align','center');
            var tpl = $("#treeTableTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
            var data = ${fns:toJson(list)}, rootId = "${not empty office.id ? office.id : '0'}";
            //console.log(data+"-----"+rootId);
            addRow("#treeTableList", tpl, data, rootId, true);
            $("#treeTable").treeTable({expandLevel : 5});
        });
        function addRow(list, tpl, data, pid, root){
            /*console.log(list+"---List--");
            console.log(data+"---data--");
            console.log(pid+"---pid--");
            console.log(root+"---root--");*/
            for (var i=0; i<data.length; i++){
                var row = data[i];
                if ((${fns:jsGetVal('row.parentId')}) == pid){
                    //console.log(pid+"***********");
                    $(list).append(Mustache.render(tpl, {
                        dict: {
                            type: getDictLabel(${fns:toJson(fns:getDictList('sys_office_type'))}, row.type)
                        }, pid: (root?0:pid), row: row
                    }));
                    //console.log(row.id+"+++++++++++");
                    addRow(list, tpl, data, row.id);
                }
            }
        }
        function refresh(){//刷新或者排序，页码不清零

            window.location="${ctx}/sys/office/list";
        }
	</script>
</head>
<body>
<div class="wrapper wrapper-content">
	<sys:message content="${message}"/>
	<!--查询条件-->
	<div class="row">
		<div class="col-sm-12">
			<form:form id="searchForm" modelAttribute="workActivityMenu" action="${ctx}/workactivitymenu/workActivityMenu/workActivityMenuList" method="post" class="form-inline">
				<div class="form-group">
					<form:hidden id="officeId" path="officeId" htmlEscape="false" maxlength="100" class="form-control input-sm"/>
				</div>
			</form:form>
			<br/>
		</div>
	</div>
	<table id="treeTable" class="table table-striped table-bordered table-hover table-condensed dataTables-example dataTable">
		<thead><tr><th>机构名称</th><th>归属区域</th><th>机构编码</th><th>机构类型</th><th>备注</th><th>操作</th></tr></thead>
		<tbody id="treeTableList"></tbody>
	</table>
</div>
<script type="text/template" id="treeTableTpl">
	<tr id="{{row.id}}" pId="{{pid}}">
		<td>
			{{row.name}}</td>
		<td>{{row.area.name}}</td>
		<td>{{row.code}}</td>
		<td>{{dict.type}}</td>
		<td>{{row.remarks}}</td>
		<td>
			<div style="text-align: center">
			  <a href="javascript:" onclick="$('#officeId').val('{{row.id}}');$('#searchForm').submit();return false;"  class="btn btn-primary btn-xs">流程定义</a>
			</div>
		</td>
	</tr>
</script>
</body>
</html>
<%--
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>公司流程模块管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
		});
	</script>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content">
	<div class="ibox">
	<div class="ibox-title">
		<h5>流程模块列表 </h5>
		<div class="ibox-tools">
			<a class="collapse-link">
				<i class="fa fa-chevron-up"></i>
			</a>
			<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)">
				<i class="fa fa-wrench"></i>
			</a>
			<ul class="dropdown-menu dropdown-user">
				<li><a href="javascript:void(0)">选项1</a>
				</li>
				<li><a href="javascript:void(0)">选项2</a>
				</li>
			</ul>
			<a class="close-link">
				<i class="fa fa-times"></i>
			</a>
		</div>
	</div>
    
    <div class="ibox-content">
	<sys:message content="${message}"/>
	
	<!--查询条件-->
	<div class="row">
	<div class="col-sm-12">
		<form:form id="searchForm" modelAttribute="workActivityMenu" action="${ctx}/workactivitymenu/workActivityMenu/workActivityMenuList" method="post" class="form-inline">
			<div class="form-group">
				<form:hidden id="officeId" path="officeId" htmlEscape="false" maxlength="100" class="form-control input-sm"/>
			</div>
		</form:form>
	<br/>
	</div>
	</div>
	
	<!-- 表格 -->
	<table id="contentTable" class="table table-striped table-bordered table-hover table-condensed dataTables-example dataTable">
		<thead>
			<tr>
				<th  class="sort-column id" style="width: 20%;">编号</th>
				<th  class="sort-column name" style="width: 20%;">名称</th>
				<th  class="sort-column createDate" style="width: 20%;">创建时间</th>
				<th  class="sort-column remarks" style="width: 20%;">备注</th>
				<th style="width: 20%;">操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${list}" var="office">

			<tr>
				<td>
					${office.id}
				</td>
				<td>
					${office.name}
				</td>
				<td><fmt:formatDate value="${office.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>

				<td>
					${office.remarks}
				</td>
				<td>
					<a href="javascript:" onclick="$('#officeId').val('${office.id}');$('#searchForm').submit();return false;"  class="btn btn-primary btn-xs">流程定义</a>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	
		<!-- 分页代码 -->
	<table:page page="${page}"></table:page>
	<br/>
	<br/>
	</div>
	</div>
</div>
</body>
</html>--%>
