From 455bdae0e5e1d9f66a552f74707f825c8b49ee5a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 15 一月 2021 00:35:22 +0800 Subject: [PATCH] 2021-01-15 --- src/index.js | 3 + src/menu/components/share/usercomponent/settingform/index.jsx | 3 + src/menu/components/share/usercomponent/index.jsx | 12 ++++-- src/api/index.js | 3 - src/menu/components/card/prop-card/index.jsx | 76 ++++++++++++++++++++++---------------- src/menu/popview/index.jsx | 2 + src/views/menudesign/index.jsx | 3 + 7 files changed, 62 insertions(+), 40 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 814044b..fc1607a 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -70,9 +70,6 @@ } } -window.GLOB.CacheMap = new Map() // 缂撳瓨閰嶇疆淇℃伅 -window.GLOB.UserCacheMap = new Map() // 缂撳瓨鐢ㄦ埛鑷畾涔夎缃� - axios.interceptors.response.use((response) => { if (response.data.ErrCode === 'LoginError') { if (window.debugger === true) { diff --git a/src/index.js b/src/index.js index 7a0c4f7..b79cd9c 100644 --- a/src/index.js +++ b/src/index.js @@ -224,6 +224,9 @@ value: GLOB }) + window.GLOB.CacheMap = new Map() // 缂撳瓨閰嶇疆淇℃伅 + window.GLOB.UserCacheMap = new Map() // 缂撳瓨鐢ㄦ埛鑷畾涔夎缃� + render(Route) }) diff --git a/src/menu/components/card/prop-card/index.jsx b/src/menu/components/card/prop-card/index.jsx index d04fe68..9b0e60f 100644 --- a/src/menu/components/card/prop-card/index.jsx +++ b/src/menu/components/card/prop-card/index.jsx @@ -19,6 +19,7 @@ const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent')) const LogComponent = asyncIconComponent(() => import('@/menu/components/share/logcomponent')) +const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader')) const { confirm } = Modal @@ -40,37 +41,6 @@ const { card } = this.props if (card.isNew) { - let subcards = null - - if (card.config) { - subcards = JSON.parse(card.config) - subcards = subcards.map(scard => { - scard.uuid = Utils.getuuid() - scard.elements = scard.elements.map(elem => { - elem.uuid = Utils.getuuid() - return elem - }) - scard.backElements = scard.backElements.map(elem => { - elem.uuid = Utils.getuuid() - return elem - }) - return scard - }) - } else { - subcards = [{ - uuid: Utils.getuuid(), - setting: { width: 6, type: 'simple'}, - style: { - borderWidth: '1px', borderColor: '#e8e8e8', - paddingTop: '15px', paddingBottom: '15px', paddingLeft: '15px', paddingRight: '15px', - marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px' - }, - backStyle: {}, - elements: [], - backElements: [] - }] - } - let _card = { uuid: card.uuid, type: card.type, @@ -90,8 +60,49 @@ headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }, columns: [], scripts: [], - subcards: subcards, + subcards: [{ + uuid: Utils.getuuid(), + setting: { width: 6, type: 'simple'}, + style: { + borderWidth: '1px', borderColor: '#e8e8e8', + paddingTop: '15px', paddingBottom: '15px', paddingLeft: '15px', paddingRight: '15px', + marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px' + }, + backStyle: {}, + elements: [], + backElements: [] + }], btnlog: [], + } + + if (card.config) { + let config = fromJS(card.config).toJS() + + _card.setting = config.setting + _card.wrap = config.wrap + _card.style = config.style + _card.headerStyle = config.headerStyle + + _card.subcards = config.subcards.map(scard => { + scard.uuid = Utils.getuuid() + scard.elements = scard.elements.map(elem => { + elem.uuid = Utils.getuuid() + return elem + }) + scard.backElements = scard.backElements.map(elem => { + elem.uuid = Utils.getuuid() + return elem + }) + return scard + }) + _card.columns = config.columns.map(col => { + col.uuid = Utils.getuuid() + return col + }) + _card.scripts = config.scripts.map(col => { + col.uuid = Utils.getuuid() + return col + }) } this.setState({ card: _card @@ -378,6 +389,7 @@ <PasteComponent config={card} options={['cardcell']} updateConfig={this.updateComponent} /> <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog} /> + <UserComponent config={card}/> <Icon className="close" title="鍒犻櫎缁勪欢" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} /> {card.wrap.datatype !== 'static' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : null} {card.wrap.datatype === 'static' ? <Icon style={{color: '#eeeeee', cursor: 'not-allowed'}} type="setting"/> : null} diff --git a/src/menu/components/share/usercomponent/index.jsx b/src/menu/components/share/usercomponent/index.jsx index ab376c6..8936f77 100644 --- a/src/menu/components/share/usercomponent/index.jsx +++ b/src/menu/components/share/usercomponent/index.jsx @@ -21,7 +21,8 @@ state = { dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, visible: false, - loading: false + loading: false, + name: '' } shouldComponentUpdate (nextProps, nextState) { @@ -29,9 +30,12 @@ } trigger = () => { + const { config } = this.props + this.setState({ visible: true, - loading: false + loading: false, + name: window.GLOB.UserComponentMap.get(config.uuid) || config.name || '' }) } @@ -91,7 +95,7 @@ } render () { - const { visible, dict, loading } = this.state + const { visible, dict, loading, name } = this.state return ( <div className="user-component-wrap"> @@ -107,7 +111,7 @@ onCancel={this.cancel} destroyOnClose > - <UserForm dict={dict} inputSubmit={this.submit} wrappedComponentRef={(inst) => this.verifyRef = inst}/> + <UserForm dict={dict} name={name} inputSubmit={this.submit} wrappedComponentRef={(inst) => this.verifyRef = inst}/> </Modal> </div> ) diff --git a/src/menu/components/share/usercomponent/settingform/index.jsx b/src/menu/components/share/usercomponent/settingform/index.jsx index 7c45ae5..50613ac 100644 --- a/src/menu/components/share/usercomponent/settingform/index.jsx +++ b/src/menu/components/share/usercomponent/settingform/index.jsx @@ -7,6 +7,7 @@ class SettingForm extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� + name: PropTypes.string, // 缁勪欢鍚嶇О inputSubmit: PropTypes.func // 鍥炶溅浜嬩欢 } @@ -63,7 +64,7 @@ </Tooltip> }> {getFieldDecorator('name', { - initialValue: '', + initialValue: this.props.name || '', rules: [ { required: true, diff --git a/src/menu/popview/index.jsx b/src/menu/popview/index.jsx index efb26ea..97061ff 100644 --- a/src/menu/popview/index.jsx +++ b/src/menu/popview/index.jsx @@ -104,7 +104,9 @@ if (!config || !item.c_name) return + window.GLOB.UserComponentMap.set(item.c_id, item.c_name) coms.push({ + uuid: item.c_id, type: 'menu', title: item.c_name, url: item.images, diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 04167a3..00c7f8a 100644 --- a/src/views/menudesign/index.jsx +++ b/src/views/menudesign/index.jsx @@ -43,6 +43,7 @@ sessionStorage.setItem('isEditState', 'true') sessionStorage.setItem('editMenuType', 'menu') // 缂栬緫鑿滃崟绫诲瀷 document.body.className = '' +window.GLOB.UserComponentMap = new Map() // 缂撳瓨鐢ㄦ埛鑷畾涔夌粍浠� class MenuDesign extends Component { state = { @@ -136,7 +137,9 @@ if (!config || !item.c_name) return + window.GLOB.UserComponentMap.set(item.c_id, item.c_name) coms.push({ + uuid: item.c_id, type: 'menu', title: item.c_name, url: item.images, -- Gitblit v1.8.0