From e9c48bd7356462ba9257540b130a47a65ad1861d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 26 八月 2021 17:17:11 +0800 Subject: [PATCH] 2021-08-26 --- src/menu/components/card/cardcomponent/index.jsx | 133 ++++++++++++++++++------------------------- 1 files changed, 56 insertions(+), 77 deletions(-) diff --git a/src/menu/components/card/cardcomponent/index.jsx b/src/menu/components/card/cardcomponent/index.jsx index af376d8..0709e4f 100644 --- a/src/menu/components/card/cardcomponent/index.jsx +++ b/src/menu/components/card/cardcomponent/index.jsx @@ -1,21 +1,20 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Modal, Popover, Icon, Switch, Col } from 'antd' +import { Popover, Icon, Switch, Col } from 'antd' import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' -import zhCN from '@/locales/zh-CN/model.js' -import enUS from '@/locales/en-US/model.js' -import SettingForm from './settingform' import { resetStyle } from '@/utils/utils-custom.js' +import getSettingForm from './options' import Utils from '@/utils/utils.js' import MKEmitter from '@/utils/events.js' import './index.scss' +const NormalForm = asyncIconComponent(() => import('@/components/normalform')) const CardCellComponent = asyncComponent(() => import('../cardcellcomponent')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) -const PasteComponent = asyncIconComponent(() => import('./pastecomponent')) +const PasteController = asyncIconComponent(() => import('@/components/paste')) class CardBoxComponent extends Component { static propTpyes = { @@ -28,12 +27,9 @@ } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, card: null, // 鍗$墖淇℃伅锛屽寘鎷鍙嶉潰 formlist: null, // 璁剧疆琛ㄥ崟淇℃伅 elements: null, // 缂栬緫缁� - visible: false, // 妯℃�佹鎺у埗 - settingVisible: false, side: 'front' } @@ -89,7 +85,7 @@ this.props.updateElement(_card) } - updateCard = (elements, type) => { + updateCard = (elements) => { const { card, side } = this.state let _card = {} @@ -100,16 +96,9 @@ _card = {...card, elements: elements} } - if (type === 'paste') { - this.setState({ - card: _card, - elements: fromJS(elements).toJS() - }) - } else { - this.setState({ - card: _card - }) - } + this.setState({ + card: _card + }) this.props.updateElement(_card) } @@ -155,24 +144,9 @@ const { cards } = this.props const { card } = this.state - let newcard = {} + let newcard = {eleType: 'button', label: 'button', verify: null, show: 'link', sqlType: '', Ot: 'requiredSgl', OpenType: 'prompt', icon: '', class: 'primary', intertype: 'system', execSuccess: 'grid', execError: 'never', popClose: 'never'} newcard.uuid = Utils.getuuid() newcard.focus = true - - newcard.eleType = 'button' - newcard.label = 'button' - newcard.sqlType = '' - newcard.Ot = 'requiredSgl' - newcard.OpenType = 'prompt' - newcard.icon = '' - newcard.class = 'primary' - newcard.intertype = 'system' - newcard.execSuccess = 'grid' - newcard.execError = 'never' - newcard.popClose = 'never' - newcard.errorTime = 10 - newcard.verify = null - newcard.show = 'link' // 娉ㄥ唽浜嬩欢-娣诲姞鍏冪礌 MKEmitter.emit('cardAddElement', [cards.uuid, card.uuid], newcard) @@ -194,24 +168,50 @@ MKEmitter.emit('changeStyle', [cards.uuid, card.uuid], options, _style) } - settingSubmit = () => { + getSettingForms = () => { + const { cards } = this.props + const { setting } = this.state.card + + return getSettingForm(setting, cards.subtype === 'propcard') + } + + updateSetting = (res) => { const { card, side } = this.state - this.settingRef.handleConfirm().then(res => { - this.setState({ - settingVisible: false, - card: {...card, setting: res} - }) - - if (side === 'back' && res.type === 'simple') { - this.setState({ - side: 'front', - elements: fromJS(card.elements).toJS() - }) - } - - this.props.updateElement({...card, setting: res}) + this.setState({ + card: {...card, setting: res} }) + + if (side === 'back' && res.type === 'simple') { + this.setState({ + side: 'front', + elements: fromJS(card.elements).toJS() + }) + } + + this.props.updateElement({...card, setting: res}) + } + + paste = (element, resolve) => { + const { cards } = this.props + const { card } = this.state + + let _uuid = Utils.getuuid() + + if (element.copyType === 'action' && element.OpenType === 'popview') { // 寮圭獥鏍囩澶嶅埗 + let _cell = fromJS(element).toJS() + _cell.$originUuid = element.uuid + _cell.uuid = _uuid + MKEmitter.emit('copyButtons', [_cell]) + } + + element.uuid = _uuid + element.focus = true + + resolve({status: true}) + + // 娉ㄥ唽浜嬩欢-娣诲姞鍏冪礌 + MKEmitter.emit('cardAddElement', [cards.uuid, card.uuid], element) } clickComponent = (e) => { @@ -231,13 +231,9 @@ render() { const { cards, offset } = this.props - const { card, elements, side, settingVisible, dict } = this.state + const { card, elements, side } = this.state let _style = {...card.style} - - if (_style.shadow) { - _style.boxShadow = '0 0 4px ' + _style.shadow - } if (side === 'back') { _style = { @@ -255,14 +251,16 @@ <Col span={card.setting.width || 6} offset={offset || 0}> <div className="card-item" style={_style} onClick={this.clickComponent} onDoubleClick={(e) => {e.stopPropagation(); this.doubleClickCard()}} id={card.uuid}> <CardCellComponent cards={cards} cardCell={card} side={side} elements={elements} updateElement={this.updateCard}/> - <div className="card-control"> + <div className="card-control" onDoubleClick={(e) => e.stopPropagation()}> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> <Icon className="plus" title="娣诲姞鍏冪礌" onClick={this.addElement} type="plus" /> <Icon className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} type="plus-square" /> - <Icon className="edit" title="缂栬緫" type="edit" onClick={() => this.setState({settingVisible: true})} /> + <NormalForm title="鍗$墖璁剧疆" width={800} update={this.updateSetting} getForms={this.getSettingForms}> + <Icon type="edit" className="edit" title="缂栬緫"/> + </NormalForm> <CopyComponent type="cardcell" card={card}/> - <PasteComponent elements={elements} options={['action', 'customCardElement']} updateConfig={(list) => this.updateCard(list, 'paste')} /> + <PasteController options={['action', 'customCardElement']} updateConfig={this.paste} /> <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> @@ -280,25 +278,6 @@ </Popover> </div> </div> - <Modal - wrapClassName="popview-modal" - title={'鍗$墖璁剧疆'} - visible={settingVisible} - width={800} - maskClosable={false} - okText={dict['model.submit']} - onOk={this.settingSubmit} - onCancel={() => { this.setState({ settingVisible: false }) }} - destroyOnClose - > - <SettingForm - dict={dict} - cards={cards} - setting={card.setting} - inputSubmit={this.settingSubmit} - wrappedComponentRef={(inst) => this.settingRef = inst} - /> - </Modal> </Col> ) } -- Gitblit v1.8.0