|
|
@@ -1,6 +1,6 @@
|
|
|
-define([ 'angular' ], function(angular) {
|
|
|
+define([ 'angular', 'toaster' ], function(angular) {
|
|
|
'use strict';
|
|
|
- angular.module('common.services', [ ]).factory('SessionService', function() {
|
|
|
+ angular.module('common.services', ['toaster' ]).factory('SessionService', function() {
|
|
|
return {
|
|
|
get : function(key) {
|
|
|
return sessionStorage.getItem(key);
|
|
|
@@ -92,5 +92,35 @@ define([ 'angular' ], function(angular) {
|
|
|
return query.length ? query.substr(0, query.length - 1) : query;
|
|
|
}
|
|
|
};
|
|
|
+ }).factory('ReportService', function($http, toaster) {
|
|
|
+ return {
|
|
|
+ /**
|
|
|
+ * 打印方法
|
|
|
+ * enuu 企业的UU号
|
|
|
+ * pageName 打印页面的名称
|
|
|
+ * condition 单据的条件(格式:{tableName.propertyName}=value;当tableName含有'$'符号时将其换成'_'符号)
|
|
|
+ * title 单据标题
|
|
|
+ */
|
|
|
+ print: function(enuu, pageName, condition, title) {
|
|
|
+ var getRootPath = function() {
|
|
|
+ var fullPath = window.document.location.href;
|
|
|
+ var path = window.document.location.pathname;
|
|
|
+ var pos = fullPath.indexOf(path);
|
|
|
+ return fullPath.substring(0, pos) + path.substring(0, path.substr(1).indexOf('/') + 1);
|
|
|
+ };
|
|
|
+ var rootPath = getRootPath();
|
|
|
+ $http.get(rootPath + '/report/getName', {params: {enuu: enuu, pagename: pageName}})
|
|
|
+ .success(function(data){
|
|
|
+ if(data) {
|
|
|
+ var url = 'http://192.168.253.6:8099/B2BCR/?reportfile=' + data + '&rcondition=' + condition;
|
|
|
+ window.open(url, title + '-打印', 'width=' + (window.screen.width-10) + ',height=' + (window.screen.height*0.87) + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', '系统错误', '没有设置相应的报表');
|
|
|
+ }
|
|
|
+ }).error(function() {
|
|
|
+ toaster.pop('error', '系统错误', '获取报表名称失败');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
});
|