From 8a0b3081ecacbb844ea639ccc53ffd2c151cec1e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 28 三月 2021 02:13:53 +0800
Subject: [PATCH] 2021-03-28

---
 src/tabviews/custom/index.jsx |   45 +++++++++++++++++++++++++++++----------------
 1 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx
index 7b61a0a..a959c60 100644
--- a/src/tabviews/custom/index.jsx
+++ b/src/tabviews/custom/index.jsx
@@ -137,12 +137,8 @@
 
         component.search = component.search.map(item => {
           item.oriInitval = item.initval
-          if (['text', 'select', 'link'].includes(item.type) && param) {
-            if (param.searchkey === item.field) {
-              item.initval = param.searchval
-            } else if (param.data && param.data[item.field]) {
-              item.initval = param.data[item.field]
-            }
+          if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) {
+            item.initval = param.$searchval
           }
 
           return item
@@ -152,7 +148,7 @@
       })
 
       let params = []
-      let BID = param && param.BID ? param.BID : ''
+      let BID = param && param.$BID ? param.$BID : ''
       let inherit = {}
 
       if (config.cacheUseful === 'true') { // 缂撳瓨缁ф壙
@@ -161,7 +157,25 @@
         inherit.cacheTime = config.cacheTime
       }
 
-      config.components = this.formatSetting(config.components, params, mainSearch, inherit)
+      let regs = []
+
+      if (window.GLOB.externalDatabase !== null) {
+        regs.push({
+          reg: /@db@/ig,
+          value: window.GLOB.externalDatabase
+        })
+      }
+      if (config.urlFields) {
+        config.urlFields.forEach(field => {
+          let val = `'${param ? (param[field] || '') : ''}'`
+          regs.push({
+            reg: new RegExp(field, 'ig'),
+            value: val
+          })
+        })
+      }
+
+      config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs)
 
       this.setState({
         BID: BID,
@@ -655,17 +669,17 @@
   }
 
   // 鏍煎紡鍖栭粯璁よ缃�
-  formatSetting = (components, params, mainSearch, inherit) => {
+  formatSetting = (components, params, mainSearch, inherit, regs) => {
     return components.map(component => {
       if (component.type === 'tabs') {
         component.subtabs = component.subtabs.map(tab => {
-          tab.components = this.formatSetting(tab.components, [], [], inherit)
+          tab.components = this.formatSetting(tab.components, [], [], inherit, regs)
           tab = {...tab, ...inherit}
           return tab
         })
         return component
       } else if (component.type === 'group') {
-        component.components = this.formatSetting(component.components, [], [], inherit)
+        component.components = this.formatSetting(component.components, [], [], inherit, regs)
         component = {...component, ...inherit}
         return component
       }
@@ -712,11 +726,10 @@
         _customScript = _customScript.replace(/@\$|\$@/ig, '')
       }
 
-      // 澶栬仈鏁版嵁搴撴浛鎹�
-      if (window.GLOB.externalDatabase !== null) {
-        component.setting.dataresource = component.setting.dataresource.replace(/@db@/ig, window.GLOB.externalDatabase)
-        _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase)
-      }
+      regs.forEach(cell => {
+        component.setting.dataresource = component.setting.dataresource.replace(cell.reg, cell.value)
+        _customScript = _customScript.replace(cell.reg, cell.value)
+      })
 
       component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰
 

--
Gitblit v1.8.0