From 62e599832e5265851c962ec7303abf29064fafe1 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 15 四月 2021 17:15:36 +0800
Subject: [PATCH] 2021-04-15

---
 src/tabviews/custom/index.jsx |   59 ++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx
index d3c9587..a068b3c 100644
--- a/src/tabviews/custom/index.jsx
+++ b/src/tabviews/custom/index.jsx
@@ -479,7 +479,7 @@
         }
 
         item.components = this.filterComponent(item.components, roleId, permAction, permMenus)
-      } else if (item.type === 'pie' || item.type === 'bar' || item.type === 'line' || item.type === 'dashboard') {
+      } else if (['pie', 'bar', 'line', 'dashboard', 'scatter'].includes(item.type)) {
         if (
           item.plot.blacklist && item.plot.blacklist.length > 0 &&
           item.plot.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0
@@ -508,7 +508,37 @@
         })
       }
       if (item.type === 'table' && item.subtype === 'normaltable') {
-        item.cols = this.getCols(item.cols, roleId, permMenus)
+        let statFields = []
+        let getCols = (cols) => {
+          return cols.filter(col => {
+            if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
+              return false
+            } else if (col.Hide === 'true') {
+              return false
+            }
+            if (col.type === 'number' && col.sum === 'true' && !statFields.includes(col.field)) {
+              statFields.push(col)
+            }
+            if (col.type === 'colspan') {
+              col.subcols = getCols(col.subcols || [])
+              if (col.subcols.length === 0) {
+                return false
+              }
+            }
+      
+            if (col.linkmenu && col.linkmenu.length > 0) {
+              let menu_id = col.linkmenu.pop()
+              col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || ''
+            } else {
+              col.linkThdMenu = ''
+            }
+      
+            return true
+          })
+        }
+        
+        item.cols = getCols(item.cols)
+        item.statFields = statFields
       }
 
       // 鏉冮檺杩囨护
@@ -656,31 +686,6 @@
     }
 
     return item
-  }
-
-  getCols = (cols, roleId, permMenus) => {
-    return cols.filter(col => {
-      if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
-        return false
-      } else if (col.Hide === 'true') {
-        return false
-      }
-      if (col.type === 'colspan') {
-        col.subcols = this.getCols(col.subcols || [], roleId, permMenus)
-        if (col.subcols.length === 0) {
-          return false
-        }
-      }
-
-      if (col.linkmenu && col.linkmenu.length > 0) {
-        let menu_id = col.linkmenu.pop()
-        col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || ''
-      } else {
-        col.linkThdMenu = ''
-      }
-
-      return true
-    })
   }
 
   // 鏍煎紡鍖栭粯璁よ缃�

--
Gitblit v1.8.0