Browse Source

js分文件夹

suntg 9 years ago
parent
commit
1e6ff15f9f
1 changed files with 48 additions and 0 deletions
  1. 48 0
      src/main/webapp/resources/js/preview/app.js

+ 48 - 0
src/main/webapp/resources/js/preview/app.js

@@ -0,0 +1,48 @@
+$(function() {
+	'use strict';
+
+	// 获取链接参数
+	var getParameter = function(key) {
+		var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
+		var r = window.location.search.substr(1).match(reg);
+		if (r != null)
+			return unescape(r[2]);
+		return null;
+	};
+	
+	// 获取url
+	var getUrl = function() {
+		var userName = getParameter("userName");
+		var reportName = getParameter("reportName");
+		var whereCondition = getParameter("whereCondition");
+		var otherParameters = getParameter("otherParameters");
+		var pageIndex = getParameter("pageIndex");
+
+		var previewUrl = "print/getData?";
+		if (userName) {
+			previewUrl += "userName=" + userName;
+		}
+		if (reportName) {
+			previewUrl += "&reportName=" + reportName;
+		}
+		if (whereCondition) {
+			previewUrl += "&whereCondition=" + whereCondition;
+		}
+		if (otherParameters) {
+			previewUrl += "&otherParameters=" + otherParameters;
+		}
+		if (pageIndex) {
+			previewUrl += "&pageIndex=" + pageIndex;
+		}
+		return previewUrl;
+	}
+	
+	var previewUrl = getUrl();
+	console.log("previewUrl: " + previewUrl);
+	
+	$.get(previewUrl).success(function(data) {
+		console.log(data);
+	}).error(function(response) {
+		console.log(response);
+	});
+});