king
2024-06-21 2bccb9ec7bdefe23292a22bc153463cfa1479a49
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'
@@ -16,43 +17,59 @@
const PrintButton = asyncComponent(() => import('./printbutton'))
const FuncMegvii = asyncComponent(() => import('./funcMegvii'))
const FuncZip = asyncComponent(() => import('./funczip'))
const EditLine = asyncComponent(() => import('./editLine'))
const ExportPdf = asyncComponent(() => import('./exportPdf'))
const FuncButton = asyncComponent(() => import('./funcbutton'))
class ActionList extends Component {
  static propTpyes = {
    BID: PropTypes.any,               // 主表ID
    lock: PropTypes.any,              // 可编辑表中按钮锁定
    BData: PropTypes.any,             // 主表数据
    selectedData: PropTypes.any,      // 子表中选择数据
    Tab: PropTypes.any,               // 如果当前元素为标签时,tab为标签信息
    MenuID: PropTypes.string,         // 菜单ID
    actions: PropTypes.array,         // 按钮组
    columns: PropTypes.array,         // 显示列
    setting: PropTypes.any,           // 页面通用设置
    ContainerId: PropTypes.any        // tab页面ID,用于弹窗控制
  }
  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))
  }
  getButtonList = (actions) => {
    const { BID, BData, MenuID, Tab, columns, setting, ContainerId, selectedData, lock } = this.props
    const { BID, BData, MenuID, columns, setting, selectedData } = this.props
    return actions.map(item => {
      if (['exec', 'prompt', 'pop'].includes(item.OpenType)) {
        return (
          <NormalButton
            key={item.uuid}
            show={item.show || 'actionList'}
            disabled={lock || false}
            disabled={false}
            BID={BID}
            Tab={Tab}
            btn={item}
            BData={BData}
            setting={setting}
            columns={columns}
            ContainerId={ContainerId}
            selectedData={selectedData}
          />
        )
@@ -61,9 +78,8 @@
          <ExcelInButton
            key={item.uuid}
            show={item.show || 'actionList'}
            disabled={lock || false}
            disabled={false}
            BID={BID}
            Tab={Tab}
            btn={item}
            BData={BData}
            setting={setting}
@@ -75,12 +91,12 @@
          <ExcelOutButton
            key={item.uuid}
            show={item.show || 'actionList'}
            disabled={lock || false}
            disabled={false}
            BID={BID}
            Tab={Tab}
            btn={item}
            BData={BData}
            setting={setting}
            selectedData={selectedData}
          />
        )
      } else if (item.OpenType === 'popview') {
@@ -88,9 +104,8 @@
          <PopupButton
            key={item.uuid}
            show={item.show || 'actionList'}
            disabled={lock || false}
            disabled={false}
            BID={BID}
            Tab={Tab}
            btn={item}
            BData={BData}
            setting={setting}
@@ -102,8 +117,9 @@
          <TabButton
            key={item.uuid}
            show={item.show || 'actionList'}
            disabled={lock || false}
            disabled={false}
            btn={item}
            BID={BID}
            BData={BData}
            MenuID={MenuID}
            selectedData={selectedData}
@@ -114,7 +130,8 @@
          <NewPageButton
            key={item.uuid}
            show={item.show || 'actionList'}
            disabled={lock || false}
            disabled={false}
            BID={BID}
            btn={item}
            BData={BData}
            selectedData={selectedData}
@@ -126,7 +143,7 @@
            <ChangeUserButton
              key={item.uuid}
              show={item.show || 'actionList'}
              disabled={lock || false}
              disabled={false}
              BID={BID}
              btn={item}
              BData={BData}
@@ -140,13 +157,12 @@
            <PrintButton
              key={item.uuid}
              show={item.show || 'actionList'}
              disabled={lock || false}
              disabled={false}
              BID={BID}
              Tab={Tab}
              btn={item}
              BData={BData}
              setting={setting}
              ContainerId={ContainerId}
              columns={columns}
              selectedData={selectedData}
            />
          )
@@ -155,9 +171,8 @@
            <FuncMegvii
              key={item.uuid}
              show={item.show || 'actionList'}
              disabled={lock || false}
              disabled={false}
              BID={BID}
              Tab={Tab}
              btn={item}
              setting={setting}
              selectedData={selectedData}
@@ -167,37 +182,67 @@
          return (
            <FuncZip
              key={item.uuid}
              show={item.show || 'actionList'}
              disabled={lock || false}
              disabled={false}
              BID={BID}
              Tab={Tab}
              btn={item}
              BData={BData}
              setting={setting}
              selectedData={selectedData}
            />
          )
        } else if (item.funcType === 'expPdf') {
          return (
            <ExportPdf
              key={item.uuid}
              btn={item}
            />
          )
        } else if (item.funcType === 'addline' || item.funcType === 'delline') {
          return (
            <EditLine
            key={item.uuid}
            disabled={false}
            btn={item}
            selectedData={selectedData}
            />
            )
          }
        } else {
          return (
            <FuncButton
              key={item.uuid}
              BID={BID}
              btn={item}
              selectedData={selectedData}
            />
          )
        }
      }
      return null
    })
  }
  render() {
    const { setting, MenuID, actions } = this.props
    let fixed = setting.actionfixed && setting.tabType === 'main' // 按钮是否固定在头部
    const { setting } = this.props
    const { actions, mores } = this.state
    if (fixed && MenuID) {
    if (setting.actionfixed === 'true') {
      return (
        <Affix offsetTop={48}>
          <div className="button-list toolbar-button" id={fixed ? MenuID + 'mainaction' : ''}>
          <div className="button-list toolbar-button">
            {this.getButtonList(actions)}
            {mores ? <Dropdown overlay={<div className="mk-button-dropdown-wrap">{this.getButtonList(mores)}</div>} trigger={['hover']}>
              <div className="mk-button-more">{window.GLOB.dict['more'] || '更多'}<DownOutlined/></div>
            </Dropdown> : null}
          </div>
        </Affix>
      )
    } else {
      return (
        <div className="button-list toolbar-button" id={fixed ? MenuID + 'mainaction' : ''}>
        <div className="button-list toolbar-button">
          {this.getButtonList(actions)}
          {mores ? <Dropdown overlay={<div className="mk-button-dropdown-wrap">{this.getButtonList(mores)}</div>} trigger={['hover']}>
            <div className="mk-button-more">{window.GLOB.dict['more'] || '更多'}<DownOutlined/></div>
          </Dropdown> : null}
        </div>
      )
    }