king
2022-05-29 f38b3321250222b81a797a538d9c3efa9f8a0ecb
src/tabviews/zshare/cardcomponent/index.jsx
@@ -1,10 +1,12 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Icon, Card, Spin, Empty } from 'antd'
import { Card, Spin, Empty } from 'antd'
import asyncComponent from '@/utils/asyncComponent'
import asyncExcelComponent from './asyncButtonComponent'
import MKEmitter from '@/utils/events.js'
import MkIcon from '@/components/mk-icon'
import '@/assets/css/table.scss'
import './index.scss'
@@ -22,16 +24,14 @@
    type: PropTypes.any,              // 卡片类型,添加按钮为 insert
    BID: PropTypes.any,               // 主表ID
    BData: PropTypes.any,             // 主表数据
    MenuName: PropTypes.any,          // 菜单名称
    Tab: PropTypes.any,               // 如果当前元素为标签时,tab为标签信息
    MenuID: PropTypes.string,         // 菜单ID
    setting: PropTypes.object,        // 页面设定
    logcolumns: PropTypes.array,      // 字段列
    columns: PropTypes.array,         // 显示列
    card: PropTypes.object,           // 卡片设置信息
    data: PropTypes.object,           // 卡片数据
    selectKey: PropTypes.string,      // 选择卡片的序号
    colMap: PropTypes.any,            // 显示列信息,用于设置标记
    refreshdata: PropTypes.func,      // 按钮操作后数据刷新
    switchCard: PropTypes.func        // 卡片切换
  }
@@ -111,13 +111,30 @@
    
    let extra = null
    if (card.header && card.header.actions) {
      let actions = this.getActionList(card.header.actions, card.header.show)
      let actions = card.header.actions.map(item => {
        if (card.header.show === 'icon') {
          item.show = 'icon'
        } else {
          item.show = 'button'
        }
        return item
      })
      actions = this.getActionList(actions)
      extra = actions[0]
    }
    let _actions = null
    if (card.bottom && card.bottom.actions) {
      _actions = this.getActionList(card.bottom.actions, card.bottom.show)
      _actions = card.bottom.actions.map(item => {
        if (card.bottom.show === 'icon') {
          item.show = 'icon'
        } else {
          item.show = 'button'
        }
        return item
      })
      _actions = this.getActionList(_actions)
    }
    this.setState({
@@ -129,51 +146,44 @@
  /**
   * @description 获取按钮元素
   */
  getActionList = (actions, show) => {
    const { BID, BData, Tab, setting, logcolumns, ContainerId, data, MenuID, MenuName } = this.props
  getActionList = (actions) => {
    const { BData, Tab, setting, columns, ContainerId, data, MenuID } = this.props
    
    return actions.map(item => {
      if (['exec', 'prompt', 'pop'].includes(item.OpenType)) {
        return (
          <NormalButton
            key={item.uuid}
            BID={BID}
            BID={data.$$BID}
            Tab={Tab}
            btn={item}
            show={show}
            BData={BData}
            setting={setting}
            MenuName={MenuName}
            columns={logcolumns}
            columns={columns}
            selectedData={[data]}
            ContainerId={ContainerId}
            updateStatus={this.props.refreshdata}
          />
        )
      } else if (item.OpenType === 'popview') {
        return (
          <PopupButton
            key={item.uuid}
            BID={BID}
            BID={data.$$BID}
            Tab={Tab}
            btn={item}
            show={show}
            BData={BData}
            setting={setting}
            selectedData={[data]}
            updateStatus={this.props.refreshdata}
          />
        )
      } else if (item.OpenType === 'tab' || item.OpenType === 'blank') {
      } else if (item.OpenType === 'tab') {
        return (
          <TabButton
            key={item.uuid}
            btn={item}
            show={show}
            MenuID={MenuID}
            setting={setting}
            selectedData={[data]}
            updateStatus={this.props.refreshdata}
          />
        )
      } else if (item.OpenType === 'innerpage' || item.OpenType === 'outerpage') {
@@ -181,38 +191,32 @@
          <NewPageButton
            key={item.uuid}
            btn={item}
            show={show}
            setting={setting}
            selectedData={[data]}
            updateStatus={this.props.refreshdata}
          />
        )
      } else if (item.OpenType === 'funcbutton') {
        if (item.funcType === 'changeuser') {
        if (item.funcType === 'changeuser' || item.funcType === 'closetab') {
          return (
            <ChangeUserButton
              key={item.uuid}
              BID={BID}
              BID={data.$$BID}
              btn={item}
              show={show}
              setting={setting}
              selectedData={[data]}
              updateStatus={this.props.refreshdata}
            />
          )
        } else if (item.funcType === 'print') {
          return (
            <PrintButton
              key={item.uuid}
              BID={BID}
              BID={data.$$BID}
              Tab={Tab}
              btn={item}
              show={show}
              BData={BData}
              setting={setting}
              selectedData={[data]}
              ContainerId={ContainerId}
              updateStatus={this.props.refreshdata}
            />
          )
        }
@@ -253,7 +257,7 @@
          if (isNaN(originVal) || isNaN(contrastVal)) {
            originVal = ''
          }
        } catch {
        } catch (e) {
          originVal = ''
        }
      }
@@ -281,7 +285,7 @@
        if (mark.position === 'front') {
          position = 'front'
        }
        icon = <Icon className={'font ' + className} type={mark.icon} />
        icon = <MkIcon className={'font ' + className} type={mark.icon} />
        className = ''
      }
@@ -340,7 +344,7 @@
          if (isNaN(content)) {
            content = ''
          }
        } catch {
        } catch (e) {
          content = ''
        }
      }
@@ -447,6 +451,7 @@
        title = card.header.content
      }
    }
    let style = {fontSize: plusSize + 'px'}
    return (
      <div className={'chart-card-box ' + card.outclass}>
@@ -494,15 +499,12 @@
            <NormalButton
              BID={this.props.BID}
              Tab={this.props.Tab}
              btn={card.insertAction}
              show={'plus' + plusSize}
              btn={{...card.insertAction, style}}
              BData={this.props.BData}
              setting={this.props.setting}
              MenuName={this.props.MenuName}
              columns={this.props.logcolumns}
              columns={this.props.columns}
              selectedData={[]}
              ContainerId={this.props.ContainerId}
              updateStatus={this.props.refreshdata}
            />
          </div>
        </Card> : null}
