From 40436544f55558d2c8d1c14c68cce79546c60dff Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 15 一月 2021 16:59:41 +0800 Subject: [PATCH] 2021-01-15 --- src/tabviews/zshare/actionList/popupbutton/index.jsx | 75 +++++++++++++++++++++++++++---------- 1 files changed, 54 insertions(+), 21 deletions(-) diff --git a/src/tabviews/zshare/actionList/popupbutton/index.jsx b/src/tabviews/zshare/actionList/popupbutton/index.jsx index 4c8143f..8baae5f 100644 --- a/src/tabviews/zshare/actionList/popupbutton/index.jsx +++ b/src/tabviews/zshare/actionList/popupbutton/index.jsx @@ -11,10 +11,12 @@ import './index.scss' const SubTabTable = asyncSpinComponent(() => import('@/tabviews/subtabtable')) +const CustomPage = asyncSpinComponent(() => import('@/tabviews/custom')) -class NormalButton extends Component { +class PopupButton extends Component { static propTpyes = { show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 + position: PropTypes.any, // 鎸夐挳浣嶇疆锛屽伐鍏锋爮涓簍oolbar BID: PropTypes.string, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 @@ -22,7 +24,6 @@ MenuID: PropTypes.string, // 鑿滃崟ID btn: PropTypes.object, // 鎸夐挳 setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 - updateStatus: PropTypes.func, // 鎸夐挳鐘舵�佹洿鏂� } state = { @@ -38,24 +39,56 @@ } componentDidMount () { - const { show } = this.props + const { position } = this.props - if (show === 'actionList') { + if (position === 'toolbar') { MKEmitter.addListener('triggerBtnId', this.actionTrigger) } + MKEmitter.addListener('openNewTab', this.openNewTab) + MKEmitter.addListener('refreshPopButton', this.refreshPopButton) } componentWillUnmount () { this.setState = () => { return } + MKEmitter.removeListener('openNewTab', this.openNewTab) MKEmitter.removeListener('triggerBtnId', this.actionTrigger) + MKEmitter.removeListener('refreshPopButton', this.refreshPopButton) } /** + * @description 鎵撳紑鏂版爣绛炬椂锛屽叧闂脊绐楁爣绛鹃〉 + */ + openNewTab = () => { + this.setState({ + visible: false, + loading: false + }) + } + + /** + * @description 寮圭獥鏍囩椤靛埛鏂� + */ + refreshPopButton = (tabId) => { + const { btn } = this.props + + if (btn.uuid !== tabId) return + + if (btn.$type === 'CustomPage') { + if (btn.popClose !== 'never') { + MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.popClose, btn) + } + } else { + let position = btn.popClose !== 'never' ? btn.popClose : 'grid' + MKEmitter.emit('refreshByButtonResult', btn.$menuId, position, btn) + } + } + + /** * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ - actionTrigger = (triggerId) => { + actionTrigger = (triggerId, record) => { const { setting, Tab, BID, btn, selectedData } = this.props const { loading } = this.state @@ -70,7 +103,7 @@ return } - let data = selectedData || [] + let data = record || selectedData || [] if (btn.Ot === 'requiredSgl' && data.length !== 1) { // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 @@ -113,11 +146,6 @@ }) } - // 鎿嶄綔鍚庡埛鏂颁富琛� - reloadtable = () => { - this.props.updateStatus('refresh', 'grid', true) - } - /** * @description 寮圭獥鍏抽棴 */ @@ -129,7 +157,9 @@ loading: false }) - this.props.updateStatus('refresh', btn.popClose) + if (btn.popClose !== 'never') { + MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.popClose, btn) + } } render() { @@ -144,16 +174,18 @@ onClick={() => {this.actionTrigger()}} loading={loading} >{btn.label}</Button> : null} - {['icon', 'text', 'all'].includes(show) ? <Button + {show !== 'actionList' ? <Button type="link" + title={show === 'icon' ? btn.label : ''} loading={loading} + style={btn.btnstyle} icon={show === 'text' ? '' : (btn.icon || '')} onClick={() => {this.actionTrigger()}} >{show === 'icon' && btn.icon ? '' : btn.label}</Button> : null} <Modal - className="popview-modal" + className={'popview-modal ' + (btn.$type === 'CustomPage' ? 'custom-popview' : '')} title={btn.label} - width={'80vw'} + width={'85vw'} maskClosable={false} visible={this.state.visible} onCancel={this.popclose} @@ -162,13 +194,14 @@ ]} destroyOnClose > - <SubTabTable + {btn.$type !== 'CustomPage' ? <SubTabTable + Tab={btn} + MenuID={btn.linkTab} + SupMenuID={this.props.MenuID} BID={popData ? primaryId : this.props.BID} BData={popData || this.props.BData} - SupMenuID={this.props.MenuID} - MenuID={btn.linkTab} - refreshSupView={this.reloadtable} - /> + /> : null} + {btn.$type === 'CustomPage' ? <CustomPage Tab={btn} MenuID={btn.uuid} param={{BID: (popData ? primaryId : this.props.BID), data: (popData || this.props.BData)}} /> : null} </Modal> </div> ) @@ -185,4 +218,4 @@ return {} } -export default connect(mapStateToProps, mapDispatchToProps)(NormalButton) \ No newline at end of file +export default connect(mapStateToProps, mapDispatchToProps)(PopupButton) \ No newline at end of file -- Gitblit v1.8.0