| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Affix } from 'antd' |
| | | import { Affix, Dropdown } from 'antd' |
| | | import { DownOutlined } from '@ant-design/icons' |
| | | |
| | | import asyncComponent from './asyncButtonComponent' |
| | | import './index.scss' |
| | |
| | | setting: PropTypes.any, // 页面通用设置 |
| | | } |
| | | |
| | | state = {} |
| | | state = { |
| | | actions: [], |
| | | mores: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { setting, actions } = this.props |
| | | |
| | | if (!setting.btnlimit || setting.btnlimit >= actions.length) { |
| | | this.setState({actions: actions}) |
| | | } else { |
| | | let mores = fromJS(actions).toJS() |
| | | |
| | | this.setState({ |
| | | actions: mores.splice(0, setting.btnlimit), |
| | | mores |
| | | }) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | |
| | | btn={item} |
| | | BData={BData} |
| | | setting={setting} |
| | | columns={columns} |
| | | selectedData={selectedData} |
| | | /> |
| | | ) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { setting, MenuID, actions } = this.props |
| | | const { setting, MenuID } = this.props |
| | | const { actions, mores } = this.state |
| | | let fixed = setting.actionfixed && setting.tabType === 'main' // 按钮是否固定在头部 |
| | | |
| | | if (fixed && MenuID) { |
| | |
| | | <Affix offsetTop={48}> |
| | | <div className="button-list toolbar-button" id={fixed ? MenuID + 'mainaction' : ''}> |
| | | {this.getButtonList(actions)} |
| | | {mores ? <Dropdown overlay={<div className="mk-button-dropdown-wrap">{this.getButtonList(mores)}</div>} trigger={['hover']}> |
| | | <div className="mk-more">更多<DownOutlined/></div> |
| | | </Dropdown> : null} |
| | | </div> |
| | | </Affix> |
| | | ) |
| | |
| | | return ( |
| | | <div className="button-list toolbar-button" id={fixed ? MenuID + 'mainaction' : ''}> |
| | | {this.getButtonList(actions)} |
| | | {mores ? <Dropdown overlay={<div className="mk-button-dropdown-wrap">{this.getButtonList(mores)}</div>} trigger={['hover']}> |
| | | <div className="mk-more">更多<DownOutlined/></div> |
| | | </Dropdown> : null} |
| | | </div> |
| | | ) |
| | | } |