<link rel="stylesheet" href="/js/ztree/zTreeStyle/zTreeStyle.css">
<script src="/js/ztree/jquery.ztree.all.min.js"></script>

<div class="layui-side layui-bg-black layui-layout-content ukefu-tab">
	<div class="row">
		<div class="col-lg-12">
			<h1 class="site-h1">
				问答分类
				<span style="float:right;">
					<button class="layui-btn layui-btn-small green" href="/setting/quickreply/addtype.html" data-toggle="ajax" data-height="450" data-width="950" data-title="创建分类">
						<i class="layui-icon">&#xe608;</i>
						创建分类
					</button>
				</span>
			</h1>
			<div class="box">
				<ul class="ztree" id="quickTypeTree"></ul>
			</div>
		</div>
	</div>
</div>
<div class="layui-body" id="ukefu-quickreply-content">
	<#include "/apps/setting/quickreply/replylist.html">
</div>

<SCRIPT type="text/javascript">
	var setting = {
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onClick: onClick
		}
	};
	
	function onClick(e, treeId, treeNode) {
		loadURLWithTip("/setting/quickreply/replylist.html?typeid="+treeNode.id,"#ukefu-quickreply-content" , null , null , true);
	}

	var zNodes =[
	    { id:'0', pId:'0', name:"问答分类", open:true }
	    <#if pubQuickTypeList??>
	    <#list pubQuickTypeList as pubQuckType>
	    ,{ id:'${pubQuckType.id!''}', pId:'${pubQuckType.parentid!''}', name:"${pubQuckType.name!''}", open:true }
	    </#list>
	    </#if>
	];
	
	$(document).ready(function(){
		var ztree = $.fn.zTree.init($("#quickTypeTree"), setting, zNodes);
		<#if quickType??>
		var node = ztree.getNodeByParam('id', '${quickType.id!''}');//获取id为1的点  
		ztree.selectNode(node);//选择点  
		</#if>
		layui.use('layer', function(){
			var layer = layui.layer;
			<#if msg?? && msg == 'qr_type_exist'>
			layer.alert('分类名称重复，请重新填写', {icon: 2});
		  </#if>
		}); 
	});
</SCRIPT>