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/newpagebutton/index.jsx | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx index dcf07e8..2ff034c 100644 --- a/src/tabviews/zshare/actionList/newpagebutton/index.jsx +++ b/src/tabviews/zshare/actionList/newpagebutton/index.jsx @@ -21,7 +21,23 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + disabled: false, visible: 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) { @@ -33,6 +49,24 @@ if (position === 'toolbar') { MKEmitter.addListener('triggerBtnId', this.actionTrigger) + } + } + + 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}) } } @@ -69,14 +103,6 @@ duration: 5 }) return - } else if (btn.Ot !== 'notRequired' && !setting.primaryKey) { - // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� - notification.warning({ - top: 92, - message: '鏈缃富閿紒', - duration: 5 - }) - return } else if (!btn.pageTemplate) { notification.warning({ top: 92, @@ -91,7 +117,7 @@ let MenuNo = '' let Remark = '' if (btn.Ot === 'requiredSgl' && data[0]) { - Id = data[0][setting.primaryKey] || '' + Id = setting.primaryKey ? (data[0][setting.primaryKey] || '') : '' name = data[0].PrintTempName || '' MenuNo = data[0].PrintTempNO || '' Remark = data[0].Remark || '' @@ -103,7 +129,7 @@ _name = '鍗曟嵁鎵撳嵃' if (btn.Ot === 'required' && data && data.length > 0) { data.forEach((item, i) => { - let _id = item[setting.primaryKey] || '' + let _id = setting.primaryKey ? (item[setting.primaryKey] || '') : '' let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: _id, tempId: btn.printTemp, dataM: sessionStorage.getItem('dataM') }))) window.open(url) }) @@ -164,12 +190,14 @@ render() { const { btn, show } = this.props + const { disabled } = this.state if (show === 'actionList') { return ( <Button className={'mk-btn mk-' + btn.class} icon={btn.icon} + disabled={disabled} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{btn.label}</Button> ) @@ -178,7 +206,8 @@ <Button type="link" title={show === 'icon' ? btn.label : ''} - style={btn.btnstyle} + style={btn.style} + disabled={disabled} icon={show === 'text' ? '' : (btn.icon || '')} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{show === 'icon' && btn.icon ? '' : btn.label}</Button> -- Gitblit v1.8.0