From 137fb8ea6af2789b3238b22bac31d80bced41dfe Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 28 七月 2021 11:39:39 +0800 Subject: [PATCH] 2021-07-28 --- src/menu/datasource/index.jsx | 164 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 132 insertions(+), 32 deletions(-) diff --git a/src/menu/datasource/index.jsx b/src/menu/datasource/index.jsx index 9732b5a..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, @@ -100,7 +188,19 @@ return item }) } - + + if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { + window.GLOB.funcs.forEach(m => { + let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig') + if (res.setting.dataresource) { + res.setting.dataresource = res.setting.dataresource.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) + } + res.scripts.forEach(item => { + item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) + }) + }) + } + this.setState({loading: false, visible: false}) this.props.updateConfig({...config, ...res}) }, () => { -- Gitblit v1.8.0