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/tabledesign/index.jsx | 161 +++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 119 insertions(+), 42 deletions(-) diff --git a/src/views/tabledesign/index.jsx b/src/views/tabledesign/index.jsx index 0689387..25d0d54 100644 --- a/src/views/tabledesign/index.jsx +++ b/src/views/tabledesign/index.jsx @@ -63,8 +63,16 @@ } UNSAFE_componentWillMount() { + if (!sessionStorage.getItem('UserID')) { + sessionStorage.removeItem('isEditState') + sessionStorage.removeItem('appType') + this.props.history.replace('/login') + return + } + sessionStorage.setItem('editMenuType', 'menu') // 缂栬緫鑿滃崟绫诲瀷 + window.GLOB.curDate = moment().format('YYYY-MM-DD') window.GLOB.UserComponentMap = new Map() // 缂撳瓨鐢ㄦ埛鑷畾涔夌粍浠� window.GLOB.TabsMap = new Map() // 缂撳瓨鐢ㄦ埛鎿嶄綔鐨勬爣绛鹃〉 window.GLOB.urlFields = [] // url鍙橀噺 @@ -95,6 +103,8 @@ } componentDidMount () { + if (!sessionStorage.getItem('UserID')) return + MKEmitter.addListener('changePopview', this.initPopview) MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave) setTimeout(() => { @@ -235,6 +245,26 @@ _btn.config.MenuID = _btn.uuid _btn.config.ParentId = card.uuid _btn.config.MenuName = _btn.label + _btn.config.components = _btn.config.components || [] + _btn.config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + tab.components[0].cols = tab.components[0].cols.map(col => { + if (col.type === 'action') { + col.type = 'custom' + } + return col + }) + }) + } else if (item.cols) { + item.cols = item.cols.map(col => { + if (col.type === 'action') { + col.type = 'custom' + } + return col + }) + } + }) } else { _btn.config = { uuid: _btn.uuid, @@ -263,6 +293,21 @@ submitPopConfig = (btnconfig) => { let config = fromJS(this.state.config).toJS() + 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' && cell.uuid === btnconfig.uuid) { + cell.config = btnconfig + } + }) + } + }) + } + config.components.forEach(item => { if (item.type === 'tabs') { item.subtabs.forEach(tab => { @@ -273,14 +318,8 @@ btn.config = btnconfig } }) - tab.components[0].cols.forEach(col => { - if (col.type !== 'action') return - col.elements.forEach(btn => { - if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { - btn.config = btnconfig - } - }) - }) + + loopCol(tab.components[0].cols) tab.components[0].$tables = getTables(tab.components[0]) }) @@ -290,14 +329,8 @@ btn.config = btnconfig } }) - item.cols.forEach(col => { - if (col.type !== 'action') return - col.elements.forEach(btn => { - if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { - btn.config = btnconfig - } - }) - }) + + loopCol(item.cols) item.$tables = getTables(item) } @@ -407,8 +440,20 @@ if (item.type === 'tabs') { item.subtabs.forEach(tab => { tab.components[0].name = tab.label + tab.components[0].cols = tab.components[0].cols.map(col => { + if (col.type === 'action') { + col.type = 'custom' + } + return col + }) }) } else { + item.cols = item.cols.map(col => { + if (col.type === 'action') { + col.type = 'custom' + } + return col + }) item.name = '涓昏〃' } }) @@ -457,15 +502,22 @@ buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`) _s++ }) - tab.components[0].cols.forEach(col => { - if (col.type !== 'action') return - col.elements.forEach(btn => { - if (btn.hidden === 'true') return - buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`) - _s++ + 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 + buttons.push(`select '${cell.uuid}' as menuid, '${cell.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`) + _s++ + }) + } }) - }) + } + + loopCol(tab.components[0].cols) }) } else { if (item.$tables) { @@ -477,15 +529,22 @@ buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) _sort++ }) - item.cols.forEach(col => { - if (col.type !== 'action') return - col.elements.forEach(btn => { - if (btn.hidden === 'true') return - buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) - _sort++ + 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 + buttons.push(`select '${cell.uuid}' as menuid, '${cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) + _sort++ + }) + } }) - }) + } + + loopCol(item.cols) } }) @@ -517,9 +576,17 @@ 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 } let tbs = [] @@ -613,6 +680,8 @@ menuloading: false }) + window.GLOB.saving = false + if (!res) return if (res.status) { @@ -637,6 +706,9 @@ this.setState({ menuloading: false }) + + window.GLOB.saving = false + if (!error) { notification.warning({ top: 92, @@ -681,17 +753,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 = '' config.components.forEach(item => { @@ -725,7 +802,7 @@ } } - if (show && error) { + if (config.enabled && error) { notification.warning({ top: 92, message: error, @@ -733,7 +810,7 @@ }) } - return error + return error === '' } // 鏇存柊閰嶇疆淇℃伅 @@ -843,7 +920,7 @@ <TableNodes config={config} /> <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/> <PasteBaseTable type="page" insert={this.insert}/> - <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} <Button type="primary" id="save-config" onClick={this.submitConfig} loading={menuloading}>淇濆瓨</Button> <Button type="default" onClick={this.closeView}>鍏抽棴</Button> </div> -- Gitblit v1.8.0