From 137fb8ea6af2789b3238b22bac31d80bced41dfe Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 28 七月 2021 11:39:39 +0800 Subject: [PATCH] 2021-07-28 --- src/tabviews/zshare/actionList/popupbutton/index.jsx | 60 ++++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/tabviews/zshare/actionList/popupbutton/index.jsx b/src/tabviews/zshare/actionList/popupbutton/index.jsx index 539e70c..c519a94 100644 --- a/src/tabviews/zshare/actionList/popupbutton/index.jsx +++ b/src/tabviews/zshare/actionList/popupbutton/index.jsx @@ -31,7 +31,23 @@ visible: false, popData: null, primaryId: '', + disabled: false, loading: false, + } + + UNSAFE_componentWillMount () { + const { btn, selectedData } = this.props + let disabled = false + + if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + this.setState({disabled}) + } } shouldComponentUpdate (nextProps, nextState) { @@ -46,6 +62,24 @@ } MKEmitter.addListener('openNewTab', this.openNewTab) MKEmitter.addListener('refreshPopButton', this.refreshPopButton) + } + + UNSAFE_componentWillReceiveProps (nextProps) { + const { btn, selectedData } = this.props + + if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) { + let disabled = false + + if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� + nextProps.selectedData.forEach(item => { + let s = item[btn.controlField] + '' + if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { + disabled = true + } + }) + } + this.setState({disabled}) + } } componentWillUnmount () { @@ -75,7 +109,7 @@ if (btn.uuid !== tabId) return - if (btn.$type === 'CustomPage') { + if (btn.$view === 'CustomPage') { if (btn.popClose !== 'never') { MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.popClose, btn) } @@ -94,7 +128,7 @@ if ((triggerId && btn.uuid !== triggerId) || loading) return - if (Tab && Tab.supMenu && !BID) { + if (((Tab && Tab.supMenu) || setting.supModule) && !BID) { notification.warning({ top: 92, message: '闇�瑕佷笂绾т富閿�硷紒', @@ -113,14 +147,6 @@ duration: 5 }) return - } else if (!setting.primaryKey) { - // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� - notification.warning({ - top: 92, - message: '鏈缃富閿紒', - duration: 5 - }) - return } else if (setting.tabType === 'subtab') { notification.warning({ top: 92, @@ -133,7 +159,7 @@ let _data = null let primaryId = '' - if (btn.Ot === 'requiredSgl') { + if (btn.Ot === 'requiredSgl' && setting.primaryKey) { _data = data[0] primaryId = _data[setting.primaryKey] || '' } @@ -168,13 +194,14 @@ render() { const { btn, show } = this.props - const { loading, popData, primaryId } = this.state + const { loading, popData, primaryId, disabled } = this.state return ( <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> {show === 'actionList' ? <Button className={'mk-btn mk-' + btn.class} icon={btn.icon} + disabled={disabled} onClick={() => {this.actionTrigger()}} loading={loading} >{btn.label}</Button> : null} @@ -182,12 +209,13 @@ type="link" title={show === 'icon' ? btn.label : ''} loading={loading} - style={btn.btnstyle} + disabled={disabled} + style={btn.style} icon={show === 'text' ? '' : (btn.icon || '')} onClick={() => {this.actionTrigger()}} >{show === 'icon' && btn.icon ? '' : btn.label}</Button> : null} <Modal - className={'popview-modal ' + (btn.$type === 'CustomPage' ? 'custom-popview' : '')} + className={'popview-modal ' + (btn.$view === 'CustomPage' ? 'custom-popview' : '')} title={btn.label} width={'85vw'} maskClosable={false} @@ -198,14 +226,14 @@ ]} destroyOnClose > - {btn.$type !== 'CustomPage' ? <SubTabTable + {btn.$view !== 'CustomPage' ? <SubTabTable Tab={btn} MenuID={btn.linkTab} SupMenuID={this.props.MenuID} BID={popData ? primaryId : this.props.BID} BData={popData || this.props.BData} /> : null} - {btn.$type === 'CustomPage' ? <CustomPage Tab={btn} MenuID={btn.uuid} param={{BID: (popData ? primaryId : this.props.BID), data: (popData || this.props.BData)}} /> : null} + {btn.$view === 'CustomPage' ? <CustomPage Tab={btn} MenuID={btn.uuid} param={{$BID: (popData ? primaryId : this.props.BID), ...(popData || this.props.BData || {})}} /> : null} </Modal> </div> ) -- Gitblit v1.8.0