<%@ 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() {
            var tpl = $("#treeTableTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
            var data = ${fns:toJson(list)}, ids = [], rootIds = [];
            for (var i=0; i<data.length; i++){
                ids.push(data[i].id);
            }
            ids = ',' + ids.join(',') + ',';
            for (var i=0; i<data.length; i++){
                if (ids.indexOf(','+data[i].parentId+',') == -1){
                    if ((','+rootIds.join(',')+',').indexOf(','+data[i].parentId+',') == -1){
                        rootIds.push(data[i].parentId);
                    }
                }
            }
            for (var i=0; i<rootIds.length; i++){
                addRow("#treeTableList", tpl, data, rootIds[i], true);
            }
            $("#treeTable").treeTable({expandLevel : 5});
		});
        function addRow(list, tpl, data, pid, root){
            for (var i=0; i<data.length; i++){
                var row = data[i];
                if ((${fns:jsGetVal('row.parentId')}) == pid){
                    $(list).append(Mustache.render(tpl, {
                        dict: {
                            blank123:0}, pid: (root?0:pid), row: row
                    }));
                    addRow(list, tpl, data, row.id);
                }
            }
        }

        function refresh(){//刷新
            window.location="${ctx}/casecategory/caseCategory/";
        }
	</script>

	<style>
		body{
			background-color:transparent;
			filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#26FFFFFF, endColorstr=#26FFFFFF);
			color:#ffffff;
			background-color:rgba(255,255,255,0);
			height:100%;
		}
	</style>

</head>
<body>
	<div class="wrapper wrapper-content">
	<sys:message content="${message}"/>
		<div class="layui-row">
			<div class="full-width fl">
				<div class="contentShadow layui-row" id="queryDiv">
					<form:form id="searchForm" modelAttribute="caseCategory" action="${ctx}/casecategory/caseCategory/" method="post" class="form-inline">
						<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
						<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
						<table:sortColumn id="orderBy" name="orderBy" value="${page.orderBy}" callback="sortOrRefresh();"/><!-- 支持排序 -->
						<div class="commonQuery">
							<div class="layui-item query athird">
								<label class="layui-form-label">编号分类名：</label>
								<div class="layui-input-block with-icon">
									<form:input path="name" htmlEscape="false" maxlength="255"  class=" form-control layui-input"/>
								</div>
							</div>
							<div class="layui-item athird fr">
								<div class="input-group">
									<button id="searchReset" class="fixed-btn searchReset fr" onclick="resetSearch()">重置</button>
									<button id="searchQuery" class="fixed-btn searchQuery fr" onclick="search()">查询</button>
								</div>
							</div>
							<div style="    clear:both;"></div>
						</div>

					</form:form>
				</div>
			</div>
			<div class="full-width fl">
				<div class="contentShadow layui-form contentDetails">
					<div class="nav-btns">
						<shiro:hasPermission name="casecategory:caseCategory:add">
							<table:addRow url="${ctx}/casecategory/caseCategory/form" title="案例分类"></table:addRow><!-- 增加按钮 -->
						</shiro:hasPermission>

						<button class="nav-btn nav-btn-refresh" data-toggle="tooltip" data-placement="left" onclick="sortOrRefresh()" title="刷新"><i class="glyphicon glyphicon-repeat"></i>&nbsp;刷新</button>
						<div style="clear: both;"></div>
					</div>
	
					<!-- 表格 -->
					<table id="treeTable" class="table table-striped table-bordered table-hover table-condensed dataTables-example dataTable">
						<thead>
						<tr>
							<th style="text-align: center;">编号分类名</th>
							<th style="text-align: center;width:70px">排序</th>
							<th style="text-align: center;width:400px;">备注</th>
							<shiro:hasPermission name="casecategory:caseCategory:edit">
							<th style="text-align: center;width: 280px">操作</th>
							</shiro:hasPermission>
						</tr>
						</thead>
						<tbody id="treeTableList"></tbody>
					</table>
					<script type="text/template" id="treeTableTpl">
						<tr id="{{row.id}}" pId="{{pid}}">
							<td><a  href="javascript:void(0)" onclick="openDialogView('查看编码管理', '${ctx}/casecategory/caseCategory/form?id={{row.id}}&tabId=0','95%','95%')">
								{{row.name}}
							</a></td>
							<td>
								{{row.sort}}
							</td>
							<td>
								{{row.remarks}}
							</td>
							<td class="op-td">
								<div style="text-align: center">
								<%--<shiro:hasPermission name="casecategory:caseCategory:view">
									<a href="javascript:void(0)" onclick="openDialogView('查看编码管理', '${ctx}/casecategory/caseCategory/form?id={{row.id}}','95%','95%')" class="btn btn-info btn-xs" ><i class="fa fa-search-plus"></i>  查看</a>
								</shiro:hasPermission>--%>
								<shiro:hasPermission name="casecategory:caseCategory:edit">
									<a href="javascript:void(0)" onclick="openDialog('修改编码管理', '${ctx}/casecategory/caseCategory/form?id={{row.id}}','95%','95%')" class="op-btn op-btn-edit" ><i class="fa fa-edit"></i> 修改</a>
								</shiro:hasPermission>
								<shiro:hasPermission name="casecategory:caseCategory:del">
									<a href="${ctx}/casecategory/caseCategory/delete?id={{row.id}}" onclick="return confirmx('确认要删除该编码管理及所有子编码管理吗？', this.href)" class="op-btn op-btn-delete" ><i class="fa fa-trash"></i> 删除</a>
								</shiro:hasPermission>
								<shiro:hasPermission name="casecategory:caseCategory:add">
									<a href="javascript:void(0)" onclick="openDialog('添加下级编码管理', '${ctx}/casecategory/caseCategory/form?parent.id={{row.id}}','95%','95%')" class="op-btn op-btn-add" ><i class="fa fa-plus"></i> 添加下级编码管理</a>
								</shiro:hasPermission>
								</div>
							</td>
						</tr>
					</script>
				</div>
			</div>
		</div>
	</div>
	<script>
        resizeListWindow1();
        $(window).resize(function(){
            resizeListWindow1();
        });
	</script>
	
		<!-- 分页代码 -->
	<%--<table:page page="${page}"></table:page>
	<br/>
	<br/>
	</div>
	</div>--%>
<%--</div>--%>
</body>
</html>