From 0847aeed380492bafaf5b27a49ac4e4b77a819b1 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 08 七月 2021 16:39:09 +0800
Subject: [PATCH] 2021-07-08

---
 src/menu/datasource/index.jsx |  150 +++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 119 insertions(+), 31 deletions(-)

diff --git a/src/menu/datasource/index.jsx b/src/menu/datasource/index.jsx
index 01d1c81..8115d65 100644
--- a/src/menu/datasource/index.jsx
+++ b/src/menu/datasource/index.jsx
@@ -16,6 +16,7 @@
 
   state = {
     dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
+    appType: sessionStorage.getItem('appType'),
     sourcelist: [],
     mainSearch: [],
     visible: false,
@@ -35,42 +36,129 @@
 
   editDataSource = () => {
     const { config } = this.props
+    const { appType } = this.state
 
     let search = []
-    let parents = []
-    let _conf = config
-    let getParents = (box) => {
-      box.components.forEach(item => {
-        if (item.type !== 'tabs') return
+    let menu = fromJS(window.GLOB.customMenu).toJS()
 
-        item.subtabs.forEach(tab => {
-          if (_conf.parentId === tab.parentId && _conf.tabId === tab.uuid) {
-            parents.unshift(tab)
-            _conf = item
-
-            if (_conf.parentId && _conf.tabId) {
-              getParents(tab)
-            }
-          } else {
-            getParents(tab)
-          }
-        })
-      })
-    }
-
-    if (config.parentId && config.tabId) {
-      getParents(window.GLOB.customMenu)
-    }
-
-    parents.unshift(window.GLOB.customMenu)
-
-    parents.forEach(parent => {
-      parent.components.forEach(item => {
-        if (item.type === 'search') {
-          search = item.search
+    if (appType === 'mob') {
+      let ms = null
+      menu.components.forEach(item => {
+        if (item.type === 'topbar' && (item.wrap.type === 'search' || (item.wrap.type === 'navbar' && item.wrap.search === 'true'))) {
+          ms = item.search
         }
       })
-    })
+
+      if (config.floor > 1) {
+        let _search = null
+        let filterComponent = (box) => {
+          box.components.forEach(item => {
+            if (_search) return
+
+            if (item.uuid === config.uuid) {
+              _search = box.slist.pop()
+            } else if (item.type === 'group') {
+              item.components.forEach(m => {
+                if (m.uuid !== config.uuid) return
+                _search = box.slist.pop()
+              })
+            } else if (item.type === 'tabs') {
+              let able = item.setting.display === 'inline-block' && item.setting.position === 'top'
+              item.subtabs.forEach(tab => {
+                if (able && tab.hasSearch === 'icon' && tab.search) {
+                  tab.slist = [...box.slist, tab.search]
+                } else {
+                  tab.slist = [...box.slist]
+                }
+                
+                filterComponent(tab)
+              })
+            }
+          })
+        }
+        menu.slist = []
+        filterComponent(menu)
+
+        if (_search) {
+          ms = _search
+        }
+      }
+
+      if (ms) {
+        if (ms.setting.type === 'search') {
+          search.push({
+            type: 'text',
+            label: '鎼滅储鏍�',
+            field: ms.setting.field,
+            match: ms.setting.match,
+            required: ms.setting.required,
+            value: ms.setting.initval || ''
+          })
+        }
+        ms.fields.forEach(item => {
+          if (item.type === 'range') {
+            item.initval = `${item.minValue},${item.maxValue}`
+          }
+          search.push(item)
+        })
+
+        ms.groups.forEach(group => {
+          if (group.setting.type === 'search') {
+            search.push({
+              type: 'text',
+              label: group.wrap.name,
+              field: group.setting.field,
+              match: group.setting.match,
+              required: group.setting.required,
+              value: group.setting.initval || ''
+            })
+          }
+
+          group.fields.forEach(item => {
+            if (item.type === 'range') {
+              item.initval = `${item.minValue},${item.maxValue}`
+            }
+            search.push(item)
+          })
+        })
+      }
+    } else {
+      if (config.floor > 1) {
+        let _search = null
+        let filterComponent = (box) => {
+          box.components.forEach(item => {
+            if (_search) return
+
+            if (item.type === 'search') {
+              box.slist = [...box.slist, item.search]
+            } else if (item.uuid === config.uuid) {
+              _search = box.slist.pop()
+            } else if (item.type === 'group') {
+              item.components.forEach(m => {
+                if (m.uuid !== config.uuid) return
+                _search = box.slist.pop()
+              })
+            } else if (item.type === 'tabs') {
+              item.subtabs.forEach(tab => {
+                tab.slist = [...box.slist]
+                filterComponent(tab)
+              })
+            }
+          })
+        }
+        menu.slist = []
+        filterComponent(menu)
+
+        if (_search) {
+          search = _search
+        }
+      } else {
+        menu.components.forEach(item => {
+          if (item.type !== 'search') return
+          search = item.search
+        })
+      }
+    }
 
     this.setState({
       visible: true,

--
Gitblit v1.8.0