| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | if (!sessionStorage.getItem('UserID')) { |
| | | sessionStorage.removeItem('isEditState') |
| | | sessionStorage.removeItem('editMenuType') |
| | | sessionStorage.removeItem('appType') |
| | | this.props.history.replace('/login') |
| | | return |
| | | } |
| | | |
| | | if (memberLevel < 30) return |
| | | try { |
| | | let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) |
| | |
| | | window.GLOB.winHeight = 738 |
| | | window.GLOB.shellWidth = 376 |
| | | window.GLOB.shellHeight = 680 |
| | | window.GLOB.curDate = moment().format('YYYY-MM-DD') |
| | | |
| | | let adapters = sessionStorage.getItem('adapter') |
| | | if (adapters) { |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | if (!sessionStorage.getItem('UserID')) return |
| | | if (memberLevel < 30) { |
| | | document.getElementById('mk-mob-design-view').innerHTML = '<div style="text-align: center; font-size: 30px; margin-top: 40vh; height: 100vh; background: #fff;">本应用没有PC端页面的编辑权限,请联系管理员!</div>' |
| | | return |
| | |
| | | _btn.config.MenuID = _btn.uuid |
| | | _btn.config.ParentId = card.uuid |
| | | _btn.config.MenuName = _btn.label |
| | | |
| | | _btn.config.components = this.updateComponents(_btn.config.components || []) |
| | | } else { |
| | | _btn.config = { |
| | | uuid: _btn.uuid, |
| | |
| | | }) |
| | | }) |
| | | |
| | | config.cols && config.cols.forEach(col => { |
| | | if (col.type === 'action') { |
| | | if (config.cols) { |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.OpenType === 'popview' && popbtns[cell.uuid]) { |
| | | cell.config = popbtns[cell.uuid] |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(config.cols) |
| | | } |
| | | |
| | | config.elements && config.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | |
| | | this.setState({ |
| | | needUpdate: true |
| | | }) |
| | | } else { |
| | | config.components = this.updateComponents(config.components) |
| | | } |
| | | |
| | | let navItem = null |
| | |
| | | this.setState({ |
| | | needUpdate: true |
| | | }) |
| | | } else { |
| | | config.components = this.updateComponents(config.components) |
| | | } |
| | | |
| | | config.enabled = false |
| | |
| | | }) |
| | | } |
| | | |
| | | updateComponents = (components) => { // 兼容性升级 table |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.components = this.updateComponents(tab.components) |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | item.components = this.updateComponents(item.components) |
| | | } else if (item.type === 'table') { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | collectTB = (components) => { |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') { |
| | |
| | | |
| | | if (item.subtype === 'tablecard') { // 兼容 |
| | | item.type = 'card' |
| | | } else if (item.type === 'table') { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | delete item.tabId |
| | |
| | | title: btn.label, |
| | | }) |
| | | }) |
| | | item.cols && item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.hidden === 'true') return |
| | | |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button' || cell.hidden === 'true') return |
| | | m.children.push({ |
| | | key: btn.uuid, |
| | | title: btn.label, |
| | | key: cell.uuid, |
| | | title: cell.label, |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(item.cols) |
| | | } |
| | | |
| | | list.push(m) |
| | |
| | | }) |
| | | } |
| | | card.elements && card.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | |
| | | if (cell.linkmenu && menuObj[cell.linkmenu]) { |
| | | menus.push(menuObj[cell.linkmenu]) |
| | | } else if (cell.openmenu && menuObj[cell.openmenu]) { |
| | | menus.push(menuObj[cell.openmenu]) |
| | | } |
| | | }) |
| | | |
| | | if (item.subtype === 'dualdatacard') { |
| | | card.backElements && card.backElements.forEach(cell => { |
| | | if (cell.linkmenu && menuObj[cell.linkmenu]) { |
| | | menus.push(menuObj[cell.linkmenu]) |
| | | } else if (cell.openmenu && menuObj[cell.openmenu]) { |
| | | menus.push(menuObj[cell.openmenu]) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } else if (item.type === 'balcony') { |
| | | item.elements && item.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | |
| | | if (cell.linkmenu && menuObj[cell.linkmenu]) { |
| | | menus.push(menuObj[cell.linkmenu]) |
| | | } else if (cell.openmenu && menuObj[cell.openmenu]) { |
| | |
| | | menus.push(menuObj[btn.openmenu]) |
| | | } |
| | | }) |
| | | item.cols && item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.linkmenu && menuObj[btn.linkmenu]) { |
| | | menus.push(menuObj[btn.linkmenu]) |
| | | } else if (btn.openmenu && menuObj[btn.openmenu]) { |
| | | menus.push(menuObj[btn.openmenu]) |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.linkmenu && menuObj[cell.linkmenu]) { |
| | | menus.push(menuObj[cell.linkmenu]) |
| | | } else if (cell.openmenu && menuObj[cell.openmenu]) { |
| | | menus.push(menuObj[cell.openmenu]) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | loopCol(item.cols) |
| | | } |
| | | }) |
| | | } |
| | |
| | | return cols.map(col => { |
| | | if (col.type === 'colspan') { |
| | | col.subcols = getCols(col.subcols || []) |
| | | } else if (col.type === 'custom' || col.type === 'action') { |
| | | } else if (col.type === 'custom') { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.miniStyle = this.transferStyle(cell.style) |
| | | return cell |
| | |
| | | return _style |
| | | } |
| | | |
| | | resetSyncQuery = (components) => { |
| | | return components.map(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.components = this.resetSyncQuery(tab.components) |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | item.components = this.resetSyncQuery(item.components) |
| | | } else if (item.setting && item.setting.interType === 'system' && item.setting.sync === 'true') { |
| | | let sql = '' |
| | | if (item.setting.execute !== 'false' && item.setting.dataresource) { |
| | | sql = item.setting.dataresource |
| | | } |
| | | |
| | | item.scripts && item.scripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | | |
| | | sql += script.sql |
| | | }) |
| | | |
| | | if (sql.length > 8000) { |
| | | item.setting.sync = 'false' |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | submitConfig = () => { |
| | | const { adapters } = this.state |
| | | let config = fromJS(this.state.config).toJS() |
| | |
| | | menuloading: true |
| | | }) |
| | | |
| | | window.GLOB.saving = true |
| | | |
| | | setTimeout(() => { |
| | | if (config.enabled && this.verifyConfig()) { |
| | | let _pass = this.verifyConfig(config) |
| | | |
| | | if (config.enabled && !_pass) { |
| | | config.enabled = false |
| | | config.force = true |
| | | } else if (!config.enabled && config.force && _pass) { |
| | | config.enabled = true |
| | | delete config.force |
| | | } |
| | | |
| | | if (config.cacheUseful !== 'true') { |
| | | config.components = this.resetSyncQuery(config.components) |
| | | } |
| | | |
| | | let tbs = [] |
| | |
| | | menuloading: false |
| | | }) |
| | | |
| | | window.GLOB.saving = false |
| | | |
| | | if (!res) return |
| | | |
| | | if (res.status) { |
| | |
| | | this.setState({ |
| | | menuloading: false |
| | | }) |
| | | |
| | | window.GLOB.saving = false |
| | | |
| | | if (!error) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | onEnabledChange = () => { |
| | | const { config } = this.state |
| | | |
| | | if (!config || (!config.enabled && this.verifyConfig(true))) { |
| | | return |
| | | } |
| | | let _config = {...config, enabled: !config.enabled} |
| | | |
| | | delete _config.force |
| | | |
| | | if (!_config.enabled) { |
| | | this.setState({ |
| | | config: {...config, enabled: !config.enabled} |
| | | config: _config |
| | | }) |
| | | } else if (this.verifyConfig(_config)) { |
| | | this.setState({ |
| | | config: _config |
| | | }) |
| | | } |
| | | } |
| | | |
| | | verifyConfig = (show) => { |
| | | const { config } = this.state |
| | | verifyConfig = (config) => { |
| | | let error = '' |
| | | let searchSum = 0 |
| | | let swipes = [] |
| | |
| | | } |
| | | } |
| | | |
| | | if (show && error) { |
| | | if (config.enabled && error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error, |
| | |
| | | }) |
| | | } |
| | | |
| | | return error |
| | | return error === '' |
| | | } |
| | | |
| | | // 更新配置信息 |
| | |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | if (item.type === 'search') { |
| | | if (config.components.filter(card => card.type === 'topbar' && card.wrap.type !== 'navbar').length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '移动端搜索组件不可粘贴!', |
| | | message: '导航栏使用了搜索,不可添加搜索组件!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | if (config.components.filter(card => card.type === 'search').length > 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '搜索条件不可重复添加!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | } |
| | | |
| | | if (item.type === 'topbar') { |
| | |
| | | </div> |
| | | <div className="wrap"> |
| | | <Button type="primary" className={needUpdate ? 'update-tip' : ''} onClick={this.submitConfig} id="save-config" loading={menuloading}>保存</Button> |
| | | <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={config && config.enabled} onChange={this.onEnabledChange} /> |
| | | {config ? <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={config.enabled} onChange={this.onEnabledChange} /> : null} |
| | | <ArrowLeftOutlined title="后退" className="back-view" onClick={this.backView}/> |
| | | <Button className="mk-border-purple" onClick={() => this.setState({eyeopen: !eyeopen})}>{!eyeopen ? <EyeOutlined /> : <EyeInvisibleOutlined />} 组件名</Button> |
| | | <CreateView resetmenu={this.getAppMenus} /> |