From 28d65cf7ebfe0dd30ade6973e0634e1c8f663b63 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 28 十月 2020 16:12:20 +0800 Subject: [PATCH] 2020-10-28 --- src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 63 ++++++++++++++++++------------- 1 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index 8e5aaad..2485148 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -11,6 +11,7 @@ import Api from '@/api' import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' +import MKEmitter from '@/utils/events.js' import './index.scss' class ExcelOutButton extends Component { @@ -22,27 +23,32 @@ setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 updateStatus: PropTypes.func, // 鎸夐挳鐘舵�佹洿鏂� getexceloutparam: PropTypes.func, // 鑾峰彇琛ㄦ牸涓弬鏁� - triggerBtn: PropTypes.any, } state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - excelName: '', + excelName: '', // 鏂囦欢鍚� search: '', // 鎼滅储鏉′欢 - loading: false - } - - /** - * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮 - */ - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) { - this.actionTrigger() - } + loading: false // 瀵煎嚭涓� } shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + const { show } = this.props + + if (show === 'actionList') { + MKEmitter.addListener('triggerBtnId', this.actionTrigger) + } + } + + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('triggerBtnId', this.actionTrigger) } /** @@ -54,20 +60,21 @@ loading: true, excelName: name }) - this.props.updateStatus('start') } else if (type === 'over') { this.setState({ loading: false }) - this.props.updateStatus('over') } } /** * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ - actionTrigger = () => { + actionTrigger = (triggerId) => { const { setting, Tab, BID, btn } = this.props + const { loading } = this.state + + if ((triggerId && btn.uuid !== triggerId) || loading) return if (Tab && Tab.supMenu && !BID) { notification.warning({ @@ -695,23 +702,25 @@ const { btn, show } = this.props const { loading } = this.state - return ( - <div className="mk-btn-wrap"> - {!show ? <Button + if (show === 'actionList') { + return ( + <Button className={'mk-btn mk-' + btn.class} icon={btn.icon} onClick={() => {this.actionTrigger()}} loading={loading} - >{btn.label}</Button> : null} - {show === 'icon' ? <Button - className="export-icon" - icon="download" - onClick={() => {this.actionTrigger()}} + >{btn.label}</Button> + ) + } else { // icon銆乼ext銆� all 鍗$墖 + return ( + <Button + type="link" loading={loading} - title={btn.label} - ></Button> : null} - </div> - ) + icon={show === 'text' ? '' : (show === 'icon' ? (btn.icon || 'download') : (btn.icon || ''))} + onClick={() => {this.actionTrigger()}} + >{show === 'icon' ? '' : btn.label}</Button> + ) + } } } -- Gitblit v1.8.0