| | |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | appType: sessionStorage.getItem('appType'), |
| | | sourcelist: [], |
| | | mainSearch: [], |
| | | visible: false, |
| | |
| | | |
| | | 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, |
| | |
| | | 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}) |
| | | }, () => { |