Bladeren bron

fix: #5329 报表页面控制补充

Tony Kang 3 dagen geleden
bovenliggende
commit
9870c968f4

+ 8 - 0
app/controller/report_controller.js

@@ -340,6 +340,10 @@ module.exports = app => {
                 let sp_id = -1;
                 let sp_id = -1;
                 if (this.ctx.subProject) sp_id = this.ctx.subProject.id;
                 if (this.ctx.subProject) sp_id = this.ctx.subProject.id;
 
 
+                // 私有化
+                const permissions = await ctx.service.rptPermission.getAllTenderPermissions(tender.id);
+                // console.log(permissions);
+
                 const renderData = {
                 const renderData = {
                     accountGroup: newAccountGroup,
                     accountGroup: newAccountGroup,
                     accountList,
                     accountList,
@@ -403,6 +407,7 @@ module.exports = app => {
                     otherChangeList: 'null',
                     otherChangeList: 'null',
                     otherHintName: '',
                     otherHintName: '',
                     advanceConst,
                     advanceConst,
+                    permissions: JSON.stringify(permissions),
                 };
                 };
                 if (ctx.stage) renderData.spGroupList = await ctx.service.shenpiGroup.getGroupListByStage(ctx.tender.id, shenpiConst.sp_type.stage);
                 if (ctx.stage) renderData.spGroupList = await ctx.service.shenpiGroup.getGroupListByStage(ctx.tender.id, shenpiConst.sp_type.stage);
                 await this.layout('report/index.ejs', renderData, 'report/rpt_all_popup.ejs');
                 await this.layout('report/index.ejs', renderData, 'report/rpt_all_popup.ejs');
@@ -610,6 +615,7 @@ module.exports = app => {
                     changes: 'null',
                     changes: 'null',
                     otherChangeList: 'null',
                     otherChangeList: 'null',
                     otherHintName: '',
                     otherHintName: '',
+                    permissions: '[]',
                 };
                 };
                 /*
                 /*
                 //*/
                 //*/
@@ -750,6 +756,7 @@ module.exports = app => {
                     changes: 'null',
                     changes: 'null',
                     otherChangeList: 'null',
                     otherChangeList: 'null',
                     otherHintName: '',
                     otherHintName: '',
+                    permissions: '[]',
                 };
                 };
                 await this.layout('report/index.ejs', renderData, 'report/rpt_all_popup.ejs');
                 await this.layout('report/index.ejs', renderData, 'report/rpt_all_popup.ejs');
 
 
@@ -953,6 +960,7 @@ module.exports = app => {
                     otherChangeList: JSON.stringify(otherChangeList || []),
                     otherChangeList: JSON.stringify(otherChangeList || []),
                     otherHintName,
                     otherHintName,
                     bizId: bglObj.BUSINESS_ID,
                     bizId: bglObj.BUSINESS_ID,
+                    permissions: '[]',
                 };
                 };
                 await this.layout('report/index.ejs', renderData, 'report/rpt_all_popup.ejs');
                 await this.layout('report/index.ejs', renderData, 'report/rpt_all_popup.ejs');
             } catch (err) {
             } catch (err) {

+ 7 - 9
app/public/report/js/rpt_format_setup.js

@@ -31,15 +31,13 @@ const reportFormatSetupObj = {
         }
         }
         me.currentTopNode = pNode.name;
         me.currentTopNode = pNode.name;
         me.currentRptId = treeNode.refId;
         me.currentRptId = treeNode.refId;
-            if (me.currentTopNode === '定制报表') {
-                me.switchButtonEnables(true, true);
-                me.initialize(treeNode);
-            } else {
-                me.switchButtonEnables(false, true);
-                me.clearTplProperties();
-                reportPermissionObj.iniReportPermission();
-                reportPermissionObj.updateSelectedMarks();
-            }
+        me.initialize(treeNode);
+        if (me.currentTopNode === '定制报表') {
+            me.switchButtonEnables(true, true);
+        } else {
+            me.switchButtonEnables(false, true);
+            me.clearTplProperties();
+        }
     },
     },
     onDeleteInfo: (dom) => {
     onDeleteInfo: (dom) => {
         // 删除表眉、表脚项
         // 删除表眉、表脚项

+ 6 - 0
app/public/report/js/rpt_main.js

@@ -139,6 +139,12 @@ let zTreeOprObj = {
                         break;
                         break;
                 }
                 }
             }
             }
