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/views/menudesign/index.jsx | 113 ++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 80 insertions(+), 33 deletions(-) diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 84cee4d..85e7fe4 100644 --- a/src/views/menudesign/index.jsx +++ b/src/views/menudesign/index.jsx @@ -8,7 +8,7 @@ import Api from '@/api' import options from '@/store/options.js' -import Utils from '@/utils/utils.js' +import Utils, { setGLOBFuncs } from '@/utils/utils.js' import zhCN from '@/locales/zh-CN/mob.js' import enUS from '@/locales/en-US/mob.js' import antdEnUS from 'antd/es/locale/en_US' @@ -34,6 +34,7 @@ const PasteController = asyncComponent(() => import('@/menu/pastecontroller')) const PaddingController = asyncComponent(() => import('@/menu/padcontroller')) const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) +const ReplaceField = asyncComponent(() => import('@/menu/replaceField')) const SysInterface = asyncComponent(() => import('@/menu/sysinterface')) const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) const PictureController = asyncComponent(() => import('@/menu/picturecontroller')) @@ -44,6 +45,7 @@ sessionStorage.setItem('isEditState', 'true') sessionStorage.setItem('editMenuType', 'menu') // 缂栬緫鑿滃崟绫诲瀷 +sessionStorage.setItem('appType', '') // 搴旂敤绫诲瀷 document.body.className = '' window.GLOB.UserComponentMap = new Map() // 缂撳瓨鐢ㄦ埛鑷畾涔夌粍浠� window.GLOB.urlFields = [] // url鍙橀噺 @@ -66,7 +68,8 @@ config: null, popBtn: null, // 寮圭獥鏍囩椤� visible: false, - customComponents: [] + customComponents: [], + comloading: false } UNSAFE_componentWillMount() { @@ -105,6 +108,7 @@ setTimeout(() => { this.updateCustomComponent() this.getAppPictures() + setGLOBFuncs() }, 1000) } @@ -152,6 +156,7 @@ updateCustomComponent = () => { Api.getSystemConfig({ func: 's_get_custom_components', + typename: '', typecharone: '' }).then(res => { let coms = [] @@ -199,10 +204,11 @@ }) this.setState({ - config: {...config, components: []} + config: {...config, components}, + comloading: true }, () => { this.setState({ - config: {...config, components: components} + comloading: false }) }) } @@ -393,6 +399,13 @@ buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) _sort++ }) + }) + } else if (item.type === 'balcony') { + item.elements && item.elements.forEach(cell => { + if (cell.eleType !== 'button') return + this.checkBtn(cell) + buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) + _sort++ }) } else if (item.type === 'line' || item.type === 'bar') { item.action && item.action.forEach(btn => { @@ -645,7 +658,8 @@ if (res.status) { config.open_edition = res.open_edition || '' this.setState({ - oriConfig: fromJS(config).toJS() + config, + oriConfig: fromJS(config).toJS(), }) if (btnParam.LText) { @@ -763,10 +777,10 @@ copyButtons: [], thawButtons: [], menuloading: false, - config: {...config, components: []} + comloading: true }, () => { this.setState({ - config: {...this.state.config, components: this.state.oriConfig.components} + comloading: false }) }) notification.success({ @@ -827,28 +841,48 @@ } verifyConfig = (show) => { - const { config, MenuType } = this.state + const { config } = this.state let error = '' - config.components.forEach(item => { - if (error) return - if (['propcard', 'brafteditor', 'sandbox'].includes(item.subtype) && item.wrap.datatype === 'static') return + let check = (components) => { + components.forEach(item => { + if (error) return + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + check(tab.components) + }) + return + } else if (item.type === 'group') { + check(item.components) + return + } + if (['propcard', 'brafteditor', 'sandbox', 'stepform'].includes(item.subtype) && item.wrap.datatype === 'static') return + if (['balcony'].includes(item.type) && item.wrap.datatype === 'static') return + + if (item.setting) { + if (item.setting.interType === 'system' && item.setting.execute !== 'false' && !item.setting.dataresource) { + error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒` + } else if (item.setting.interType === 'system' && item.setting.execute === 'false' && item.scripts.length === 0) { + error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒` + } else if (!item.setting.primaryKey) { + error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婚敭锛乣 + } + } + if (item.type === 'bar' || item.type === 'line' || item.type === 'pie') { + if (!item.plot.Xaxis) { + error = `缁勪欢銆�${item.name}銆嬪浘琛ㄥ瓧娈靛皻鏈缃紒` + } + } else if (item.type === 'dashboard' && !item.plot.valueField) { + error = `缁勪欢銆�${item.name}銆嬫樉绀哄�煎皻鏈缃紒` + } else if (item.type === 'scatter' && (!item.plot.Xaxis || !item.plot.Yaxis || !item.plot.gender)) { + error = `缁勪欢銆�${item.name}銆嬪潗鏍囪酱灏氭湭璁剧疆锛乣 + } else if (item.type === 'tree' && (!item.wrap.valueField || !item.wrap.labelField || !item.wrap.parentField)) { + error = `缁勪欢銆�${item.name}銆嬪熀鏈俊鎭皻鏈缃紒` + } + }) + } - if (item.setting) { - if (item.setting.interType === 'system' && item.setting.execute !== 'false' && !item.setting.dataresource) { - error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒` - } else if (item.setting.interType === 'system' && item.setting.execute === 'false' && item.scripts.length === 0) { - error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒` - } else if (item.setting.interType && !item.setting.primaryKey && MenuType !== 'billPrint') { - error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婚敭锛乣 - } - } - if (item.type === 'bar' || item.type === 'line' || item.type === 'pie') { - if (!item.plot.Xaxis) { - error = `缁勪欢銆�${item.name}銆嬪浘琛ㄥ瓧娈靛皻鏈缃紒` - } - } - }) + check(config.components) if (show && error) { notification.warning({ @@ -869,6 +903,18 @@ window.GLOB.customMenu = config } + resetConfig = (config) => { + this.setState({ + config, + comloading: true + }, () => { + this.setState({ + comloading: false + }) + }) + window.GLOB.customMenu = config + } + insert = (item) => { let config = fromJS(this.state.config).toJS() @@ -879,7 +925,7 @@ } render () { - const { activeKey, MenuType, popBtn, visible, dict, MenuId, config, ParentId, MenuName, MenuNo, menuloading, customComponents } = this.state + const { activeKey, comloading, MenuType, popBtn, visible, dict, MenuId, config, ParentId, MenuName, MenuNo, menuloading, customComponents } = this.state return ( <ConfigProvider locale={_locale}> @@ -901,10 +947,6 @@ MenuNo={MenuNo} updateConfig={this.updateConfig} /> : null} - {config && MenuType === 'custom' ? <UrlFieldComponent - config={config} - updateConfig={this.updateConfig} - /> : null} {config && MenuType === 'home' ? <HomeForm dict={dict} config={config} @@ -912,6 +954,10 @@ /> : null} {config && MenuType === 'billPrint' ? <PrintMenuForm dict={dict} + config={config} + updateConfig={this.updateConfig} + /> : null} + {config ? <UrlFieldComponent config={config} updateConfig={this.updateConfig} /> : null} @@ -938,16 +984,17 @@ <div> {config && config.MenuName} </div> } bordered={false} extra={ <div> + <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/> <SysInterface config={config} updateConfig={this.updateConfig}/> <PictureController/> <StyleCombControlButton menu={config} /> <PasteController type="menu" Tab={null} insert={this.insert} /> <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config && config.enabled} onChange={this.onEnabledChange} /> <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button> - <Button type="default" onClick={this.closeView}>{dict['mob.return']}</Button> + <Button type="default" onClick={this.closeView}>鍏抽棴</Button> </div> } style={{ width: '100%' }}> - {config && config.components ? <MenuShell menu={config} handleList={this.updateConfig} /> : null} + {config && !comloading ? <MenuShell menu={config} handleList={this.updateConfig} /> : null} </Card> </div> </div> -- Gitblit v1.8.0