From 08cce3334a2dc81d690b518136b0aaea64e48b0b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 14 六月 2023 09:55:50 +0800 Subject: [PATCH] 2023-06-14 --- src/views/mobdesign/index.jsx | 224 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 177 insertions(+), 47 deletions(-) diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx index 7e740f5..9fca5e9 100644 --- a/src/views/mobdesign/index.jsx +++ b/src/views/mobdesign/index.jsx @@ -81,6 +81,14 @@ } 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))) @@ -103,6 +111,7 @@ 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) { @@ -139,6 +148,7 @@ } 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;">鏈簲鐢ㄦ病鏈塒C绔〉闈㈢殑缂栬緫鏉冮檺锛岃鑱旂郴绠$悊鍛橈紒</div>' return @@ -232,6 +242,8 @@ _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, @@ -298,15 +310,23 @@ }) }) - config.cols && config.cols.forEach(col => { - if (col.type === 'action') { - col.elements.forEach(cell => { - if (cell.OpenType === 'popview' && popbtns[cell.uuid]) { - cell.config = popbtns[cell.uuid] + 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 @@ -604,6 +624,8 @@ this.setState({ needUpdate: true }) + } else { + config.components = this.updateComponents(config.components) } let navItem = null @@ -823,6 +845,8 @@ this.setState({ needUpdate: true }) + } else { + config.components = this.updateComponents(config.components) } config.enabled = false @@ -921,6 +945,27 @@ }) } + 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') { @@ -939,6 +984,13 @@ 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 @@ -1081,17 +1133,22 @@ title: btn.label, }) }) - item.cols && item.cols.forEach(col => { - if (col.type !== 'action') return - col.elements.forEach(btn => { - if (btn.hidden === 'true') return - - m.children.push({ - key: btn.uuid, - title: btn.label, - }) + 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: cell.uuid, + title: cell.label, + }) + }) + } }) - }) + } + loopCol(item.cols) } list.push(m) @@ -1181,19 +1238,25 @@ }) } 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]) { @@ -1214,16 +1277,22 @@ 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) } }) } @@ -1287,7 +1356,7 @@ 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 @@ -1321,6 +1390,35 @@ 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() @@ -1342,9 +1440,21 @@ 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 = [] @@ -1589,6 +1699,8 @@ menuloading: false }) + window.GLOB.saving = false + if (!res) return if (res.status) { @@ -1623,6 +1735,9 @@ this.setState({ menuloading: false }) + + window.GLOB.saving = false + if (!error) { notification.warning({ top: 92, @@ -1668,17 +1783,22 @@ onEnabledChange = () => { const { config } = this.state - if (!config || (!config.enabled && this.verifyConfig(true))) { - return - } + let _config = {...config, enabled: !config.enabled} - this.setState({ - config: {...config, enabled: !config.enabled} - }) + delete _config.force + + if (!_config.enabled) { + this.setState({ + 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 = [] @@ -1745,7 +1865,7 @@ } } - if (show && error) { + if (config.enabled && error) { notification.warning({ top: 92, message: error, @@ -1753,7 +1873,7 @@ }) } - return error + return error === '' } // 鏇存柊閰嶇疆淇℃伅 @@ -1769,12 +1889,22 @@ let config = fromJS(this.state.config).toJS() if (item.type === 'search') { - notification.warning({ - top: 92, - message: '绉诲姩绔悳绱㈢粍浠朵笉鍙矘璐达紒', - duration: 5 - }) - return + if (config.components.filter(card => card.type === 'topbar' && card.wrap.type !== 'navbar').length > 0) { + notification.warning({ + top: 92, + 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') { @@ -2036,7 +2166,7 @@ </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} /> -- Gitblit v1.8.0