+            if (!rst) {
+                // 判断私有化
+                if (PERMISSION_CACHE[`${rptItem.refId}`]) {
+                    rst = !PERMISSION_CACHE[`${rptItem.refId}`].includes(CUST_ID);
+                }
+            }
             return rst;
             return rst;
         };
         };
         const private_remove_hide_item = function (items, nlv) {
         const private_remove_hide_item = function (items, nlv) {

+ 1 - 0
app/public/report/js/rpt_public.js

@@ -395,3 +395,4 @@ function chkAndSetNode(parentItem) {
         }
         }
     }
     }
 }
 }
+

+ 9 - 0
app/service/rpt_permission.js

@@ -34,6 +34,15 @@ module.exports = app => {
             return list;
             return list;
         }
         }
 
 
+        async getAllTenderPermissions(tid) {
+            const sql = 'SELECT tt.*,' +
+                'pa.`name` As `user_name`, pa.`role` As `user_role`, pa.`company` As `user_company` ' +
+                'FROM ?? As tt LEFT JOIN ?? As pa ON tt.`user_id` = pa.`id` ' +
+                'WHERE tt.`tid` = ?';
+            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tid];
+            return await this.db.query(sql, sqlParam);
+        }
+
         async getTenderPermissions(tid, rpt_id) {
         async getTenderPermissions(tid, rpt_id) {
             const sql = 'SELECT tt.*,' +
             const sql = 'SELECT tt.*,' +
                 'pa.`name` As `user_name`, pa.`role` As `user_role`, pa.`company` As `user_company` ' +
                 'pa.`name` As `user_name`, pa.`role` As `user_role`, pa.`company` As `user_company` ' +

+ 11 - 0
app/view/report/index.ejs

@@ -545,6 +545,16 @@
     const BGL_OBJ = <%- bglObj %>;
     const BGL_OBJ = <%- bglObj %>;
     const ADVANCE_LIST = <%- advanceList %>;
     const ADVANCE_LIST = <%- advanceList %>;
     const ADVANCE_AUDIT_LISt = <%- advanceAuditList %>;
     const ADVANCE_AUDIT_LISt = <%- advanceAuditList %>;
+    const PERMISSIONS = <%- permissions %>;
+
+    const PERMISSION_CACHE = {};
+    for (const permission of PERMISSIONS) {
+        if (!PERMISSION_CACHE[`${permission.rpt_id}`]) {
+            PERMISSION_CACHE[`${permission.rpt_id}`] = [];
+        }
+        PERMISSION_CACHE[`${permission.rpt_id}`].push(permission.user_id);
+    }
+
     ADVANCE_LIST.sort(function(a1, a2) {
     ADVANCE_LIST.sort(function(a1, a2) {
         return a1.order - a2.order;
         return a1.order - a2.order;
     });
     });
@@ -641,6 +651,7 @@
     const CONSTRUCT_UNIT_LIST = <%- unitList %>;
     const CONSTRUCT_UNIT_LIST = <%- unitList %>;
     const ROLE_LIST = <%- role_list %>;
     const ROLE_LIST = <%- role_list %>;
     const CUST_NAME = '<%- ctx.session.sessionUser.name %>';
     const CUST_NAME = '<%- ctx.session.sessionUser.name %>';
+    const CUST_ID = <%- ctx.session.sessionUser.accountId %>;
     const fujianOssPath = '<%- ctx.app.config.fujianOssPath %>';
     const fujianOssPath = '<%- ctx.app.config.fujianOssPath %>';
     const PRE_PAY = <%- prePay %>;
     const PRE_PAY = <%- prePay %>;
     if (localStorage[CUST_NAME + '_custCfg']) {
     if (localStorage[CUST_NAME + '_custCfg']) {