Browse Source

解决树勾选偶尔报错问题

zhouchenglin 7 years ago
parent
commit
f11b4acb14

+ 17 - 11
src/main/resources/templates/base/role/data.html

@@ -33,14 +33,23 @@
 			role : {}
 		},
 		methods : {
-			getOrg : function(menuId) {
-				$.get('../../sys/org/list?_' + $.now(), function(r) {
-					ztree = $.fn.zTree
-							.init($("#orgTree"), setting, r);
-					ztree.expandAll(true);
-				})
-			},
-			setForm: function() {
+            getOrg : function(menuId) {
+                $.ajax({
+                    type: 'get',
+                    async: false,
+                    contentType : 'application/json',
+                    url: '../../sys/org/list?_' + $.now(),
+                    data: null,
+                    success: function(r) {
+                        ztree = $.fn.zTree
+                            .init($("#orgTree"), setting, r);
+                        ztree.expandAll(true);
+                    },
+                    dataType: 'json'
+                });
+            },
+            setForm: function() {
+                this.getOrg();
 				$.SetForm({
 					url: '../../sys/role/info',
 			    	param: vm.role.roleId,
@@ -70,9 +79,6 @@
 			    	}
 			    });
 			}
-		},
-		created : function() {
-			this.getOrg();
 		}
 	})
 	</script>

+ 17 - 11
src/main/resources/templates/base/role/opt.html

@@ -32,14 +32,23 @@
 			role : {}
 		},
 		methods : {
-			getMenu : function(menuId) {
-				$.get('../../sys/menu/list?_' + $.now(), function(r) {
-					ztree = $.fn.zTree
-							.init($("#menuTree"), setting, r);
-					ztree.expandAll(true);
-				})
-			},
-			setForm: function() {
+            getMenu : function(menuId) {
+                $.ajax({
+                    type: 'get',
+                    async: false,
+                    contentType : 'application/json',
+                    url: '../../sys/menu/list?_' + $.now(),
+                    data: null,
+                    success: function(r) {
+                        ztree = $.fn.zTree
+                            .init($("#menuTree"), setting, r);
+                        ztree.expandAll(true);
+                    },
+                    dataType: 'json'
+                });
+            },
+            setForm: function() {
+                this.getMenu();
 				$.SetForm({
 					url: '../../sys/role/info',
 			    	param: vm.role.roleId,
@@ -68,9 +77,6 @@
 			    	}
 			    });
 			}
-		},
-		created : function() {
-			this.getMenu();
 		}
 	})
 	</script>