| | |
| | | import { is, fromJS } from 'immutable' |
| | | import { Button, notification, Icon } from 'antd' |
| | | |
| | | import { modifyTabview } from '@/store/action' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { position } = this.props |
| | | |
| | | if (position === 'toolbar') { |
| | | MKEmitter.addListener('triggerBtnId', this.actionTrigger) |
| | | } |
| | | MKEmitter.addListener('triggerBtnId', this.actionTrigger) |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | |
| | | /** |
| | | * @description 触发按钮操作 |
| | | */ |
| | | actionTrigger = (triggerId, record) => { |
| | | const { setting, btn, tabviews, MenuID, selectedData } = this.props |
| | | actionTrigger = (triggerId, record, type) => { |
| | | const { setting, btn, selectedData } = this.props |
| | | const { disabled } = this.state |
| | | |
| | | if (triggerId && btn.uuid !== triggerId) return |
| | | if ((triggerId && btn.uuid !== triggerId) || disabled) return |
| | | |
| | | if (type === 'linkbtn' && selectedData && selectedData.length === 1) { |
| | | if (record[0].$Index !== selectedData[0].$Index) { |
| | | return |
| | | } |
| | | } |
| | | |
| | | let data = record || selectedData || [] |
| | | |
| | |
| | | MenuID: btn.uuid, |
| | | MenuName: btn.label, |
| | | type: btn.tabTemplate, |
| | | selected: true, |
| | | param: { |
| | | parentId: this.props.MenuID, |
| | | btn: btn, |
| | |
| | | primaryId: primaryId |
| | | } |
| | | } |
| | | } else if (btn.tabTemplate === 'ThdMenu') { |
| | | } else { |
| | | let menu = null |
| | | |
| | | if (btn.linkmenu && btn.linkmenu.length > 0) { |
| | | if (btn.MenuID) { |
| | | menu = { |
| | | MenuID: btn.MenuID, |
| | | MenuName: btn.MenuName, |
| | | MenuNo: btn.MenuNo, |
| | | type: btn.tabType |
| | | } |
| | | } else if (btn.linkmenu && btn.linkmenu.length > 0) { |
| | | let menu_id = btn.linkmenu.slice(-1)[0] |
| | | menu = this.props.permMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | } |
| | |
| | | |
| | | newtab = { |
| | | ...menu, |
| | | selected: true, |
| | | param: { |
| | | $BID: primaryId |
| | | } |
| | | } |
| | | } |
| | | |
| | | let index = 0 |
| | | let tabs = tabviews.filter((tab, i) => { |
| | | tab.selected = false |
| | | |
| | | if (tab.MenuID === MenuID) { |
| | | index = i |
| | | } |
| | | |
| | | return tab.MenuID !== newtab.MenuID |
| | | }) |
| | | |
| | | if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) { |
| | | this.props.modifyTabview([newtab]) |
| | | MKEmitter.emit('modifyTabs', newtab, 'replace') |
| | | } else { |
| | | if (tabviews.length !== tabs.length) { |
| | | this.props.modifyTabview(fromJS(tabs).toJS()) |
| | | } |
| | | |
| | | this.setState({}, () => { |
| | | if (MenuID) { |
| | | tabs.splice(index + 1, 0, newtab) |
| | | } else { |
| | | tabs.push(newtab) |
| | | } |
| | | this.props.modifyTabview(tabs) |
| | | }) |
| | | MKEmitter.emit('modifyTabs', newtab, 'plus', true) |
| | | } |
| | | |
| | | MKEmitter.emit('openNewTab') |
| | |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | tabviews: state.tabviews, |
| | | permMenus: state.permMenus, |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return { |
| | | modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) |
| | | } |
| | | const mapDispatchToProps = () => { |
| | | return {} |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(TabButton) |