| | |
| | | import { resetStyle } from '@/utils/utils-custom.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import getWrapForm from '../data-card/options' |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import './index.scss' |
| | | |
| | | const SettingComponent = asyncIconComponent(() => import('@/menu/datasource')) |
| | | const WrapComponent = asyncIconComponent(() => import('../data-card/wrapsetting')) |
| | | const NormalForm = asyncIconComponent(() => import('@/components/normalform')) |
| | | const CardComponent = asyncComponent(() => import('../cardcomponent')) |
| | | const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) |
| | | const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent')) |
| | | const PasteComponent = asyncIconComponent(() => import('@/components/paste')) |
| | | const LogComponent = asyncIconComponent(() => import('@/menu/components/share/logcomponent')) |
| | | const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) |
| | | const ClockComponent = asyncIconComponent(() => import('@/menu/components/share/clockcomponent')) |
| | |
| | | this.props.updateConfig(_card) |
| | | } |
| | | |
| | | addCard = () => { |
| | | addCard = (copy) => { |
| | | let card = fromJS(this.state.card).toJS() |
| | | let newcard = {} |
| | | |
| | | let newcard = { |
| | | 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: [] |
| | | } |
| | | |
| | | if (card.subcards.length > 0) { |
| | | newcard = fromJS(card.subcards.slice(-1)[0]).toJS() |
| | | newcard.uuid = Utils.getuuid() |
| | | newcard.elements = newcard.elements.map(elem => { |
| | | elem.uuid = Utils.getuuid() |
| | | return elem |
| | | }) |
| | | newcard.backElements = newcard.backElements.map(elem => { |
| | | elem.uuid = Utils.getuuid() |
| | | return elem |
| | | }) |
| | | if (copy) { // 粘贴 |
| | | newcard = copy |
| | | } else { |
| | | newcard = { |
| | | 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: [] |
| | | } |
| | | |
| | | if (card.subcards.length > 0) { |
| | | newcard = fromJS(card.subcards.slice(-1)[0]).toJS() |
| | | newcard.uuid = Utils.getuuid() |
| | | newcard.elements = newcard.elements.map(elem => { |
| | | elem.uuid = Utils.getuuid() |
| | | return elem |
| | | }) |
| | | newcard.backElements = newcard.backElements.map(elem => { |
| | | elem.uuid = Utils.getuuid() |
| | | return elem |
| | | }) |
| | | } |
| | | } |
| | | |
| | | card.subcards.push(newcard) |
| | |
| | | this.props.updateConfig(card) |
| | | } |
| | | |
| | | pasteComponent = (res, resolve) => { |
| | | const { appType } = this.state |
| | | |
| | | delete res.copyType |
| | | delete res.$cardType |
| | | |
| | | res.uuid = Utils.getuuid() |
| | | res.setting = res.setting || {} |
| | | res.setting.width = res.setting.width || 6 |
| | | |
| | | let copyBtns = [] |
| | | let mobtypes = ['pop', 'prompt', 'exec', 'innerpage'] |
| | | |
| | | let elements = [] |
| | | res.elements && res.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') { |
| | | cell.uuid = Utils.getuuid() |
| | | elements.push(cell) |
| | | } else if (appType === 'mob' && !mobtypes.includes(cell.OpenType)) { |
| | | return |
| | | } else { |
| | | let _uuid = Utils.getuuid() |
| | | |
| | | if (cell.OpenType === 'popview') { |
| | | let _cell = fromJS(cell).toJS() |
| | | _cell.$originUuid = _cell.uuid |
| | | _cell.uuid = _uuid |
| | | copyBtns.push(_cell) |
| | | } |
| | | |
| | | cell.uuid = _uuid |
| | | elements.push(cell) |
| | | } |
| | | }) |
| | | |
| | | res.elements = elements |
| | | |
| | | let backElements = [] |
| | | |
| | | if (appType !== 'mob') { |
| | | res.backElements && res.backElements.forEach(cell => { |
| | | if (cell.eleType !== 'button') { |
| | | cell.uuid = Utils.getuuid() |
| | | backElements.push(cell) |
| | | } else if (appType === 'mob' && !mobtypes.includes(cell.OpenType)) { |
| | | return |
| | | } else { |
| | | let _uuid = Utils.getuuid() |
| | | |
| | | if (cell.OpenType === 'popview') { |
| | | let _cell = fromJS(cell).toJS() |
| | | _cell.$originUuid = _cell.uuid |
| | | _cell.uuid = _uuid |
| | | copyBtns.push(_cell) |
| | | } |
| | | |
| | | cell.uuid = _uuid |
| | | backElements.push(cell) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | res.backElements = backElements |
| | | |
| | | if (copyBtns.length > 0) { |
| | | MKEmitter.emit('copyButtons', copyBtns) |
| | | } |
| | | |
| | | resolve({status: true}) |
| | | |
| | | this.addCard(res) |
| | | } |
| | | |
| | | getWrapForms = () => { |
| | | const { card } = this.state |
| | | |
| | | return getWrapForm(card.wrap, card.subtype) |
| | | } |
| | | |
| | | updateWrap = (res) => { |
| | | this.updateComponent({...this.state.card, wrap: res}) |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | |
| | | <NormalHeader defaultshow="hidden" config={card} updateComponent={this.updateComponent}/> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | <Icon className="plus" title="添加卡片" onClick={this.addCard} type="plus" /> |
| | | <WrapComponent config={card} updateConfig={this.updateComponent} /> |
| | | <Icon className="plus" title="添加卡片" onClick={() => this.addCard()} type="plus" /> |
| | | <NormalForm title="属性卡设置" width={800} update={this.updateWrap} getForms={this.getWrapForms}> |
| | | <Icon type="edit" style={{color: '#1890ff'}} title="编辑"/> |
| | | </NormalForm> |
| | | <CopyComponent type="propcard" card={card}/> |
| | | <PasteComponent config={card} options={['cardcell']} updateConfig={this.updateComponent} /> |
| | | <PasteComponent options={['cardcell']} updateConfig={this.pasteComponent} /> |
| | | <Icon className="style" title="调整样式" onClick={this.changeStyle} type="font-colors" /> |
| | | <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog} /> |
| | | <ClockComponent config={card} updateConfig={this.updateComponent}/> |