@@ -517,17 +519,13 @@
    BData: PropTypes.any,             // 主表数据
    Tab: PropTypes.any,               // 如果当前元素为标签时,tab为标签信息
    MenuID: PropTypes.string,         // 菜单ID
    MenuName: PropTypes.any,          // 菜单名称
    config: PropTypes.object,         // 页面配置信息
    logcolumns: PropTypes.array,      // 显示列
    columns: PropTypes.array,         // 显示列
    ContainerId: PropTypes.any,       // tab页面ID,用于弹窗控制
    plot: PropTypes.object,
    tableId: PropTypes.string,
    loading: PropTypes.bool,
    data: PropTypes.array,
    refreshdata: PropTypes.func,
    getexceloutparam: PropTypes.func,
    handleTableId: PropTypes.func
  }
  state = {
@@ -568,8 +566,10 @@
      if ((item.Ot && item.Ot !== 'notRequired' && !['excelIn', 'excelOut'].includes(item.OpenType)) || item.funcType === 'changeuser') {
        actionMap.set(item.uuid, item)
      } else if (plot.extraAction && plot.extraAction === item.uuid && ['pop', 'prompt', 'exec'].includes(item.OpenType) && item.Ot === 'notRequired') {
        item.show = 'icon'
        insertAction = item
      } else if (plot.actions && plot.actions.length > 0 && plot.actions.includes(item.uuid) && (item.OpenType === 'excelOut' || (item.OpenType === 'excelIn' && item.Ot === 'notRequired'))) {
        item.show = 'icon'
        actionList.push(item)
      }
    })
@@ -749,20 +749,11 @@
    this.setState({selectKey: data.key})
    this.props.handleTableId(this.props.tableId, _id, data)
  }
  /**
   * @description 操作完成后,数据刷新
   */
  updateStatus = (type, positon, btn) => {
    if (type === 'refresh') {
      this.props.refreshdata(positon, btn)
    }
    MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.tableId, _id, data)
  }
  render() {
    const { plot, data, loading, BID, BData, Tab, MenuID, config, logcolumns, ContainerId, MenuName } = this.props
    const { plot, data, loading, BID, BData, Tab, MenuID, config, columns, ContainerId } = this.props
    const { card, colMap, selectKey, actionList } = this.state
    
    return (
@@ -784,10 +775,7 @@
                    BID={BID}
                    Tab={Tab}
                    btn={action}
                    show="icon"
                    MenuName={MenuName}
                    setting={config.setting}
                    updateStatus={this.updateStatus}
                  />
                )
              } else {
@@ -797,11 +785,7 @@
                    BID={BID}
                    Tab={Tab}
                    btn={action}
                    show="icon"
                    MenuName={MenuName}
                    setting={config.setting}
                    getexceloutparam={this.props.getexceloutparam}
                    updateStatus={this.updateStatus}
                  />
                )
              }
@@ -820,13 +804,11 @@
              BData={BData}
              MenuID={MenuID}
              colMap={colMap}
              MenuName={MenuName}
              columns={columns}
              selectKey={selectKey}
              logcolumns={logcolumns}
              setting={config.setting}
              ContainerId={ContainerId}
              switchCard={this.switchCard}
              refreshdata={this.updateStatus}
            />
          ))
        }
@@ -840,11 +822,9 @@
            data={{key: 'insert'}}
            BData={BData}
            MenuID={MenuID}
            MenuName={MenuName}
            setting={config.setting}
            ContainerId={ContainerId}
            switchCard={() => {}}
            refreshdata={this.updateStatus}
          /> : null
        }
        {(loading || !card.insertAction) && (!data || data.length === 0) ? <Empty description={false}/> : null}