From fb64bcf1fab18b33d21470c83f28d4cda8d309ce Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 26 十月 2022 12:15:59 +0800 Subject: [PATCH] 2022-10-26 --- src/menu/components/share/actioncomponent/index.jsx | 58 +++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/menu/components/share/actioncomponent/index.jsx b/src/menu/components/share/actioncomponent/index.jsx index 0f29f3c..ce85dbf 100644 --- a/src/menu/components/share/actioncomponent/index.jsx +++ b/src/menu/components/share/actioncomponent/index.jsx @@ -60,17 +60,9 @@ } componentDidMount () { + MKEmitter.addListener('revert', this.revert) MKEmitter.addListener('addButton', this.addButton) - } - - /** - * @description 鐩戝惉鍒版寜閽鍒舵椂锛岃Е鍙戞寜閽紪杈� - */ - UNSAFE_componentWillReceiveProps (nextProps) { - const { actionlist } = this.state - if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) { - this.setState({actionlist: fromJS(nextProps.config.action).toJS()}) - } + MKEmitter.addListener('submitModal', this.handleSave) } shouldComponentUpdate (nextProps, nextState) { @@ -84,7 +76,41 @@ this.setState = () => { return } + MKEmitter.removeListener('revert', this.revert) MKEmitter.removeListener('addButton', this.addButton) + MKEmitter.removeListener('submitModal', this.handleSave) + } + + revert = () => { + this.setState({ + actionlist: fromJS(this.props.config.action).toJS() + }) + } + + handleSave = (componentId, btnId, modal) => { + const { config } = this.props + + if (config.uuid !== componentId) return + + const { actionlist } = this.state + + let _index = actionlist.findIndex(cell => cell.uuid === btnId) + + if (_index === -1) return + + let _actionlist = actionlist.map(cell => { + if (cell.uuid === btnId) { + cell.modal = modal + } + + return cell + }) + + this.setState({ + actionlist: _actionlist + }, () => { + this.props.updateaction({...config, action: _actionlist}) + }) } getStyle = (style) => { @@ -290,7 +316,6 @@ */ deleteElement = (card) => { const { config } = this.props - const { appType } = this.state let _this = this confirm({ @@ -305,11 +330,6 @@ }, () => { _this.props.updateaction({...config, action: _actionlist}) }) - - if (card.origin || appType === 'mob') return - if (appType === 'pc' && card.OpenType !== 'popview') return - - MKEmitter.emit('delButtons', [card.uuid]) }, onCancel() {} }) @@ -323,7 +343,6 @@ profVisible: true, card: element }) - MKEmitter.emit('modalStatus', '楠岃瘉淇℃伅') } /** @@ -351,7 +370,6 @@ }, () => { this.props.updateaction({...config, action: _actionlist}) }) - MKEmitter.emit('modalStatus', false) }) } @@ -437,7 +455,7 @@ let btn = null let _col = null - if (config.subtype === 'normaltable' || config.subtype === 'editable' || config.subtype === 'basetable') { + if (config.type === 'table') { config.cols.forEach(col => { if (col.type !== 'action') return @@ -555,11 +573,9 @@ if (this.verifyRef.handleCancel) { this.verifyRef.handleCancel().then(() => { this.setState({ profVisible: false }) - MKEmitter.emit('modalStatus', false) }) } else { this.setState({ profVisible: false }) - MKEmitter.emit('modalStatus', false) } }} destroyOnClose -- Gitblit v1.8.0