From 9d65dcb2e35f8091f71110c4de7a04215b63b81e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 08 五月 2021 16:59:28 +0800
Subject: [PATCH] 2021-05-08

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

diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx
index 40f0818..cbec0bc 100644
--- a/src/tabviews/custom/index.jsx
+++ b/src/tabviews/custom/index.jsx
@@ -190,7 +190,9 @@
         })
       }
 
-      config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs)
+      let isEmpty = mainSearch.filter(item => item.required && (!item.value || item.value.length === 0)).length > 0
+
+      config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, isEmpty)
 
       this.setState({
         BID: BID,
@@ -719,7 +721,7 @@
   }
 
   // 鏍煎紡鍖栭粯璁よ缃�
-  formatSetting = (components, params, mainSearch, inherit, regs) => {
+  formatSetting = (components, params, mainSearch, inherit, regs, isEmpty) => {
     return components.map(component => {
       if (component.type === 'tabs') {
         component.subtabs = component.subtabs.map(tab => {
@@ -787,8 +789,32 @@
       // dataName 绯荤粺鐢熸垚鐨勬暟鎹簮鍚嶇О
       // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ
       if (component.floor === 1 && component.dataName && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') {
-        let param = this.getDefaultParam(component, mainSearch)
-        params.push(param)
+        if (isEmpty && component.setting.useMSearch === 'true') {
+          component.setting.sync = 'false'
+          component.setting.onload = 'false'
+        } else {
+          let searchlist = []
+          if (component.search && component.search.length > 0) {
+            searchlist = Utils.initMainSearch(component.search)
+          }
+
+          let _empty = searchlist.filter(item => item.required && (!item.value || item.value.length === 0)).length > 0
+  
+          if (_empty) {
+            component.setting.sync = 'false'
+            component.setting.onload = 'false'
+          } else {
+            if (component.setting.useMSearch === 'true') {
+              let keys = searchlist.map(item => item.key)
+              mainSearch.forEach(item => {
+                if (!keys.includes(item.key)) {
+                  searchlist.push(item)
+                }
+              })
+            }
+            params.push(this.getDefaultParam(component, searchlist))
+          }
+        }
       } else if (component.floor === 1) {
         component.setting.sync = 'false'
       }
@@ -800,22 +826,8 @@
   /**
    * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁�
    */
-  getDefaultParam = (component, mainSearch) => {
-    const { columns, search, setting, dataName, format } = component
-    
-    let searchlist = []
-    if (search && search.length > 0) {
-      searchlist = Utils.initMainSearch(search)
-    }
-
-    if (setting.useMSearch === 'true') {
-      let keys = searchlist.map(item => item.key)
-      mainSearch.forEach(item => {
-        if (!keys.includes(item.key)) {
-          searchlist.push(item)
-        }
-      })
-    }
+  getDefaultParam = (component, searchlist) => {
+    const { columns, setting, dataName, format } = component
 
     let arr_field = columns.map(col => col.field)
     let _dataresource = setting.dataresource

--
Gitblit v1.8.0