From af6486b3629d23e426ce85b87dbc20dfa15b1afe Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 07 十一月 2022 18:50:27 +0800
Subject: [PATCH] 2022-11-07

---
 src/tabviews/custom/components/code/sand-box/index.jsx |   42 ++++++++++++++++++++++++------------------
 1 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/src/tabviews/custom/components/code/sand-box/index.jsx b/src/tabviews/custom/components/code/sand-box/index.jsx
index 8f8eac0..4863e1f 100644
--- a/src/tabviews/custom/components/code/sand-box/index.jsx
+++ b/src/tabviews/custom/components/code/sand-box/index.jsx
@@ -10,11 +10,9 @@
 
 class SandBoxComponent extends Component {
   static propTpyes = {
-    BID: PropTypes.any,              // 鐖剁骇Id
     data: PropTypes.array,           // 缁熶竴鏌ヨ鏁版嵁
     config: PropTypes.object,        // 缁勪欢閰嶇疆淇℃伅
     mainSearch: PropTypes.any,       // 澶栧眰鎼滅储鏉′欢
-    menuType: PropTypes.any,         // 鑿滃崟绫诲瀷
   }
 
   state = {
@@ -27,13 +25,25 @@
   }
 
   UNSAFE_componentWillMount () {
-    const { data, initdata, BID } = this.props
+    const { data, initdata } = this.props
     let _config = fromJS(this.props.config).toJS()
 
     let _data = {}
     let _sync = false
+
+    let BID = ''
+    let BData = ''
+
+    if (_config.setting.supModule) {
+      BData = window.GLOB.CacheData.get(_config.setting.supModule)
+    } else {
+      BData = window.GLOB.CacheData.get(_config.$pageId)
+    }
+    if (BData) {
+      BID = BData.$BID || ''
+    }
     
-    if (_config.setting && _config.wrap.datatype !== 'static') {
+    if (_config.wrap.datatype !== 'static') {
       _sync = _config.setting.sync === 'true'
 
       if (_sync && data) {
@@ -67,7 +77,9 @@
       arr_field: _config.columns.map(col => col.field).join(','),
     }, () => {
       if (_config.wrap.datatype !== 'static' && _config.setting && _config.setting.sync !== 'true' && _config.setting.onload === 'true') {
-        this.loadData()
+        setTimeout(() => {
+          this.loadData()
+        }, _config.setting.delay || 0)
       }
       this.renderView()
     })
@@ -106,7 +118,7 @@
       this.setState({sync: false, data: _data}, () => {
         this.renderView()
       })
-    } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
+    } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
       this.setState({}, () => {
         this.loadData()
       })
@@ -122,7 +134,7 @@
   }
 
   async loadData () {
-    const { mainSearch, menuType } = this.props
+    const { mainSearch } = this.props
     const { config, arr_field, BID } = this.state
 
     if (config.wrap.datatype === 'static') {
@@ -139,16 +151,10 @@
       return
     }
 
-    let searches = []
-    if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
-      searches = mainSearch
-    }
+    let searches = config.setting.useMSearch && mainSearch ? mainSearch : []
 
-    let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0))
+    let requireFields = searches.filter(item => item.required && item.value === '')
     if (requireFields.length > 0) {
-      this.setState({
-        loading: false
-      })
       return
     }
 
@@ -157,7 +163,7 @@
     })
 
     let _orderBy = config.setting.order || ''
-    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, 1, BID, menuType)
+    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, 1, BID)
 
     let result = await Api.genericInterface(param)
     if (result.status) {
@@ -201,7 +207,7 @@
         try {
           // eslint-disable-next-line no-eval
           eval(js)
-        } catch {
+        } catch (e) {
           console.warn('JS 鎵ц澶辫触锛�')
         }
       }
@@ -212,7 +218,7 @@
     const { config, loading, html } = this.state
 
     return (
-      <div className="custom-sand-box" style={{...config.style}}>
+      <div className="custom-sand-box" id={'anchor' + config.uuid} style={{...config.style}}>
         {loading ?
           <div className="loading-mask">
             <div className="ant-spin-blur"></div>

--
Gitblit v1.8.0