king
2023-01-05 876a5e6657d67df66bb525d02dd6d147ba81cae5
src/tabviews/zshare/actionList/index.jsx
@@ -1,7 +1,8 @@
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'
@@ -29,7 +30,25 @@
    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))
@@ -139,6 +158,7 @@
              btn={item}
              BData={BData}
              setting={setting}
              columns={columns}
              selectedData={selectedData}
            />
          )
@@ -173,7 +193,8 @@
  }
  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) {
@@ -181,6 +202,9 @@
        <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>
      )
@@ -188,6 +212,9 @@
      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>
      )
    }