<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include/header_css::header('数据权限-角色管理')"></head>
<body>
	<div id="dpLTE" class="container-fluid" v-cloak>
		<ul id="orgTree" class="ztree"></ul>
	</div>
	<div th:include="include/footer_js::footer"></div>
	<script type="text/javascript">
	var setting = {
		data : {
			simpleData : {
				enable : true,
				idKey : "orgId",
				pIdKey : "parentId",
				rootPId : 0
			},
			key : {
				url : "nourl"
			}
		},
		check:{
	        enable:true,
	        nocheckInherit:true,
	        chkboxType:{ "Y" : "", "N" : "" }
	    }
	};
	var ztree;

	var vm = new Vue({
		el : '#dpLTE',
		data : {
			role : {}
		},
		methods : {
			getOrg : function(menuId) {
				$.get('../../sys/org/list?_' + $.now(), function(r) {
					ztree = $.fn.zTree
							.init($("#orgTree"), setting, r);
					ztree.expandAll(true);
				})
			},
			setForm: function() {
				$.SetForm({
					url: '../../sys/role/info',
			    	param: vm.role.roleId,
			    	success: function(data) {
			    		vm.role = data;
			    		//勾选角色所拥有的数据权限
		    			var orgIds = vm.role.orgIdList;
		    			for(var i=0; i<orgIds.length; i++) {
		    				var node = ztree.getNodeByParam("orgId", orgIds[i]);
		    				ztree.checkNode(node, true, false);
		    			}
			    	}
				});
			},
			acceptClick: function() {
				var nodes = ztree.getCheckedNodes(true);
				var orgIdList = new Array();
				for(var i=0; i<nodes.length; i++) {
					orgIdList.push(nodes[i].orgId);
				}
				vm.role.orgIdList = orgIdList;
				$.ConfirmForm({
			    	url: '../../sys/role/authorize/data?_' + $.now(),
			    	param: vm.role,
			    	success: function(data) {
			    		
			    	}
			    });
			}
		},
		created : function() {
			this.getOrg();
		}
	})
	</script>
</body>
</html>