From 176c6e1da22e96a1110fa91f8fc8eb8ad2881e08 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 08 八月 2022 18:13:37 +0800
Subject: [PATCH] 2022-08-08

---
 src/tabviews/custom/index.jsx |   72 ++++++++++++++++++++++++++++++++----
 1 files changed, 64 insertions(+), 8 deletions(-)

diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx
index 63a6a2c..5b729ce 100644
--- a/src/tabviews/custom/index.jsx
+++ b/src/tabviews/custom/index.jsx
@@ -73,7 +73,7 @@
    * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅
    */
   async loadconfig () {
-    const { permAction, param } = this.props
+    const { permAction } = this.props
 
     let _param = {
       func: 'sPC_Get_LongParam',
@@ -138,7 +138,9 @@
       let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID
       let balMap = new Map()
       let skip = config.permission === 'false' || window.GLOB.mkHS
-      config.components = this.filterComponent(config.components, roleId, permAction, balMap, skip)
+      let param = this.props.param || {} // url鍙傛暟
+
+      config.components = this.filterComponent(config.components, roleId, permAction, balMap, skip, param)
       
       // 鑾峰彇涓绘悳绱㈡潯浠�
       let mainSearch = []
@@ -147,7 +149,7 @@
 
         component.search = component.search.map(item => {
           item.oriInitval = item.initval
-          if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) {
+          if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) {
             item.initval = param.$searchval
           }
 
@@ -158,7 +160,7 @@
       })
 
       let params = []
-      let BID = param && param.$BID ? param.$BID : ''
+      let BID = param.$BID || ''
       let inherit = {}
 
       if (config.cacheUseful === 'true') { // 缂撳瓨缁ф壙
@@ -188,7 +190,7 @@
       }
       if (config.urlFields) {
         config.urlFields.forEach(field => {
-          let val = `'${param ? (param[field] || '') : ''}'`
+          let val = `'${param[field] || ''}'`
           regs.push({
             reg: new RegExp('@' + field + '@', 'ig'),
             value: val
@@ -441,7 +443,7 @@
     })
   }
 
-  filterComponent = (components, roleId, permAction, balMap, skip) => {
+  filterComponent = (components, roleId, permAction, balMap, skip, urlparam) => {
     return components.filter(item => {
       
       if (item.style && item.style.boxShadow) {
@@ -473,8 +475,58 @@
           return true
         })
 
+        if (item.setting.supModule) {
+          let pid = item.setting.supModule.pop()
+          item.setting.supModule = pid || ''
+
+          if (item.setting.supModule) {
+            item.setting.controlField = item.setting.controlField.toLowerCase()
+  
+            if (item.setting.supModule === 'preview') {
+              item.setting.supModule = ''
+              let val = ''
+              Object.keys(urlparam).forEach(key => {
+                if (key.toLowerCase() === item.setting.controlField) {
+                  val = urlparam[key]
+                }
+              })
+  
+              item.subtabs = item.subtabs.filter(tab => {
+                if (tab.controlVal === val) {
+                  return false
+                } else if (/,/ig.test(tab.controlVal)) {
+                  return !tab.controlVal.split(',').includes(val)
+                }
+      
+                return true
+              })
+            }
+          }
+        }
+
+        if (item.setting.selectField) {
+          item.setting.selectField = item.setting.selectField.toLowerCase()
+
+          let val = ''
+          Object.keys(urlparam).forEach(key => {
+            if (key.toLowerCase() === item.setting.selectField) {
+              val = urlparam[key]
+            }
+          })
+
+          let activeKey = ''
+
+          item.subtabs.forEach(tab => {
+            if (!activeKey && tab.selectVal === val) {
+              activeKey = tab.uuid
+            }
+          })
+
+          item.activeKey = activeKey
+        }
+
         item.subtabs = item.subtabs.map(tab => {
-          tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip)
+          tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam)
           return tab
         })
 
@@ -489,6 +541,8 @@
           })
         })
         item.parentIds = supIds
+
+        return true
       } else if (item.type === 'group') {
         if (
           item.setting.blacklist && item.setting.blacklist.length > 0 &&
@@ -497,7 +551,9 @@
           return false
         }
 
-        item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip)
+        item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam)
+
+        return true
       } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) {
         if (
           item.plot.blacklist && item.plot.blacklist.length > 0 &&

--
Gitblit v1.8.0