Browse Source

表单打印权限验证

zhuth 7 years ago
parent
commit
6a4dd7a734

+ 5 - 0
frontend/saas-web/app/Application.scss

@@ -465,4 +465,9 @@ div::-webkit-scrollbar-track {
       background-size: 16px 16px;
       background-position: center;
   }
+}
+
+/** tab **/
+.x-tab-default.x-tab-active .x-tab-close-btn {
+  color: #34BAF6;
 }

+ 46 - 16
frontend/saas-web/app/view/core/form/FormPanelController.js

@@ -410,10 +410,47 @@ Ext.define('saas.view.core.form.FormPanelController', {
         caller = form.caller,
         id = viewModel.get(form._idField);
 
-        saas.util.BaseUtil.request({
-            url: '/api/commons/jasperReport/printByDefault',
-            // url: 'http://192.168.253.58:8920/jasperReport/printByDefault',
-            method: 'POST',
+        me.beforePrint(caller).then(function(flag) {
+            if(!flag) {
+                return false;
+            }
+            saas.util.BaseUtil.request({
+                url: '/api/commons/jasperReport/printByDefault',
+                // url: 'http://192.168.253.58:8920/jasperReport/printByDefault',
+                method: 'POST',
+                headers: {
+                    "Content-Type": 'application/x-www-form-urlencoded;charset=UTF-8'
+                },
+                params: {
+                    caller: caller,
+                    id: id
+                }
+            }).then(function(res) {
+                var data = res.data,
+                printurl = data.printurl,
+                printtype = data.printtype,
+                reportName = data.reportName,
+                title = data.title,
+                whereCondition = data.whereCondition,
+                companyId = saas.util.BaseUtil.getCurrentUser().companyId;
+    
+                var url = printurl + '?' + 'reportName=' + reportName + '&' + 'companyId=' + companyId + '&whereCondition=' + whereCondition
+    
+                window.open(url);
+            }).catch(function(res) {
+                console.error(res.message);
+                saas.util.BaseUtil.showErrorToast('获取打印报表错误:' + res.message);
+            });
+        });
+    },
+
+    /**
+     * 判断权限
+     */
+    beforePrint: function(caller) {
+        return saas.util.BaseUtil.request({
+            url: '/api/commons/' + caller + '/print',
+            method: 'GET',
             headers: {
                 "Content-Type": 'application/x-www-form-urlencoded;charset=UTF-8'
             },
@@ -422,17 +459,10 @@ Ext.define('saas.view.core.form.FormPanelController', {
                 id: id
             }
         }).then(function(res) {
-            var data = res.data,
-            printurl = data.printurl,
-            printtype = data.printtype,
-            reportName = data.reportName,
-            title = data.title,
-            whereCondition = data.whereCondition,
-            companyId = saas.util.BaseUtil.getCurrentUser().companyId;
-
-            var url = printurl + '?' + 'reportName=' + reportName + '&' + 'companyId=' + companyId + '&whereCondition=' + whereCondition
-
-            window.open(url);
+            return res.success;
+        }).catch(function(res) {
+            console.error(res.message);
+            saas.util.BaseUtil.showErrorToast('未通过权限验证:' + res.message);
         });
-    },
+    }
 });