| | |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import { getCardCellForm } from './formconfig' |
| | | |
| | | import MKEmitter from '@/utils/events.js' |
| | | import ElementForm from './elementform' |
| | | import DragElement from './dragaction' |
| | | import './index.scss' |
| | |
| | | }) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('cardAddElement', this.cardAddElement) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props.config), fromJS(nextProps.config)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | | * @description 按钮顺序调整,或拖拽添加 |
| | | * @description 组件销毁,清除state更新,清除快捷键设置 |
| | | */ |
| | | handleList = (list, card) => { |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('cardAddElement', this.cardAddElement) |
| | | } |
| | | |
| | | cardAddElement = (cardId, element) => { |
| | | if (cardId !== this.props.config.uuid) return |
| | | |
| | | const { elements } = this.state |
| | | |
| | | this.setState({elements: [...elements, element]}) |
| | | this.handleElement(element) |
| | | } |
| | | |
| | | /** |
| | | * @description 按钮顺序调整 |
| | | */ |
| | | handleList = (list) => { |
| | | const { config } = this.props |
| | | |
| | | if (card) { |
| | | this.setState({elements: list}) |
| | | this.handleElement(card) |
| | | } else { |
| | | this.setState({elements: list}, () => { |
| | | this.props.updateElement({...config, elements: list}) |
| | | }) |
| | | } |
| | | this.setState({elements: list}, () => { |
| | | this.props.updateElement({...config, elements: list}) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } |
| | | |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props.config), fromJS(nextProps.config)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | | * @description 组件销毁,清除state更新 |
| | | */ |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | } |
| | | |
| | | render() { |